X-Git-Url: http://vcs.maemo.org/git/?a=blobdiff_plain;f=mainform.cpp;h=c36675458d5b09d749e3ad48272e08ee0391219e;hb=HEAD;hp=c271bed6bf13fbcdeb80044c071757bb2fcda1d9;hpb=fce0a4ef7d2ce4f362f314799652514fbec56180;p=easylist
diff --git a/mainform.cpp b/mainform.cpp
index c271bed..c366754 100755
--- a/mainform.cpp
+++ b/mainform.cpp
@@ -8,6 +8,10 @@ MainForm::MainForm(QWidget *parent) :
ui->setupUi(this);
settings = new QSettings(WILLEM_LIU, EASY_LIST);
+ /* Make a call every x milliseconds */
+ timer = new QTimer(this);
+ connect(timer, SIGNAL(timeout()), this, SLOT(Keep_backlight_on()));
+
requestWebpage = new RequestWebpage(this);
connect(requestWebpage, SIGNAL(finished(QNetworkReply*)), this, SLOT(slotSyncList(QNetworkReply*)));
@@ -28,6 +32,14 @@ MainForm::MainForm(QWidget *parent) :
ui->actionChecked_bottom->setChecked(settings->value(CHECKED_ITEMS_TO_BOTTOM).toBool());
on_actionChecked_bottom_triggered();
+ // Set a default value for CHECKED_BACKLIGHT
+ if(settings->contains(CHECKED_BACKLIGHT) == false)
+ {
+ settings->setValue(CHECKED_BACKLIGHT, false);
+ }
+ ui->actionKeep_backlight_on->setChecked(settings->value(CHECKED_BACKLIGHT).toBool());
+ on_actionKeep_backlight_on_triggered();
+
// Create a default for landscape mode.
landscape = settings->value(LANDSCAPE).toBool();
// If LANDSCAPE exists in QSettings.
@@ -166,14 +178,15 @@ void MainForm::on_actionAbout_triggered()
{
qDebug() << "About";
QString aboutText;
- aboutText.append("");
+ aboutText.append("
");
aboutText.append("EasyList (c) 2010-");
aboutText.append(QDate::currentDate().toString("yyyy"));
aboutText.append("
");
aboutText.append("Created by Willem Liu.
");
+ aboutText.append("Thanks to Ade.
");
aboutText.append("Created with QtCreator.
");
aboutText.append("Please donate any amount you deem this app is worthy to keep me going on.
");
- aboutText.append("");
+ aboutText.append("");
QMessageBox::about(this, "EasyList", aboutText);
}
@@ -198,7 +211,7 @@ void MainForm::on_actionAuto_Orientation_triggered()
qDebug() << "Auto orientation" << ui->actionAuto_Orientation->isChecked();
if(ui->actionAuto_Orientation->isChecked())
{
-#ifdef Q_WS_MAEMO_5
+#if defined(Q_WS_MAEMO_5) || defined(Q_WS_HILDON)
setAttribute(Qt::WA_Maemo5PortraitOrientation, false);
setAttribute(Qt::WA_Maemo5LandscapeOrientation, false);
setAttribute(Qt::WA_Maemo5AutoOrientation, true);
@@ -224,19 +237,27 @@ void MainForm::on_actionLists_triggered()
void MainForm::on_actionSync_triggered()
{
- QString username = settings->value(USERNAME, "").toString();
- QString password = settings->value(PASSWORD, "").toString();
- QString url = settings->value(SYNC_URL, DEFAULT_SYNC_URL).toString();
- url.append("?username=" + username);
- url.append("&password=" + password);
- qDebug() << url;
- requestWebpage->fetch(url);
+ 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);
+
+ if(res == QMessageBox::Ok)
+ {
+ QString username = settings->value(USERNAME, "").toString();
+ QString password = settings->value(PASSWORD, "").toString();
+ QString url = settings->value(SYNC_URL, DEFAULT_SYNC_URL).toString();
+ url.append("?username=" + username);
+ url.append("&password=" + password);
+ qDebug() << url;
+ requestWebpage->post(url,settings->value(LIST_TEXT,"").toString().toUtf8());
+ //requestWebpage->fetch(url);
+ }
}
void MainForm::slotSyncList(QNetworkReply* pReply)
{
+ settings->setValue(LIST_TEXT, MyCheckBoxContainer::getInstance()->getListText());
+ SystemSettings::getInstance()->saveCurrentList();
QByteArray data=pReply->readAll();
- QString list(data);
+ QString list = QString::fromUtf8(data);
settings->setValue(LIST_TEXT, list);
settings->setValue(SELECTED_LIST_NAME, SYNC_LIST_NAME);
settings->setValue(SYNC_LIST_NAME, settings->value(LIST_TEXT, ""));
@@ -254,3 +275,33 @@ void MainForm::on_actionSetting_triggered()
{
changeWidget(3);
}
+
+void MainForm::on_actionKeep_backlight_on_triggered()
+{
+ bool setBacklight = ui->actionKeep_backlight_on->isChecked();
+ if(setBacklight)
+ {
+ if(timer->isActive() == false)
+ {
+ timer->start(5000);
+ }
+ }
+ else
+ {
+ qDebug() << "Backlight: " << setBacklight;
+ timer->stop();
+ }
+ qDebug() << "Checked Backlight" << setBacklight;
+ settings->setValue(CHECKED_BACKLIGHT, setBacklight);
+}
+
+void MainForm::Keep_backlight_on()
+{
+ bool setBacklight = ui->actionKeep_backlight_on->isChecked();
+ if(setBacklight)
+ {
+ qDebug() << "Backlight: " << setBacklight;
+ QString strUnlock = "dbus-send --system --type=method_call --dest=com.nokia.mce /com/nokia/mce/request com.nokia.mce.request.req_display_blanking_pause";
+ QProcess::startDetached(strUnlock);
+ }
+}