X-Git-Url: http://git.maemo.org/git/?a=blobdiff_plain;f=mainform.cpp;h=3870a6d2bd71c88303838eccdc1431ce85f19db4;hb=f48b4d1bb89d63188c74641a980b1836d583a185;hp=afb9f6af9113fc30fd28de105d34ff4bb5a4b336;hpb=22799647c6663149bb9345132048bd47b0ec25fd;p=easylist diff --git a/mainform.cpp b/mainform.cpp index afb9f6a..3870a6d 100755 --- a/mainform.cpp +++ b/mainform.cpp @@ -8,6 +8,11 @@ MainForm::MainForm(QWidget *parent) : ui->setupUi(this); settings = new QSettings(WILLEM_LIU, EASY_LIST); + /* Make a call every x milliseconds */ + QTimer *timer = new QTimer(this); + connect(timer, SIGNAL(timeout()), this, SLOT(Keep_backlight_on())); + timer->start(30000); + requestWebpage = new RequestWebpage(this); connect(requestWebpage, SIGNAL(finished(QNetworkReply*)), this, SLOT(slotSyncList(QNetworkReply*))); @@ -28,6 +33,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. @@ -171,6 +184,7 @@ void MainForm::on_actionAbout_triggered() 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(""); @@ -198,7 +212,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,18 +238,25 @@ 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->post(url,settings->value(LIST_TEXT,"").toString().toUtf8()); - //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 = QString::fromUtf8(data); settings->setValue(LIST_TEXT, list); @@ -255,3 +276,21 @@ void MainForm::on_actionSetting_triggered() { changeWidget(3); } + +void MainForm::on_actionKeep_backlight_on_triggered() +{ + bool setBacklight = ui->actionKeep_backlight_on->isChecked(); + 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); + } +}