-easylist (0.3.4) unstable; urgency=low
+easylist (0.3.5) unstable; urgency=low
- * Now supports sorting checked items to bottom of the list.
+ * Button added for unchecking all checked items.
-- Willem Liu <willem.liu@gmail.com> Tue, 07 Sep 2010 13:56:12 +0200
+++ /dev/null
-auto
\ No newline at end of file
--- /dev/null
+#!/usr/bin/make -f
+APPNAME := easylist
+builddir:
+ mkdir -p builddir
+
+builddir/Makefile: builddir
+ cd builddir && qmake-qt4 PREFIX=/usr ../$(APPNAME).pro
+
+build: build-stamp
+
+build-stamp: builddir/Makefile
+ dh_testdir
+ # Add here commands to compile the package.
+ cd builddir && $(MAKE)
+ touch $@
+
+clean:
+ dh_testdir
+ dh_testroot
+ rm -f build-stamp
+ # Add here commands to clean up after the build process.
+ rm -rf builddir
+ dh_clean
+install: build
+ dh_testdir
+ dh_testroot
+ dh_clean -k
+ dh_installdirs
+
+ # Add here commands to install the package into debian/your_appname
+ cd builddir && $(MAKE) INSTALL_ROOT=$(CURDIR)/debian/$(APPNAME) install
+# Build architecture-independent files here.
+binary-indep: build install
+# We have nothing to do by default.
+
+# Build architecture-dependent files here.
+binary-arch: build install
+ dh_testdir
+ dh_testroot
+ dh_installdocs
+ dh_installexamples
+ dh_installman
+ dh_link
+ #dh_strip --dbg-package=dicer-dbg
+ dh_compress
+ dh_fixperms
+ dh_installdeb
+ dh_shlibdeps
+ dh_gencontrol
+ dh_md5sums
+ dh_builddeb
+
+binary: binary-indep binary-arch
+.PHONY: build clean binary-indep binary-arch binary install configure
<qtcreator>
<data>
<variable>ProjectExplorer.Project.ActiveTarget</variable>
- <value type="int">1</value>
+ <value type="int">0</value>
</data>
<data>
<variable>ProjectExplorer.Project.EditorSettings</variable>
<value key="Packaging Enabled" type="bool">true</value>
<value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString"></value>
<value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">Qt4ProjectManager.MaemoPackageCreationStep</value>
- <valuelist key="Qt4ProjectManager.BuildStep.MaemoPackage.LocalFiles" type="QVariantList">
- <value type="QString">C:/dev/cpp/easylist-0.3.4/src/data/26x26/easylist.png</value>
- <value type="QString">C:/dev/cpp/easylist-0.3.4/src/data/40x40/easylist.png</value>
- <value type="QString">C:/dev/cpp/easylist-0.3.4/src/data/48x48/easylist.png</value>
- <value type="QString">C:/dev/cpp/easylist-0.3.4/src/data/64x64/easylist.png</value>
- <value type="QString">C:/dev/cpp/easylist-0.3.4/src/easylist.desktop</value>
- </valuelist>
- <value key="Qt4ProjectManager.BuildStep.MaemoPackage.Modified" type="bool">false</value>
- <value key="Qt4ProjectManager.BuildStep.MaemoPackage.RemoteExe" type="QString">/usr/local/bin/easylist</value>
- <valuelist key="Qt4ProjectManager.BuildStep.MaemoPackage.RemoteFiles" type="QVariantList">
- <value type="QString">/usr/share/icons/hicolor/26x26/apps/easylist.png</value>
- <value type="QString">/usr/share/icons/hicolor/40x40/apps/easylist.png</value>
- <value type="QString">/usr/share/icons/hicolor/48x48/apps/easylist.png</value>
- <value type="QString">/usr/share/icons/hicolor/64x64/apps/easylist.png</value>
- <value type="QString">/usr/share/applications/hildon/easylist.desktop</value>
- </valuelist>
+ <valuelist key="Qt4ProjectManager.BuildStep.MaemoPackage.LocalFiles" type="QVariantList"/>
+ <value key="Qt4ProjectManager.BuildStep.MaemoPackage.Modified" type="bool">true</value>
+ <value key="Qt4ProjectManager.BuildStep.MaemoPackage.RemoteExe" type="QString"></value>
+ <valuelist key="Qt4ProjectManager.BuildStep.MaemoPackage.RemoteFiles" type="QVariantList"/>
<value key="Version Number" type="QString">0.0.1</value>
</valuemap>
<value key="ProjectExplorer.BuildConfiguration.BuildStepsCount" type="int">3</value>
<value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">Qt4ProjectManager.Qt4BuildConfiguration</value>
<value key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration" type="int">2</value>
<value key="Qt4ProjectManager.Qt4BuildConfiguration.BuildDirectory" type="QString">C:/dev/cpp/easylist-0.3.4</value>
- <value key="Qt4ProjectManager.Qt4BuildConfiguration.QtVersionId" type="int">4</value>
+ <value key="Qt4ProjectManager.Qt4BuildConfiguration.QtVersionId" type="int">27</value>
<value key="Qt4ProjectManager.Qt4BuildConfiguration.ToolChain" type="int">9</value>
<value key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild" type="bool">false</value>
</valuemap>
<value type="QString">/usr/share/icons/hicolor/48x48/apps/easylist.png</value>
<value type="QString">/usr/share/icons/hicolor/64x64/apps/easylist.png</value>
</valuelist>
- <value key="Version Number" type="QString">0.3.4</value>
+ <value key="Version Number" type="QString">0.3.5</value>
</valuemap>
<value key="ProjectExplorer.BuildConfiguration.BuildStepsCount" type="int">3</value>
<valuemap key="ProjectExplorer.BuildConfiguration.CleanStep.0" type="QVariantMap">
<value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">Qt4ProjectManager.Qt4BuildConfiguration</value>
<value key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration" type="int">0</value>
<value key="Qt4ProjectManager.Qt4BuildConfiguration.BuildDirectory" type="QString">C:/dev/cpp/easylist-0.3.4</value>
- <value key="Qt4ProjectManager.Qt4BuildConfiguration.QtVersionId" type="int">4</value>
+ <value key="Qt4ProjectManager.Qt4BuildConfiguration.QtVersionId" type="int">27</value>
<value key="Qt4ProjectManager.Qt4BuildConfiguration.ToolChain" type="int">9</value>
<value key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild" type="bool">false</value>
</valuemap>
--- /dev/null
+#include "editform.h"\r
+#include "ui_editform.h"\r
+\r
+EditForm::EditForm(QWidget *parent) :\r
+ SlideWidget(parent),\r
+ ui(new Ui::EditForm)\r
+{\r
+ ui->setupUi(this);\r
+ settings = new QSettings(WILLEM_LIU, EASY_LIST);\r
+ shown();\r
+}\r
+\r
+EditForm::~EditForm()\r
+{\r
+ delete ui;\r
+}\r
+\r
+void EditForm::shown()\r
+{\r
+ ui->textEdit->setText(MyCheckBoxContainer::getInstance()->getListText());\r
+}\r
+\r
+void EditForm::on_savePushButton_clicked()\r
+{\r
+ qDebug() << "Save";\r
+ settings->setValue(LIST_TEXT, ui->textEdit->toPlainText());\r
+ emit signalSavePushButtonClicked(this);\r
+}\r
+\r
+void EditForm::on_cancelPushButton_clicked()\r
+{\r
+ qDebug() << "Cancel";\r
+ emit signalCancelPushButtonClicked(this);\r
+}\r
--- /dev/null
+#ifndef EDITFORM_H\r
+#define EDITFORM_H\r
+\r
+#include <QWidget>\r
+#include <QDebug>\r
+#include <QSettings>\r
+#include "mycheckboxcontainer.h"\r
+#include "slidewidget.h"\r
+\r
+#define WILLEM_LIU "WillemLiu"\r
+#define EASY_LIST "easylist"\r
+#define LIST_TEXT "ListText"\r
+\r
+namespace Ui {\r
+ class EditForm;\r
+}\r
+\r
+class EditForm : public SlideWidget\r
+{\r
+ Q_OBJECT\r
+\r
+public:\r
+ explicit EditForm(QWidget *parent = 0);\r
+ ~EditForm();\r
+\r
+ virtual void shown();\r
+\r
+private:\r
+ Ui::EditForm *ui;\r
+\r
+ QSettings * settings;\r
+\r
+signals:\r
+ void signalSavePushButtonClicked(SlideWidget * thisWidget);\r
+ void signalCancelPushButtonClicked(SlideWidget * thisWidget);\r
+\r
+private slots:\r
+ void on_cancelPushButton_clicked();\r
+ void on_savePushButton_clicked();\r
+};\r
+\r
+#endif // EDITFORM_H\r
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>\r
+<ui version="4.0">\r
+ <class>EditForm</class>\r
+ <widget class="QWidget" name="EditForm">\r
+ <property name="geometry">\r
+ <rect>\r
+ <x>0</x>\r
+ <y>0</y>\r
+ <width>400</width>\r
+ <height>300</height>\r
+ </rect>\r
+ </property>\r
+ <property name="windowTitle">\r
+ <string>Form</string>\r
+ </property>\r
+ <layout class="QGridLayout" name="gridLayout">\r
+ <property name="margin">\r
+ <number>0</number>\r
+ </property>\r
+ <property name="spacing">\r
+ <number>0</number>\r
+ </property>\r
+ <item row="1" column="0">\r
+ <layout class="QHBoxLayout" name="horizontalLayout">\r
+ <property name="spacing">\r
+ <number>0</number>\r
+ </property>\r
+ <item>\r
+ <widget class="QPushButton" name="savePushButton">\r
+ <property name="text">\r
+ <string>Save</string>\r
+ </property>\r
+ </widget>\r
+ </item>\r
+ <item>\r
+ <widget class="QPushButton" name="cancelPushButton">\r
+ <property name="text">\r
+ <string>Cancel</string>\r
+ </property>\r
+ </widget>\r
+ </item>\r
+ </layout>\r
+ </item>\r
+ <item row="0" column="0">\r
+ <layout class="QGridLayout" name="gridLayout_2">\r
+ <item row="0" column="0">\r
+ <widget class="QTextEdit" name="textEdit"/>\r
+ </item>\r
+ </layout>\r
+ </item>\r
+ </layout>\r
+ </widget>\r
+ <resources/>\r
+ <connections/>\r
+</ui>\r
--- /dev/null
+#include "listform.h"\r
+#include "ui_listform.h"\r
+\r
+ListForm::ListForm(QWidget *parent) :\r
+ SlideWidget(parent),\r
+ ui(new Ui::ListForm)\r
+{\r
+ ui->setupUi(this);\r
+ ui->checkBoxVerticalLayout->setAlignment(Qt::AlignTop);\r
+\r
+ settings = new QSettings(WILLEM_LIU, EASY_LIST);\r
+\r
+ // Add the list text to the MyCheckBoxContainer. It will create a list of MyCheckBox objects.\r
+ MyCheckBoxContainer::getInstance()->add(settings->value(LIST_TEXT, "").toString());\r
+ connect(MyCheckBoxContainer::getInstance(), SIGNAL(signalSorted()), this, SLOT(addCheckBoxes()));\r
+ addCheckBoxes();\r
+}\r
+\r
+ListForm::~ListForm()\r
+{\r
+ delete ui;\r
+}\r
+\r
+void ListForm::shown()\r
+{\r
+ MyCheckBoxContainer::getInstance()->set(settings->value(LIST_TEXT, "").toString());\r
+ addCheckBoxes();\r
+}\r
+\r
+void ListForm::addCheckBoxes()\r
+{\r
+ // Add the MyCheckBox items to the view.\r
+ foreach(MyCheckBox * cb, MyCheckBoxContainer::getInstance()->getCheckBoxes())\r
+ {\r
+ // Reset the parent.\r
+ ui->checkBoxVerticalLayout->addWidget(cb);\r
+ }\r
+}\r
+\r
+\r
+void ListForm::on_editListPushButton_clicked()\r
+{\r
+ // Do animation. Then emit signalEditListPushButtonTriggered when finished.\r
+ emit signalEditListPushButtonTriggered(this);\r
+}\r
+\r
+void ListForm::on_uncheckAllPushButton_clicked()\r
+{\r
+ MyCheckBoxContainer::getInstance()->uncheckAll();\r
+}\r
+\r
+void ListForm::on_clearCheckedPushButton_clicked()\r
+{\r
+ MyCheckBoxContainer::getInstance()->removeChecked();\r
+}\r
--- /dev/null
+#ifndef LISTFORM_H\r
+#define LISTFORM_H\r
+\r
+#include <QWidget>\r
+#include <QSettings>\r
+#include "mycheckboxcontainer.h"\r
+#include "systemsettings.h"\r
+#include "slidewidget.h"\r
+\r
+#define WILLEM_LIU "WillemLiu"\r
+#define EASY_LIST "easylist"\r
+#define LIST_TEXT "ListText"\r
+\r
+namespace Ui {\r
+ class ListForm;\r
+}\r
+\r
+class ListForm : public SlideWidget\r
+{\r
+ Q_OBJECT\r
+\r
+public:\r
+ explicit ListForm(QWidget *parent = 0);\r
+ ~ListForm();\r
+\r
+ virtual void shown();\r
+\r
+private:\r
+ QSettings * settings;\r
+\r
+ Ui::ListForm *ui;\r
+signals:\r
+ void signalEditListPushButtonTriggered(SlideWidget * thisWidget);\r
+\r
+private slots:\r
+ void on_clearCheckedPushButton_clicked();\r
+ void on_uncheckAllPushButton_clicked();\r
+ void on_editListPushButton_clicked();\r
+ void addCheckBoxes();\r
+};\r
+\r
+#endif // LISTFORM_H\r
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>\r
+<ui version="4.0">\r
+ <class>ListForm</class>\r
+ <widget class="QWidget" name="ListForm">\r
+ <property name="geometry">\r
+ <rect>\r
+ <x>0</x>\r
+ <y>0</y>\r
+ <width>400</width>\r
+ <height>300</height>\r
+ </rect>\r
+ </property>\r
+ <property name="windowTitle">\r
+ <string>Form</string>\r
+ </property>\r
+ <layout class="QGridLayout" name="gridLayout">\r
+ <property name="margin">\r
+ <number>0</number>\r
+ </property>\r
+ <property name="spacing">\r
+ <number>0</number>\r
+ </property>\r
+ <item row="1" column="0">\r
+ <layout class="QHBoxLayout" name="horizontalLayout">\r
+ <property name="spacing">\r
+ <number>0</number>\r
+ </property>\r
+ <item>\r
+ <widget class="QPushButton" name="editListPushButton">\r
+ <property name="text">\r
+ <string>Edit list</string>\r
+ </property>\r
+ </widget>\r
+ </item>\r
+ <item>\r
+ <widget class="QPushButton" name="uncheckAllPushButton">\r
+ <property name="text">\r
+ <string>Uncheck all</string>\r
+ </property>\r
+ </widget>\r
+ </item>\r
+ <item>\r
+ <widget class="QPushButton" name="clearCheckedPushButton">\r
+ <property name="text">\r
+ <string>Clear checked</string>\r
+ </property>\r
+ </widget>\r
+ </item>\r
+ </layout>\r
+ </item>\r
+ <item row="0" column="0">\r
+ <layout class="QGridLayout" name="gridLayout_2">\r
+ <item row="0" column="0">\r
+ <widget class="QScrollArea" name="scrollArea">\r
+ <property name="widgetResizable">\r
+ <bool>true</bool>\r
+ </property>\r
+ <property name="alignment">\r
+ <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>\r
+ </property>\r
+ <widget class="QWidget" name="scrollAreaWidgetContents">\r
+ <property name="geometry">\r
+ <rect>\r
+ <x>0</x>\r
+ <y>0</y>\r
+ <width>396</width>\r
+ <height>271</height>\r
+ </rect>\r
+ </property>\r
+ <layout class="QGridLayout" name="gridLayout_3">\r
+ <property name="margin">\r
+ <number>0</number>\r
+ </property>\r
+ <property name="spacing">\r
+ <number>0</number>\r
+ </property>\r
+ <item row="0" column="0">\r
+ <layout class="QVBoxLayout" name="checkBoxVerticalLayout">\r
+ <property name="spacing">\r
+ <number>0</number>\r
+ </property>\r
+ </layout>\r
+ </item>\r
+ </layout>\r
+ </widget>\r
+ </widget>\r
+ </item>\r
+ </layout>\r
+ </item>\r
+ </layout>\r
+ </widget>\r
+ <resources/>\r
+ <connections/>\r
+</ui>\r
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>\r
-<ui version="4.0">\r
- <class>ListWindow</class>\r
- <widget class="QMainWindow" name="ListWindow">\r
- <property name="geometry">\r
- <rect>\r
- <x>0</x>\r
- <y>0</y>\r
- <width>800</width>\r
- <height>480</height>\r
- </rect>\r
- </property>\r
- <property name="sizePolicy">\r
- <sizepolicy hsizetype="Preferred" vsizetype="Preferred">\r
- <horstretch>0</horstretch>\r
- <verstretch>0</verstretch>\r
- </sizepolicy>\r
- </property>\r
- <property name="windowTitle">\r
- <string>EasyList - by Willem Liu</string>\r
- </property>\r
- <widget class="QWidget" name="centralwidget">\r
- <layout class="QVBoxLayout" name="verticalLayout">\r
- <item>\r
- <widget class="QScrollArea" name="scrollArea">\r
- <property name="sizePolicy">\r
- <sizepolicy hsizetype="Expanding" vsizetype="Expanding">\r
- <horstretch>0</horstretch>\r
- <verstretch>0</verstretch>\r
- </sizepolicy>\r
- </property>\r
- <property name="verticalScrollBarPolicy">\r
- <enum>Qt::ScrollBarAsNeeded</enum>\r
- </property>\r
- <property name="widgetResizable">\r
- <bool>true</bool>\r
- </property>\r
- <property name="alignment">\r
- <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>\r
- </property>\r
- <widget class="QWidget" name="scrollAreaWidgetContents">\r
- <property name="geometry">\r
- <rect>\r
- <x>0</x>\r
- <y>0</y>\r
- <width>780</width>\r
- <height>408</height>\r
- </rect>\r
- </property>\r
- <layout class="QGridLayout" name="gridLayout">\r
- <item row="0" column="0">\r
- <layout class="QVBoxLayout" name="listVerticalLayout">\r
- <property name="spacing">\r
- <number>6</number>\r
- </property>\r
- <property name="sizeConstraint">\r
- <enum>QLayout::SetDefaultConstraint</enum>\r
- </property>\r
- <property name="rightMargin">\r
- <number>6</number>\r
- </property>\r
- </layout>\r
- </item>\r
- </layout>\r
- </widget>\r
- </widget>\r
- </item>\r
- <item>\r
- <layout class="QHBoxLayout" name="horizontalLayout">\r
- <property name="spacing">\r
- <number>6</number>\r
- </property>\r
- <property name="sizeConstraint">\r
- <enum>QLayout::SetDefaultConstraint</enum>\r
- </property>\r
- <item>\r
- <widget class="QPushButton" name="editListPushButton">\r
- <property name="text">\r
- <string>Edit list</string>\r
- </property>\r
- </widget>\r
- </item>\r
- <item>\r
- <widget class="QPushButton" name="clearSelectedPushButton">\r
- <property name="text">\r
- <string>Clear selected</string>\r
- </property>\r
- </widget>\r
- </item>\r
- </layout>\r
- </item>\r
- </layout>\r
- </widget>\r
- <widget class="QMenuBar" name="menubar">\r
- <property name="geometry">\r
- <rect>\r
- <x>0</x>\r
- <y>0</y>\r
- <width>800</width>\r
- <height>21</height>\r
- </rect>\r
- </property>\r
- <widget class="QMenu" name="menuAbout">\r
- <property name="title">\r
- <string>About</string>\r
- </property>\r
- <addaction name="actionAbout"/>\r
- </widget>\r
- <widget class="QMenu" name="menuRotate">\r
- <property name="title">\r
- <string>Rotate</string>\r
- </property>\r
- <addaction name="actionRotate"/>\r
- </widget>\r
- <widget class="QMenu" name="menuChecked_Bottom">\r
- <property name="title">\r
- <string>Checked Bottom</string>\r
- </property>\r
- <addaction name="actionChecked_Bottom"/>\r
- </widget>\r
- <addaction name="menuRotate"/>\r
- <addaction name="menuAbout"/>\r
- <addaction name="menuChecked_Bottom"/>\r
- </widget>\r
- <action name="actionAbout">\r
- <property name="text">\r
- <string>About</string>\r
- </property>\r
- </action>\r
- <action name="actionRotate">\r
- <property name="text">\r
- <string>Rotate</string>\r
- </property>\r
- </action>\r
- <action name="actionChecked_Bottom">\r
- <property name="checkable">\r
- <bool>true</bool>\r
- </property>\r
- <property name="checked">\r
- <bool>false</bool>\r
- </property>\r
- <property name="text">\r
- <string>Checked Bottom</string>\r
- </property>\r
- </action>\r
- </widget>\r
- <resources/>\r
- <connections/>\r
-</ui>\r
*/\r
\r
#include <QtGui/QApplication>\r
-#include "mainwindow.h"\r
+#include "mainform.h"\r
\r
int main(int argc, char *argv[])\r
{\r
QApplication a(argc, argv);\r
- MainWindow w;\r
+ MainForm w;\r
+\r
#if defined(Q_WS_S60)\r
w.showMaximized();\r
#else\r
--- /dev/null
+#include "mainform.h"\r
+#include "ui_mainform.h"\r
+\r
+MainForm::MainForm(QWidget *parent) :\r
+ QMainWindow(parent),\r
+ ui(new Ui::MainForm)\r
+{\r
+ ui->setupUi(this);\r
+ settings = new QSettings(WILLEM_LIU, EASY_LIST);\r
+\r
+ newIndex = 0;\r
+\r
+ connect(SystemSettings::getInstance(), SIGNAL(signalKeyboardClosed(bool)), this, SLOT(keyboardClosed(bool)));\r
+\r
+ // Set a default value for CHECKED_ITEMS_TO_BOTTOM\r
+ if(settings->contains(CHECKED_ITEMS_TO_BOTTOM) == false)\r
+ {\r
+ settings->setValue(CHECKED_ITEMS_TO_BOTTOM, false);\r
+ }\r
+ ui->actionChecked_bottom->setChecked(settings->value(CHECKED_ITEMS_TO_BOTTOM).toBool());\r
+ on_actionChecked_bottom_triggered();\r
+\r
+ // Create a default for landscape mode.\r
+ landscape = settings->value(LANDSCAPE).toBool();\r
+ // If LANDSCAPE exists in QSettings.\r
+ if(settings->contains(LANDSCAPE))\r
+ {\r
+ // We use the LANDSCAPE value in the QSettings.\r
+ landscape = settings->value(LANDSCAPE).toBool();\r
+ }\r
+ else\r
+ {\r
+ // Otherwise we set our default into the QSettings.\r
+ settings->setValue(LANDSCAPE, landscape);\r
+ }\r
+ // If keyboard is opened at start. We do landscape mode.\r
+ // Otherwise we do what's read from the QSettings.\r
+ if(SystemSettings::getInstance()->getKeyboardClosed() == false)\r
+ {\r
+ setLandscapeMode(true);\r
+ }\r
+ else\r
+ {\r
+ setLandscapeMode(landscape);\r
+ }\r
+\r
+ // Populate the QStackedWidget. ListForm is set as the current widget.\r
+ listForm = new ListForm(this);\r
+ editForm = new EditForm(this);\r
+\r
+ connect(listForm, SIGNAL(signalTransitionOutFinished()), this, SLOT(stateOutFinished()));\r
+ connect(listForm, SIGNAL(signalEditListPushButtonTriggered(SlideWidget*)), this, SLOT(changeWidget(SlideWidget*)));\r
+\r
+ connect(editForm, SIGNAL(signalTransitionOutFinished()), this, SLOT(stateOutFinished()));\r
+ connect(editForm, SIGNAL(signalCancelPushButtonClicked(SlideWidget*)), this, SLOT(changeWidget(SlideWidget*)));\r
+ connect(editForm, SIGNAL(signalSavePushButtonClicked(SlideWidget*)), this, SLOT(changeWidget(SlideWidget*)));\r
+\r
+ ui->stackedWidget->addWidget(listForm);\r
+ ui->stackedWidget->addWidget(editForm);\r
+ ui->stackedWidget->setCurrentWidget(listForm);\r
+}\r
+\r
+MainForm::~MainForm()\r
+{\r
+ delete ui;\r
+}\r
+\r
+void MainForm::stateOutFinished()\r
+{\r
+ qDebug() << "Show new widget" << newIndex;\r
+ ui->stackedWidget->setCurrentIndex(newIndex);\r
+ SlideWidget * newWidget = dynamic_cast<SlideWidget * >(ui->stackedWidget->currentWidget());\r
+ newWidget->move(0, -newWidget->height());\r
+ newWidget->setStateIn();\r
+ newWidget->shown();\r
+}\r
+\r
+void MainForm::changeWidget(SlideWidget * currentWidget)\r
+{\r
+ currentWidget->initStates();\r
+ int currentIndex = ui->stackedWidget->indexOf(currentWidget);\r
+ // Because all widgets are started with StateOut as initial state, we\r
+ // need to reset the current widget to StateIn. The view is showing the\r
+ // current widget at the place of its StateIn position. But the state\r
+ // is never set to StateIn.\r
+ currentWidget->setStateIn();\r
+ qDebug() << "Current widget index" << currentIndex;\r
+ if(currentIndex < ui->stackedWidget->count()-1)\r
+ {\r
+ newIndex = currentIndex+1;\r
+ currentWidget->setStateOut();\r
+ }\r
+ else\r
+ {\r
+ if(ui->stackedWidget->count() > 0)\r
+ {\r
+ newIndex = 0;\r
+ currentWidget->setStateOut();\r
+ }\r
+ else\r
+ {\r
+ qDebug() << "StackedWidget does not have any widgets";\r
+ }\r
+ }\r
+ qDebug() << "New widget index" << newIndex;\r
+}\r
+\r
+void MainForm::keyboardClosed(bool closed)\r
+{\r
+ // When keyboard is opened.\r
+ if(closed == false)\r
+ {\r
+ setLandscapeMode(true);\r
+ }\r
+ else\r
+ {\r
+ setLandscapeMode(landscape);\r
+ }\r
+}\r
+\r
+void MainForm::setLandscapeMode(bool landscape)\r
+{\r
+ if(landscape)\r
+ {\r
+ tempLandscapeMode = true;\r
+ qDebug() << LANDSCAPE;\r
+#ifdef Q_WS_MAEMO_5\r
+ setAttribute(Qt::WA_Maemo5LandscapeOrientation, true);\r
+ setAttribute(Qt::WA_Maemo5PortraitOrientation, false);\r
+#endif\r
+ }\r
+ else\r
+ {\r
+ tempLandscapeMode = false;\r
+ qDebug() << PORTRAIT;\r
+#ifdef Q_WS_MAEMO_5\r
+ setAttribute(Qt::WA_Maemo5PortraitOrientation, true);\r
+ setAttribute(Qt::WA_Maemo5LandscapeOrientation, false);\r
+#endif\r
+ }\r
+}\r
+\r
+void MainForm::on_actionRotate_triggered()\r
+{\r
+ qDebug() << "Rotate";\r
+\r
+ landscape = !tempLandscapeMode;\r
+ settings->setValue(LANDSCAPE, landscape);\r
+ setLandscapeMode(landscape);\r
+}\r
+\r
+void MainForm::on_actionAbout_triggered()\r
+{\r
+ qDebug() << "About";\r
+ QString aboutText;\r
+ aboutText.append("EasyList (c) 2010\n\n");\r
+ aboutText.append("Created by Willem Liu.\n");\r
+ aboutText.append("Created with QtCreator.\n");\r
+ QMessageBox::about(this, "EasyList", aboutText);\r
+}\r
+\r
+void MainForm::on_actionChecked_bottom_triggered()\r
+{\r
+ bool sortToBottom = ui->actionChecked_bottom->isChecked();\r
+ qDebug() << "Checked Bottom" << sortToBottom;\r
+ settings->setValue(CHECKED_ITEMS_TO_BOTTOM, sortToBottom);\r
+ MyCheckBoxContainer::getInstance()->setSortCheckedToBottom(sortToBottom);\r
+}\r
--- /dev/null
+#ifndef MAINFORM_H
+#define MAINFORM_H
+
+#include <QMainWindow>
+#include <QSettings>
+#include <QDebug>
+#include <QMessageBox>
+#include <QStateMachine>
+#include <QState>
+#include <QAbstractTransition>
+#include <QPropertyAnimation>
+#include "slidewidget.h"
+#include "listform.h"
+#include "editform.h"
+#include "systemsettings.h"
+#include "mycheckboxcontainer.h"
+
+#define WILLEM_LIU "WillemLiu"
+#define EASY_LIST "easylist"
+#define DBUS_KEYBOARD_SLIDE "/org/freedesktop/Hal/devices/platform_slide"
+#define CHECKED_ITEMS_TO_BOTTOM "CheckedItemsToBottom"
+#define LANDSCAPE "Landscape"
+#define PORTRAIT "Portrait"
+#define LIST_TEXT "ListText"
+
+namespace Ui {
+ class MainForm;
+}
+
+class MainForm : public QMainWindow
+{
+ Q_OBJECT
+
+public:
+ explicit MainForm(QWidget *parent = 0);
+ ~MainForm();
+
+ void setLandscapeMode(bool landscape);
+
+public slots:
+ void keyboardClosed(bool closed);
+ void changeWidget(SlideWidget * currentWidget);
+ void stateOutFinished();
+private:
+ QSettings *settings;
+ bool landscape;
+ bool tempLandscapeMode;
+ int newIndex;
+ Ui::MainForm *ui;
+
+ ListForm * listForm;
+ EditForm * editForm;
+
+private slots:
+ void on_actionChecked_bottom_triggered();
+ void on_actionAbout_triggered();
+ void on_actionRotate_triggered();
+};
+
+#endif // MAINFORM_H
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>\r
+<ui version="4.0">\r
+ <class>MainForm</class>\r
+ <widget class="QMainWindow" name="MainForm">\r
+ <property name="geometry">\r
+ <rect>\r
+ <x>0</x>\r
+ <y>0</y>\r
+ <width>800</width>\r
+ <height>480</height>\r
+ </rect>\r
+ </property>\r
+ <property name="windowTitle">\r
+ <string>EasyList - by Willem Liu</string>\r
+ </property>\r
+ <widget class="QWidget" name="centralwidget">\r
+ <layout class="QGridLayout" name="gridLayout">\r
+ <property name="margin">\r
+ <number>0</number>\r
+ </property>\r
+ <property name="spacing">\r
+ <number>0</number>\r
+ </property>\r
+ <item row="0" column="0">\r
+ <widget class="QStackedWidget" name="stackedWidget">\r
+ <property name="currentIndex">\r
+ <number>-1</number>\r
+ </property>\r
+ </widget>\r
+ </item>\r
+ </layout>\r
+ </widget>\r
+ <widget class="QMenuBar" name="menubar">\r
+ <property name="geometry">\r
+ <rect>\r
+ <x>0</x>\r
+ <y>0</y>\r
+ <width>800</width>\r
+ <height>21</height>\r
+ </rect>\r
+ </property>\r
+ <widget class="QMenu" name="menuRotate">\r
+ <property name="title">\r
+ <string>Rotate</string>\r
+ </property>\r
+ <addaction name="actionRotate"/>\r
+ </widget>\r
+ <widget class="QMenu" name="menuAbout">\r
+ <property name="title">\r
+ <string>About</string>\r
+ </property>\r
+ <addaction name="actionAbout"/>\r
+ </widget>\r
+ <widget class="QMenu" name="menuChecked_bottom">\r
+ <property name="title">\r
+ <string>Checked bottom</string>\r
+ </property>\r
+ <addaction name="actionChecked_bottom"/>\r
+ </widget>\r
+ <addaction name="menuRotate"/>\r
+ <addaction name="menuAbout"/>\r
+ <addaction name="menuChecked_bottom"/>\r
+ </widget>\r
+ <action name="actionRotate">\r
+ <property name="text">\r
+ <string>Rotate</string>\r
+ </property>\r
+ </action>\r
+ <action name="actionAbout">\r
+ <property name="text">\r
+ <string>About</string>\r
+ </property>\r
+ </action>\r
+ <action name="actionChecked_bottom">\r
+ <property name="checkable">\r
+ <bool>true</bool>\r
+ </property>\r
+ <property name="text">\r
+ <string>Checked bottom</string>\r
+ </property>\r
+ </action>\r
+ </widget>\r
+ <resources/>\r
+ <connections/>\r
+</ui>\r
+++ /dev/null
-/*\r
- * Copyright (c) 2010 Willem Liu\r
- *\r
- * Permission is hereby granted, free of charge, to any person obtaining a copy\r
- * of this software and associated documentation files (the "Software"), to deal\r
- * in the Software without restriction, including without limitation the rights\r
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r
- * copies of the Software, and to permit persons to whom the Software is\r
- * furnished to do so, subject to the following conditions:\r
- *\r
- * The above copyright notice and this permission notice shall be included in\r
- * all copies or substantial portions of the Software.\r
- *\r
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r
- * THE SOFTWARE.\r
- */\r
-\r
-#include "mainwindow.h"\r
-#include "ui_mainwindow.h"\r
-#include "ui_listwindow.h"\r
-\r
-/**\r
- * Constructor.\r
- * Settings are initialised here.\r
- * Landscape mode is set to true.\r
- * List window is loaded.\r
- * @fn MainWindow\r
- * @param parent - The parent widget.\r
- */\r
-MainWindow::MainWindow(QWidget *parent) :\r
- QMainWindow(parent),\r
- editUi(new Ui::EditWindow),\r
- listUi(new Ui::ListWindow)\r
-{\r
- // Connect to DBUS of keyboard slider.\r
- QDBusConnection::systemBus().connect(QString("org.freedesktop.Hal"),\r
- DBUS_KEYBOARD_SLIDE,\r
- QString("org.freedesktop.Hal.Device"),\r
- QString("PropertyModified"),\r
- this, SLOT(slotKeyboardSlide()));\r
- // Initialise the settings.\r
- settings = new QSettings(WILLEM_LIU, EASY_LIST);\r
-\r
- // Set a default value for CHECKED_ITEMS_TO_BOTTOM\r
- if(settings->contains(CHECKED_ITEMS_TO_BOTTOM) == false)\r
- {\r
- settings->setValue(CHECKED_ITEMS_TO_BOTTOM, false);\r
- }\r
-\r
- // We always start in landscape mode.\r
- landscape = settings->value(LANDSCAPE).toBool();\r
- if(settings->contains(LANDSCAPE))\r
- {\r
- landscape = settings->value(LANDSCAPE).toBool();\r
- }\r
- settings->setValue(LANDSCAPE, landscape);\r
- // If keyboard is opened at start. We do landscape mode.\r
- // Otherwise we do what's read from the QSettings.\r
- if(isKeyboardClosed() == false)\r
- {\r
- setLandscapeMode(true);\r
- }\r
- else\r
- {\r
- setLandscapeMode(landscape);\r
- }\r
- // Auto-detect portrait/landscape mode. Only works on top widget.\r
-// setAttribute(Qt::WA_Maemo5AutoOrientation, true);\r
-\r
- showListWindow();\r
-}\r
-\r
-/**\r
- * Destructor.\r
- * User interface pointers are deleted here.\r
- *\r
- * @fn ~MainWindow\r
- */\r
-MainWindow::~MainWindow()\r
-{\r
- delete editUi;\r
- delete listUi;\r
-}\r
-\r
-/**\r
- * Check the DBUS property to see if the keyboard is closed or opened.\r
- */\r
-bool MainWindow::isKeyboardClosed()\r
-{\r
- QDBusInterface propertyInterface("org.freedesktop.Hal",\r
- DBUS_KEYBOARD_SLIDE,\r
- "org.freedesktop.Hal.Device",\r
- QDBusConnection::systemBus());\r
- bool result = propertyInterface.call("GetProperty", "button.state.value").arguments().at(0).toBool();\r
- qDebug() << "Keyboard is closed:" << result;\r
- return result;\r
-}\r
-\r
-/**\r
- * Slot is called when a DBUS event has been received caused by opening/closing the keyboard.\r
- */\r
-void MainWindow::slotKeyboardSlide()\r
-{\r
- // When keyboard is opened.\r
- if(isKeyboardClosed() == false)\r
- {\r
- setLandscapeMode(true);\r
- }\r
- else\r
- {\r
- setLandscapeMode(landscape);\r
- }\r
-}\r
-\r
-/**\r
- * Slot for action from Edit list button in de the list window.\r
- *\r
- * @fn slotListWindowEdit\r
- */\r
-void MainWindow::slotListWindowEdit()\r
-{\r
- qDebug() << "Edit list";\r
- showEditWindow();\r
-}\r
-\r
-/**\r
- * Slot for action from Cancel button in de the edit window.\r
- *\r
- * @fn slotEditWindowCancel\r
- */\r
-void MainWindow::slotEditWindowCancel()\r
-{\r
- qDebug() << "Cancel";\r
- showListWindow();\r
-}\r
-\r
-/**\r
- * Slot for action from Save button in de the edit window.\r
- *\r
- * @fn slotEditWindowSave\r
- */\r
-void MainWindow::slotEditWindowSave()\r
-{\r
- qDebug() << "Save";\r
- settings->setValue(LIST_TEXT, editUi->textEdit->toPlainText());\r
- showListWindow();\r
-}\r
-\r
-/**\r
- * Slot for action from Clear selected button in de the list window.\r
- * It clears all QCheckBoxes from the layout, removes all checked items from\r
- * the list text and finally calls generateList().\r
- *\r
- * @fn slotListWindowClearSelected\r
- */\r
-void MainWindow::slotListWindowClearSelected()\r
-{\r
- qDebug() << "Clear selected";\r
- QString listText("");\r
- foreach(QCheckBox * cb, checkBoxes)\r
- {\r
- cb->deleteLater();\r
- if(cb->isChecked() == false)\r
- {\r
- listText.append(cb->text());\r
- listText.append("\n");\r
- }\r
- }\r
-\r
- settings->setValue(LIST_TEXT, listText);\r
- generateList();\r
-}\r
-\r
-/**\r
- * Prefix all checked items with ! in the list text and save it to QSettings.\r
- */\r
-void MainWindow::slotListWindowSaveChecked()\r
-{\r
- qDebug() << "Save selected";\r
- QString listText("");\r
- foreach(QCheckBox * cb, checkBoxes)\r
- {\r
- QString item(cb->text());\r
- if(cb->isChecked() == true)\r
- {\r
- if(item.startsWith("!") == false)\r
- {\r
- item.push_front("!");\r
- }\r
- listText.append(item);\r
- }\r
- else\r
- {\r
- if(item.startsWith("!") == true)\r
- {\r
- item = item.replace("!", "");\r
- }\r
- listText.append(item);\r
- }\r
- listText.append("\n");\r
- }\r
-\r
- settings->setValue(LIST_TEXT, listText);\r
-}\r
-\r
-/**\r
- * Is called when a checkbox has been clicked.\r
- *\r
- * @fn slotActionCheckBox\r
- * @param bool checked - true if checkbox is checked.\r
- */\r
-void MainWindow::slotActionCheckBox(bool checked)\r
-{\r
- qDebug() << "CheckBox checked=" << checked;\r
- slotListWindowSaveChecked();\r
- if(settings->value(CHECKED_ITEMS_TO_BOTTOM).toBool())\r
- {\r
- slotSortCheckedBottom();\r
- // Remove all the checkboxes from the screen.\r
- foreach(QCheckBox * cb, checkBoxes)\r
- {\r
- cb->deleteLater();\r
- }\r
- generateList();\r
- }\r
- else\r
- {\r
- qDebug() << "No need to sort items to bottom";\r
- }\r
-}\r
-\r
-/**\r
- * Sort checked items to bottom of the list text and returns the new list text.\r
- *\r
- * @fn slotSortCheckedBottom\r
- *\r
- * @return QString - the new list text.\r
- */\r
-QString MainWindow::slotSortCheckedBottom()\r
-{\r
- QString result(settings->value(LIST_TEXT).toString());\r
- if(settings->value(CHECKED_ITEMS_TO_BOTTOM).toBool())\r
- {\r
- QStringList list = result.split("\n");\r
- QString listText("");\r
- QString checkedListText("");\r
- foreach(QString item, list)\r
- {\r
- if(item.length() > 0)\r
- {\r
- if(item.startsWith("!"))\r
- {\r
- checkedListText.append(item);\r
- checkedListText.append("\n");\r
- }\r
- else\r
- {\r
- listText.append(item);\r
- listText.append("\n");\r
- }\r
- }\r
- }\r
- listText.append(checkedListText);\r
- qDebug() << "Sort checked items to bottom";\r
- settings->setValue(LIST_TEXT, listText);\r
- result = listText;\r
- }\r
- return result;\r
-}\r
-\r
-/**\r
- * Show the edit window.\r
- *\r
- * @fn showEditWindow\r
- */\r
-void MainWindow::showEditWindow()\r
-{\r
- slotListWindowSaveChecked();\r
- editUi->setupUi(this);\r
- editUi->textEdit->setText(settings->value(LIST_TEXT).toString());\r
- connect(editUi->savePushButton, SIGNAL(clicked()), this, SLOT(slotEditWindowSave()));\r
- connect(editUi->cancelPushButton, SIGNAL(clicked()), this, SLOT(slotEditWindowCancel()));\r
-}\r
-\r
-/**\r
- * Show the list window.\r
- *\r
- * @fn showListWindow\r
- */\r
-void MainWindow::showListWindow()\r
-{\r
- listUi->setupUi(this);\r
- listUi->listVerticalLayout->setAlignment(Qt::AlignTop);\r
- listUi->actionChecked_Bottom->setChecked(settings->value(CHECKED_ITEMS_TO_BOTTOM).toBool());\r
- slotSortCheckedBottom();\r
- generateList();\r
- connect(listUi->editListPushButton, SIGNAL(clicked()), this, SLOT(slotListWindowEdit()));\r
- connect(listUi->clearSelectedPushButton, SIGNAL(clicked()), this, SLOT(slotListWindowClearSelected()));\r
- connect(listUi->menuChecked_Bottom, SIGNAL(triggered(QAction*)), this, SLOT(slotActionCheckedBottom(QAction*)));\r
- connect(listUi->menuAbout, SIGNAL(triggered(QAction*)), this, SLOT(slotActionAbout(QAction*)));\r
- connect(listUi->menuRotate, SIGNAL(triggered(QAction*)), this, SLOT(slotActionRotate(QAction*)));\r
-}\r
-\r
-/**\r
- * Generate the list of checkboxes. A pointer to such a checkbox will be stored\r
- * in a container for later use.\r
- *\r
- * @fn generateList\r
- */\r
-void MainWindow::generateList()\r
-{\r
- qDebug() << "Generate List";\r
-\r
- checkBoxes.clear();\r
- QString text = settings->value(LIST_TEXT).toString();\r
- QStringList list = text.split("\n");\r
-\r
- foreach(QString item, list)\r
- {\r
- if(item.length() > 0)\r
- {\r
- QCheckBox * cb = new QCheckBox(item);\r
- connect(cb, SIGNAL(clicked(bool)), this, SLOT(slotActionCheckBox(bool)));\r
- if(item.startsWith("!"))\r
- {\r
- QString itemName(item.right(item.length()-1));\r
- cb->setText(itemName);\r
- cb->setChecked(true);\r
- }\r
- checkBoxes.append(cb);\r
- listUi->listVerticalLayout->addWidget(cb);\r
- }\r
- }\r
-}\r
-\r
-/**\r
- * Is called when the application terminates.\r
- *\r
- * @fn closeEvent\r
- * @param event - the QCloseEvent.\r
- */\r
-void MainWindow::closeEvent(QCloseEvent *event)\r
-{\r
- qDebug() << "Closed";\r
- slotListWindowSaveChecked();\r
- event->accept();\r
-}\r
-\r
-/**\r
- * Is called when the Rotate menu item is triggered. Display orientation is saved in the QSettings.\r
- *\r
- * @fn slotActionRotate\r
- * @param QAction* action - the action.\r
- */\r
-void MainWindow::slotActionRotate(QAction* action)\r
-{\r
- qDebug() << "Rotate" << action->text();\r
-\r
- landscape = !tempLandscapeMode;\r
- settings->setValue(LANDSCAPE, landscape);\r
- setLandscapeMode(landscape);\r
-}\r
-\r
-/**\r
- * Set landscape/portrait mode.\r
- */\r
-void MainWindow::setLandscapeMode(bool landscape)\r
-{\r
- if(landscape)\r
- {\r
- tempLandscapeMode = true;\r
- qDebug() << LANDSCAPE;\r
- setAttribute(Qt::WA_Maemo5LandscapeOrientation, true);\r
- setAttribute(Qt::WA_Maemo5PortraitOrientation, false);\r
- }\r
- else\r
- {\r
- tempLandscapeMode = false;\r
- qDebug() << PORTRAIT;\r
- setAttribute(Qt::WA_Maemo5PortraitOrientation, true);\r
- setAttribute(Qt::WA_Maemo5LandscapeOrientation, false);\r
- }\r
-}\r
-\r
-/**\r
- * Is called when the About menu item is triggered.\r
- *\r
- * @fn slotActionAbout\r
- * @param QAction* action - the action.\r
- */\r
-void MainWindow::slotActionAbout(QAction* action)\r
-{\r
- qDebug() << "About" << action->text();\r
- QString aboutText;\r
- aboutText.append("EasyList (c) 2010\n\n");\r
- aboutText.append("Created by Willem Liu.\n");\r
- aboutText.append("Created with QtCreator.\n");\r
- QMessageBox::about(this, "EasyList", aboutText);\r
-}\r
-\r
-/**\r
- * Is called when the Checked Bottom menu item is triggered.\r
- * The menu item is a checkable item. So we need to check if it's checked or not.\r
- *\r
- * @fn slotActionCheckedBottom\r
- * @param QAction* action - the action.\r
- */\r
-void MainWindow::slotActionCheckedBottom(QAction* action)\r
-{\r
- qDebug() << "Checked Bottom" << action->text() << listUi->actionChecked_Bottom->isChecked();\r
- settings->setValue(CHECKED_ITEMS_TO_BOTTOM, listUi->actionChecked_Bottom->isChecked());\r
-}\r
+++ /dev/null
-/*
- * Copyright (c) 2010 Willem Liu
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-#ifndef MAINWINDOW_H
-#define MAINWINDOW_H
-
-#include <QMainWindow>
-#include <QDebug>
-#include <QFrame>
-#include <QCloseEvent>
-#include <QSettings>
-#include <QCheckBox>
-#include <QMessageBox>
-#include <QtDBus/QDBusConnection>
-#include <QtDBus/QDBusInterface>
-
-#define WILLEM_LIU "WillemLiu"
-#define EASY_LIST "easylist"
-#define DBUS_KEYBOARD_SLIDE "/org/freedesktop/Hal/devices/platform_slide"
-#define CHECKED_ITEMS_TO_BOTTOM "CheckedItemsToBottom"
-#define LANDSCAPE "Landscape"
-#define PORTRAIT "Portrait"
-#define LIST_TEXT "ListText"
-
-namespace Ui {
- class EditWindow;
- class ListWindow;
-}
-
-class MainWindow : public QMainWindow
-{
- Q_OBJECT
-
-public:
- explicit MainWindow(QWidget *parent = 0);
- ~MainWindow();
-
-private:
- QVector<QCheckBox * > checkBoxes;
- QSettings *settings;
- bool landscape;
- bool tempLandscapeMode;
-
- Ui::EditWindow *editUi;
- Ui::ListWindow *listUi;
-
- void closeEvent(QCloseEvent *event);
-
- void showEditWindow();
- void showListWindow();
- void generateList();
- void setLandscapeMode(bool landscape);
- bool isKeyboardClosed();
-
-public slots:
- void slotEditWindowSave();
- void slotEditWindowCancel();
- void slotListWindowEdit();
- void slotListWindowClearSelected();
- void slotListWindowSaveChecked();
- void slotActionCheckBox(bool checked);
- QString slotSortCheckedBottom();
- void slotKeyboardSlide();
-
-private slots:
- void slotActionCheckedBottom(QAction* action);
- void slotActionAbout(QAction* action);
- void slotActionRotate(QAction* action);
-};
-
-#endif // MAINWINDOW_H
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>\r
-<ui version="4.0">\r
- <class>EditWindow</class>\r
- <widget class="QMainWindow" name="EditWindow">\r
- <property name="geometry">\r
- <rect>\r
- <x>0</x>\r
- <y>0</y>\r
- <width>800</width>\r
- <height>480</height>\r
- </rect>\r
- </property>\r
- <property name="windowTitle">\r
- <string>EasyList - by Willem Liu</string>\r
- </property>\r
- <widget class="QWidget" name="centralWidget">\r
- <layout class="QVBoxLayout" name="verticalLayout">\r
- <item>\r
- <layout class="QGridLayout" name="gridLayout">\r
- <item row="0" column="0">\r
- <widget class="QTextEdit" name="textEdit"/>\r
- </item>\r
- </layout>\r
- </item>\r
- <item>\r
- <layout class="QGridLayout" name="gridLayout_2">\r
- <item row="0" column="1">\r
- <widget class="QPushButton" name="cancelPushButton">\r
- <property name="text">\r
- <string>Cancel</string>\r
- </property>\r
- </widget>\r
- </item>\r
- <item row="0" column="0">\r
- <widget class="QPushButton" name="savePushButton">\r
- <property name="text">\r
- <string>Save</string>\r
- </property>\r
- </widget>\r
- </item>\r
- </layout>\r
- </item>\r
- </layout>\r
- </widget>\r
- </widget>\r
- <layoutdefault spacing="6" margin="11"/>\r
- <resources/>\r
- <connections/>\r
-</ui>\r
--- /dev/null
+#include "mycheckbox.h"\r
+\r
+int MyCheckBox::instances = 0;\r
+\r
+MyCheckBox::MyCheckBox(QWidget *parent) :\r
+ QCheckBox(parent)\r
+{\r
+ ++instances;\r
+ qDebug() << "MyCheckBox instances:" << instances;\r
+ setContextMenuPolicy(Qt::CustomContextMenu);\r
+ connect(this, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(slotContextMenuActivated(QPoint)));\r
+}\r
+\r
+MyCheckBox::MyCheckBox(const QString & text, QWidget *parent) :\r
+ QCheckBox(text, parent)\r
+{\r
+ ++instances;\r
+ qDebug() << "MyCheckBox instances:" << instances;\r
+ setContextMenuPolicy(Qt::CustomContextMenu);\r
+ connect(this, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(slotContextMenuActivated(QPoint)));\r
+}\r
+\r
+MyCheckBox::~MyCheckBox()\r
+{\r
+ --instances;\r
+ qDebug() << "MyCheckBox instances left:" << instances;\r
+}\r
+\r
+void MyCheckBox::slotDeleteClicked()\r
+{\r
+ qDebug() << "Delete clicked";\r
+ emit signalDeleteClicked(this);\r
+}\r
+\r
+void MyCheckBox::slotContextMenuActivated(QPoint point)\r
+{\r
+ qDebug() << "Context menu activated";\r
+ QMenu menu(this);\r
+ menu.addAction(tr("Delete"), this, SLOT(slotDeleteClicked()));\r
+ menu.exec(this->mapToGlobal(point));\r
+}\r
--- /dev/null
+#ifndef MYCHECKBOX_H
+#define MYCHECKBOX_H
+
+#include <QCheckBox>
+#include <QDebug>
+#include <QMenu>
+#include <QObject>
+
+class MyCheckBox : public QCheckBox
+{
+ Q_OBJECT
+public:
+ MyCheckBox(QWidget *parent = 0);
+ MyCheckBox(const QString & text, QWidget *parent = 0);
+ virtual ~MyCheckBox();
+private:
+ static int instances;
+signals:
+ void signalDeleteClicked(MyCheckBox * myCheckBox);
+public slots:
+ void slotContextMenuActivated(QPoint point);
+ void slotDeleteClicked();
+};
+
+#endif // MYCHECKBOX_H
--- /dev/null
+#include "mycheckboxcontainer.h"\r
+\r
+MyCheckBoxContainer * MyCheckBoxContainer::instance = 0;\r
+int MyCheckBoxContainer::instances = 0;\r
+\r
+MyCheckBoxContainer::MyCheckBoxContainer()\r
+{\r
+ ++instances;\r
+ qDebug() << "MyCheckBoxContainer instances:" << instances;\r
+ sortToBottom = false;\r
+}\r
+\r
+MyCheckBoxContainer::~MyCheckBoxContainer()\r
+{\r
+ --instances;\r
+ qDebug() << "MyCheckBoxContainer instances left:" << instances;\r
+ clear();\r
+}\r
+\r
+MyCheckBoxContainer * MyCheckBoxContainer::getInstance()\r
+{\r
+ if(instance == 0)\r
+ {\r
+ instance = new MyCheckBoxContainer();\r
+ }\r
+ return instance;\r
+}\r
+\r
+void MyCheckBoxContainer::add(QString item)\r
+{\r
+ QStringList list = item.split("\n");\r
+ foreach(QString item, list)\r
+ {\r
+ if(item.length() > 0)\r
+ {\r
+ MyCheckBox * checkBox;\r
+ if(item.startsWith("!"))\r
+ {\r
+ checkBox = new MyCheckBox(item.right(item.length()-1));\r
+ checkBox->setChecked(true);\r
+ }\r
+ else\r
+ {\r
+ checkBox = new MyCheckBox(item);\r
+ }\r
+ connect(checkBox, SIGNAL(clicked()), this, SLOT(clickedAction()));\r
+ checkBoxes.append(checkBox);\r
+ }\r
+ }\r
+ sortCheckedToBottom();\r
+}\r
+\r
+void MyCheckBoxContainer::set(QString item)\r
+{\r
+ clear();\r
+ add(item);\r
+}\r
+\r
+void MyCheckBoxContainer::clear()\r
+{\r
+ foreach(MyCheckBox * item, checkBoxes)\r
+ {\r
+ item->setParent(0);\r
+ item->deleteLater();\r
+ }\r
+ checkBoxes.clear();\r
+}\r
+\r
+void MyCheckBoxContainer::sortCheckedToBottom()\r
+{\r
+ if(sortToBottom)\r
+ {\r
+ qDebug() << "Sort checked to bottom";\r
+ QList<MyCheckBox * > tempList;\r
+ QList<MyCheckBox * > tempListChecked;\r
+ foreach(MyCheckBox * item, checkBoxes)\r
+ {\r
+ if(item->isChecked())\r
+ {\r
+ tempListChecked.append(item);\r
+ }\r
+ else\r
+ {\r
+ tempList.append(item);\r
+ }\r
+ }\r
+ checkBoxes.clear();\r
+ checkBoxes.append(tempList);\r
+ checkBoxes.append(tempListChecked);\r
+ emit signalSorted();\r
+ }\r
+}\r
+\r
+QList<MyCheckBox * > const & MyCheckBoxContainer::getCheckBoxes()\r
+{\r
+ return checkBoxes;\r
+}\r
+\r
+QString MyCheckBoxContainer::getListText()\r
+{\r
+ QString listText("");\r
+ foreach(MyCheckBox * item, checkBoxes)\r
+ {\r
+ if(item->isChecked())\r
+ {\r
+ listText.append("!");\r
+ }\r
+ listText.append(item->text());\r
+ listText.append("\n");\r
+ }\r
+ return listText;\r
+}\r
+\r
+void MyCheckBoxContainer::uncheckAll()\r
+{\r
+ foreach(MyCheckBox * item, checkBoxes)\r
+ {\r
+ item->setChecked(false);\r
+ }\r
+}\r
+\r
+void MyCheckBoxContainer::removeChecked()\r
+{\r
+ QMutableListIterator<MyCheckBox * > i(checkBoxes);\r
+ while (i.hasNext())\r
+ {\r
+ MyCheckBox * item = i.next();\r
+ if (item->isChecked())\r
+ {\r
+ item->setParent(0);\r
+ item->deleteLater();\r
+ i.remove();\r
+ }\r
+ }\r
+}\r
+\r
+void MyCheckBoxContainer::setSortCheckedToBottom(bool sortToBottom)\r
+{\r
+ this->sortToBottom = sortToBottom;\r
+ sortCheckedToBottom();\r
+}\r
+\r
+void MyCheckBoxContainer::clickedAction()\r
+{\r
+ qDebug() << "Clicked a MyCheckBox";\r
+ sortCheckedToBottom();\r
+}\r
--- /dev/null
+#ifndef MYCHECKBOXCONTAINER_H\r
+#define MYCHECKBOXCONTAINER_H\r
+\r
+#include <QString>\r
+#include <QList>\r
+#include <QObject>\r
+#include <QLayout>\r
+#include <QVBoxLayout>\r
+#include "mycheckbox.h"\r
+\r
+class MyCheckBoxContainer : public QObject\r
+{\r
+ Q_OBJECT\r
+public:\r
+ QList<MyCheckBox * > const & getCheckBoxes();\r
+ QString getListText();\r
+\r
+ virtual ~MyCheckBoxContainer();\r
+ static MyCheckBoxContainer * getInstance();\r
+\r
+ void add(QString item);\r
+ void set(QString item);\r
+ void clear();\r
+ void uncheckAll();\r
+ void removeChecked();\r
+ void setSortCheckedToBottom(bool sortToBottom);\r
+ void sortCheckedToBottom();\r
+\r
+private:\r
+ QList<MyCheckBox * > checkBoxes;\r
+ static MyCheckBoxContainer * instance;\r
+ static int instances;\r
+\r
+ bool sortToBottom;\r
+\r
+ MyCheckBoxContainer();\r
+signals:\r
+ void signalSorted();\r
+public slots:\r
+ void clickedAction();\r
+\r
+};\r
+\r
+#endif // MYCHECKBOXCONTAINER_H\r
--- /dev/null
+#include "slidewidget.h"\r
+\r
+SlideWidget::SlideWidget(QWidget *parent) :\r
+ QWidget(parent)\r
+{\r
+ initStates();\r
+\r
+ QAbstractTransition * t1 = stateIn.addTransition(this, SIGNAL(signalDoStateOut()), &stateOut);\r
+ QAbstractTransition * t2 = stateOut.addTransition(this, SIGNAL(signalDoStateIn()), &stateIn);\r
+\r
+ t1->addAnimation(&animPosOut);\r
+ t2->addAnimation(&animPosIn);\r
+\r
+ connect(&animPosIn, SIGNAL(finished()), this, SIGNAL(signalTransitionInFinished()));\r
+ connect(&animPosIn, SIGNAL(finished()), this, SLOT(slotStateInFinished()));\r
+ connect(&animPosOut, SIGNAL(finished()), this, SIGNAL(signalTransitionOutFinished()));\r
+ connect(&animPosOut, SIGNAL(finished()), this, SLOT(slotStateOutFinished()));\r
+\r
+ machine.addState(&stateIn);\r
+ machine.addState(&stateOut);\r
+ machine.setInitialState(&stateOut);\r
+ machine.start();\r
+}\r
+\r
+SlideWidget::~SlideWidget()\r
+{\r
+}\r
+\r
+void SlideWidget::initStates()\r
+{\r
+ animPosIn.setTargetObject(this);\r
+ animPosIn.setPropertyName("pos");\r
+ animPosIn.setDuration(500);\r
+ animPosIn.setEasingCurve(QEasingCurve::OutExpo);\r
+\r
+ animPosOut.setTargetObject(this);\r
+ animPosOut.setPropertyName("pos");\r
+ animPosOut.setDuration(500);\r
+ animPosOut.setEasingCurve(QEasingCurve::OutExpo);\r
+\r
+ stateIn.assignProperty(this, "pos", QPoint(0, 0));\r
+\r
+ stateOut.assignProperty(this, "pos", QPoint(0, -this->height()));\r
+}\r
+\r
+void SlideWidget::setStateIn()\r
+{\r
+ qDebug() << "State In";\r
+ emit signalDoStateIn();\r
+}\r
+\r
+void SlideWidget::setStateOut()\r
+{\r
+ qDebug() << "State Out";\r
+ emit signalDoStateOut();\r
+}\r
+\r
+void SlideWidget::slotStateInFinished()\r
+{\r
+ qDebug() << "State in finished" << pos();\r
+}\r
+\r
+void SlideWidget::slotStateOutFinished()\r
+{\r
+ qDebug() << "State out finished" << pos();\r
+}\r
--- /dev/null
+#ifndef SLIDEWIDGET_H
+#define SLIDEWIDGET_H
+
+#include <QStateMachine>
+#include <QState>
+#include <QPropertyAnimation>
+#include <QAbstractTransition>
+#include <QtCore>
+#include <QWidget>
+#include <QPoint>
+#include <qDebug>
+
+class SlideWidget : public QWidget
+{
+ Q_OBJECT
+public:
+ explicit SlideWidget(QWidget *parent = 0);
+ virtual ~SlideWidget();
+
+ virtual void shown() = 0;
+
+ void initStates();
+
+ void setStateIn();
+ void setStateOut();
+
+private:
+ QStateMachine machine;
+ QState stateIn;
+ QState stateOut;
+
+ QPropertyAnimation animPosIn;
+ QPropertyAnimation animPosOut;
+
+protected:
+
+signals:
+ void signalDoStateIn();
+ void signalDoStateOut();
+ void signalTransitionOutFinished();
+ void signalTransitionInFinished();
+public slots:
+ void slotStateInFinished();
+ void slotStateOutFinished();
+};
+
+#endif // SLIDEWIDGET_H
\r
# This needs to be removed in order for the binary\r
# to be chmod to 755 in the debian package.\r
-#QT += core gui\r
-QT += dbus\r
+QT += core gui\r
TARGET = easylist\r
TEMPLATE = app\r
DEPENDPATH += .\r
DESTDIR = ../\r
\r
SOURCES += main.cpp\\r
- mainwindow.cpp\r
-\r
-HEADERS += mainwindow.h\r
-\r
-FORMS += mainwindow.ui \\r
- listwindow.ui\r
+ mycheckbox.cpp\\r
+ mainform.cpp \\r
+ mycheckboxcontainer.cpp \\r
+ systemsettings.cpp \\r
+ listform.cpp \\r
+ editform.cpp \\r
+ slidewidget.cpp\r
+\r
+HEADERS +=\\r
+ mycheckbox.h \\r
+ mainform.h \\r
+ mycheckboxcontainer.h \\r
+ systemsettings.h \\r
+ listform.h \\r
+ editform.h \\r
+ slidewidget.h\r
+\r
+FORMS += \\r
+ mainform.ui \\r
+ listform.ui \\r
+ editform.ui\r
\r
CONFIG += mobility\r
\r
unix {\r
+ QT += dbus\r
#VARIABLES\r
PREFIX = /usr\r
BINDIR = /opt/easylist/bin\r
--- /dev/null
+#include "systemsettings.h"\r
+\r
+SystemSettings * SystemSettings::instance = 0;\r
+int SystemSettings::instances = 0;\r
+\r
+SystemSettings::SystemSettings()\r
+{\r
+ ++instances;\r
+#ifdef Q_WS_MAEMO_5\r
+ // Connect to DBUS of keyboard slider.\r
+ QDBusConnection::systemBus().connect(QString("org.freedesktop.Hal"),\r
+ DBUS_KEYBOARD_SLIDE,\r
+ QString("org.freedesktop.Hal.Device"),\r
+ QString("PropertyModified"),\r
+ this, SLOT(slotKeyboardSlide()));\r
+#endif\r
+}\r
+\r
+SystemSettings * SystemSettings::getInstance()\r
+{\r
+ if(instance == 0)\r
+ {\r
+ instance = new SystemSettings();\r
+ }\r
+ return instance;\r
+}\r
+\r
+void SystemSettings::slotKeyboardSlide()\r
+{\r
+ emit signalKeyboardClosed(getKeyboardClosed());\r
+}\r
+\r
+bool SystemSettings::getKeyboardClosed()\r
+{\r
+ bool closed = false;\r
+#ifdef Q_WS_MAEMO_5\r
+ QDBusInterface propertyInterface("org.freedesktop.Hal",\r
+ DBUS_KEYBOARD_SLIDE,\r
+ "org.freedesktop.Hal.Device",\r
+ QDBusConnection::systemBus());\r
+ closed = propertyInterface.call("GetProperty", "button.state.value").arguments().at(0).toBool();\r
+ qDebug() << "Keyboard is closed:" << closed;\r
+#endif\r
+ return closed;\r
+}\r
--- /dev/null
+#ifndef SYSTEMSETTINGS_H
+#define SYSTEMSETTINGS_H
+
+#include <QObject>
+#include <QDebug>
+#include <QtDBus/QDBusConnection>
+#include <QtDBus/QDBusInterface>
+
+#define DBUS_KEYBOARD_SLIDE "/org/freedesktop/Hal/devices/platform_slide"
+
+class SystemSettings : public QObject
+{
+ Q_OBJECT
+public:
+ static SystemSettings * getInstance();
+
+ bool getKeyboardClosed();
+private:
+ bool landscape;
+ static SystemSettings * instance;
+ static int instances;
+ SystemSettings();
+
+public slots:
+ void slotKeyboardSlide();
+signals:
+ void signalKeyboardClosed(bool open);
+};
+
+#endif // SYSTEMSETTINGS_H