--- /dev/null
+# -------------------------------------------------
+# 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
--- /dev/null
+#include <QtGui/QApplication>
+#include "mainwindow.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication a(argc, argv);
+ MainWindow w;
+ w.show();
+ return a.exec();
+}
--- /dev/null
+#include "mainwindow.h"
+#include "ui_mainwindow.h"
+#include "progressdialog.h"
+
+#include <QFileInfo>
+
+
+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()));
+
+}
+
--- /dev/null
+#ifndef MAINWINDOW_H
+#define MAINWINDOW_H
+
+#include <QtGui/QMainWindow>
+#include <QFileDialog>
+#include <QLabel>
+#include <QPixmap>
+#include <QTextStream>
+#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
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>MainWindowClass</class>
+ <widget class="QMainWindow" name="MainWindowClass">
+ <property name="windowModality">
+ <enum>Qt::ApplicationModal</enum>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>800</width>
+ <height>400</height>
+ </rect>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>800</width>
+ <height>480</height>
+ </size>
+ </property>
+ <property name="windowTitle">
+ <string>MainWindow</string>
+ </property>
+ <widget class="QWidget" name="centralWidget">
+ <widget class="QWidget" name="originalImage" native="true">
+ <property name="geometry">
+ <rect>
+ <x>80</x>
+ <y>50</y>
+ <width>661</width>
+ <height>110</height>
+ </rect>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ </widget>
+ <widget class="QSplitter" name="splitter">
+ <property name="geometry">
+ <rect>
+ <x>240</x>
+ <y>310</y>
+ <width>531</width>
+ <height>71</height>
+ </rect>
+ </property>
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <widget class="QPushButton" name="select">
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="text">
+ <string>Select</string>
+ </property>
+ </widget>
+ <widget class="QPushButton" name="crop">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>Crop Image</string>
+ </property>
+ </widget>
+ <widget class="QPushButton" name="install">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>Install</string>
+ </property>
+ </widget>
+ <widget class="QPushButton" name="set">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>Set</string>
+ </property>
+ </widget>
+ </widget>
+ <widget class="QWidget" name="layoutWidget">
+ <property name="geometry">
+ <rect>
+ <x>80</x>
+ <y>180</y>
+ <width>661</width>
+ <height>101</height>
+ </rect>
+ </property>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <widget class="QWidget" name="image_1" native="true"/>
+ </item>
+ <item>
+ <widget class="QWidget" name="image_2" native="true"/>
+ </item>
+ <item>
+ <widget class="QWidget" name="image_3" native="true"/>
+ </item>
+ <item>
+ <widget class="QWidget" name="image_4" native="true"/>
+ </item>
+ </layout>
+ </widget>
+ </widget>
+ </widget>
+ <layoutdefault spacing="6" margin="11"/>
+ <resources/>
+ <connections>
+ <connection>
+ <sender>select</sender>
+ <signal>clicked()</signal>
+ <receiver>MainWindowClass</receiver>
+ <slot>openFile()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>324</x>
+ <y>365</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>235</x>
+ <y>316</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>crop</sender>
+ <signal>clicked()</signal>
+ <receiver>MainWindowClass</receiver>
+ <slot>cropImage()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>424</x>
+ <y>341</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>427</x>
+ <y>278</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>install</sender>
+ <signal>clicked()</signal>
+ <receiver>MainWindowClass</receiver>
+ <slot>installImageSet()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>604</x>
+ <y>341</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>595</x>
+ <y>306</y>
+ </hint>
+ </hints>
+ </connection>
+ </connections>
+ <slots>
+ <slot>openFile()</slot>
+ <slot>cropImage()</slot>
+ <slot>installImageSet()</slot>
+ </slots>
+</ui>
--- /dev/null
+#include "namedialog.h"
+#include "ui_namedialog.h"
+#include <QTextStream>
+
+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);
+ }
+}
--- /dev/null
+#ifndef NAMEDIALOG_H
+#define NAMEDIALOG_H
+
+#include <QtGui/QDialog>
+
+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
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>NameDialog</class>
+ <widget class="QDialog" name="NameDialog">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>800</width>
+ <height>150</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Dialog</string>
+ </property>
+ <widget class="QLineEdit" name="nameInput">
+ <property name="geometry">
+ <rect>
+ <x>130</x>
+ <y>50</y>
+ <width>391</width>
+ <height>51</height>
+ </rect>
+ </property>
+ </widget>
+ <widget class="QPushButton" name="acceptButton">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>630</x>
+ <y>40</y>
+ <width>111</width>
+ <height>71</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>OK</string>
+ </property>
+ </widget>
+ </widget>
+ <resources/>
+ <connections>
+ <connection>
+ <sender>acceptButton</sender>
+ <signal>clicked()</signal>
+ <receiver>NameDialog</receiver>
+ <slot>acceptName()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>604</x>
+ <y>89</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>536</x>
+ <y>126</y>
+ </hint>
+ </hints>
+ </connection>
+ </connections>
+ <slots>
+ <slot>acceptName()</slot>
+ </slots>
+</ui>
--- /dev/null
+#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;
+ }
+}
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>ProgressDialog</class>
+ <widget class="QDialog" name="ProgressDialog">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>800</width>
+ <height>150</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Dialog</string>
+ </property>
+ <widget class="QProgressBar" name="progressBar">
+ <property name="geometry">
+ <rect>
+ <x>110</x>
+ <y>30</y>
+ <width>391</width>
+ <height>41</height>
+ </rect>
+ </property>
+ <property name="value">
+ <number>24</number>
+ </property>
+ </widget>
+ <widget class="QLabel" name="label">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>60</x>
+ <y>80</y>
+ <width>511</width>
+ <height>31</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>ImageSet installed. It is now available in: Desktop > Change Background</string>
+ </property>
+ </widget>
+ <widget class="QPushButton" name="finishButton">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>600</x>
+ <y>30</y>
+ <width>141</width>
+ <height>61</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>Finish</string>
+ </property>
+ </widget>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
--- /dev/null
+#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);
+}
--- /dev/null
+#ifndef PROGRESSDIALOG_H
+#define PROGRESSDIALOG_H
+
+#include <QtGui/QDialog>
+
+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
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>ProgressDialog</class>
+ <widget class="QDialog" name="ProgressDialog">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>800</width>
+ <height>200</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Dialog</string>
+ </property>
+ <widget class="QProgressBar" name="progressBar">
+ <property name="geometry">
+ <rect>
+ <x>160</x>
+ <y>50</y>
+ <width>401</width>
+ <height>81</height>
+ </rect>
+ </property>
+ <property name="value">
+ <number>0</number>
+ </property>
+ </widget>
+ <widget class="QLabel" name="doneLabel">
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>120</x>
+ <y>60</y>
+ <width>481</width>
+ <height>51</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>Done. Now available as ImageSet!</string>
+ </property>
+ </widget>
+ <widget class="QPushButton" name="noticedButton">
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>600</x>
+ <y>50</y>
+ <width>131</width>
+ <height>61</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>OK</string>
+ </property>
+ </widget>
+ </widget>
+ <resources/>
+ <connections>
+ <connection>
+ <sender>noticedButton</sender>
+ <signal>clicked()</signal>
+ <receiver>ProgressDialog</receiver>
+ <slot>accept()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>677</x>
+ <y>70</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>677</x>
+ <y>312</y>
+ </hint>
+ </hints>
+ </connection>
+ </connections>
+</ui>