From 548c0a152139533e27756576c81d00cc570ea61e Mon Sep 17 00:00:00 2001 From: daniel wilms Date: Wed, 4 Nov 2009 11:53:27 +0200 Subject: [PATCH] putting project-files up --- src/WallpaperCreator.pro | 15 ++++ src/main.cpp | 10 +++ src/mainwindow.cpp | 146 ++++++++++++++++++++++++++++++++++++++ src/mainwindow.h | 48 +++++++++++++ src/mainwindow.ui | 176 ++++++++++++++++++++++++++++++++++++++++++++++ src/namedialog.cpp | 45 ++++++++++++ src/namedialog.h | 33 +++++++++ src/namedialog.ui | 65 +++++++++++++++++ src/processingdialog.cpp | 25 +++++++ src/processingdialog.ui | 64 +++++++++++++++++ src/progressdialog.cpp | 39 ++++++++++ src/progressdialog.h | 28 ++++++++ src/progressdialog.ui | 81 +++++++++++++++++++++ 13 files changed, 775 insertions(+) create mode 100644 src/WallpaperCreator.pro create mode 100644 src/main.cpp create mode 100644 src/mainwindow.cpp create mode 100644 src/mainwindow.h create mode 100644 src/mainwindow.ui create mode 100644 src/namedialog.cpp create mode 100644 src/namedialog.h create mode 100644 src/namedialog.ui create mode 100644 src/processingdialog.cpp create mode 100644 src/processingdialog.ui create mode 100644 src/progressdialog.cpp create mode 100644 src/progressdialog.h create mode 100644 src/progressdialog.ui diff --git a/src/WallpaperCreator.pro b/src/WallpaperCreator.pro new file mode 100644 index 0000000..dae43a3 --- /dev/null +++ b/src/WallpaperCreator.pro @@ -0,0 +1,15 @@ +# ------------------------------------------------- +# Project created by QtCreator 2009-10-28T16:40:20 +# ------------------------------------------------- +TARGET = wallpaperCreator +TEMPLATE = app +SOURCES += main.cpp \ + mainwindow.cpp \ + namedialog.cpp \ + progressdialog.cpp +HEADERS += mainwindow.h \ + namedialog.h \ + progressdialog.h +FORMS += mainwindow.ui \ + namedialog.ui \ + progressdialog.ui diff --git a/src/main.cpp b/src/main.cpp new file mode 100644 index 0000000..6e7efd9 --- /dev/null +++ b/src/main.cpp @@ -0,0 +1,10 @@ +#include +#include "mainwindow.h" + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + MainWindow w; + w.show(); + return a.exec(); +} diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp new file mode 100644 index 0000000..961df17 --- /dev/null +++ b/src/mainwindow.cpp @@ -0,0 +1,146 @@ +#include "mainwindow.h" +#include "ui_mainwindow.h" +#include "progressdialog.h" + +#include + + +MainWindow::MainWindow(QWidget *parent) + : QMainWindow(parent), ui(new Ui::MainWindowClass) +{ + ui->setupUi(this); + ui->set->setVisible(false); +} + +MainWindow::~MainWindow() +{ + delete ui; +} + + +void MainWindow::openFile () { + QFileDialog *dialog = new QFileDialog(this,QString(),QString(),"*.png"); + connect (dialog,SIGNAL(fileSelected(QString)),this,SLOT(getImage(QString))); + dialog->show(); +} + + +void MainWindow::getImage (QString image) { + QTextStream out (stdout); + out << image << endl; + basicImage = new QPixmap (image); + if (!(basicImage->height()==480&&basicImage->width()==3200)){ + out << "show Warning!" << endl; + basicImage = &basicImage->scaled(3200,480); + } + //else { + QPixmap showImage = basicImage->scaled(640,96); + out << basicImage->height() << endl; + QLabel *origLabel = new QLabel (ui->originalImage); + origLabel->setGeometry (0,0,650,110); + origLabel->setPixmap (showImage); + ui->crop->setEnabled(true); + origLabel->show(); + //} +} + +void MainWindow::cropImage () { + img_1 = new QPixmap(basicImage->copy(0,0,800,480)); + QLabel *img1Label = new QLabel (ui->image_1); + img1Label->setPixmap(img_1->scaled(160,96)); + img1Label->setGeometry (0,0,160,99); + img1Label->show(); + + img_2 = new QPixmap(basicImage->copy(800,0,800,480)); + QLabel *img2Label = new QLabel (ui->image_2); + img2Label->setPixmap(img_2->scaled(160,96)); + img2Label->setGeometry (0,0,160,99); + img2Label->show(); + + img_3 = new QPixmap(basicImage->copy(1600,0,800,480)); + QLabel *img3Label = new QLabel (ui->image_3); + img3Label->setPixmap(img_3->scaled(160,96)); + img3Label->setGeometry (0,0,160,99); + img3Label->show(); + + img_4 = new QPixmap(basicImage->copy(2400,0,800,480)); + QLabel *img4Label = new QLabel (ui->image_4); + img4Label->setPixmap(img_4->scaled(160,96)); + img4Label->setGeometry (0,0,160,99); + img4Label->show(); + + ui->install->setEnabled(true); + +} + +void MainWindow::installImageSet () { + nameDialog =new NameDialog(this); + nameDialog->setWindowTitle ("Choose a name"); + connect (nameDialog, SIGNAL (nameEntered(QString)),this,SLOT(installImageSetWithName(QString))); + nameDialog->show(); +} + + +void MainWindow::installImageSetWithName(QString name) { + QTextStream out (stdout); + nameDialog->close(); + ProgressDialog *progress = new ProgressDialog (this); + connect (this,SIGNAL (installationStatusUpdate(int)),progress,SLOT(updateInstallationStatus(int))); + connect (this,SIGNAL (installationFinished()),progress,SLOT(installationFinished())); + progress->show(); + #ifdef Q_WS_HILDON + QString base = "/home/user/MyDocs/.images/"; + #else + QString base = "/home/dwilms/testapp/"; + #endif + QString filename = base +name; + out << filename; + if (QFileInfo (filename+"1.png").exists()) { + int i = 1; + QString basic_filename (filename); + while (QFileInfo (filename+"-1.png").exists()) { + filename=basic_filename+"-"+QString::number(i); + i=i+1; + } + } + emit installationStatusUpdate(10); + bool suc = false; + suc = img_1->save(filename+"-1.png"); + if (suc){ + emit installationStatusUpdate(30); + suc = img_2->save(filename+"-2.png"); + } + if (suc) { + emit installationStatusUpdate(50); + suc = img_3->save(filename+"-3.png"); + } + if (suc) { + emit installationStatusUpdate(70); + suc = img_4->save(filename+"-4.png"); + } + if (suc) { + emit installationStatusUpdate(90); + //create install file + QFile file (base + "."+name+".desktop"); + if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) { + out << "fileerror " + file.fileName()<< endl; + //todo + } + QTextStream file_writer (&file); + file_writer << "[Desktop Entry]\nType=Background Image\nName="+name+"\nHidden=true" << endl; + file_writer << "X-File1="+filename+"-1.png" << endl; + file_writer << "X-File2="+filename+"-2.png" << endl; + file_writer << "X-File3="+filename+"-3.png" << endl; + file_writer << "X-File4="+filename+"-4.png" << endl; + file_writer << "X-Order=1" << endl; + file.close(); + emit installationFinished(); + } + else { + //error + } + disconnect (this,SIGNAL (installationStatusUpdate(int)),progress,SLOT(updateInstallationStatus(int))); + disconnect (this,SIGNAL (installationFinished()),progress,SLOT(installationFinished())); + +} + diff --git a/src/mainwindow.h b/src/mainwindow.h new file mode 100644 index 0000000..0e9e057 --- /dev/null +++ b/src/mainwindow.h @@ -0,0 +1,48 @@ +#ifndef MAINWINDOW_H +#define MAINWINDOW_H + +#include +#include +#include +#include +#include +#include "namedialog.h" + +namespace Ui +{ + class MainWindowClass; +} + +class MainWindow : public QMainWindow +{ + Q_OBJECT + +public: + MainWindow(QWidget *parent = 0); + ~MainWindow(); + + +public slots: + void openFile(); + void getImage (QString); + void cropImage (); + void installImageSet(); + void installImageSetWithName(QString); + +signals: + void installationStatusUpdate (int); + void installationFinished (); + + + +private: + Ui::MainWindowClass *ui; + QPixmap *basicImage; + QPixmap *img_1; + QPixmap *img_2; + QPixmap *img_3; + QPixmap *img_4; + NameDialog *nameDialog; +}; + +#endif // MAINWINDOW_H diff --git a/src/mainwindow.ui b/src/mainwindow.ui new file mode 100644 index 0000000..ca2d542 --- /dev/null +++ b/src/mainwindow.ui @@ -0,0 +1,176 @@ + + + MainWindowClass + + + Qt::ApplicationModal + + + + 0 + 0 + 800 + 400 + + + + + 0 + 0 + + + + + 800 + 480 + + + + MainWindow + + + + + + 80 + 50 + 661 + 110 + + + + + 0 + 0 + + + + + + + 240 + 310 + 531 + 71 + + + + Qt::Horizontal + + + + true + + + Select + + + + + false + + + Crop Image + + + + + false + + + Install + + + + + false + + + Set + + + + + + + 80 + 180 + 661 + 101 + + + + + + + + + + + + + + + + + + + + + + + + select + clicked() + MainWindowClass + openFile() + + + 324 + 365 + + + 235 + 316 + + + + + crop + clicked() + MainWindowClass + cropImage() + + + 424 + 341 + + + 427 + 278 + + + + + install + clicked() + MainWindowClass + installImageSet() + + + 604 + 341 + + + 595 + 306 + + + + + + openFile() + cropImage() + installImageSet() + + diff --git a/src/namedialog.cpp b/src/namedialog.cpp new file mode 100644 index 0000000..bf73de1 --- /dev/null +++ b/src/namedialog.cpp @@ -0,0 +1,45 @@ +#include "namedialog.h" +#include "ui_namedialog.h" +#include + +NameDialog::NameDialog(QWidget *parent) : + QDialog(parent), + m_ui(new Ui::NameDialog) +{ + m_ui->setupUi(this); + connect (m_ui->nameInput, SIGNAL (textChanged(QString)),this,SLOT (activateButton(QString))); +} + +NameDialog::~NameDialog() +{ + delete m_ui; +} + +void NameDialog::changeEvent(QEvent *e) +{ + switch (e->type()) { + case QEvent::LanguageChange: + m_ui->retranslateUi(this); + break; + default: + break; + } +} + + +void NameDialog::acceptName() { + QTextStream out (stdout); + out << m_ui->nameInput->text() << endl; + emit nameEntered (m_ui->nameInput->text()); + this->close(); +} + + +void NameDialog::activateButton(QString enteredName) { + if (!enteredName.isEmpty()) { + m_ui->acceptButton->setEnabled(true); + } + else { + m_ui->acceptButton->setEnabled(false); + } +} diff --git a/src/namedialog.h b/src/namedialog.h new file mode 100644 index 0000000..46c6d1d --- /dev/null +++ b/src/namedialog.h @@ -0,0 +1,33 @@ +#ifndef NAMEDIALOG_H +#define NAMEDIALOG_H + +#include + +namespace Ui { + class NameDialog; +} + +class NameDialog : public QDialog { + Q_OBJECT + Q_DISABLE_COPY(NameDialog) + +public: + explicit NameDialog(QWidget *parent = 0); + virtual ~NameDialog(); + +signals: + void nameEntered (QString); + +protected: + virtual void changeEvent(QEvent *e); + +public slots: + void acceptName (); + void activateButton (QString); + + +private: + Ui::NameDialog *m_ui; +}; + +#endif // NAMEDIALOG_H diff --git a/src/namedialog.ui b/src/namedialog.ui new file mode 100644 index 0000000..c492adf --- /dev/null +++ b/src/namedialog.ui @@ -0,0 +1,65 @@ + + + NameDialog + + + + 0 + 0 + 800 + 150 + + + + Dialog + + + + + 130 + 50 + 391 + 51 + + + + + + false + + + + 630 + 40 + 111 + 71 + + + + OK + + + + + + + acceptButton + clicked() + NameDialog + acceptName() + + + 604 + 89 + + + 536 + 126 + + + + + + acceptName() + + diff --git a/src/processingdialog.cpp b/src/processingdialog.cpp new file mode 100644 index 0000000..887f17b --- /dev/null +++ b/src/processingdialog.cpp @@ -0,0 +1,25 @@ +#include "processingdialog.h" +#include "ui_processingdialog.h" + +ProcessingDialog::ProcessingDialog(QWidget *parent) : + QDialog(parent), + m_ui(new Ui::ProcessingDialog) +{ + m_ui->setupUi(this); +} + +ProcessingDialog::~ProcessingDialog() +{ + delete m_ui; +} + +void ProcessingDialog::changeEvent(QEvent *e) +{ + switch (e->type()) { + case QEvent::LanguageChange: + m_ui->retranslateUi(this); + break; + default: + break; + } +} diff --git a/src/processingdialog.ui b/src/processingdialog.ui new file mode 100644 index 0000000..bb6f635 --- /dev/null +++ b/src/processingdialog.ui @@ -0,0 +1,64 @@ + + + ProgressDialog + + + + 0 + 0 + 800 + 150 + + + + Dialog + + + + + 110 + 30 + 391 + 41 + + + + 24 + + + + + false + + + + 60 + 80 + 511 + 31 + + + + ImageSet installed. It is now available in: Desktop > Change Background + + + + + false + + + + 600 + 30 + 141 + 61 + + + + Finish + + + + + + diff --git a/src/progressdialog.cpp b/src/progressdialog.cpp new file mode 100644 index 0000000..ff8b805 --- /dev/null +++ b/src/progressdialog.cpp @@ -0,0 +1,39 @@ +#include "progressdialog.h" +#include "ui_progressdialog.h" + +ProgressDialog::ProgressDialog(QWidget *parent) : + QDialog(parent), + m_ui(new Ui::ProgressDialog) +{ + m_ui->setupUi(this); + m_ui->noticedButton->setVisible(false); + m_ui->doneLabel->setVisible(false); +} + +ProgressDialog::~ProgressDialog() +{ + delete m_ui; +} + +void ProgressDialog::changeEvent(QEvent *e) +{ + switch (e->type()) { + case QEvent::LanguageChange: + m_ui->retranslateUi(this); + break; + default: + break; + } +} + + +void ProgressDialog::updateInstallationStatus(int status) { + m_ui->progressBar->setValue(status); +} + +void ProgressDialog::installationFinished () { + m_ui->progressBar->setValue(100); + m_ui->progressBar->setVisible(false); + m_ui->noticedButton->setVisible(true); + m_ui->doneLabel->setVisible(true); +} diff --git a/src/progressdialog.h b/src/progressdialog.h new file mode 100644 index 0000000..f294ac2 --- /dev/null +++ b/src/progressdialog.h @@ -0,0 +1,28 @@ +#ifndef PROGRESSDIALOG_H +#define PROGRESSDIALOG_H + +#include + +namespace Ui { + class ProgressDialog; +} + +class ProgressDialog : public QDialog { + Q_OBJECT + Q_DISABLE_COPY(ProgressDialog) +public: + explicit ProgressDialog(QWidget *parent = 0); + virtual ~ProgressDialog(); + +public slots: + void updateInstallationStatus(int); + void installationFinished (); + +protected: + virtual void changeEvent(QEvent *e); + +private: + Ui::ProgressDialog *m_ui; +}; + +#endif // PROGRESSDIALOG_H diff --git a/src/progressdialog.ui b/src/progressdialog.ui new file mode 100644 index 0000000..4ec9922 --- /dev/null +++ b/src/progressdialog.ui @@ -0,0 +1,81 @@ + + + ProgressDialog + + + + 0 + 0 + 800 + 200 + + + + Dialog + + + + + 160 + 50 + 401 + 81 + + + + 0 + + + + + true + + + + 120 + 60 + 481 + 51 + + + + Done. Now available as ImageSet! + + + + + true + + + + 600 + 50 + 131 + 61 + + + + OK + + + + + + + noticedButton + clicked() + ProgressDialog + accept() + + + 677 + 70 + + + 677 + 312 + + + + + -- 1.7.9.5