From: jakub Date: Wed, 29 Dec 2010 14:07:40 +0000 (+0100) Subject: Merge branch 'qml' of ssh://drop.maemo.org/git/mdictionary into qml X-Git-Url: http://vcs.maemo.org/git/?a=commitdiff_plain;h=97d38e49e5466769cf74644ee9fa2c668f39ed9c;hp=cb312e2582ca127874eb31ddac520f3c227d21fa;p=mdictionary Merge branch 'qml' of ssh://drop.maemo.org/git/mdictionary into qml --- diff --git a/data/button/buttonCenterDisabled.png b/data/button/buttonCenterDisabled.png new file mode 100644 index 0000000..2621381 Binary files /dev/null and b/data/button/buttonCenterDisabled.png differ diff --git a/data/button/buttonCenterPushed.png b/data/button/buttonCenterPushed.png new file mode 100644 index 0000000..58203c0 Binary files /dev/null and b/data/button/buttonCenterPushed.png differ diff --git a/data/button/buttonLeftDisabled.png b/data/button/buttonLeftDisabled.png new file mode 100644 index 0000000..ef89fb8 Binary files /dev/null and b/data/button/buttonLeftDisabled.png differ diff --git a/data/button/buttonLeftPushed.png b/data/button/buttonLeftPushed.png new file mode 100644 index 0000000..976abd6 Binary files /dev/null and b/data/button/buttonLeftPushed.png differ diff --git a/data/button/buttonRightDisabled.png b/data/button/buttonRightDisabled.png new file mode 100644 index 0000000..db3fc2b Binary files /dev/null and b/data/button/buttonRightDisabled.png differ diff --git a/data/button/buttonRightPushed.png b/data/button/buttonRightPushed.png new file mode 100644 index 0000000..30206c5 Binary files /dev/null and b/data/button/buttonRightPushed.png differ diff --git a/data/button/checkbox.png b/data/button/checkbox.png new file mode 100644 index 0000000..fe9872f Binary files /dev/null and b/data/button/checkbox.png differ diff --git a/data/button/checkboxChecked.png b/data/button/checkboxChecked.png new file mode 100644 index 0000000..df9013e Binary files /dev/null and b/data/button/checkboxChecked.png differ diff --git a/data/gui.qrc b/data/gui.qrc index 70533fe..28c0c87 100644 --- a/data/gui.qrc +++ b/data/gui.qrc @@ -16,5 +16,13 @@ button/buttonR.png button/go-previous.png progressBar/background.png + button/buttonCenterDisabled.png + button/buttonCenterPushed.png + button/buttonRightDisabled.png + button/buttonRightPushed.png + button/buttonLeftDisabled.png + button/buttonLeftPushed.png + button/checkbox.png + button/checkboxChecked.png diff --git a/src/include/CommonDictInterface.h b/src/include/CommonDictInterface.h index 0f0c415..73415b1 100644 --- a/src/include/CommonDictInterface.h +++ b/src/include/CommonDictInterface.h @@ -91,6 +91,9 @@ class CommonDictInterface : public QObject, public AccentsNormalizer { //! \returns plugin icon virtual QIcon* icon() = 0; + //! \returns plugin icon's path + virtual QString iconPath() = 0; + //! \returns empty translation object (to be fetched later) for a given key virtual Translation* getTranslationFor(QString ) {return 0;} diff --git a/src/mdictionary/gui/DictManagerModel.cpp b/src/mdictionary/gui/DictManagerModel.cpp new file mode 100644 index 0000000..4714730 --- /dev/null +++ b/src/mdictionary/gui/DictManagerModel.cpp @@ -0,0 +1,144 @@ +#include "DictManagerModel.h" + +DictManagerModel::DictManagerModel(QHash dictionaries, QObject *parent) : + QAbstractListModel(parent) +{ + QHash roles; + roles[NameRole] = "name"; + roles[IconPathRole] = "iconPath"; + roles[IsSelectedRole] = "isSelected"; + roles[NumberRole] = "number"; + setRoleNames(roles); + + setDictionaries(dictionaries); + + connect(this, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SIGNAL(itemChanged())); +} + +int DictManagerModel::rowCount(const QModelIndex &parent) const +{ + return _dictList.count(); +} + +void DictManagerModel::setDictionaries(QHash dictionaries) +{ + QHashIterator i(dictionaries); + while (i.hasNext()) { + i.next(); + addDictionary(i.key(), i.value()); + } +} + +void DictManagerModel::clear() +{ + beginRemoveRows(QModelIndex(), 0, rowCount()); + _dictionaries.clear(); + _dictList.clear(); + endRemoveRows(); + emit dataChanged(QModelIndex(), QModelIndex()); +} + +QVariant DictManagerModel::data(const QModelIndex & index, int role) const +{ + if (index.row() < 0 || index.row() > _dictList.count()) + return QVariant(); + + CommonDictInterface* dictionary = _dictList[index.row()]; + if (role == NameRole) + { + QString name; + if (dictionary->type() == "stardict") { + name = dictionary->name() + " (" + dictionary->type() + ")"; + } + else { + name = dictionary->langFrom() + " - " + dictionary->langTo() + + " (" + dictionary->type() + " " + + dictionary->name() + ")"; + } + return name; + } + if (role == NumberRole){ + return index.row(); + } + if (role == IconPathRole){ + return dictionary->iconPath(); + } + if (role == IsSelectedRole){ + return _dictionaries[dictionary]; + } + return QVariant(); +} + +bool DictManagerModel::setData(const QModelIndex &index, const QVariant &value, int role) +{ + int res = setDataPriv(index.row(), value, role); + if (res == 0) + return false; + if (res > 0) + return true; + return true; +} + +int DictManagerModel::setDataPriv(int index, const QVariant &value, int role) +{ + if (index < 0 || index > _dictList.count()) + return 0; + + CommonDictInterface* dictionary = _dictList[index]; + if (role == NameRole) + return 1; + if (role == NumberRole) + return 1; + if (role == IconPathRole) + return 1; + if (role == IsSelectedRole) + { + if (value.type() == QVariant::Bool) + { + _dictionaries[dictionary] = value.toBool(); +// if (index == _dictList.count()) +// emit dataChanged(this->index(index-1), this->index(index)); + emit dataChanged(this->index(0), this->index(_dictList.count() - 1)); + return 2; + } + else + { + return 0; + } + } + return 0; +} + +void DictManagerModel::setModelProperty(int index, const QVariant value, QString role) +{ + if (role.contains("isSelected")) + { + setDataPriv(index, value, IsSelectedRole); + } + +} + +Qt::ItemFlags DictManagerModel::flags(const QModelIndex &index) const +{ + Qt::ItemFlags fl = QAbstractItemModel::flags(index); + qDebug("lol1"); + return (fl | Qt::ItemIsEditable); +} + +void DictManagerModel::addDictionary(CommonDictInterface *dictionary, bool isActive) +{ + beginInsertRows(QModelIndex(), rowCount(), rowCount()); + _dictionaries.insert(dictionary, isActive); + _dictList << dictionary; + endInsertRows(); +} + +QHash DictManagerModel::dictionaries() +{ + return _dictionaries; +} + +QList DictManagerModel::dictList() +{ + return _dictList; +} diff --git a/src/mdictionary/gui/DictManagerModel.h b/src/mdictionary/gui/DictManagerModel.h new file mode 100644 index 0000000..6c599f1 --- /dev/null +++ b/src/mdictionary/gui/DictManagerModel.h @@ -0,0 +1,57 @@ +#ifndef DICTMANAGERMODEL_H +#define DICTMANAGERMODEL_H + +#include +#include +#include "../../include/GUIInterface.h" + +/*! + Contains a list of installed dictionaries. + Data source for qml list view. +*/ +class DictManagerModel : public QAbstractListModel +{ + Q_OBJECT +public: + enum DictTypeRoles + { + NameRole = Qt::UserRole + 1, + IconPathRole, + IsSelectedRole, + NumberRole + }; + + //! Constructor + /*! + \param dictionaries list of dictionaries + \param parent parent of this class. + */ + explicit DictManagerModel(QHash dictionaries, QObject *parent = 0); + + int rowCount(const QModelIndex & parent = QModelIndex()) const; + + QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const; + bool setData(const QModelIndex &index, const QVariant &value, int role); + + Qt::ItemFlags flags(const QModelIndex &index) const; + void setDictionaries(QHash dictionaries); + QHash dictionaries(); + QList dictList(); + + void clear(); + +public Q_SLOTS: + void setModelProperty(int index, const QVariant value, QString role); + +Q_SIGNALS: + void itemChanged(); + +private: + QHash _dictionaries; + QList _dictList; + + int setDataPriv(int index, const QVariant &value, int role); + void addDictionary(CommonDictInterface* dictionary, bool isActive); +}; + +#endif // DICTMANAGERMODEL_H diff --git a/src/mdictionary/gui/DictManagerWidget.cpp b/src/mdictionary/gui/DictManagerWidget.cpp index 8519c93..62d971c 100644 --- a/src/mdictionary/gui/DictManagerWidget.cpp +++ b/src/mdictionary/gui/DictManagerWidget.cpp @@ -36,6 +36,9 @@ DictManagerWidget::DictManagerWidget(GUIInterface *parent) : setWindowTitle(tr("Dictionaries")); this->guiInterface = parent; + #ifndef Q_WS_MAEMO_5 + model = 0; + #endif initalizeUI(); setModal(true); @@ -45,6 +48,25 @@ void DictManagerWidget::initalizeUI() { verticalLayout = new QVBoxLayout; setLayout(verticalLayout); + #ifndef Q_WS_MAEMO_5 + qmlView = new QDeclarativeView(this); + qmlView->setSource(QUrl::fromLocalFile("/usr/share/mdictionary/qml/DictManagerWidget.qml")); + ctxt = qmlView->rootContext(); + + refreshDictsList(); + ctxt->setContextProperty("dictModel", &(*model)); + + QGraphicsObject *rootObject = qmlView->rootObject(); + //connect(rootObject, SIGNAL(selectedRow(int)), + // this, SLOT(pluginSelected(int))); + + qmlView->setResizeMode(QDeclarativeView::SizeRootObjectToView); + verticalLayout->addWidget(qmlView); + + //connecty zwrotne + #endif + + #ifdef Q_WS_MAEMO_5 dictList = new QListWidget; verticalLayout->addWidget(dictList); @@ -87,34 +109,78 @@ void DictManagerWidget::initalizeUI() { connect(dictList, SIGNAL(itemChanged(QListWidgetItem*)), this, SLOT(changed())); + #endif #ifndef Q_WS_MAEMO_5 - connect(dictList, SIGNAL(itemActivated(QListWidgetItem*)), - this, SLOT(saveChanges())); - connect(dictList, SIGNAL(itemActivated(QListWidgetItem*)), - this, SLOT(itemSelected(QListWidgetItem*))); - connect(dictList, SIGNAL(itemActivated(QListWidgetItem*)), - settingsButton, SIGNAL(clicked())); + connect(rootObject, SIGNAL(addButtonClicked()), + this, SLOT(saveChanges())); + connect(rootObject, SIGNAL(addButtonClicked()), + this, SLOT(addNewDictButtonClicked())); + + connect(rootObject, SIGNAL(removeButtonClicked()), + this, SLOT(saveChanges())); + connect(rootObject, SIGNAL(removeButtonClicked()), + this, SLOT(removeButtonClicked())); + + connect(rootObject, SIGNAL(settingsButtonClicked()), + this, SLOT(saveChanges())); + connect(rootObject, SIGNAL(settingsButtonClicked()), + this, SLOT(settingsButtonClicked())); + + //z modelu sygnał, oraz z okienka zmian ustawień w pluginie, gdy są zmiany +// oryginalnie: +// connect(dictList, SIGNAL(itemChanged(QListWidgetItem*)), +// this, SLOT(changed())); + connect(model, SIGNAL(itemChanged()), + this, SLOT(changed())); + //pozmieniać connecty, to jest na dwuklik mysza na liście, sprawdzić, zrobic alternatywne sloty + connect(rootObject, SIGNAL(itemActivated(int)), + this, SLOT(saveChanges())); + connect(rootObject, SIGNAL(itemActivated(int)), + settingsButton, SIGNAL(clicked())); + +// connect(dictList, SIGNAL(itemActivated(QListWidgetItem*)), +// this, SLOT(saveChanges())); +// connect(dictList, SIGNAL(itemActivated(QListWidgetItem*)), +// this, SLOT(itemSelected(QListWidgetItem*))); +// connect(dictList, SIGNAL(itemActivated(QListWidgetItem*)), +// settingsButton, SIGNAL(clicked())); #endif + #ifdef Q_WS_MAEMO_5 refreshDictsList(); + #endif #ifndef Q_WS_MAEMO_5 setMinimumSize(500,300); - closeButton = new QPushButton(tr("Save")); - buttonGroup->addWidget(closeButton); - - setMinimumWidth(sizeHint().width()*1.2); - setMaximumWidth(sizeHint().width()*2); - setMinimumHeight(sizeHint().height()); - setMaximumHeight(sizeHint().height()*2); - connect(closeButton, SIGNAL(clicked()), this, SLOT(save())); + //closeButton = new QPushButton(tr("Save")); + //buttonGroup->addWidget(closeButton); + +// setMinimumWidth(sizeHint().width()*1.2); +// setMaximumWidth(sizeHint().width()*2); +// setMinimumHeight(sizeHint().height()); +// setMaximumHeight(sizeHint().height()*2); + //connect(closeButton, SIGNAL(clicked()), this, SLOT(save())); + connect(rootObject, SIGNAL(saveButtonClicked()), this, SLOT(save())); #endif } void DictManagerWidget::refreshDictsList() { + #ifndef Q_WS_MAEMO_5 + QHash dicts = guiInterface->getDictionaries(); + + if (model == 0){ + model = new DictManagerModel(dicts, this); + } else { + model->clear(); + model->setDictionaries(dicts); + } + + #endif + + #ifdef Q_WS_MAEMO_5 dictList->clear(); dictsHash.clear(); removeDictButton->setEnabled(false); @@ -126,6 +192,7 @@ void DictManagerWidget::refreshDictsList() { while(i.hasNext()) { i.next(); + QListWidgetItem* item = new QListWidgetItem(); QString name; if (i.key()->type() == "stardict") { @@ -151,6 +218,7 @@ void DictManagerWidget::refreshDictsList() { } dictList->sortItems(); + #endif } void DictManagerWidget::showEvent(QShowEvent *e) { diff --git a/src/mdictionary/gui/DictManagerWidget.h b/src/mdictionary/gui/DictManagerWidget.h index 3e7e4d7..f988659 100644 --- a/src/mdictionary/gui/DictManagerWidget.h +++ b/src/mdictionary/gui/DictManagerWidget.h @@ -32,6 +32,10 @@ #include #include "../../include/GUIInterface.h" #include "MenuWidget.h" +#include "DictManagerModel.h" +#include +#include +#include /*! @@ -119,6 +123,12 @@ private: QHash dictsHash; GUIInterface* guiInterface; + #ifndef Q_WS_MAEMO_5 + QDeclarativeView* qmlView; + QDeclarativeContext* ctxt; + DictManagerModel* model; + #endif + bool _changed; void refreshDictsList(); diff --git a/src/mdictionary/mdictionary.pro b/src/mdictionary/mdictionary.pro index 79ddab6..d01fcc4 100644 --- a/src/mdictionary/mdictionary.pro +++ b/src/mdictionary/mdictionary.pro @@ -39,7 +39,8 @@ SOURCES += gui/main.cpp \ gui/DBusAdapter.cpp \ gui/NotifyManager.cpp \ gui/SpinBox.cpp \ - gui/DictTypeModel.cpp + gui/DictTypeModel.cpp \ + gui/DictManagerModel.cpp HEADERS += gui/MainWindow.h \ backbone/ConfigGenerator.h \ @@ -71,7 +72,8 @@ HEADERS += gui/MainWindow.h \ gui/DBusAdapter.h \ gui/NotifyManager.h \ gui/SpinBox.h \ - gui/DictTypeModel.h + gui/DictTypeModel.h \ + gui/DictManagerModel.h RESOURCES += ../../data/gui.qrc diff --git a/src/mdictionary/qml/Button.qml b/src/mdictionary/qml/Button.qml index a21cf2f..fd49c8e 100644 --- a/src/mdictionary/qml/Button.qml +++ b/src/mdictionary/qml/Button.qml @@ -27,16 +27,6 @@ BorderImage { style: Text.Sunken; color: "white"; styleColor: "black"; smooth: true } - Rectangle { - id: shade - anchors.centerIn: parent; - radius: parent.height*.4; - color: "black"; - opacity: 0 - width: parent.width; - height: parent.height; - } - Image { id: image1 width: (35*parent.height)/107 +1 @@ -68,11 +58,20 @@ BorderImage { states: [ State { - name: "pressed"; when: mouseArea.pressed == true - PropertyChanges { target: shade; opacity: 0.4 } - PropertyChanges { target: image1; opacity: 0.5 } - PropertyChanges { target: image3; opacity: 0.5 } - PropertyChanges { target: image2; opacity: 0.5 } + name: "pressed"; + when: (mouseArea.pressed == true && button.enabled == true); + + PropertyChanges { target: image1; source: "qrc:/button/buttonLeftPushed.png" } + PropertyChanges { target: image3; source: "qrc:/button/buttonCenterPushed.png" } + PropertyChanges { target: image2; source: "qrc:/button/buttonRightPushed.png" } + }, + State { + name: "disabled"; + when: (button.enabled == false); + + PropertyChanges { target: image1; source: "qrc:/button/buttonLeftDisabled.png" } + PropertyChanges { target: image3; source: "qrc:/button/buttonCenterDisabled.png" } + PropertyChanges { target: image2; source: "qrc:/button/buttonRightDisabled.png" } } ] diff --git a/src/mdictionary/qml/DictManagerWidget.qml b/src/mdictionary/qml/DictManagerWidget.qml index 15b01c6..db75cde 100644 --- a/src/mdictionary/qml/DictManagerWidget.qml +++ b/src/mdictionary/qml/DictManagerWidget.qml @@ -1,6 +1,195 @@ +/******************************************************************************* + + This file is part of mDictionary. + + mDictionary is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + mDictionary is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with mDictionary. If not, see . + + Copyright 2010 Comarch S.A. + +*******************************************************************************/ +/*! + author: Marcin Kaźmierczak +*/ + import Qt 4.7 Rectangle { - width: 100 - height: 62 + SystemPalette { id: myPalette; colorGroup: SystemPalette.Active } + + function setEnableRemove(Boolean) { removeButton.enabled = Boolean } + function setEnableSettings(Boolean) { settingsButton.enabled = Boolean } + + signal addButtonClicked; + signal removeButtonClicked; + signal settingsButtonClicked; + signal saveButtonClicked; + signal itemActivated(int nr); + + id: rectangle1 + color: myPalette.base + anchors.fill: parent + + ElementsListView{ + id: dictList + width: rectangle1.width +// height: rectangle1.height + anchors.top: parent.top + anchors.bottom: buttonsBox.top + anchors.bottomMargin: buttonsBox.height + buttonsBox.anchors.topMargin + highlightResizeSpeed: 1000 + delegate: Component{ + id: dictListDelegate + Item { + width: rectangle1.width + height: { + if (nameText.height + 4 > logo.height) + return nameText.height + 4; + else + return logo.height; + } + MouseArea{ + anchors.fill: parent + onClicked: { + dictList.currentIndex = number + rectangle1.setEnableRemove(true) + rectangle1.setEnableSettings(true) + } + onDoubleClicked: { + rectangle1.itemActivated(dictList.currentIndex) + } + } + Row { + anchors.fill: parent + Image { + id: checkbox + height: { + var aspectRatio = sourceSize.height / sourceSize.width + return checkbox.width * aspectRatio + } + anchors.verticalCenter: parent.verticalCenter + width: nameText.height + smooth: true + states: [ + State { + name: "checked"; + when: (isSelected == true); + + PropertyChanges { target: checkbox; source: "qrc:/button/checkboxChecked.png" } + }, + State { + name: "unchecked"; + when: (isSelected == false); + + PropertyChanges { target: checkbox; source: "qrc:/button/checkbox.png" } + } + ] + MouseArea{ + anchors.fill: parent + onClicked: { + dictList.currentIndex = number + dictModel.setModelProperty(dictList.currentIndex, !isSelected, "isSelected") + rectangle1.setEnableRemove(true) + rectangle1.setEnableSettings(true) + } + } + } + + Image { + id: logo + source: iconPath + height: { + var aspectRatio = sourceSize.height / sourceSize.width + return logo.width * aspectRatio + } + anchors.left: checkbox.right + anchors.leftMargin: 5 + anchors.verticalCenter: parent.verticalCenter + width: nameText.height + 4 + smooth: true + } + Text { + id: nameText + text: name + anchors.left: logo.right + anchors.leftMargin: 5 + anchors.verticalCenter: parent.verticalCenter + } + } + } + + } + model: dictModel + } + + //buttons + + Item { + id: buttonsBox + width: parent.width + height: 30 + anchors.bottom: parent.bottom + anchors.top: dictList.bottom + anchors.topMargin: 8 + + Button { + id: addButton + width: (parent.width - 4) / 4 + height: buttonsBox.height + anchors.left: buttonsBox.left + anchors.leftMargin: 4 + anchors.verticalCenter: parent.verticalCenter + textInButton: qsTr("Add") + onClicked: rectangle1.addButtonClicked + } + + Button { + id: removeButton + width: (parent.width - 4) / 4 + height: buttonsBox.height + anchors.left: addButton.right + anchors.leftMargin: 4 + anchors.verticalCenter: parent.verticalCenter + textInButton: qsTr("Remove") + enabled: false + onClicked: rectangle1.removeButtonClicked + } + + Button { + id: settingsButton + width: (parent.width - 4) / 4 + height: buttonsBox.height + anchors.left: removeButton.right + anchors.leftMargin: 4 + anchors.verticalCenter: parent.verticalCenter + textInButton: qsTr("Settings") + enabled: false + onClicked: rectangle1.settingsButtonClicked + } + + Button { + id: saveButton + width: (parent.width - 4) / 4 + height: buttonsBox.height + anchors.left: settingsButton.right + anchors.leftMargin: 4 + anchors.right: buttonsBox.right + anchors.rightMargin: 4 + anchors.verticalCenter: parent.verticalCenter + textInButton: qsTr("Save") + onClicked: rectangle1.saveButtonClicked + } + + } + } diff --git a/src/mdictionary/qml/IconButton.qml b/src/mdictionary/qml/IconButton.qml index 9b66836..7fc32ea 100644 --- a/src/mdictionary/qml/IconButton.qml +++ b/src/mdictionary/qml/IconButton.qml @@ -58,37 +58,21 @@ Rectangle { source: "qrc:/button/buttonR.png" } - Rectangle { - id: shade - z: 4 - anchors.centerIn: parent; - color: "black"; - radius: 20; - opacity: 1; - width: rectangle.width; - height: rectangle.height; - } states: [ State { - name: "enable"; - when: (mouseArea.pressed == false && rectangle.enabled == true); - PropertyChanges { target: shade; - opacity: 0; } - }, - State { name: "disable"; when: (rectangle.enabled == false); - PropertyChanges { target: shade; - color: "black"; - opacity: .5; } + PropertyChanges { target: image1; source: "qrc:/button/buttonLeftDisabled.png" } + PropertyChanges { target: image3; source: "qrc:/button/buttonCenterDisabled.png" } + PropertyChanges { target: image2; source: "qrc:/button/buttonRightDisabled.png" } }, State { name: "clicked"; when: (mouseArea.pressed == true && rectangle.enabled == true); - PropertyChanges { target: shade; - color: "#fffead" - opacity: 0.5; } + PropertyChanges { target: image1; source: "qrc:/button/buttonLeftPushed.png" } + PropertyChanges { target: image3; source: "qrc:/button/buttonCenterPushed.png" } + PropertyChanges { target: image2; source: "qrc:/button/buttonRightPushed.png" } } ] } diff --git a/src/plugins/google/GooglePlugin.cpp b/src/plugins/google/GooglePlugin.cpp index 0374115..733a51f 100644 --- a/src/plugins/google/GooglePlugin.cpp +++ b/src/plugins/google/GooglePlugin.cpp @@ -41,7 +41,8 @@ GooglePlugin::GooglePlugin(QObject *parent): CommonDictInterface(parent), _settings->setValue("type","google"); _settings->setValue("connection_accepted","true"); _dictDialog = new GoogleDictDialog(this,this); - _icon = QIcon("/usr/share/mdictionary/google.png"); + _iconPath = "/usr/share/mdictionary/google.png"; + _icon = QIcon(_iconPath); stopped = false; initLanguages(); @@ -150,6 +151,10 @@ QIcon* GooglePlugin::icon() { return &_icon; } +QString GooglePlugin::iconPath(){ + return _iconPath; +} + CommonDictInterface* GooglePlugin::getNew(const Settings* settings) const { GooglePlugin *plugin = new GooglePlugin(); diff --git a/src/plugins/google/GooglePlugin.h b/src/plugins/google/GooglePlugin.h index 2808195..f62603c 100644 --- a/src/plugins/google/GooglePlugin.h +++ b/src/plugins/google/GooglePlugin.h @@ -102,6 +102,9 @@ public: //! \returns plugin icon QIcon* icon(); + //! \returns plugin icon's resource path + QString iconPath(); + //! \returns empty translation object (to be fetched later) for a given key Translation* getTranslationFor(QString key); @@ -147,6 +150,8 @@ private: //! icon displayed during translations and when a dictionary is chosen QIcon _icon; + //! Path to icon + QString _iconPath; Settings *_settings; //! indicates if search is stopped bool stopped; diff --git a/src/plugins/stardict/StarDictPlugin.cpp b/src/plugins/stardict/StarDictPlugin.cpp index 67e2db3..229cff4 100644 --- a/src/plugins/stardict/StarDictPlugin.cpp +++ b/src/plugins/stardict/StarDictPlugin.cpp @@ -42,7 +42,8 @@ StarDictPlugin::StarDictPlugin(QObject *parent) : CommonDictInterface(parent), this, SIGNAL(notify(Notify::NotifyType,QString))); _settings->setValue("type","stardict"); - _icon = QIcon("/usr/share/mdictionary/stardict.png"); + _iconPath = "/usr/share/mdictionary/stardict.png"; + _icon = QIcon(_iconPath); stopped = false; _settings->setValue("strip_accents","true"); @@ -343,4 +344,8 @@ QIcon* StarDictPlugin::icon() { return &_icon; } +QString StarDictPlugin::iconPath(){ + return _iconPath; +} + Q_EXPORT_PLUGIN2(stardict, StarDictPlugin) diff --git a/src/plugins/stardict/StarDictPlugin.h b/src/plugins/stardict/StarDictPlugin.h index 5937b3a..94aa674 100644 --- a/src/plugins/stardict/StarDictPlugin.h +++ b/src/plugins/stardict/StarDictPlugin.h @@ -103,6 +103,9 @@ public: //! \returns plugin icon QIcon* icon(); + //! \returns plugin icon's resource path + QString iconPath(); + /*! plugin should delete any files (eg. cache) that have been created and are ready to be deleted @@ -194,6 +197,8 @@ private: QString _name; QString _infoNote; QIcon _icon; + //! Path to icon + QString _iconPath; volatile bool stopped; Settings *_settings; StarDictDialog* _dictDialog; diff --git a/src/plugins/xdxf/xdxfplugin.cpp b/src/plugins/xdxf/xdxfplugin.cpp index 17e8eca..044bcca 100644 --- a/src/plugins/xdxf/xdxfplugin.cpp +++ b/src/plugins/xdxf/xdxfplugin.cpp @@ -52,7 +52,8 @@ XdxfPlugin::XdxfPlugin(QObject *parent) : CommonDictInterface(parent), } _settings->setValue("type","xdxf"); - _icon = QIcon("/usr/share/mdictionary/xdxf.png"); + _iconPath = "/usr/share/mdictionary/xdxf.png"; + _icon = QIcon(_iconPath); _wordsCount = -1; stopped = false; @@ -452,6 +453,10 @@ QIcon* XdxfPlugin::icon() { return &_icon; } +QString XdxfPlugin::iconPath(){ + return _iconPath; +} + int XdxfPlugin::countWords() { if(_wordsCount>0) diff --git a/src/plugins/xdxf/xdxfplugin.h b/src/plugins/xdxf/xdxfplugin.h index 858fd49..6f32451 100644 --- a/src/plugins/xdxf/xdxfplugin.h +++ b/src/plugins/xdxf/xdxfplugin.h @@ -99,6 +99,9 @@ public: //! \returns plugin icon QIcon* icon(); + //! \returns plugin icon's resource path + QString iconPath(); + /*! plugin should delete any files (eg. cache) that have been created and are ready to be deleted @@ -185,6 +188,8 @@ private: QString _infoNote; QString _dictionaryInfo; QIcon _icon; + //! Path to icon + QString _iconPath; QSqlDatabase db; QString db_name; long _wordsCount;