Merge branch 'qml' of ssh://drop.maemo.org/git/mdictionary into qml
authorMarcin Kaźmierczak <marcin@marcin-desktop.(none)>
Thu, 13 Jan 2011 14:50:48 +0000 (15:50 +0100)
committerMarcin Kaźmierczak <marcin@marcin-desktop.(none)>
Thu, 13 Jan 2011 14:50:48 +0000 (15:50 +0100)
12 files changed:
mdictionary.pri
src/mdictionary/gui/SettingsWidget.cpp
src/mdictionary/gui/SettingsWidget.h
src/mdictionary/gui/TranslationView.cpp
src/mdictionary/mdictionary.pro
src/mdictionary/qml/AboutWidget.qml
src/mdictionary/qml/MySpinBox.qml
src/mdictionary/qml/SettingsWidget.qml [new file with mode: 0644]
src/mdictionary/qml/XdxfDialog.qml [new file with mode: 0644]
src/plugins/xdxf/XdxfDialog.cpp
src/plugins/xdxf/XdxfDialog.h
src/plugins/xdxf/xdxf.pro

index 5b4b2ea..c48f80d 100644 (file)
@@ -30,3 +30,5 @@ DEFINES += MDICTIONARY_PLUGINS_DIR=\\\"$$PLUGINS_DIR\\\"
 
 system(echo "ENABLED_SRC = $$ENABLED_SRC" >src/src.pri)
 system(echo "ENABLED_PLUGINS = $$ENABLED_PLUGINS" >src/plugins/plugins.pri)
+
+OTHER_FILES +=
index 06226a9..4c37017 100644 (file)
 #include "SettingsWidget.h"
 #include <QDebug>
 
-SettingsWidget::SettingsWidget(GUIInterface *parent) :
-        QDialog(parent)
-{
-    guiInterface = parent;
+SettingsWidget::SettingsWidget(GUIInterface *parent) : QDialog(parent) {
 
+guiInterface = parent;
+
+#ifndef Q_WS_MAEMO_5
+    view= new QDeclarativeView();
+    view->setSource(QUrl::fromLocalFile("/usr/share/mdictionary/qml/SettingsWidget.qml"));
+    view->setResizeMode(QDeclarativeView::SizeRootObjectToView);
+    view->setAlignment(Qt::AlignCenter);
+    view->show();
+
+    view->setMinimumWidth(250);
+    view->setMaximumWidth(250);
+    view->setMinimumHeight(view->sizeHint().height());
+    view->setMaximumHeight(view->sizeHint().height());
+
+    mainLayout = new QVBoxLayout;
+    mainLayout->addWidget(view);
+    setLayout(mainLayout);
+    view->setWindowTitle(tr("Settings"));
+
+    QGraphicsObject *rootObject = view->rootObject();
+
+    connect(this, SIGNAL(setMinHistory(QVariant)),
+           rootObject, SLOT(setMinHistory(QVariant)));
+    connect(this, SIGNAL(setValueHistory(QVariant)),
+           rootObject, SLOT(setValueHistory(QVariant)));
+    connect(this, SIGNAL(setMaxHistory(QVariant)),
+           rootObject, SLOT(setMaxHistory(QVariant)));
+    connect(this, SIGNAL(setMinSearchResult(QVariant)),
+           rootObject, SLOT(setMinSearchResult(QVariant)));
+    connect(this, SIGNAL(setValueSearchResult(QVariant)),
+           rootObject, SLOT(setValueSearchResult(QVariant)));
+    connect(this, SIGNAL(setMaxSearchResult(QVariant)),
+           rootObject, SLOT(setMaxSearchResult(QVariant)));
+    connect(this, SIGNAL(setCheckedBookmarks(QVariant)),
+           rootObject, SLOT(setCheckedBookmarks(QVariant)));
+    connect(this, SIGNAL(setCheckedDictionaries(QVariant)),
+           rootObject, SLOT(setCheckedDictionaries(QVariant)));
+
+    connect(rootObject, SIGNAL(historySizeValueChanged(int)),
+           this, SLOT(historySizeValueChanged(int)));
+    connect(rootObject, SIGNAL(searchResulValueChanged(int)),
+           this, SLOT(searchResulValueChanged(int)));
+    connect(rootObject, SIGNAL(dictionariesCheckBoxChanged(bool)),
+           this, SLOT(dictionariesCheckBoxChanged(bool)));
+    connect(rootObject, SIGNAL(bookmarksCheckBoxChanged(bool)),
+           this, SLOT(bookmarksCheckBoxChanged(bool)));
+    connect(rootObject, SIGNAL(saveButtonClicked()),
+           this, SLOT(save()));
+
+#else
     setWindowTitle(tr("Settings"));
+    setModal(true);
+#endif
 
     initalizeUI();
+}
 
-    setModal(true);
+void SettingsWidget::historySizeValueChanged(int value){
+    historyValue = value;
+    changed();
+}
+
+void SettingsWidget::searchResulValueChanged(int value){
+    searchResultValue=value;
+    changed();
+}
+
+void SettingsWidget::dictionariesCheckBoxChanged(bool boolean){
+    dictionariesCheckBox=boolean;
+    changed();
+}
+
+void SettingsWidget::bookmarksCheckBoxChanged(bool boolean){
+    bookmarksCheckBox=boolean;
+    changed();
 }
 
 void SettingsWidget::initalizeUI() {
+#ifndef Q_WS_MAEMO_5
+    emit setMinHistory(1);
+    emit setMaxHistory(50);
+    emit setMinHistory(0);
+    emit setMaxHistory(500);
+    settings = 0;
+#else
     verticalLayout = new QVBoxLayout;
-    setLayout(verticalLayout);
-
     historySizeLayout = new QHBoxLayout;
-
     historySizeSpinBox = new SpinBox;
+    searchResultLayout = new QHBoxLayout;
+    searchResultSizeSpinBox = new SpinBox;
+    searchInBookmarksCheckBox = new QCheckBox(tr("Bookmarks"));
+    searchInDictionariesCheckBox = new QCheckBox(tr("Dictionaries"));
+
     historySizeSpinBox->setMinimum(1);
     historySizeSpinBox->setMaximum(50);
-
     historySizeToolTip = tr("Limits maximum number of words saved in history");
+    historySizeLayout->addWidget(historySizeSpinBox);
 
     #ifdef Q_WS_MAEMO_5
         historySizeInfoToolButton = new QToolButton;
         historySizeInfoToolButton->setIcon(QIcon::fromTheme("general_information"));
-    #endif
-
-    historySizeLayout->addWidget(historySizeSpinBox);
-    #ifdef Q_WS_MAEMO_5
         historySizeLayout->addWidget(historySizeInfoToolButton);
+        searchResultSizeInfoToolButton = new QToolButton;
+        searchResultSizeInfoToolButton->setIcon(QIcon::fromTheme("general_information"));
     #endif
 
-
-
-
-    searchResultLayout = new QHBoxLayout;
-
-    searchResultSizeSpinBox = new SpinBox;
     searchResultSizeSpinBox->setMinimum(0);
     searchResultSizeSpinBox->setMaximum(500);
     searchResultSizeSpinBox->setSpecialValueText(tr("Unlimited"));
-
     searchResultSizeToolTip = tr("Limits maximum number of found words, affects"
                                  " only when searching in file.");
-
-    #ifdef Q_WS_MAEMO_5
-        searchResultSizeInfoToolButton = new QToolButton;
-        searchResultSizeInfoToolButton->setIcon(QIcon::fromTheme("general_information"));
-    #endif
-
     searchResultLayout->addWidget(searchResultSizeSpinBox);
+
     #ifdef Q_WS_MAEMO_5
         searchResultLayout->addWidget(searchResultSizeInfoToolButton);
     #endif
 
-
-
-
-
     spinBoxesFormLayout = new QFormLayout;
-    spinBoxesFormLayout->addRow(tr("Search result size"),
-                                searchResultLayout);
-    spinBoxesFormLayout->addRow(tr("History size"),
-                                historySizeLayout);
-
-
-
+    spinBoxesFormLayout->addRow(tr("Search result size"), searchResultLayout);
+    spinBoxesFormLayout->addRow(tr("History size"), historySizeLayout);
 
     verticalLayout->addLayout(spinBoxesFormLayout);
-
-
     checkBoxesLabel = new QLabel(tr("Search in:"),this);
 
-    searchInBookmarksCheckBox = new QCheckBox(tr("Bookmarks"));
-    searchInDictionariesCheckBox = new QCheckBox(tr("Dictionaries"));
-
     verticalLayout->addSpacing(20);
     verticalLayout->addWidget(checkBoxesLabel);
     verticalLayout->addWidget(searchInDictionariesCheckBox);
     verticalLayout->addWidget(searchInBookmarksCheckBox);
 
+    setLayout(verticalLayout);
 
-    connect(historySizeSpinBox, SIGNAL(valueChanged(int)), this,
-            SLOT(changed()));
-    connect(searchResultSizeSpinBox, SIGNAL(valueChanged(int)), this,
-            SLOT(changed()));
-    connect(searchInDictionariesCheckBox, SIGNAL(toggled(bool)), this,
-            SLOT(changed()));
-    connect(searchInBookmarksCheckBox, SIGNAL(toggled(bool)), this,
-            SLOT(changed()));
-
+    connect(historySizeSpinBox, SIGNAL(valueChanged(int)),
+            this,SLOT(changed()));
+    connect(searchResultSizeSpinBox, SIGNAL(valueChanged(int)),
+            this,SLOT(changed()));
+    connect(searchInDictionariesCheckBox, SIGNAL(toggled(bool)),
+            this,SLOT(changed()));
+    connect(searchInBookmarksCheckBox, SIGNAL(toggled(bool)),
+            this,SLOT(changed()));
 
-#ifdef Q_WS_MAEMO_5
+    #ifdef Q_WS_MAEMO_5
         connect(searchResultSizeInfoToolButton, SIGNAL(clicked()),
                 this, SLOT(showSearchResultSizeInfo()));
-
         connect(historySizeInfoToolButton, SIGNAL(clicked()),
                 this, SLOT(showHistorySizeInfo()));
-#else
+    #else
         historySizeSpinBox->setToolTip(historySizeToolTip);
         searchResultSizeSpinBox->setToolTip(searchResultSizeToolTip);
-#endif
+    #endif
 
 
     settings = 0;
@@ -148,10 +195,29 @@ void SettingsWidget::initalizeUI() {
         setMaximumHeight(sizeHint().height());
         connect(closeButton, SIGNAL(clicked()), this, SLOT(save()));
     #endif
+#endif
 }
 
 void SettingsWidget::showEvent(QShowEvent *e) {
 
+#ifndef Q_WS_MAEMO_5
+    settings = guiInterface->settings();
+
+    emit setValueHistory(settings->value("history_size").toInt());
+    emit setValueSearchResult(settings->value("search_limit").toInt());
+
+    if(settings->value("search_bookmarks") == "true")
+        emit setCheckedBookmarks(true);
+    else
+        emit setCheckedBookmarks(false);
+
+    if(settings->value("search_dictionaries") == "true")
+        emit setCheckedDictionaries(true);
+    else
+        emit setCheckedDictionaries(false);
+
+    QDialog::showEvent(e);
+#else
    #ifndef Q_WS_MAEMO_5
        _save = false;
    #endif
@@ -173,24 +239,47 @@ void SettingsWidget::showEvent(QShowEvent *e) {
         searchInDictionariesCheckBox->setChecked(true);
     else
         searchInDictionariesCheckBox->setChecked(false);
-
-    _changed = false;
     QDialog::showEvent(e);
+#endif
+    _changed = false;
 }
 
 void SettingsWidget::hideEvent(QHideEvent *e) {
     QDialog::hideEvent(e);
 
-    #ifndef Q_WS_MAEMO_5
-        if(settings && _save) {
-    #else
-        if(settings && _changed &&
-           QMessageBox::question(this,
-                                 tr("Save"),
-                                 tr("Do you want to save changes?"),
-             QMessageBox::Save, QMessageBox::Cancel) == QMessageBox::Save) {
+#ifndef Q_WS_MAEMO_5
+    if(settings && _save) {
+        Settings* newSettings = new Settings;
+        newSettings->setValue("history_size",QString::number(historyValue));
+        newSettings->setValue("search_limit",QString::number(searchResultValue));
+        if(dictionariesCheckBox==true)
+            newSettings->setValue("search_dictionaries", "true");
+        else
+            newSettings->setValue("search_dictionaries", "false");
+
+        if(bookmarksCheckBox==true)
+            newSettings->setValue("search_bookmarks", "true");
+        else
+            newSettings->setValue("search_bookmarks", "false");
+        foreach(QString key, newSettings->keys()) {
+            if(settings->value(key) != newSettings->value(key)) {
+                guiInterface->setSettings(newSettings);
+                break;
+            }
+        }
+        _changed = false;
+        if(settings) {
+            delete settings;
+            settings = 0;
+        }
+    }
+#else
+    if(settings && _changed &&
+       QMessageBox::question(this,
+                             tr("Save"),
+                             tr("Do you want to save changes?"),
+        QMessageBox::Save, QMessageBox::Cancel) == QMessageBox::Save) {
 
-    #endif
         Settings* newSettings = new Settings;
         newSettings->setValue("history_size",
                               QString::number(historySizeSpinBox->value()));
@@ -209,20 +298,19 @@ void SettingsWidget::hideEvent(QHideEvent *e) {
             newSettings->setValue("search_bookmarks", "false");
 
         //setting new settings only if they are different than old ones
-        QString key;
-        foreach(key, newSettings->keys()) {
+        foreach(QString key, newSettings->keys()) {
             if(settings->value(key) != newSettings->value(key)) {
                 guiInterface->setSettings(newSettings);
                 break;
             }
         }
-
     }
     if(settings) {
         delete settings;
         settings = 0;
     }
     _changed = false;
+#endif
 }
 
 
index f6ada01..d721cd9 100644 (file)
 #include <QWidget>
 #include <QtGui>
 #include <QPushButton>
+#include <QDeclarativeView>
+#include <QVariant>
+
 #include "../../include/GUIInterface.h"
 #include "../../include/settings.h"
 #include "SpinBox.h"
 
+
 /*!
   Shows settings that user can change.
   It allows to change limit of searches and limit of history.
@@ -54,6 +58,15 @@ public:
     explicit SettingsWidget(GUIInterface *parent = 0);
 
 Q_SIGNALS:
+    void setMinHistory(QVariant minValue);
+    void setMaxHistory(QVariant minValue);
+    void setValueHistory(QVariant value);
+    void setMinSearchResult(QVariant minValue);
+    void setMaxSearchResult(QVariant minValue);
+    void setValueSearchResult(QVariant value);
+    void setCheckedBookmarks(QVariant boolen);
+    void setCheckedDictionaries(QVariant boolen);
+
     void notify(Notify::NotifyType, QString);
 
 protected:
@@ -61,6 +74,11 @@ protected:
     void hideEvent(QHideEvent *);
 
 private Q_SLOTS:
+    void historySizeValueChanged(int value);
+    void searchResulValueChanged(int value);
+    void dictionariesCheckBoxChanged(bool boolean);
+    void bookmarksCheckBoxChanged(bool boolean);
+
     void changed();
     #ifndef Q_WS_MAEMO_5
         void save();
@@ -72,6 +90,10 @@ private Q_SLOTS:
 
 private:
     void initalizeUI();
+
+    QVBoxLayout* mainLayout;
+    QDeclarativeView *view;
+
     SpinBox* historySizeSpinBox;
     SpinBox* searchResultSizeSpinBox;
     QVBoxLayout* verticalLayout;
@@ -101,9 +123,10 @@ private:
         QHBoxLayout* footerLayout;
         bool _save;
     #endif
-
-
-
+    int historyValue;
+    int searchResultValue;
+    bool dictionariesCheckBox;
+    bool bookmarksCheckBox;
 };
 
 #endif // SETTINGSWIDGET_H
index 84efd21..d60a2f0 100644 (file)
@@ -36,7 +36,7 @@ TranslationView::TranslationView(QWidget *parent) : QWebView(parent) {
 #ifndef Q_WS_MAEMO_5
 
     view= new QDeclarativeView();
-    view->setSource(QUrl("src/mdictionary/qml/TranslationView.qml"));
+    view->setSource(QUrl::fromLocalFile("/usr/share/mdictionary/qml/TranslationView.qml"));
     view->setResizeMode(QDeclarativeView::SizeRootObjectToView);
     view->setAlignment(Qt::AlignCenter);
     view->show();
index cf327d7..2a80942 100644 (file)
@@ -98,7 +98,8 @@ OTHER_FILES += \
     qml/FlickableWebView.qml \
     qml/ScrollBar.qml \
     qml/Checkbox.qml \
-    qml/MySpinBox.qml
+    qml/MySpinBox.qml \
+    qml/SettingsWidget.qml
 
 target.path = $$BIN_DIR
 INSTALLS += target
@@ -180,6 +181,22 @@ unix {
     meego {
         qmls.path = $$DATA_DIR/qml
         qmls.files += ./qml/WelcomeScreenWidget.qml
+        qmls.files += ./qml/Button.qml
+        qmls.files += ./qml/AboutWidget.qml
+        qmls.files += ./qml/SearchBarWidget.qml
+        qmls.files += ./qml/IconButton.qml
+        qmls.files += ./qml/MyTextLineEdit.qml
+        qmls.files += ./qml/ProgressBar.qml
+        qmls.files += ./qml/ElementsListView.qml
+        qmls.files += ./qml/DictTypeSelectDialog.qml
+        qmls.files += ./qml/DictManagerWidget.qml
+        qmls.files += ./qml/WordListWidget.qml
+        qmls.files += ./qml/TranslationView.qml
+        qmls.files += ./qml/FlickableWebView.qml
+        qmls.files += ./qml/ScrollBar.qml
+        qmls.files += ./qml/Checkbox.qml
+        qmls.files += ./qml/MySpinBox.qml
+        qmls.files += ./qml/SettingsWidget.qml
     }
     else:maemo5 {
         qmls.path = $$DATA_DIR/qml
@@ -203,6 +220,7 @@ unix {
         qmls.files += ./qml/ScrollBar.qml
         qmls.files += ./qml/Checkbox.qml
         qmls.files += ./qml/MySpinBox.qml
+        qmls.files += ./qml/SettingsWidget.qml
     }
        
     INSTALLS += desktop icon64 shared service css css_images qmls
index a8e85bc..a600d1b 100644 (file)
@@ -53,12 +53,12 @@ Rectangle {
         onLinkActivated: linkClicked(link);
     }
 
-    MySpinBox {
+  /*  MySpinBox {
         id: test01
-        y:50;
-        x:100;
+        y:20;
+        x:20;
         width: 40
         height: 20;
     }
-
+    */
 }
index e0d536b..9f0d47c 100644 (file)
@@ -8,46 +8,86 @@ Rectangle {
     property int minValue:0;
     property alias value:text_input1.text
 
+    signal valueChange(int intiger);
+
+    function stringToInt(string){
+        var value=0;
+        var pow10=1;
+        for (var i=string.length-1;i>=0;i--){
+            value+=(string.charCodeAt(i)-48)*pow10;
+            pow10= pow10*10;
+        }
+        if(value>maxValue)
+            return maxValue;
+        if(value<minValue)
+            return minValue;
+        return value;
+    }
+
     TextInput {
         id: text_input1
         x: 1
         width: rectangle1.width-15
         height: rectangle1.height*0.6;
-        text: "0"
+        text: "123"
         anchors.centerIn: parent
-        validator: IntValidator{bottom: 0; top: 500;}
+        validator: IntValidator{bottom: minValue; top: maxValue;}
         transformOrigin: Item.Left
         selectByMouse: true;
         font.pixelSize: rectangle1.height * .5;
         onCursorPositionChanged:  moveCursorSelection(cursorPosition);
-        focus: rectangle1.focus;
- /*       Keys.onPressed: {
-            if ((event.key == Qt.Key_Enter) || (event.key == Qt.Key_Return))
-                rectangle1.enterPressed(text_input1.text)
+        onTextChanged: rectangle1.valueChange(stringToInt(text_input1.text));
+        onFocusChanged: {
+            if(focus==false)
+               text=stringToInt(text);
+        }
+    }
+
+    Timer {
+        id:timerUp;
+        interval: 100;
+        running: false;
+        repeat: true
+        onTriggered:{
+            if(mouseAreaUp.pressedButtons==Qt.LeftButton)
+                text_input1.text=((stringToInt(text_input1.text)+1)>maxValue)?(maxValue):(stringToInt(text_input1.text)+1);
+            else
+                running=false;
+        }
+    }
+
+    Timer {
+        id:timerDown;
+        interval: 100;
+        running: false;
+        repeat: true
+        onTriggered:{
+            if(mouseAreaDown.pressedButtons==Qt.LeftButton)
+                text_input1.text=((stringToInt(text_input1.text)-1)<minValue)?(minValue):(stringToInt(text_input1.text)-1);
+            else
+                running=false;
         }
-*/
     }
 
     Rectangle {
         id: shadeDisable
+        width:  parent.width;
+        height: parent.height;
         anchors.centerIn: parent;
         radius: parent.radius
         color: "grey";
         opacity: 0
-        width:  parent.width;
-        height: parent.height;
     }
 
     Image {
         id: imageUp
         z:4;
+        width: 11;
+        height: 6;
         anchors.right: parent.right
         anchors.top: parent.top
         anchors.rightMargin: 2
         anchors.topMargin: 2
-        width: 11;
-        height: 6;
-
         source: "qrc:/button/up_enable.png";
     }
 
@@ -65,38 +105,38 @@ Rectangle {
 
     MouseArea {
         id: mouseAreaUp
+        z:5
+        width: 13;
+        height: rectangle1.height/2;
         anchors.right: parent.right
         anchors.top: parent.top
-        anchors.rightMargin: 2
-        anchors.topMargin: 2
-        width: 11;
-        height: rectangle1/2;
-        onClicked: {
-            console.log("t1");
-            //rectangle.clicked();
+        onClicked: text_input1.text=((stringToInt(text_input1.text)+1)>maxValue)?(maxValue):(stringToInt(text_input1.text)+1);
+        onPressAndHold:{
+            timerUp.restart;
+            timerUp.running=true;
         }
     }
 
     MouseArea {
         id: mouseAreaDown
+        z:5
+        width: 13;
+        height: rectangle1.height/2;
         anchors.right: parent.right
-        anchors.top: parent.top
-        anchors.rightMargin: 2
-        anchors.topMargin: 2
-        width: 11;
-        height: rectangle1/2;
-        onClicked: {
-            console.log("t2");
-            //rectangle.clicked();
+        anchors.bottom: parent.bottom
+        onClicked: text_input1.text=((stringToInt(text_input1.text)-1)<minValue)?(minValue):(stringToInt(text_input1.text)-1);
+        onPressAndHold:{
+            timerDown.restart;
+            timerDown.running=true;
         }
-
     }
 
-    states: [
+   /* states: [
         State {
             name: "DisableState"; when: rectangle1.enabled==false;
             PropertyChanges { target: shadeDisable; z: 3; opacity: 0.5 }
         }
     ]
+    */
 }
 
diff --git a/src/mdictionary/qml/SettingsWidget.qml b/src/mdictionary/qml/SettingsWidget.qml
new file mode 100644 (file)
index 0000000..74d3a9f
--- /dev/null
@@ -0,0 +1,154 @@
+import Qt 4.7
+
+Rectangle {
+    id: rectangle1
+    width: 230
+    height:170
+
+    SystemPalette { id: myPalette; colorGroup: SystemPalette.Active }
+    color : myPalette.window;
+
+    signal historySizeValueChanged(int intiger);
+    signal searchResulValueChanged(int intiger);
+    signal dictionariesCheckBoxChanged(bool Boolean);
+    signal bookmarksCheckBoxChanged(bool Boolean);
+    signal saveButtonClicked();
+
+    function setMinHistory(intiger){
+        historySpinbox.minValue=intiger;
+    }
+    function setMaxHistory(intiger){
+        historySpinbox.maxValue=intiger;
+    }
+    function setValueHistory(intiger){
+        historySpinbox.value=intiger;
+    }
+
+    function setMaxSearchResult(intiger){
+        searchSpinbox.maxValue=intiger;
+    }
+    function setMinSearchResult(intiger){
+        searchSpinbox.minValue=intiger;
+    }
+    function setValueSearchResult(intiger){
+        searchSpinbox.value=intiger;
+    }
+
+    function setCheckedBookmarks(bool){
+        bookmarkCheckBox.selected=bool;
+    }
+    function setCheckedDictionaries(bool){
+        dictionariesCheckBox.selected=bool;
+    }
+
+    Text {
+        id: textSearch
+        width: 120
+        height: paintedHeight+5;
+        text: qsTr("Search result size")
+        anchors.verticalCenterOffset: 2
+        anchors.left: parent.left
+        anchors.verticalCenter: searchSpinbox.verticalCenter
+        font.pixelSize: 12
+    }
+
+    Text {
+        id: textHistory
+        width: 120
+        height: paintedHeight+5;
+        text: qsTr("History size")
+        anchors.verticalCenterOffset: 2
+        anchors.left: parent.left
+        anchors.verticalCenter: historySpinbox.verticalCenter
+        font.pixelSize: 12
+    }
+
+    Text {
+        id: textSearchIn
+        width: 120
+        height: paintedHeight+5;
+        text: qsTr("Search in:")
+        anchors.top: textHistory.bottom
+        anchors.topMargin: 15
+        anchors.left: parent.left
+        font.pixelSize: 12
+    }
+
+    Text {
+        id: textBookmark
+        width: 120
+        height: 20
+        text: qsTr("Bookmarks")
+        anchors.verticalCenterOffset: 2
+        anchors.left: bookmarkCheckBox.right
+        anchors.leftMargin: 10
+        anchors.verticalCenter: bookmarkCheckBox.verticalCenter
+        font.pixelSize: 12
+    }
+
+    Text {
+        id: textDictionaries
+        width: 120
+        height: 20
+        text: qsTr("Dictionaries")
+        anchors.verticalCenterOffset: 2
+        anchors.left: dictionariesCheckBox.right
+        anchors.leftMargin: 10
+        anchors.verticalCenter: dictionariesCheckBox.verticalCenter
+        font.pixelSize: 12
+    }
+
+    MySpinBox {
+        id: searchSpinbox
+        width: 40
+        height: 20;
+        anchors.top: parent.top
+        anchors.topMargin: 10
+        anchors.left: textSearch.right
+        anchors.leftMargin: 20
+        onValueChange: rectangle1.searchResulValueChanged(intiger);
+    }
+
+    MySpinBox {
+        id: historySpinbox
+        width: 40
+        height: 20;
+        anchors.horizontalCenter: searchSpinbox.horizontalCenter
+        anchors.top: searchSpinbox.bottom
+        anchors.topMargin: 10
+        onValueChange: rectangle1.historySizeValueChanged(intiger);
+    }
+
+    Checkbox {
+        id: bookmarkCheckBox
+        width: 20
+        height: 20
+        anchors.left: parent.left
+        anchors.leftMargin: 20
+        anchors.top: textSearchIn.bottom
+        anchors.topMargin: 0
+        onChanged: rectangle1.bookmarksCheckBoxChanged(selected);
+    }
+
+    Checkbox {
+        id: dictionariesCheckBox
+        width: 20
+        height: 20
+        anchors.horizontalCenter: bookmarkCheckBox.horizontalCenter
+        anchors.top: bookmarkCheckBox.bottom
+        anchors.topMargin: 3
+        onChanged: rectangle1.dictionariesCheckBoxChanged(selected);
+    }
+
+    Button {
+        id: saveButton
+        width: 66
+        height:26
+        anchors.bottom: parent.bottom
+        anchors.bottomMargin: 5
+        anchors.right: parent.right
+        anchors.rightMargin: 5
+        textInButton: qsTr("Save")
+        onClicked: rectangle1.saveButtonClicked();
+    }
+}
diff --git a/src/mdictionary/qml/XdxfDialog.qml b/src/mdictionary/qml/XdxfDialog.qml
new file mode 100644 (file)
index 0000000..567c455
--- /dev/null
@@ -0,0 +1,220 @@
+import Qt 4.7
+
+Rectangle{
+    id:rectangle1
+    width: 220
+    height: textPlugin.height + textFrom.height + textTo.height + textDescription.height + textInfo.height +90
+
+    property bool newPlugin:false;
+
+    SystemPalette { id: myPalette; colorGroup: SystemPalette.Active }
+    color : myPalette.window;
+
+    function setPlugin(string){
+        textPlugin.text = qsTr("Plugin") + ": " + string;
+    }
+    function setFrom(string){
+        textFrom.text = qsTr("From") + ": " + string;
+    }
+    function setTo(string){
+        textTo.text = qsTr("To") + ": " + string;
+    }
+    function setDescription(string){
+        textDescription.text = qsTr("Description") + ": " + string;
+    }
+    function setInfo(string){
+        textInfo.text = string;
+    }
+    function setButtonText(string){
+        saveButton.textInButton=string;
+    }
+    function setCheckedOptimalize(bool){
+        optimalizeCheckbox.selected=bool;
+    }
+    function setCheckedStrip(bool){
+        stripCheckbox.selected=bool;
+    }
+    function setNew(bool){
+        newPlugin=bool;
+    }
+    function setPath(string){
+        console.log("new path");
+        textPath.text=string;
+    }
+
+
+    signal saveButtonClicked();
+    signal downloadButtonClicked();
+    signal browseButtonClicked();
+    signal optimalizeCheckboxChanged(bool Boolean);
+    signal stripCheckboxChanged(bool Boolean);
+
+    Text {
+        id: textPlugin
+        width: rectangle1.width
+        height: paintedHeight+5;
+        text: "Plugin: "
+        wrapMode: Text.Wrap;
+        transformOrigin: Item.Left
+        anchors.horizontalCenter: parent.horizontalCenter
+        font.pixelSize: 12
+    }
+
+    Text {
+        id: textFrom
+        width:rectangle1.width
+        height: paintedHeight+5;
+        text: "From: "
+        wrapMode: Text.Wrap;
+        anchors.top: textPlugin.bottom
+        anchors.horizontalCenter: parent.horizontalCenter
+        font.pixelSize: 12
+    }
+
+    Text {
+        id: textTo
+        width: rectangle1.width
+        height: paintedHeight+5;
+        text: "To: "
+        wrapMode: Text.Wrap;
+        anchors.top: textFrom.bottom
+        transformOrigin: Item.Left
+        anchors.horizontalCenter: parent.horizontalCenter
+        font.pixelSize: 12
+    }
+
+    Text {
+        id: textDescription
+        width: rectangle1.width
+        height: paintedHeight+5;
+        text: "Description: "
+        wrapMode: Text.Wrap;
+        anchors.top: textTo.bottom
+        transformOrigin: Item.Left
+        anchors.horizontalCenter: parent.horizontalCenter
+        font.pixelSize: 12
+    }
+
+    Text {
+        id: textInfo
+        width: rectangle1.width
+        height: paintedHeight+5;
+        text: ": "
+        wrapMode: Text.Wrap;
+        anchors.top: textDescription.bottom
+        transformOrigin: Item.Left
+        anchors.horizontalCenter: parent.horizontalCenter
+        font.pixelSize: 12
+    }
+
+    Checkbox {
+        id: optimalizeCheckbox
+        width: 20
+        height: 20
+        anchors.left: parent.left
+        anchors.leftMargin: 5
+        anchors.top: textInfo.bottom
+        onChanged: rectangle1.optimalizeCheckboxChanged(selected);
+    }
+
+    Checkbox {
+        id: stripCheckbox
+        width: 20
+        height: 20
+        anchors.top: optimalizeCheckbox.bottom
+        anchors.topMargin: 5
+        anchors.horizontalCenter: optimalizeCheckbox.horizontalCenter
+        onChanged: rectangle1.stripCheckboxChanged(selected);
+    }
+
+    Text {
+        id: textOptimalize
+        width: 80
+        height: 20
+        text: qsTr("Optimize")
+        anchors.left: optimalizeCheckbox.right
+        anchors.leftMargin: 5
+        anchors.verticalCenterOffset: 3
+        anchors.verticalCenter: optimalizeCheckbox.verticalCenter
+        font.pixelSize: 12
+    }
+
+    Text {
+        id: textStrip
+        width: 80
+        height: 20
+        text: qsTr("Strip accents")
+        anchors.verticalCenterOffset: 3
+        anchors.verticalCenter: stripCheckbox.verticalCenter
+        anchors.horizontalCenter: textOptimalize.horizontalCenter
+        font.pixelSize: 12
+    }
+
+    Button {
+        id: saveButton
+        height: 30
+        textInButton: qsTr("Save")
+        anchors.top: stripCheckbox.bottom
+        anchors.topMargin: 10
+        anchors.right: parent.right
+        anchors.left: parent.left
+        onClicked: rectangle1.saveButtonClicked();
+    }
+
+    Text {
+        id: textPath
+        height: paintedHeight+5;
+        text: qsTr("Dictionary file: not selected")
+        wrapMode: Text.Wrap;
+        anchors.top: parent.top
+        anchors.topMargin: 10
+        anchors.right: browseButton.left
+        anchors.rightMargin: 0
+        anchors.left: parent.left
+        anchors.leftMargin: 0
+        font.pixelSize: 12
+        opacity: 0
+    }
+
+    Button {
+        id: browseButton
+        width: 80;
+        height: 25;
+        textInButton: qsTr("Browse");
+        anchors.top: parent.top
+        anchors.topMargin: 10
+        anchors.right: parent.right
+        anchors.rightMargin: 10
+        opacity: 0
+        onClicked: rectangle1.browseButtonClicked();
+    }
+
+    Button {
+        id: downloadButton
+        width: 80;
+        height: 25;
+        textInButton: qsTr("Download");
+        anchors.right: parent.right
+        anchors.rightMargin: 10
+        anchors.top: browseButton.bottom
+        anchors.topMargin: 10
+        opacity: 0
+        onClicked: rectangle1.downloadButtonClicked();
+    }
+
+    states: [
+        State {
+            name: "Stan1"
+            when: newPlugin==true
+            PropertyChanges { target: textPlugin; opacity: 0}
+            PropertyChanges { target: textFrom; opacity: 0}
+            PropertyChanges { target: textTo; opacity: 0}
+            PropertyChanges { target: textDescription; opacity: 0}
+            PropertyChanges { target: textInfo; opacity: 0}
+
+            PropertyChanges { target: textPath; opacity: 1}
+            PropertyChanges { target: browseButton; opacity: 1 }
+            PropertyChanges { target: downloadButton; opacity: 1}
+        }
+    ]
+}
index c0d8bac..32abb55 100644 (file)
@@ -32,14 +32,63 @@ XdxfDialog::XdxfDialog(XdxfPlugin *plugin,
                        XdxfDialogType type,
                        QWidget *parent) :
                 QDialog(parent) {
+
     this->plugin = plugin;
     this->type = type;
 
+#ifndef Q_WS_MAEMO_5
+
+    view= new QDeclarativeView();
+    view->setSource(QUrl::fromLocalFile("/usr/share/mdictionary/qml/XdxfDialog.qml"));
+    view->setResizeMode(QDeclarativeView::SizeRootObjectToView);
+    view->setAlignment(Qt::AlignCenter);
+    view->show();
+
+    mainLayout = new QVBoxLayout;
+    mainLayout->addWidget(view);
+    setLayout(mainLayout);
+    view->setWindowTitle(tr("Xdxf Settings"));
+
+    QGraphicsObject *rootObject = view->rootObject();
+
+    connect(this, SIGNAL(setPlugin(QVariant)),
+           rootObject, SLOT(setPlugin(QVariant)));
+    connect(this, SIGNAL(setFrom(QVariant)),
+           rootObject, SLOT(setFrom(QVariant)));
+    connect(this, SIGNAL(setTo(QVariant)),
+           rootObject, SLOT(setTo(QVariant)));
+    connect(this, SIGNAL(setDescription(QVariant)),
+           rootObject, SLOT(setDescription(QVariant)));
+    connect(this, SIGNAL(setInfo(QVariant)),
+           rootObject, SLOT(setInfo(QVariant)));
+    connect(this, SIGNAL(setCheckedOptimalize(QVariant)),
+           rootObject, SLOT(setCheckedOptimalize(QVariant)));
+    connect(this, SIGNAL(setCheckedStrip(QVariant)),
+           rootObject, SLOT(setCheckedStrip(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(downloadButtonClicked()),
+           this, SLOT(downloadFile()));
+    connect(rootObject, SIGNAL(browseButtonClicked()),
+           this, SLOT(selectFile()));
+
+    connect(rootObject, SIGNAL(optimalizeCheckboxChanged(bool)),
+           this, SLOT(setGenerateCache(bool)));
+    connect(rootObject, SIGNAL(stripCheckboxChanged(bool)),
+           this, SLOT(setAccents(bool)));
+
+#else
+
     cacheToolTip = tr("Optimize for quicker searches (may take some time)");
     accentsToolTip = tr("Strip accents (searching takes more time, but spelling doesn't have to be exact)");
 
-    initializeUI();
-
     connect(cacheCheckBox, SIGNAL(toggled(bool)),
             this, SLOT(setGenerateCache(bool)));
     connect(accentsCheckBox, SIGNAL(toggled(bool)),
@@ -60,20 +109,64 @@ XdxfDialog::XdxfDialog(XdxfPlugin *plugin,
         connect(&XdxfPlugin::dictDownloader, SIGNAL(fileDownloaded(QString)),
                 this, SLOT(fileDownloaded(QString)));
     }
-
     connect(confirmButton, SIGNAL(clicked()),
             this, SLOT(accept()));
-}
-
+#endif
 
-void XdxfDialog::fileDownloaded(QString) {
-    infoLabel->setText(tr("Dictionary file: %1").arg(XdxfPlugin::dictDownloader.downloadedFile()));
-    _dictionaryFilePath = XdxfPlugin::dictDownloader.downloadedFile();
-    updateGeometry();
+    initializeUI();
 }
 
 
 void XdxfDialog::initializeUI() {
+#ifndef Q_WS_MAEMO_5
+
+    if(type != New){
+        emit setNew(false);
+        emit setPlugin(plugin->type().toUpper());
+        emit setFrom(plugin->langFrom());
+        emit setTo(plugin->langTo());
+        emit setDescription(plugin->name());
+        emit setInfo(plugin->infoNote());
+    }
+    else{
+        emit setNew(true);
+        connect(&XdxfPlugin::dictDownloader, SIGNAL(fileDownloaded(QString)),
+                this, SLOT(fileDownloaded(QString)));
+    }
+
+    if(!plugin) {
+        emit setCheckedOptimalize(true);
+        emit setCheckedStrip(true);
+//        accentsCheckBox->setEnabled(false);
+        _generateCache = true;
+        _accents = true;
+        _dictionaryFilePath = "";
+    }
+    else if(plugin && plugin->settings()->value("cached") == "true") {
+        emit setCheckedOptimalize(true);
+        emit setCheckedStrip(true);
+//        accentsCheckBox->setEnabled(false);
+        _generateCache = true;
+        _accents = true;
+    }
+    else {
+        emit setCheckedOptimalize(false);
+        _generateCache = false;
+        if(plugin->settings()->value("strip_accents") == "true") {
+            emit setCheckedStrip(true);
+            _accents = true;
+        }
+        else {
+            emit setCheckedStrip(false);
+            _accents = false;
+        }
+    }
+    if(type == New)
+        emit setButtonText("Add");
+    else
+        emit setButtonText("Save settings");
+
+#else
     mainVerticalLayout = new QVBoxLayout;
     widget = new QWidget;
     widget->setLayout(mainVerticalLayout);
@@ -201,17 +294,29 @@ void XdxfDialog::initializeUI() {
     scrollArea->setLineWidth(0);
     scrollArea->setMidLineWidth(0);
     scrollArea->setFrameStyle(QFrame::NoFrame);
+#endif
 }
 
 
 void XdxfDialog::setAccents(bool accents) {
+    qDebug()<<"setAcents"<<accents;
     _accents = accents;
 }
 
 
 void XdxfDialog::setGenerateCache(bool generate) {
     _generateCache = generate;
-
+#ifndef Q_WS_MAEMO_5
+    if(generate) {
+        _lastAccents = _accents;
+        emit setCheckedOptimalize(true);
+        emit setCheckedStrip(true);
+    }
+    else{
+        emit setCheckedStrip(_lastAccents);
+    }
+//  accentsCheckBox->setEnabled(!generate);
+#else
     if(generate) {
         _lastAccents = _accents;
         accentsCheckBox->setChecked(true);
@@ -219,6 +324,7 @@ void XdxfDialog::setGenerateCache(bool generate) {
     else
         accentsCheckBox->setChecked(_lastAccents);
     accentsCheckBox->setEnabled(!generate);
+#endif
 }
 
 
@@ -230,15 +336,32 @@ void XdxfDialog::selectFile() {
                                      NULL,
                                      NULL);
     if (!fileName.isEmpty()) {
-        infoLabel->setText(tr("Dictionary file: %1").arg(fileName));
         _dictionaryFilePath = fileName;
-        updateGeometry();
+        #ifndef Q_WS_MAEMO_5
+            emit setPath(tr("Dictionary file: %1").arg(fileName));
+        #else
+            infoLabel->setText(tr("Dictionary file: %1").arg(fileName));
+            updateGeometry();
+        #endif
     }
 }
 
 
+void XdxfDialog::fileDownloaded(QString) {
+#ifndef Q_WS_MAEMO_5
+    qDebug()<<"fileDownloaded";
+    emit setPath(tr("Dictionary file: %1").arg(XdxfPlugin::dictDownloader.downloadedFile()));
+    _dictionaryFilePath = XdxfPlugin::dictDownloader.downloadedFile();
+#else
+    infoLabel->setText(tr("Dictionary file: %1").arg(XdxfPlugin::dictDownloader.downloadedFile()));
+    _dictionaryFilePath = XdxfPlugin::dictDownloader.downloadedFile();
+    updateGeometry();
+#endif
+}
+
+
 void XdxfDialog::downloadFile() {
-   XdxfPlugin::dictDownloader.download(this);
+    XdxfPlugin::dictDownloader.download(this);
 }
 
 
@@ -250,7 +373,6 @@ void XdxfDialog::saveSettings() {
     }
     else
         _settings->setValue("path", _dictionaryFilePath);
-
     if(_generateCache)
         _settings->setValue("generateCache", "true");
     else
index 8e031f6..2f1a053 100644 (file)
@@ -32,6 +32,7 @@
 #include <QDialog>
 #include "../../include/settings.h"
 #include <QtGui>
+#include <QDeclarativeView>
 #include "xdxfplugin.h"
 
 
@@ -82,6 +83,17 @@ Q_SIGNALS:
     //! Requests to show notification
     void notify(Notify::NotifyType, QString);
 
+    void setPlugin(QVariant name);
+    void setFrom(QVariant lang);
+    void setTo(QVariant lang);
+    void setDescription(QVariant descript);
+    void setInfo(QVariant info);
+    void setCheckedOptimalize(QVariant boolean);
+    void setCheckedStrip(QVariant boolean);
+    void setButtonText(QVariant text);
+    void setNew(QVariant text);
+    void setPath(QVariant path);
+
 public Q_SLOTS:
     /*!
         Reimplemented accept method, to check if all necessary fields in
@@ -91,6 +103,7 @@ public Q_SLOTS:
     void accept();
 
 private Q_SLOTS:
+
     //! displays dialog to browse and select file
     void selectFile();
 
@@ -115,6 +128,9 @@ private Q_SLOTS:
 
 
 private:
+    QVBoxLayout* mainLayout;
+    QDeclarativeView *view;
+
     void initializeUI();
 
     //! saves new settings after acceptance of dialog
index 79bf8c8..f91a16a 100644 (file)
@@ -4,7 +4,9 @@ QT = core \
     gui \
     xml \
     sql \
-    network
+    network\
+    declarative
+
 maemo5 {
     LIBS += -lbz2 \
 }
@@ -44,15 +46,36 @@ HEADERS += xdxfplugin.h \
 RESOURCES += xdxf.qrc
 TRANSLATIONS += pl_PL.ts \
     en_US.ts
-unix { 
-    INSTALLS += dicts \
-        plugin-icon
+OTHER_FILES += \
+    ../../mdictionary/qml/XdxfDialog.qml
+
+
+unix {
     dicts.path = $$PLUGINS_DIR
     dicts.files += ../../../data/dicts/eng-us.xdxf
     dicts.files += ../../../data/dicts/eng-thai.xdxf
     plugin-icon.path = $$DATA_DIR
     plugin-icon.files += xdxf.png
+
+    meego {
+        qmls.path = $$DATA_DIR/qml
+        qmls.files += ../../mdictionary/qml/XdxfDialog.qml
+    }
+    else:maemo5 {
+        qmls.path = $$DATA_DIR/qml
+        qmls.files += ../../mdictionary/qml/XdxfDialog.qml
+    }
+    else {
+        qmls.path = $$DATA_DIR/qml
+        qmls.files += ../../mdictionary/qml/XdxfDialog.qml
+    }
+
+    INSTALLS += dicts \
+        plugin-icon\
+        qmls
 }
 check.commands = echo \
     'No check here'
 QMAKE_EXTRA_TARGETS += check
+
+