diff --git a/sources/awesome-widget-kf5/package/contents/config/config.qml b/sources/awesome-widget-kf5/package/contents/config/config.qml index 38d863e..5f62ce6 100644 --- a/sources/awesome-widget-kf5/package/contents/config/config.qml +++ b/sources/awesome-widget-kf5/package/contents/config/config.qml @@ -26,4 +26,22 @@ ConfigModel { icon: "utilities-system-monitor" source: "widget.qml" } + + ConfigCategory { + name: i18n("Advanced") + icon: "system-run" + source: "advanced.qml" + } + + ConfigCategory { + name: i18n("Appearance") + icon: "preferences-desktop-theme" + source: "appearance.qml" + } + + ConfigCategory { + name: i18n("About") + icon: "help-about" + source: "about.qml" + } } diff --git a/sources/awesome-widget-kf5/package/contents/config/main.xml b/sources/awesome-widget-kf5/package/contents/config/main.xml index d39d930..d90e4a7 100644 --- a/sources/awesome-widget-kf5/package/contents/config/main.xml +++ b/sources/awesome-widget-kf5/package/contents/config/main.xml @@ -17,9 +17,6 @@ true - - true - $hh:$mm diff --git a/sources/awesome-widget-kf5/package/contents/ui/about.qml b/sources/awesome-widget-kf5/package/contents/ui/about.qml new file mode 100644 index 0000000..00df0d2 --- /dev/null +++ b/sources/awesome-widget-kf5/package/contents/ui/about.qml @@ -0,0 +1,98 @@ +/*************************************************************************** + * This file is part of awesome-widgets * + * * + * awesome-widgets 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. * + * * + * awesome-widgets 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 awesome-widgets. If not, see http://www.gnu.org/licenses/ * + ***************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Controls 1.3 as QtControls +import QtQuick.Layouts 1.0 as QtLayouts + +import org.kde.plasma.private.awesomewidget 1.0 + + +Item { + id: aboutPage + width: childrenRect.width + height: childrenRect.height + implicitWidth: pageColumn.implicitWidth + implicitHeight: pageColumn.implicitHeight + + property bool debug: AWKeys.isDebugEnabled() + + Column { + id: pageColumn + width: units.gridUnit * 25 + QtControls.TabView { + height: parent.height + width: parent.width + QtControls.Tab { + title: i18n("About") + + QtLayouts.ColumnLayout { + QtControls.Label { + QtLayouts.Layout.fillWidth: true + horizontalAlignment: Text.AlignHCenter + text: AWActions.getAboutText("header") + } + + QtControls.Label { + QtLayouts.Layout.fillWidth: true + horizontalAlignment: Text.AlignJustify + text: AWActions.getAboutText("description") + } + + QtControls.Label { + QtLayouts.Layout.fillWidth: true + horizontalAlignment: Text.AlignLeft + textFormat: Text.RichText + text: AWActions.getAboutText("links") + } + + QtControls.Label { + QtLayouts.Layout.fillWidth: true + font.capitalization: Font.SmallCaps + horizontalAlignment: Text.AlignHCenter + textFormat: Text.RichText + text: AWActions.getAboutText("copy") + } + } + } + + QtControls.Tab { + title: i18n("Acknowledgment") + + QtLayouts.ColumnLayout { + QtControls.Label { + QtLayouts.Layout.fillWidth: true + wrapMode: Text.WordWrap + horizontalAlignment: Text.AlignJustify + text: AWActions.getAboutText("translators") + } + + QtControls.Label { + QtLayouts.Layout.fillWidth: true + horizontalAlignment: Text.AlignJustify + textFormat: Text.RichText + text: AWActions.getAboutText("3rdparty") + } + } + } + } + } + + Component.onCompleted: { + if (debug) console.log("[about::onCompleted]") + } +} diff --git a/sources/awesome-widget-kf5/package/contents/ui/advanced.qml b/sources/awesome-widget-kf5/package/contents/ui/advanced.qml new file mode 100644 index 0000000..1cfaddc --- /dev/null +++ b/sources/awesome-widget-kf5/package/contents/ui/advanced.qml @@ -0,0 +1,170 @@ +/*************************************************************************** + * This file is part of awesome-widgets * + * * + * awesome-widgets 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. * + * * + * awesome-widgets 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 awesome-widgets. If not, see http://www.gnu.org/licenses/ * + ***************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Controls 1.3 as QtControls +import QtQuick.Layouts 1.0 as QtLayouts +import QtQuick.Controls.Styles 1.3 as QtStyles + +import org.kde.plasma.private.awesomewidget 1.0 + + +Item { + id: advancedPage + width: childrenRect.width + height: childrenRect.height + implicitWidth: pageColumn.implicitWidth + implicitHeight: pageColumn.implicitHeight + + property bool debug: AWKeys.isDebugEnabled() + + property alias cfg_background: background.checked + property alias cfg_customTime: customTime.text + property alias cfg_customUptime: customUptime.text + property string cfg_tempUnits: tempUnits.currentText + + + Column { + id: pageColumn + width: units.gridUnit * 25 + Row { + height: implicitHeight + width: parent.width + QtControls.Label { + height: parent.heigth + width: parent.width * 2 / 5 + } + QtControls.CheckBox { + id: background + width: parent.width * 3 / 5 + text: i18n("Enable background") + } + } + + Row { + height: implicitHeight + width: parent.width + QtControls.Label { + height: parent.height + width: parent.width * 2 / 5 + horizontalAlignment: Text.AlignRight + verticalAlignment: Text.AlignVCenter + text: i18n("Custom time format") + } + QtControls.TextField { + id: customTime + width: parent.width * 3 / 5 + text: plasmoid.configuration.customTime + } + } + + Row { + height: implicitHeight + width: parent.width + QtControls.Label { + height: parent.height + width: parent.width * 2 / 5 + horizontalAlignment: Text.AlignRight + verticalAlignment: Text.AlignVCenter + text: i18n("Custom uptime format") + } + QtControls.TextField { + id: customUptime + width: parent.width * 3 / 5 + text: plasmoid.configuration.customUptime + } + } + + Row { + height: implicitHeight + width: parent.width + QtControls.Label { + height: parent.height + width: parent.width * 2 / 5 + horizontalAlignment: Text.AlignRight + verticalAlignment: Text.AlignVCenter + text: i18n("Temperature units") + } + QtControls.ComboBox { + id: tempUnits + width: parent.width * 3 / 5 + textRole: "label" + model: [ + { + 'label': i18n("Celsius"), + 'name': "Celsius" + }, + { + 'label': i18n("Fahrenheit"), + 'name': "Fahrenheit" + }, + { + 'label': i18n("Kelvin"), + 'name': "Kelvin" + }, + { + 'label': i18n("Reaumur"), + 'name': "Reaumur" + }, + { + 'label': i18n("cm^-1"), + 'name': "cm^-1" + }, + { + 'label': i18n("kJ/mol"), + 'name': "kJ/mol" + }, + { + 'label': i18n("kcal/mol"), + 'name': "kcal/mol" + } + ] + onCurrentIndexChanged: cfg_tempUnits = model[currentIndex]["name"] + Component.onCompleted: { + for (var i = 0; i < model.length; i++) { + if (model[i]["name"] == plasmoid.configuration.tempUnits) { + tempUnits.currentIndex = i; + } + } + } + } + } + + Row { + height: implicitHeight + width: parent.width + QtControls.Label { + height: implicitHeight + width: parent.width * 2 / 5 + horizontalAlignment: Text.AlignRight + verticalAlignment: Text.AlignVCenter + text: i18n("Temperature devices") + } + QtControls.Button { + width: parent.width * 3 / 5 + text: i18n("Select devices") + onClicked: plasmoid.configuration.customNetdev = AWActions.selectDevices(AWActions.getNetworkDevices(), + plasmoid.configuration.customNetdev.split("@@")) + } + } + } + + + Component.onCompleted: { + if (debug) console.log("[advanced::onCompleted]") + } +} diff --git a/sources/awesome-widget-kf5/package/contents/ui/appearance.qml b/sources/awesome-widget-kf5/package/contents/ui/appearance.qml new file mode 100644 index 0000000..b5b532a --- /dev/null +++ b/sources/awesome-widget-kf5/package/contents/ui/appearance.qml @@ -0,0 +1,240 @@ +/*************************************************************************** + * This file is part of awesome-widgets * + * * + * awesome-widgets 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. * + * * + * awesome-widgets 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 awesome-widgets. If not, see http://www.gnu.org/licenses/ * + ***************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Controls 1.3 as QtControls +import QtQuick.Controls.Styles 1.3 as QtStyles +import QtQuick.Dialogs 1.1 as QtDialogs +import QtQuick.Layouts 1.0 as QtLayouts + +import org.kde.plasma.private.awesomewidget 1.0 + + +Item { + id: appearancePage + width: childrenRect.width + height: childrenRect.height + implicitWidth: pageColumn.implicitWidth + implicitHeight: pageColumn.implicitHeight + + property bool debug: AWKeys.isDebugEnabled() + property variant weight: { + 25: 0, + 50: 1, + 63: 3, + 75: 4, + 87: 5 + } + + property alias cfg_interval: update.value + property alias cfg_fontFamily: selectFont.text + property alias cfg_fontSize: fontSize.value + property string cfg_fontWeight: fontWeight.currentText + property string cfg_fontStyle: fontStyle.currentText + property alias cfg_fontColor: selectColor.text + + + Column { + id: pageColumn + width: units.gridUnit * 25 + Row { + height: implicitHeight + width: parent.width + QtControls.Label { + height: parent.height + width: parent.width / 3 + horizontalAlignment: Text.AlignRight + verticalAlignment: Text.AlignVCenter + text: i18n("Time interval") + } + QtControls.SpinBox { + id: update + width: parent.width * 2 / 3 + minimumValue: 1000 + maximumValue: 10000 + stepSize: 500 + value: plasmoid.configuration.interval + } + } + + Row { + height: implicitHeight + width: parent.width + QtControls.Label { + height: parent.height + width: parent.width / 3 + horizontalAlignment: Text.AlignRight + verticalAlignment: Text.AlignVCenter + text: i18n("Font") + } + QtControls.Button { + id: selectFont + width: parent.width * 2 / 3 + text: plasmoid.configuration.fontFamily + onClicked: fontDialog.visible = true + } + } + + Row { + height: implicitHeight + width: parent.width + QtControls.Label { + height: parent.height + width: parent.width / 3 + horizontalAlignment: Text.AlignRight + verticalAlignment: Text.AlignVCenter + text: i18n("Font size") + } + QtControls.SpinBox { + id: fontSize + width: parent.width * 2 / 3 + minimumValue: 8 + maximumValue: 32 + stepSize: 1 + value: plasmoid.configuration.fontSize + } + } + + Row { + height: implicitHeight + width: parent.width + QtControls.Label { + height: parent.height + width: parent.width / 3 + horizontalAlignment: Text.AlignRight + verticalAlignment: Text.AlignVCenter + text: i18n("Font weight") + } + QtControls.ComboBox { + id: fontWeight + width: parent.width * 2 / 3 + textRole: "label" + model: [ + { + 'label': i18n("light"), + 'name': "light" + }, + { + 'label': i18n("normal"), + 'name': "normal" + }, + { + 'label': i18n("demi bold"), + 'name': "demibold" + }, + { + 'label': i18n("bold"), + 'name': "bold" + }, + { + 'label': i18n("black"), + 'name': "black" + } + ] + onCurrentIndexChanged: cfg_fontWeight = model[currentIndex]["name"] + Component.onCompleted: { + for (var i = 0; i < model.length; i++) { + if (model[i]["name"] == plasmoid.configuration.fontWeight) { + fontWeight.currentIndex = i; + } + } + } + } + } + + Row { + height: implicitHeight + width: parent.width + QtControls.Label { + height: parent.height + width: parent.width / 3 + horizontalAlignment: Text.AlignRight + verticalAlignment: Text.AlignVCenter + text: i18n("Font style") + } + QtControls.ComboBox { + id: fontStyle + width: parent.width * 2 / 3 + textRole: "label" + model: [ + { + 'label': i18n("normal"), + 'name': "normal" + }, + { + 'label': i18n("italic"), + 'name': "italic" + } + ] + onCurrentIndexChanged: cfg_fontStyle = model[currentIndex]["name"] + Component.onCompleted: { + for (var i = 0; i < model.length; i++) { + if (model[i]["name"] == plasmoid.configuration.fontStyle) { + fontStyle.currentIndex = i; + } + } + } + } + } + + Row { + height: implicitHeight + width: parent.width + QtControls.Label { + height: parent.height + width: parent.width / 3 + horizontalAlignment: Text.AlignRight + verticalAlignment: Text.AlignVCenter + text: i18n("Font color") + } + QtControls.Button { + id: selectColor + width: parent.width * 2 / 3 + style: QtStyles.ButtonStyle { + background: Rectangle { + color: plasmoid.configuration.fontColor + } + } + text: plasmoid.configuration.fontColor + onClicked: colorDialog.visible = true + } + } + } + + QtDialogs.ColorDialog { + id: colorDialog + title: i18n("Select a color") + color: selectColor.text + onAccepted: selectColor.text = colorDialog.color + } + + QtDialogs.FontDialog { + id: fontDialog + title: i18n("Select a font") + font: Qt.font({ family: selectFont.text, pointSize: fontSize.value, weight: Font.Normal }) + onAccepted: { + selectFont.text = fontDialog.font.family + fontSize.value = fontDialog.font.pointSize + fontStyle.currentIndex = fontDialog.font.italic ? 1 : 0 + fontWeight.currentIndex = weight[fontDialog.font.weight] + } + } + + Component.onCompleted: { + if (debug) console.log("[appearance::onCompleted]") + } +} diff --git a/sources/awesome-widget-kf5/package/contents/ui/main.qml b/sources/awesome-widget-kf5/package/contents/ui/main.qml index 7058100..4fd371b 100644 --- a/sources/awesome-widget-kf5/package/contents/ui/main.qml +++ b/sources/awesome-widget-kf5/package/contents/ui/main.qml @@ -96,7 +96,7 @@ Item { onNewData: { if (debug) console.log("[main::onNewData] : Update source " + sourceName) - if ((data.value == "N\\A") || (data.value == "")) return + if (!AWActions.checkKeys(data)) return if (AWKeys.isReady()) AWKeys.setDataBySource(sourceName, data, settings) } @@ -116,7 +116,7 @@ Item { onNewData: { if (debug) console.log("[main::onNewData] : Update source " + sourceName) - if ((data.value == "N\\A") || (data.value == "")) return + if (!AWActions.checkKeys(data)) return if (AWKeys.isReady()) AWKeys.setDataBySource(sourceName, data, settings) // update if (sourceName == "update") needUpdate() @@ -132,7 +132,7 @@ Item { onNewData: { if (debug) console.log("[main::onNewData] : Update source " + sourceName) - if ((data.value == "N\\A") || (data.value == "")) return + if (!AWActions.checkKeys(data)) return if (AWKeys.isReady()) AWKeys.setDataBySource(sourceName, data, settings) } } diff --git a/sources/awesome-widget-kf5/package/metadata.desktop b/sources/awesome-widget-kf5/package/metadata.desktop index df5abab..e87c445 100644 --- a/sources/awesome-widget-kf5/package/metadata.desktop +++ b/sources/awesome-widget-kf5/package/metadata.desktop @@ -15,7 +15,6 @@ Icon=utilities-system-monitor X-KDE-ServiceTypes=Plasma/Applet X-Plasma-API=declarativeappletscript X-Plasma-MainScript=ui/main.qml -X-Plasma-NotificationArea=true X-Plasma-RemoteLocation= X-KDE-PluginInfo-Author=Evgeniy Alekseev aka arcanis diff --git a/sources/awesome-widget-kf5/plugin/awactions.cpp b/sources/awesome-widget-kf5/plugin/awactions.cpp index dcbd110..f9198f7 100644 --- a/sources/awesome-widget-kf5/plugin/awactions.cpp +++ b/sources/awesome-widget-kf5/plugin/awactions.cpp @@ -23,8 +23,11 @@ #include #include #include +#include +#include #include #include +#include #include #include #include @@ -57,6 +60,15 @@ AWActions::~AWActions() } +bool AWActions::checkKeys(const QMap data) +{ + if (debug) qDebug() << PDEBUG; + if (debug) qDebug() << PDEBUG << ":" << "Data" << data; + + return (data.count() != 0); +} + + void AWActions::checkUpdates() { if (debug) qDebug() << PDEBUG; @@ -124,10 +136,49 @@ void AWActions::addDevice(const QString source) } +QString AWActions::getAboutText(const QString type) +{ + if (debug) qDebug() << PDEBUG; + if (debug) qDebug() << PDEBUG << ":" << "Type" << type; + + QString text; + if (type == QString("header")) + text = QString(NAME); + else if (type == QString("description")) + text = i18n("A set of minimalistic plasmoid widgets"); + else if (type == QString("links")) + text = i18n("Links:") + QString("
") + + QString("%2
").arg(QString(HOMEPAGE)).arg(i18n("Homepage")) + + QString("%2
").arg(QString(REPOSITORY)).arg(i18n("Repository")) + + QString("%2
").arg(QString(BUGTRACKER)).arg(i18n("Bugtracker")) + + QString("%2
").arg(QString(TRANSLATION)).arg(i18n("Translation issue")) + + QString("%2
").arg(QString(AUR_PACKAGES)).arg(i18n("AUR packages")) + + QString("%2").arg(QString(OPENSUSE_PACKAGES)).arg(i18n("openSUSE packages")); + else if (type == QString("copy")) + text = QString("© %1 %3
").arg(QString(DATE)).arg(QString(EMAIL)).arg(QString(AUTHOR)) + + i18n("This software is licensed under %1", QString(LICENSE)) + QString("
"); + else if (type == QString("translators")) + text = i18n("Translators: %1", QString(TRANSLATORS)); + else if (type == QString("3rdparty")) { + QStringList trdPartyList = QString(TRDPARTY_LICENSE).split(QChar(';'), QString::SkipEmptyParts); + for (int i=0; i%1 (%2 license)") + .arg(trdPartyList[i].split(QChar(','))[0]) + .arg(trdPartyList[i].split(QChar(','))[1]) + .arg(trdPartyList[i].split(QChar(','))[2]); + text = i18n("This software uses: %1", trdPartyList.join(QString(", "))); + } + + return text; +} + + QStringList AWActions::getDiskDevices() { if (debug) qDebug() << PDEBUG; + diskDevices.sort(); + return diskDevices; } @@ -136,6 +187,8 @@ QStringList AWActions::getFanDevices() { if (debug) qDebug() << PDEBUG; + fanDevices.sort(); + return fanDevices; } @@ -148,6 +201,7 @@ QStringList AWActions::getHddDevices() QStringList devices = allDevices.filter(QRegExp(QString("^[hms]d[a-z]$"))); for (int i=0; i rawInterfaceList = QNetworkInterface::allInterfaces(); + for (int i=0; i AWActions::getFont(const QMap default } +QString AWActions::selectDevices(const QStringList source, const QStringList current) +{ + if (debug) qDebug() << PDEBUG; + + // paint + QDialog *dialog = new QDialog(0); + QListWidget *widget = new QListWidget(dialog); + QDialogButtonBox *buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, + Qt::Horizontal, dialog); + QHBoxLayout *layout = new QHBoxLayout(dialog); + layout->addWidget(widget); + layout->addWidget(buttons); + dialog->setLayout(layout); + + // fill + for (int i=0; isetCheckState(Qt::Checked); + else + item->setCheckState(Qt::Unchecked); + widget->addItem(item); + } + + // exec + QStringList selected; + int ret = dialog->exec(); + if (ret == QDialog::Accepted) { + for (int i=0; icount(); i++) + if (widget->item(i)->checkState() == Qt::Checked) + selected.append(widget->item(i)->text()); + } else + selected = current; + delete dialog; + + return selected.join(QString("@@")); +} + + QMap AWActions::readDataEngineConfiguration() { if (debug) qDebug() << PDEBUG; diff --git a/sources/awesome-widget-kf5/plugin/awactions.h b/sources/awesome-widget-kf5/plugin/awactions.h index 3118085..0e739d6 100644 --- a/sources/awesome-widget-kf5/plugin/awactions.h +++ b/sources/awesome-widget-kf5/plugin/awactions.h @@ -34,18 +34,22 @@ public: AWActions(QObject *parent = 0); ~AWActions(); + Q_INVOKABLE bool checkKeys(const QMap data); Q_INVOKABLE void checkUpdates(); Q_INVOKABLE void runCmd(const QString cmd = QString("/usr/bin/true")); Q_INVOKABLE void sendNotification(const QString eventId, const QString message); Q_INVOKABLE void showReadme(); // configuration slots Q_INVOKABLE void addDevice(const QString source); + Q_INVOKABLE QString getAboutText(const QString type = "header"); Q_INVOKABLE QStringList getDiskDevices(); Q_INVOKABLE QStringList getFanDevices(); Q_INVOKABLE QStringList getHddDevices(); Q_INVOKABLE QStringList getMountDevices(); + Q_INVOKABLE QStringList getNetworkDevices(); Q_INVOKABLE QStringList getTempDevices(); Q_INVOKABLE QMap getFont(const QMap defaultFont); + Q_INVOKABLE QString selectDevices(const QStringList source, const QStringList current); // dataengine Q_INVOKABLE QMap readDataEngineConfiguration(); Q_INVOKABLE void writeDataEngineConfiguration(const QMap configuration); diff --git a/sources/version.h.in b/sources/version.h.in index fb2fec4..0807c6a 100644 --- a/sources/version.h.in +++ b/sources/version.h.in @@ -21,6 +21,7 @@ #define BUGTRACKER "https://github.com/arcan1s/awesome-widgets/issues" #define TRANSLATION "https://github.com/arcan1s/awesome-widgets/issues/14" #define AUR_PACKAGES "https://aur.archlinux.org/packages/kdeplasma-applets-awesome-widgets/" +#define OPENSUSE_PACKAGES "http://software.opensuse.org/package/awesome-widgets" // build information #define BUILD_DATE "@CURRENT_DATE@"