X-Git-Url: http://git.maemo.org/git/?a=blobdiff_plain;f=src%2Fgui%2Fmainwindow.cpp;h=8d75fea4a52bc7f2361173cb17dee17f9f8a7f6a;hb=d187495fd3566da1ee1eb94cc313c2f561a0fac5;hp=1e4de14ce473b3509f1236e679c8d80d4344a293;hpb=10e8a9c76ee07e04061562e0012e1ef1233e6b3e;p=jenirok diff --git a/src/gui/mainwindow.cpp b/src/gui/mainwindow.cpp index 1e4de14..8d75fea 100644 --- a/src/gui/mainwindow.cpp +++ b/src/gui/mainwindow.cpp @@ -22,14 +22,18 @@ #include #include #include +#include +#include +#include #include -#include #include "mainwindow.h" #include "settingsdialog.h" #include "searchdialog.h" #include "daemon.h" #include "settings.h" #include "db.h" +#include "source.h" +#include "sourcecoreconfig.h" namespace { @@ -39,7 +43,7 @@ namespace MainWindow::MainWindow(QWidget* parent): QMainWindow(parent), searchResults_(0), settingsDialog_(0), running_(false), -toggleButton_(0), searchDialog_(0), aboutDialog_(0) +toggleButton_(0), searchDialog_(0), aboutDialog_(0), warning_(0) { setWindowTitle(tr("Jenirok")); setAttribute(Qt::WA_Maemo5StackedWindow); @@ -86,6 +90,11 @@ MainWindow::~MainWindow() void MainWindow::showSettings() { + if(warning_ && warning_->isVisible()) + { + warning_->hide(); + } + if(!settingsDialog_) { settingsDialog_ = new SettingsDialog(this); @@ -110,6 +119,33 @@ void MainWindow::toggleDaemon() } else { + if(Settings::instance()->getConnectionType() == Settings::ALWAYS_ASK) + { + if(!warning_) + { + warning_ = new QDialog(this); + warning_->setWindowTitle(tr("Unable to start daemon")); + QHBoxLayout* warningLayout = new QHBoxLayout; + QTextEdit* text = new QTextEdit(tr("Daemon cannot be started because it's not allowed to connect to the Internet. You have to either allow automatic Internet connection in Jenirok settings or in global Maemo settings.")); + text->setReadOnly(true); + QDialogButtonBox* buttons = new QDialogButtonBox; + buttons->setOrientation(Qt::Vertical); + QPushButton* settingsButton = new QPushButton(tr("Open settings")); + connect(settingsButton, SIGNAL(pressed()), this, SLOT(showSettings())); + QPushButton* okButton = new QPushButton(tr("Close")); + connect(okButton, SIGNAL(pressed()), warning_, SLOT(hide())); + buttons->addButton(settingsButton, QDialogButtonBox::YesRole); + buttons->addButton(okButton, QDialogButtonBox::AcceptRole); + warningLayout->addWidget(text); + warningLayout->addWidget(buttons); + warning_->setLayout(warningLayout); + } + + warning_->show(); + + return; + } + readyText = tr("Daemon was successfully started."); failText = tr("Unable to start daemon."); buttonText = tr("Stop daemon"); @@ -132,16 +168,17 @@ void MainWindow::toggleDaemon() void MainWindow::openSearch() { - DB::connect(); + Source::SourceId sourceId = Source::stringToId(Settings::instance()->get("source")); + SourceCoreConfig* config = SourceCoreConfig::getCoreConfig(sourceId); - QString username = Settings::instance()->get("eniro_username"); - QString password = Settings::instance()->get("eniro_password"); + Q_ASSERT(config != 0); - DB::disconnect(); + bool readyToSearch = config->readyToSearch(); + delete config; - if(username.isEmpty() || password.isEmpty()) + if(!readyToSearch) { - QMessageBox::information(this, tr("Info"), tr("You need to set Eniro login details in settings before using this feature.")); + QMessageBox::information(this, tr("Info"), tr("You need to set login details or other options in settings before using this feature.")); return; }