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
+ ui->actionAuto_Orientation->setChecked(settings->value(AUTO_ORIENTATION).toBool());\r
+ on_actionAuto_Orientation_triggered();\r
+\r
+ ui->actionSort_A_Z->setChecked(settings->value(SORT_A_Z).toBool());\r
+ on_actionSort_A_Z_triggered();\r
+\r
// Set a default value for CHECKED_ITEMS_TO_BOTTOM\r
if(settings->contains(CHECKED_ITEMS_TO_BOTTOM) == false)\r
{\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
+ if(ui->actionAuto_Orientation->isChecked() == false)\r
{\r
- setLandscapeMode(true);\r
- }\r
- else\r
- {\r
- setLandscapeMode(landscape);\r
+ if(SystemSettings::getInstance()->getKeyboardClosed() == false)\r
+ {\r
+ setLandscapeMode(true);\r
+ }\r
+ else\r
+ {\r
+ setLandscapeMode(landscape);\r
+ }\r
}\r
\r
// Populate the QStackedWidget. ListForm is set as the current widget.\r
listForm = new ListForm(this);\r
editForm = new EditForm(this);\r
+ chooseListForm = new ChooseListForm(this);\r
\r
connect(listForm, SIGNAL(signalTransitionOutFinished()), this, SLOT(stateOutFinished()));\r
- connect(listForm, SIGNAL(signalEditListPushButtonTriggered(SlideWidget*)), this, SLOT(changeWidget(SlideWidget*)));\r
+ connect(listForm, SIGNAL(signalNavigate(int)), this, SLOT(changeWidget(int)));\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
+ connect(editForm, SIGNAL(signalNavigate(int)), this, SLOT(changeWidget(int)));\r
+\r
+ connect(chooseListForm, SIGNAL(signalTransitionOutFinished()), this, SLOT(stateOutFinished()));\r
+ connect(chooseListForm, SIGNAL(signalNavigate(int)), this, SLOT(changeWidget(int)));\r
\r
ui->stackedWidget->addWidget(listForm);\r
ui->stackedWidget->addWidget(editForm);\r
+ ui->stackedWidget->addWidget(chooseListForm);\r
ui->stackedWidget->setCurrentWidget(listForm);\r
}\r
\r
newWidget->shown();\r
}\r
\r
-void MainForm::changeWidget(SlideWidget * currentWidget)\r
+void MainForm::changeWidget(int step)\r
{\r
+ SlideWidget * currentWidget = dynamic_cast<SlideWidget * >(ui->stackedWidget->currentWidget());\r
currentWidget->initStates();\r
int currentIndex = ui->stackedWidget->indexOf(currentWidget);\r
// Because all widgets are started with StateOut as initial state, we\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
+ newIndex = step;\r
+ currentWidget->setStateOut();\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
+ if(ui->actionAuto_Orientation->isChecked() == false)\r
{\r
- setLandscapeMode(landscape);\r
+ if(closed == false)\r
+ {\r
+ setLandscapeMode(true);\r
+ }\r
+ else\r
+ {\r
+ setLandscapeMode(landscape);\r
+ }\r
}\r
}\r
\r
tempLandscapeMode = true;\r
qDebug() << LANDSCAPE;\r
#ifdef Q_WS_MAEMO_5\r
+ setAttribute(Qt::WA_Maemo5AutoOrientation, false);\r
setAttribute(Qt::WA_Maemo5LandscapeOrientation, true);\r
setAttribute(Qt::WA_Maemo5PortraitOrientation, false);\r
#endif\r
tempLandscapeMode = false;\r
qDebug() << PORTRAIT;\r
#ifdef Q_WS_MAEMO_5\r
+ setAttribute(Qt::WA_Maemo5AutoOrientation, false);\r
setAttribute(Qt::WA_Maemo5PortraitOrientation, true);\r
setAttribute(Qt::WA_Maemo5LandscapeOrientation, false);\r
#endif\r
{\r
qDebug() << "Rotate";\r
\r
- landscape = !tempLandscapeMode;\r
+ landscape = (width() < height());\r
settings->setValue(LANDSCAPE, landscape);\r
+ ui->actionAuto_Orientation->setChecked(false);\r
+ settings->setValue(AUTO_ORIENTATION, ui->actionAuto_Orientation->isChecked());\r
setLandscapeMode(landscape);\r
}\r
\r
settings->setValue(CHECKED_ITEMS_TO_BOTTOM, sortToBottom);\r
MyCheckBoxContainer::getInstance()->setSortCheckedToBottom(sortToBottom);\r
}\r
+\r
+void MainForm::closeEvent(QCloseEvent *event)\r
+{\r
+ settings->setValue(LIST_TEXT, MyCheckBoxContainer::getInstance()->getListText());\r
+ event->accept();\r
+}\r
+\r
+void MainForm::on_actionAuto_Orientation_triggered()\r
+{\r
+ settings->setValue(AUTO_ORIENTATION, ui->actionAuto_Orientation->isChecked());\r
+ qDebug() << "Auto orientation" << ui->actionAuto_Orientation->isChecked();\r
+ if(ui->actionAuto_Orientation->isChecked())\r
+ {\r
+#ifdef Q_WS_MAEMO_5\r
+ setAttribute(Qt::WA_Maemo5PortraitOrientation, false);\r
+ setAttribute(Qt::WA_Maemo5LandscapeOrientation, false);\r
+ setAttribute(Qt::WA_Maemo5AutoOrientation, true);\r
+#endif\r
+ }\r
+ else\r
+ {\r
+ setLandscapeMode(landscape);\r
+ }\r
+}\r
+\r
+void MainForm::on_actionSort_A_Z_triggered()\r
+{\r
+ settings->setValue(SORT_A_Z, ui->actionSort_A_Z->isChecked());\r
+ MyCheckBoxContainer::getInstance()->setSortAlphabetically(ui->actionSort_A_Z->isChecked());\r
+}\r
+\r
+void MainForm::on_actionLists_triggered()\r
+{\r
+ listForm->saveList();\r
+ changeWidget(2);\r
+}\r