Added include for QTimer in header file.
[easylist] / mainform.cpp
index afb9f6a..c366754 100755 (executable)
@@ -8,6 +8,10 @@ MainForm::MainForm(QWidget *parent) :
     ui->setupUi(this);\r
     settings = new QSettings(WILLEM_LIU, EASY_LIST);\r
 \r
+    /* Make a call every x milliseconds */\r
+    timer = new QTimer(this);\r
+    connect(timer, SIGNAL(timeout()), this, SLOT(Keep_backlight_on()));\r
+\r
     requestWebpage = new RequestWebpage(this);\r
     connect(requestWebpage, SIGNAL(finished(QNetworkReply*)), this, SLOT(slotSyncList(QNetworkReply*)));\r
 \r
@@ -28,6 +32,14 @@ MainForm::MainForm(QWidget *parent) :
     ui->actionChecked_bottom->setChecked(settings->value(CHECKED_ITEMS_TO_BOTTOM).toBool());\r
     on_actionChecked_bottom_triggered();\r
 \r
+    // Set a default value for CHECKED_BACKLIGHT\r
+    if(settings->contains(CHECKED_BACKLIGHT) == false)\r
+    {\r
+        settings->setValue(CHECKED_BACKLIGHT, false);\r
+    }\r
+    ui->actionKeep_backlight_on->setChecked(settings->value(CHECKED_BACKLIGHT).toBool());\r
+    on_actionKeep_backlight_on_triggered();\r
+\r
     // Create a default for landscape mode.\r
     landscape = settings->value(LANDSCAPE).toBool();\r
     // If LANDSCAPE exists in QSettings.\r
@@ -171,6 +183,7 @@ void MainForm::on_actionAbout_triggered()
     aboutText.append(QDate::currentDate().toString("yyyy"));\r
     aboutText.append("<br><br>");\r
     aboutText.append("Created by Willem Liu.<br>");\r
+    aboutText.append("Thanks to Ade.<br>");\r
     aboutText.append("Created with QtCreator.<br><br>");\r
     aboutText.append("Please <a href='http://www.willemliu.nl/donate'>donate</a> any amount you deem this app is worthy to keep me going on.<br><br>");\r
     aboutText.append("</body></html>");\r
@@ -198,7 +211,7 @@ void MainForm::on_actionAuto_Orientation_triggered()
     qDebug() << "Auto orientation" << ui->actionAuto_Orientation->isChecked();\r
     if(ui->actionAuto_Orientation->isChecked())\r
     {\r
-#ifdef Q_WS_MAEMO_5\r
+#if defined(Q_WS_MAEMO_5) || defined(Q_WS_HILDON)\r
         setAttribute(Qt::WA_Maemo5PortraitOrientation, false);\r
         setAttribute(Qt::WA_Maemo5LandscapeOrientation, false);\r
         setAttribute(Qt::WA_Maemo5AutoOrientation, true);\r
@@ -224,18 +237,25 @@ void MainForm::on_actionLists_triggered()
 \r
 void MainForm::on_actionSync_triggered()\r
 {\r
-    QString username = settings->value(USERNAME, "").toString();\r
-    QString password = settings->value(PASSWORD, "").toString();\r
-    QString url = settings->value(SYNC_URL, DEFAULT_SYNC_URL).toString();\r
-    url.append("?username=" + username);\r
-    url.append("&password=" + password);\r
-    qDebug() << url;\r
-    requestWebpage->post(url,settings->value(LIST_TEXT,"").toString().toUtf8());\r
-    //requestWebpage->fetch(url);\r
+    int res = QMessageBox::warning(this, "Synchronize list", "If you haven't saved your current list under a list name other than SyncList then it will be overwritten by the items on the website.", QMessageBox::Ok, QMessageBox::Cancel);\r
+\r
+    if(res == QMessageBox::Ok)\r
+    {\r
+        QString username = settings->value(USERNAME, "").toString();\r
+        QString password = settings->value(PASSWORD, "").toString();\r
+        QString url = settings->value(SYNC_URL, DEFAULT_SYNC_URL).toString();\r
+        url.append("?username=" + username);\r
+        url.append("&password=" + password);\r
+        qDebug() << url;\r
+        requestWebpage->post(url,settings->value(LIST_TEXT,"").toString().toUtf8());\r
+        //requestWebpage->fetch(url);\r
+    }\r
 }\r
 \r
 void MainForm::slotSyncList(QNetworkReply* pReply)\r
 {\r
+    settings->setValue(LIST_TEXT, MyCheckBoxContainer::getInstance()->getListText());\r
+    SystemSettings::getInstance()->saveCurrentList();\r
     QByteArray data=pReply->readAll();\r
     QString list = QString::fromUtf8(data);\r
     settings->setValue(LIST_TEXT, list);\r
@@ -255,3 +275,33 @@ void MainForm::on_actionSetting_triggered()
 {\r
     changeWidget(3);\r
 }\r
+\r
+void MainForm::on_actionKeep_backlight_on_triggered()\r
+{\r
+    bool setBacklight = ui->actionKeep_backlight_on->isChecked();\r
+    if(setBacklight)\r
+    {\r
+       if(timer->isActive() == false)\r
+        {\r
+            timer->start(5000);\r
+        }\r
+    }\r
+    else\r
+    {\r
+        qDebug() << "Backlight: " << setBacklight;\r
+        timer->stop();\r
+    }\r
+    qDebug() << "Checked Backlight" << setBacklight;\r
+    settings->setValue(CHECKED_BACKLIGHT, setBacklight);\r
+}\r
+\r
+void MainForm::Keep_backlight_on()\r
+{\r
+    bool setBacklight = ui->actionKeep_backlight_on->isChecked();\r
+    if(setBacklight)\r
+    {\r
+        qDebug() << "Backlight: " << setBacklight;\r
+        QString strUnlock = "dbus-send --system --type=method_call --dest=com.nokia.mce /com/nokia/mce/request com.nokia.mce.request.req_display_blanking_pause";\r
+        QProcess::startDetached(strUnlock);\r
+    }\r
+}\r