#include <QFile>
StarDialog::StarDialog(StarDictPlugin *plugin, StarDialogType type,
- QWidget *parent) : QDialog(parent) {
+ QWidget *parent) : QDialog(parent) {
this->plugin = plugin;
this->type = type;
- initializeUI();
+
+#ifndef Q_WS_MAEMO_5
+ view= new QDeclarativeView();
+ view->setSource(QUrl::fromLocalFile("/usr/share/mdictionary/qml/StarDictDialog.qml"));
+ view->setResizeMode(QDeclarativeView::SizeRootObjectToView);
+ view->setAlignment(Qt::AlignCenter);
+ view->show();
+
+ mainLayout = new QVBoxLayout;
+ mainLayout->addWidget(view);
+ setLayout(mainLayout);
+ view->setWindowTitle(tr("StarDict Settings"));
+
+ QGraphicsObject *rootObject = view->rootObject();
+
+ connect(this, SIGNAL(setInfo(QVariant)),
+ rootObject, SLOT(setInfo(QVariant)));
+ connect(this,SIGNAL(setButtonText(QVariant)),
+ rootObject, SLOT(setButtonText(QVariant)));
+ connect(this,SIGNAL(setNew(QVariant)),
+ rootObject, SLOT(setNew(QVariant)));
+ connect(this,SIGNAL(setPath(QVariant)),
+ rootObject, SLOT(setPath(QVariant)));
+
+ connect(rootObject, SIGNAL(saveButtonClicked()),
+ this, SLOT(accept()));
+ connect(rootObject, SIGNAL(browseButtonClicked()),
+ this, SLOT(selectFile()));
+ connect(rootObject, SIGNAL(heightChange(int)),
+ this, SLOT(heightChange(int)));
+
+#else
if(type == New)
connect(browseButton, SIGNAL(clicked()),this, SLOT(selectFile()));
connect(confirmButton, SIGNAL(clicked()),this, SLOT(accept()));
+#endif
+ initializeUI();
+}
+
+void StarDialog::heightChange(int height){
+ if(height>sizeHint().height())
+ resize(sizeHint().width(),height);
+ lastHeight=height;
}
+void StarDialog::resizeEvent(QResizeEvent *e){
+ QDialog::resizeEvent(e);
+ if(lastHeight>sizeHint().height()){
+ resize(sizeHint().width(),lastHeight);
+ }
+}
void StarDialog::initializeUI() {
+#ifndef Q_WS_MAEMO_5
+ if(type != New){
+ emit setNew(false);
+ QString info=tr("Plugin: ") + plugin->type().toUpper() +"\n" +
+ tr("Book name: ") + plugin->settings()->value("bookname") + "\n" +
+ tr("Version: ") + plugin->settings()->value("version") + "\n" +
+ tr("Word count: ") + plugin->settings()->value("wordcount") + "\n" +
+ tr("Author: ") + plugin->settings()->value("author") + "\n" +
+ tr("E-mail: ") + plugin->settings()->value("email") + "\n" +
+ tr("Website: ") + plugin->settings()->value("website") + "\n" +
+ tr("Description: ") + plugin->settings()->value("description")+"\n"+
+ tr("Date: ") + plugin->settings()->value("date");
+ emit setInfo(info);
+ emit setButtonText("Save settings");
+ }
+ else{
+ emit setNew(true);
+ emit setButtonText("Add");
+ }
+
+ if(!plugin)
+ _dictionaryFilePath = "";
+
+#else
mainVerticalLayout = new QVBoxLayout;
widget = new QWidget;
widget->setLayout(mainVerticalLayout);
browseButton->setMaximumWidth(150);
infoLabel->setText(tr("Dictionary file: not selected"));
setWindowTitle(tr("Add new StarDict dictionary"));
- infoLabel->setText(tr("Dictionary file: not selected"));
browseLayout->addWidget(infoLabel, 0, Qt::AlignLeft);
browseLayout->addLayout(buttonLayout);
browseLayout->addWidget(browseButton, 0, Qt::AlignRight);
scrollArea->setLineWidth(0);
scrollArea->setMidLineWidth(0);
scrollArea->setFrameStyle(QFrame::NoFrame);
+#endif
}
NULL,
NULL);
if (!fileName.isEmpty()) {
+#ifndef Q_WS_MAEMO_5
+ emit setPath(tr("Dictionary file: %1").arg(fileName));
+#else
infoLabel->setText(tr("Dictionary file: %1").arg(fileName));
+#endif
_dictionaryFilePath = fileName;
if (_dictionaryFilePath.endsWith(".tar.bz2"))
_isCompressed = true;
else
_isCompressed = false;
+#ifndef Q_WS_MAEMO_5
+ // qDebug()<<"hint"<<view->sizeHint();
+ // qDebug()<<"size"<<view->size();
+ resize(view->sizeHint());
+
+#else
updateGeometry();
+#endif
}
}
void StarDialog::saveSettings() {
- _settings = new Settings;
+ _settings = new Settings;
if(plugin)
foreach(QString key, plugin->settings()->keys())
_settings->setValue(key, plugin->settings()->value(key));
else
_settings->setValue("dictFileName", _dictName + ".dict");
}
-
if(_settings->value("synFileName")=="")
if (QFile::exists(_dictName + ".syn") == true)
_settings->setValue("synFileName", _dictName + ".syn");