system(echo "ENABLED_SRC = $$ENABLED_SRC" >src/src.pri)
system(echo "ENABLED_PLUGINS = $$ENABLED_PLUGINS" >src/plugins/plugins.pri)
+
+OTHER_FILES +=
#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;
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
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()));
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
}
#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.
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:
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();
private:
void initalizeUI();
+
+ QVBoxLayout* mainLayout;
+ QDeclarativeView *view;
+
SpinBox* historySizeSpinBox;
SpinBox* searchResultSizeSpinBox;
QVBoxLayout* verticalLayout;
QHBoxLayout* footerLayout;
bool _save;
#endif
-
-
-
+ int historyValue;
+ int searchResultValue;
+ bool dictionariesCheckBox;
+ bool bookmarksCheckBox;
};
#endif // SETTINGSWIDGET_H
#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();
qml/FlickableWebView.qml \
qml/ScrollBar.qml \
qml/Checkbox.qml \
- qml/MySpinBox.qml
+ qml/MySpinBox.qml \
+ qml/SettingsWidget.qml
target.path = $$BIN_DIR
INSTALLS += target
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
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
onLinkActivated: linkClicked(link);
}
- MySpinBox {
+ /* MySpinBox {
id: test01
- y:50;
- x:100;
+ y:20;
+ x:20;
width: 40
height: 20;
}
-
+ */
}
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";
}
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 }
}
]
+ */
}
--- /dev/null
+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();
+ }
+}
--- /dev/null
+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}
+ }
+ ]
+}
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)),
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);
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);
else
accentsCheckBox->setChecked(_lastAccents);
accentsCheckBox->setEnabled(!generate);
+#endif
}
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);
}
}
else
_settings->setValue("path", _dictionaryFilePath);
-
if(_generateCache)
_settings->setValue("generateCache", "true");
else
#include <QDialog>
#include "../../include/settings.h"
#include <QtGui>
+#include <QDeclarativeView>
#include "xdxfplugin.h"
//! 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
void accept();
private Q_SLOTS:
+
//! displays dialog to browse and select file
void selectFile();
private:
+ QVBoxLayout* mainLayout;
+ QDeclarativeView *view;
+
void initializeUI();
//! saves new settings after acceptance of dialog
gui \
xml \
sql \
- network
+ network\
+ declarative
+
maemo5 {
LIBS += -lbz2 \
}
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
+
+