X-Git-Url: http://vcs.maemo.org/git/?a=blobdiff_plain;f=src%2Fplugins%2Fgoogle%2FGoogleDialog.cpp;h=4ca07eb96c272f7e35682aa85454edd2b3c4e85d;hb=0920a54ebc21e26ea44fab232832f45b7882da19;hp=45bf7245da7410c837af68860ad9af76dee3d7c8;hpb=8ef1fe7254cfa683e0d3377bd8832ce12410c7dc;p=mdictionary diff --git a/src/plugins/google/GoogleDialog.cpp b/src/plugins/google/GoogleDialog.cpp index 45bf724..4ca07eb 100644 --- a/src/plugins/google/GoogleDialog.cpp +++ b/src/plugins/google/GoogleDialog.cpp @@ -19,7 +19,9 @@ *******************************************************************************/ /*! - \file GoogleSettingsDialog.cpp + \file GoogleDialog.cpp + \brief Implementation of google plugin's dialogs. + \author Jakub Jaszczynski */ @@ -32,6 +34,8 @@ GoogleDialog::GoogleDialog(GooglePlugin *plugin, this->plugin = plugin; this->type = type; _settings = 0; + _actualLangFrom = 0; + _actualLangTo = 0; if(plugin) { _langTo=GooglePlugin::languages.key( @@ -45,8 +49,7 @@ GoogleDialog::GoogleDialog(GooglePlugin *plugin, _langFrom=GooglePlugin::languages.key("en"); } - initializeUI(); - +#ifdef Q_WS_MAEMO_5 connect(confirmButton, SIGNAL(clicked()), this, SLOT(accept())); @@ -58,10 +61,81 @@ GoogleDialog::GoogleDialog(GooglePlugin *plugin, connect(changeLangButton, SIGNAL(clicked()), this, SLOT(changeLangButtonClicked())); +#else + + int i=0,j=0; + int actualLangTo=0; + int actualLangFrom=0; + + QList langList; + foreach(QString langs, GooglePlugin::languages.keys()){ + if(langs==_langTo) + actualLangTo=j; + if(langs==_langFrom) + actualLangFrom=i; + if(langs!="Detect langlage"){ + langList.append(langs); + j++; + } + i++; + } + + _actualLangFrom = actualLangFrom; + _actualLangTo = actualLangTo; + model = new ComboBoxModel(langList); + + view= new QDeclarativeView(); + ctxt = view->rootContext(); + ctxt->setContextProperty("comboBoxModel", &(*model)); + view->setSource(QUrl::fromLocalFile("/usr/share/mdictionary/qml/GoogleDialog.qml")); + view->setResizeMode(QDeclarativeView::SizeRootObjectToView); + //view->setAlignment(Qt::AlignCenter); + view->show(); + + mainLayout = new QVBoxLayout; + mainLayout->addWidget(view); + setLayout(mainLayout); + view->setWindowTitle(tr("Google Settings")); + + QGraphicsObject *rootObject = view->rootObject(); + + connect(rootObject, SIGNAL(saveButtonClicked(QString, QString)), + this, SLOT(saveButtonClicked(QString,QString))); + + connect(this, SIGNAL(setInfo(QVariant)), + rootObject, SLOT(setInfo(QVariant))); + connect(this,SIGNAL(setNew(QVariant)), + rootObject, SLOT(setNew(QVariant))); + connect(this,SIGNAL(setStartValues(QVariant,QVariant,QVariant,QVariant)), + rootObject, SLOT(setStartValues(QVariant, QVariant, QVariant, QVariant))); + +#endif + + initializeUI(); } void GoogleDialog::initializeUI() { +#ifndef Q_WS_MAEMO_5 + + setWindowTitle(tr("Google Plugin Settings")); + if (type != New){ + emit setNew(false); + QString info=tr("Plugin: ") + plugin->type().toUpper() +"\n" + + tr("From: ") + _langFrom + "\n" + + tr("To: ") + _langTo; + emit setInfo(info); + } + else{ + emit setNew(true); + } + emit setStartValues(_langFrom, _langTo, _actualLangFrom, _actualLangTo); + +// setMinimumSize(sizeHint()); + + +#else + int i=0,j=0; int actualLangTo=0; int actualLangFrom=0; @@ -142,6 +216,7 @@ void GoogleDialog::initializeUI() { setModal(true); setMinimumSize(sizeHint()); setMaximumSize(sizeHint()); +#endif } @@ -165,7 +240,7 @@ void GoogleDialog::changeLangButtonClicked() { } } - +#ifdef Q_WS_MAEMO_5 void GoogleDialog::accept() { saveSettings(); QDialog::accept(); @@ -185,6 +260,27 @@ void GoogleDialog::saveSettings() { GooglePlugin::languages.value(_langFrom)); } +#else +void GoogleDialog::saveButtonClicked(QString langFrom, QString langTo){ + saveSettings(langFrom, langTo); + QDialog::accept(); +} + +void GoogleDialog::saveSettings(QString langFrom, QString langTo){ + _settings = new Settings; + _langFrom = langFrom; + _langTo = langTo; + if(plugin) { + foreach(QString key, plugin->settings()->keys()) + _settings->setValue(key, plugin->settings()->value(key)); + } + + _settings->setValue("lang_to", + GooglePlugin::languages.value(langTo)); + _settings->setValue("lang_from", + GooglePlugin::languages.value(langFrom)); +} +#endif Settings* GoogleDialog::getSettings() { return _settings;