end work on awesomewidget

edit setdatabysource method
This commit is contained in:
arcan1s 2015-02-02 08:21:56 +03:00
parent 9611677254
commit 27fd4e8f1e
12 changed files with 945 additions and 67 deletions

View File

@ -33,12 +33,24 @@ ConfigModel {
source: "advanced.qml" source: "advanced.qml"
} }
ConfigCategory {
name: i18n("Tooltip")
icon: "preferences-desktop-color"
source: "tooltip.qml"
}
ConfigCategory { ConfigCategory {
name: i18n("Appearance") name: i18n("Appearance")
icon: "preferences-desktop-theme" icon: "preferences-desktop-theme"
source: "appearance.qml" source: "appearance.qml"
} }
ConfigCategory {
name: i18n("DataEngine")
icon: "utilities-system-monitor"
source: "dataengine.qml"
}
ConfigCategory { ConfigCategory {
name: i18n("About") name: i18n("About")
icon: "help-about" icon: "help-about"

View File

@ -44,7 +44,7 @@
<entry name="useTooltipBackground" type="bool"> <entry name="useTooltipBackground" type="bool">
<default>true</default> <default>true</default>
</entry> </entry>
<entry name="tooltipBackgroung" type="string"> <entry name="tooltipBackground" type="string">
<default>#ffffff</default> <default>#ffffff</default>
</entry> </entry>
<entry name="cpuTooltip" type="bool"> <entry name="cpuTooltip" type="bool">

View File

@ -0,0 +1,275 @@
/***************************************************************************
* 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.0 as QtControls
import QtQuick.Dialogs 1.1 as QtDialogs
import QtQuick.Layouts 1.0 as QtLayouts
import QtQuick.Controls.Styles 1.3 as QtStyles
import org.kde.plasma.private.awesomewidget 1.0
import "."
Item {
id: dataenginePage
width: childrenRect.width
height: childrenRect.height
implicitWidth: pageColumn.implicitWidth
implicitHeight: pageColumn.implicitHeight
property bool debug: AWKeys.isDebugEnabled()
property variant tooltipSettings: {
"tooltipNumber": plasmoid.configuration.tooltipNumber,
"useTooltipBackground": plasmoid.configuration.useTooltipBackground,
"tooltipBackgroung": plasmoid.configuration.tooltipBackgroung,
"cpuTooltip": plasmoid.configuration.cpuTooltip,
"cpuclTooltip": plasmoid.configuration.cpuclTooltip,
"memTooltip": plasmoid.configuration.memTooltip,
"swapTooltip": plasmoid.configuration.swapTooltip,
"downTooltip": plasmoid.configuration.downTooltip,
"upTooltip": plasmoid.configuration.downTooltip,
"batteryTooltip": plasmoid.configuration.batteryTooltip,
"cpuTooltipColor": plasmoid.configuration.cpuTooltipColor,
"cpuclTooltipColor": plasmoid.configuration.cpuclTooltipColor,
"memTooltipColor": plasmoid.configuration.memTooltipColor,
"swapTooltipColor": plasmoid.configuration.swapTooltipColor,
"downTooltipColor": plasmoid.configuration.downTooltipColor,
"upTooltipColor": plasmoid.configuration.upTooltipColor,
"batteryTooltipColor": plasmoid.configuration.batteryTooltipColor,
"batteryInTooltipColor": plasmoid.configuration.batteryInTooltipColor
}
property variant cfg_dataengine: AWActions.readDataEngineConfiguration()
Column {
id: pageColumn
width: units.gridUnit * 25
Row {
height: implicitHeight
width: parent.width
QtControls.Label {
height: parent.height
width: parent.width * 2 / 5
horizontalAlignment: Text.AlignRight
verticalAlignment: Text.AlignVCenter
text: i18n("ACPI path")
}
QtControls.TextField {
height: parent.height
width: parent.width * 3 / 5
text: cfg_dataengine["ACPIPATH"]
}
}
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 scripts")
}
QtControls.Button {
width: parent.width * 3 / 5
text: i18n("Edit scripts")
onClicked: AWKeys.editItem("extscript")
}
}
Row {
height: implicitHeight
width: parent.width
QtControls.Label {
height: parent.height
width: parent.width * 2 / 5
horizontalAlignment: Text.AlignRight
verticalAlignment: Text.AlignVCenter
text: i18n("GPU device")
}
QtControls.ComboBox {
id: gpuDev
width: parent.width * 3 / 5
model: ["auto", "disable", "ati", "nvidia"]
onCurrentIndexChanged: cfg_dataengine["GPUDEV"] = gpuDev.currentText
Component.onCompleted: {
for (var i=0; i<model.length; i++) {
if (model[i] == cfg_dataengine["GPUDEV"]) {
gpuDev.currentIndex = i;
}
}
}
}
}
Row {
height: implicitHeight
width: parent.width
QtControls.Label {
height: parent.height
width: parent.width * 2 / 5
horizontalAlignment: Text.AlignRight
verticalAlignment: Text.AlignVCenter
text: i18n("HDD")
}
QtControls.ComboBox {
id: hdd
width: parent.width * 3 / 5
model: AWKeys.getHddDevices(true)
onCurrentIndexChanged: cfg_dataengine["HDDDEV"] = hdd.currentText
Component.onCompleted: {
for (var i=0; i<model.length; i++) {
if (model[i] == cfg_dataengine["HDDDEV"]) {
hdd.currentIndex = i;
}
}
}
}
}
Row {
height: implicitHeight
width: parent.width
QtControls.Label {
height: parent.height
width: parent.width * 2 / 5
horizontalAlignment: Text.AlignRight
verticalAlignment: Text.AlignVCenter
text: i18n("hddtemp cmd")
}
QtControls.TextField {
height: parent.height
width: parent.width * 3 / 5
text: cfg_dataengine["HDDTEMP"]
}
}
Row {
height: implicitHeight
width: parent.width
QtControls.Label {
height: parent.height
width: parent.width * 2 / 5
horizontalAlignment: Text.AlignRight
verticalAlignment: Text.AlignVCenter
text: i18n("MPD address")
}
QtControls.TextField {
height: parent.height
width: parent.width * 3 / 5
text: cfg_dataengine["MPDADDRESS"]
}
}
Row {
height: implicitHeight
width: parent.width
QtControls.Label {
height: parent.height
width: parent.width * 2 / 5
horizontalAlignment: Text.AlignRight
verticalAlignment: Text.AlignVCenter
text: i18n("MPD port")
}
QtControls.SpinBox {
width: parent.width * 3 / 5
minimumValue: 1000
maximumValue: 65535
stepSize: 1
value: cfg_dataengine["MPDPORT"]
}
}
Row {
height: implicitHeight
width: parent.width
QtControls.Label {
height: parent.height
width: parent.width * 2 / 5
horizontalAlignment: Text.AlignRight
verticalAlignment: Text.AlignVCenter
text: i18n("MPRIS player name")
}
QtControls.ComboBox {
id: mpris
width: parent.width * 3 / 5
editable: true
model: ["auto", "amarok", "audacious", "clementine", "deadbeef",
"vlc", "qmmp", "xmms2", cfg_dataengine["MPRIS"]]
currentIndex: model.length - 1
}
}
Row {
height: implicitHeight
width: parent.width
QtControls.Label {
height: parent.height
width: parent.width * 2 / 5
horizontalAlignment: Text.AlignRight
verticalAlignment: Text.AlignVCenter
text: i18n("Music player")
}
QtControls.ComboBox {
id: player
width: parent.width * 3 / 5
model: ["mpris", "mpd"]
onCurrentIndexChanged: cfg_dataengine["PLAYER"] = model[currentIndex]
Component.onCompleted: {
for (var i=0; i<model.length; i++) {
if (model[i] == cfg_dataengine["PLAYER"]) {
player.currentIndex = i;
}
}
}
}
}
Row {
height: implicitHeight
width: parent.width
QtControls.Label {
height: parent.height
width: parent.width * 2 / 5
horizontalAlignment: Text.AlignRight
verticalAlignment: Text.AlignVCenter
text: i18n("Package manager")
}
QtControls.Button {
width: parent.width * 3 / 5
text: i18n("Edit command")
onClicked: AWKeys.editItem("extupgrade")
}
}
}
Component.onCompleted: {
if (debug) console.log("[dataengine::onCompleted]")
// init submodule
AWKeys.initKeys(plasmoid.configuration.text, tooltipSettings)
}
Component.onDestruction: {
if (debug) console.log("[dataengine::onDestruction]")
cfg_dataengine["MPRIS"] = mpris.currentText
AWActions.writeDataEngineConfiguration(cfg_dataengine)
}
}

View File

@ -141,7 +141,6 @@ Item {
// actions // actions
plasmoid.setAction("requestKey", i18n("Request key"), "utilities-system-monitor") plasmoid.setAction("requestKey", i18n("Request key"), "utilities-system-monitor")
plasmoid.setAction("showReadme", i18n("Show README"), "text-x-readme") plasmoid.setAction("showReadme", i18n("Show README"), "text-x-readme")
plasmoid.setAction("updateText", i18n("Update text"), "view-refresh")
plasmoid.setAction("checkUpdates", i18n("Check updates"), "system-software-update") plasmoid.setAction("checkUpdates", i18n("Check updates"), "system-software-update")
} }
@ -175,8 +174,4 @@ Item {
if (message.length == 0) return if (message.length == 0) return
AWActions.sendNotification("tag", message) AWActions.sendNotification("tag", message)
} }
function action_updateText() {
if (debug) console.log("[main::action_updateText]")
}
} }

View File

@ -0,0 +1,513 @@
/***************************************************************************
* 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 org.kde.plasma.private.awesomewidget 1.0
import "."
Item {
id: tooltipPage
width: childrenRect.width
height: childrenRect.height
implicitWidth: pageColumn.implicitWidth
implicitHeight: pageColumn.implicitHeight
property bool debug: AWKeys.isDebugEnabled()
property alias cfg_tooltipNumber: tooltipNumber.value
property alias cfg_useTooltipBackground: useTooltipBackground.checked
property alias cfg_tooltipBackground: tooltipBackground.text
property alias cfg_cpuTooltip: cpuTooltip.checked
property alias cfg_cpuTooltipColor: cpuTooltipColor.text
property alias cfg_cpuclTooltip: cpuclTooltip.checked
property alias cfg_cpuclTooltipColor: cpuclTooltipColor.text
property alias cfg_memTooltip: memTooltip.checked
property alias cfg_memTooltipColor: memTooltipColor.text
property alias cfg_swapTooltip: swapTooltip.checked
property alias cfg_swapTooltipColor: swapTooltipColor.text
property alias cfg_downTooltip: downTooltip.checked
property alias cfg_downTooltipColor: downTooltipColor.text
property alias cfg_upTooltipColor: upTooltipColor.text
property alias cfg_batteryTooltip: batteryTooltip.checked
property alias cfg_batteryTooltipColor: batteryTooltipColor.text
property alias cfg_batteryInTooltipColor: batteryInTooltipColor.text
Column {
id: pageColumn
width: units.gridUnit * 25
QtControls.Label {
width: parent.width
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
text: i18n("CPU, CPU clock, memory, swap and network labels support graphical tooltip. To enable them just make needed checkbox fully checked.")
}
Row {
height: implicitHeight
width: parent.width
QtControls.Label {
height: parent.height
width: parent.width * 2 / 5
horizontalAlignment: Text.AlignRight
verticalAlignment: Text.AlignVCenter
text: i18n("Number of values for tooltips")
}
QtControls.SpinBox {
id: tooltipNumber
width: parent.width * 3 / 5
minimumValue: 50
maximumValue: 1000
stepSize: 25
value: plasmoid.configuration.tooltipNumber
}
}
Row {
height: implicitHeight
width: parent.width
QtControls.Label {
height: parent.height
width: parent.width * 2 / 5 - useTooltipBackground.width
horizontalAlignment: Text.AlignRight
verticalAlignment: Text.AlignVCenter
text: i18n("Background")
}
QtControls.CheckBox {
id: useTooltipBackground
height: parent.height
width: implicitWidth
style: QtStyles.CheckBoxStyle {
indicator: Rectangle {
implicitWidth: 16
implicitHeight: 16
radius: 3
border.width: 1
border.color: control.activeFocus ? "darkblue" : "gray"
Rectangle {
visible: control.checked
radius: 1
anchors.fill: parent
anchors.margins: 4
color: "#555555"
border.color: "#333333"
}
}
}
}
QtControls.Button {
id: tooltipBackground
width: parent.width * 3 / 5
style: QtStyles.ButtonStyle {
background: Rectangle {
color: plasmoid.configuration.tooltipBackground
}
}
text: plasmoid.configuration.tooltipBackground
onClicked: tooltipBackgroundDialog.visible = true
}
QtDialogs.ColorDialog {
id: tooltipBackgroundDialog
title: i18n("Select a color")
color: tooltipBackground.text
onAccepted: tooltipBackground.text = tooltipBackgroundDialog.color
}
}
Row {
height: implicitHeight
width: parent.width
QtControls.Label {
height: parent.height
width: parent.width * 2 / 5 - cpuTooltip.width
horizontalAlignment: Text.AlignRight
verticalAlignment: Text.AlignVCenter
text: i18n("CPU color")
}
QtControls.CheckBox {
id: cpuTooltip
height: parent.height
width: implicitWidth
style: QtStyles.CheckBoxStyle {
indicator: Rectangle {
implicitWidth: 16
implicitHeight: 16
radius: 3
border.width: 1
border.color: control.activeFocus ? "darkblue" : "gray"
Rectangle {
visible: control.checked
radius: 1
anchors.fill: parent
anchors.margins: 4
color: "#555555"
border.color: "#333333"
}
}
}
}
QtControls.Button {
id: cpuTooltipColor
width: parent.width * 3 / 5
style: QtStyles.ButtonStyle {
background: Rectangle {
color: plasmoid.configuration.cpuTooltipColor
}
}
text: plasmoid.configuration.cpuTooltipColor
onClicked: cpuTooltipColorDialog.visible = true
}
QtDialogs.ColorDialog {
id: cpuTooltipColorDialog
title: i18n("Select a color")
color: cpuTooltipColor.text
onAccepted: cpuTooltipColor.text = cpuTooltipColorDialog.color
}
}
Row {
height: implicitHeight
width: parent.width
QtControls.Label {
height: parent.height
width: parent.width * 2 / 5 - cpuclTooltip.width
horizontalAlignment: Text.AlignRight
verticalAlignment: Text.AlignVCenter
text: i18n("CPU clock color")
}
QtControls.CheckBox {
id: cpuclTooltip
height: parent.height
width: implicitWidth
style: QtStyles.CheckBoxStyle {
indicator: Rectangle {
implicitWidth: 16
implicitHeight: 16
radius: 3
border.width: 1
border.color: control.activeFocus ? "darkblue" : "gray"
Rectangle {
visible: control.checked
radius: 1
anchors.fill: parent
anchors.margins: 4
color: "#555555"
border.color: "#333333"
}
}
}
}
QtControls.Button {
id: cpuclTooltipColor
width: parent.width * 3 / 5
style: QtStyles.ButtonStyle {
background: Rectangle {
color: plasmoid.configuration.cpuclTooltipColor
}
}
text: plasmoid.configuration.cpuclTooltipColor
onClicked: cpuclTooltipColorDialog.visible = true
}
QtDialogs.ColorDialog {
id: cpuclTooltipColorDialog
title: i18n("Select a color")
color: cpuclTooltipColor.text
onAccepted: cpuclTooltipColor.text = cpuclTooltipColorDialog.color
}
}
Row {
height: implicitHeight
width: parent.width
QtControls.Label {
height: parent.height
width: parent.width * 2 / 5 - memTooltip.width
horizontalAlignment: Text.AlignRight
verticalAlignment: Text.AlignVCenter
text: i18n("Memory color")
}
QtControls.CheckBox {
id: memTooltip
height: parent.height
width: implicitWidth
style: QtStyles.CheckBoxStyle {
indicator: Rectangle {
implicitWidth: 16
implicitHeight: 16
radius: 3
border.width: 1
border.color: control.activeFocus ? "darkblue" : "gray"
Rectangle {
visible: control.checked
radius: 1
anchors.fill: parent
anchors.margins: 4
color: "#555555"
border.color: "#333333"
}
}
}
}
QtControls.Button {
id: memTooltipColor
width: parent.width * 3 / 5
style: QtStyles.ButtonStyle {
background: Rectangle {
color: plasmoid.configuration.memTooltipColor
}
}
text: plasmoid.configuration.memTooltipColor
onClicked: memTooltipColorDialog.visible = true
}
QtDialogs.ColorDialog {
id: memTooltipColorDialog
title: i18n("Select a color")
color: memTooltipColor.text
onAccepted: memTooltipColor.text = memTooltipColorDialog.color
}
}
Row {
height: implicitHeight
width: parent.width
QtControls.Label {
height: parent.height
width: parent.width * 2 / 5 - swapTooltip.width
horizontalAlignment: Text.AlignRight
verticalAlignment: Text.AlignVCenter
text: i18n("Swap color")
}
QtControls.CheckBox {
id: swapTooltip
height: parent.height
width: implicitWidth
style: QtStyles.CheckBoxStyle {
indicator: Rectangle {
implicitWidth: 16
implicitHeight: 16
radius: 3
border.width: 1
border.color: control.activeFocus ? "darkblue" : "gray"
Rectangle {
visible: control.checked
radius: 1
anchors.fill: parent
anchors.margins: 4
color: "#555555"
border.color: "#333333"
}
}
}
}
QtControls.Button {
id: swapTooltipColor
width: parent.width * 3 / 5
style: QtStyles.ButtonStyle {
background: Rectangle {
color: plasmoid.configuration.swapTooltipColor
}
}
text: plasmoid.configuration.swapTooltipColor
onClicked: swapTooltipColorDialog.visible = true
}
QtDialogs.ColorDialog {
id: swapTooltipColorDialog
title: i18n("Select a color")
color: swapTooltipColor.text
onAccepted: swapTooltipColor.text = swapTooltipColorDialog.color
}
}
Row {
height: implicitHeight
width: parent.width
QtControls.Label {
height: parent.height
width: parent.width * 2 / 5 - downTooltip.width
horizontalAlignment: Text.AlignRight
verticalAlignment: Text.AlignVCenter
text: i18n("Download speed color")
}
QtControls.CheckBox {
id: downTooltip
height: parent.height
width: implicitWidth
style: QtStyles.CheckBoxStyle {
indicator: Rectangle {
implicitWidth: 16
implicitHeight: 16
radius: 3
border.width: 1
border.color: control.activeFocus ? "darkblue" : "gray"
Rectangle {
visible: control.checked
radius: 1
anchors.fill: parent
anchors.margins: 4
color: "#555555"
border.color: "#333333"
}
}
}
}
QtControls.Button {
id: downTooltipColor
width: parent.width * 3 / 5
style: QtStyles.ButtonStyle {
background: Rectangle {
color: plasmoid.configuration.downTooltipColor
}
}
text: plasmoid.configuration.downTooltipColor
onClicked: downTooltipColorDialog.visible = true
}
QtDialogs.ColorDialog {
id: downTooltipColorDialog
title: i18n("Select a color")
color: downTooltipColor.text
onAccepted: downTooltipColor.text = downTooltipColorDialog.color
}
}
Row {
height: implicitHeight
width: parent.width
QtControls.Label {
height: parent.height
width: parent.width * 2 / 5
horizontalAlignment: Text.AlignRight
verticalAlignment: Text.AlignVCenter
text: i18n("Upload speed color")
}
QtControls.Button {
id: upTooltipColor
width: parent.width * 3 / 5
style: QtStyles.ButtonStyle {
background: Rectangle {
color: plasmoid.configuration.upTooltipColor
}
}
text: plasmoid.configuration.upTooltipColor
onClicked: upTooltipColorDialog.visible = true
}
QtDialogs.ColorDialog {
id: upTooltipColorDialog
title: i18n("Select a color")
color: upTooltipColor.text
onAccepted: upTooltipColor.text = upTooltipColorDialog.color
}
}
Row {
height: implicitHeight
width: parent.width
QtControls.Label {
height: parent.height
width: parent.width * 2 / 5 - batteryTooltip.width
horizontalAlignment: Text.AlignRight
verticalAlignment: Text.AlignVCenter
text: i18n("Battery active color")
}
QtControls.CheckBox {
id: batteryTooltip
height: parent.height
width: implicitWidth
style: QtStyles.CheckBoxStyle {
indicator: Rectangle {
implicitWidth: 16
implicitHeight: 16
radius: 3
border.width: 1
border.color: control.activeFocus ? "darkblue" : "gray"
Rectangle {
visible: control.checked
radius: 1
anchors.fill: parent
anchors.margins: 4
color: "#555555"
border.color: "#333333"
}
}
}
}
QtControls.Button {
id: batteryTooltipColor
width: parent.width * 3 / 5
style: QtStyles.ButtonStyle {
background: Rectangle {
color: plasmoid.configuration.batteryTooltipColor
}
}
text: plasmoid.configuration.batteryTooltipColor
onClicked: batteryTooltipColorDialog.visible = true
}
QtDialogs.ColorDialog {
id: batteryTooltipColorDialog
title: i18n("Select a color")
color: batteryTooltipColor.text
onAccepted: batteryTooltipColor.text = batteryTooltipColorDialog.color
}
}
Row {
height: implicitHeight
width: parent.width
QtControls.Label {
height: parent.height
width: parent.width * 2 / 5
horizontalAlignment: Text.AlignRight
verticalAlignment: Text.AlignVCenter
text: i18n("Battery inactive color")
}
QtControls.Button {
id: batteryInTooltipColor
width: parent.width * 3 / 5
style: QtStyles.ButtonStyle {
background: Rectangle {
color: plasmoid.configuration.batteryInTooltipColor
}
}
text: plasmoid.configuration.batteryInTooltipColor
onClicked: batteryInTooltipColorDialog.visible = true
}
QtDialogs.ColorDialog {
id: batteryInTooltipColorDialog
title: i18n("Select a color")
color: batteryInTooltipColor.text
onAccepted: batteryInTooltipColor.text = batteryInTooltipColorDialog.color
}
}
}
Component.onCompleted: {
if (debug) console.log("[tooltip::onCompleted]")
}
}

View File

@ -153,48 +153,6 @@ QMap<QString, QVariant> AWActions::getFont(const QMap<QString, QVariant> 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::Vertical, dialog);
QHBoxLayout *layout = new QHBoxLayout(dialog);
layout->addWidget(widget);
layout->addWidget(buttons);
dialog->setLayout(layout);
connect(buttons, SIGNAL(accepted()), dialog, SLOT(accept()));
connect(buttons, SIGNAL(rejected()), dialog, SLOT(reject()));
// fill
for (int i=0; i<source.count(); i++) {
QListWidgetItem *item = new QListWidgetItem(source[i]);
if (current.contains(source[i]))
item->setCheckState(Qt::Checked);
else
item->setCheckState(Qt::Unchecked);
widget->addItem(item);
}
// exec
QStringList selected;
int ret = dialog->exec();
if (debug) qDebug() << PDEBUG << ":" << "Dialog returns" << ret;
if (ret == QDialog::Accepted) {
for (int i=0; i<widget->count(); i++)
if (widget->item(i)->checkState() == Qt::Checked)
selected.append(widget->item(i)->text());
} else
selected = current;
delete dialog;
return selected.join(QString("@@"));
}
QMap<QString, QVariant> AWActions::readDataEngineConfiguration() QMap<QString, QVariant> AWActions::readDataEngineConfiguration()
{ {
if (debug) qDebug() << PDEBUG; if (debug) qDebug() << PDEBUG;

View File

@ -238,11 +238,15 @@ QStringList AWKeys::dictKeys()
allKeys.append(QString("hddw") + QString::number(i)); allKeys.append(QString("hddw") + QString::number(i));
} }
// hdd temp // hdd temp
for (int i=getHddDevices.count()-1; i>=0; i--) { for (int i=getHddDevices().count()-1; i>=0; i--) {
allKeys.append(QString("hddtemp") + QString::number(i)); allKeys.append(QString("hddtemp") + QString::number(i));
allKeys.append(QString("hddtemp") + QString::number(i)); allKeys.append(QString("hddtemp") + QString::number(i));
} }
// network // network
for (int i=getNetworkDevices().count()-1; i>=0; i--) {
allKeys.append(QString("down") + QString::number(i));
allKeys.append(QString("up") + QString::number(i));
}
allKeys.append(QString("down")); allKeys.append(QString("down"));
allKeys.append(QString("up")); allKeys.append(QString("up"));
allKeys.append(QString("netdev")); allKeys.append(QString("netdev"));
@ -274,6 +278,9 @@ QStringList AWKeys::dictKeys()
allKeys.append(QString("desktop")); allKeys.append(QString("desktop"));
allKeys.append(QString("ndesktop")); allKeys.append(QString("ndesktop"));
allKeys.append(QString("tdesktops")); allKeys.append(QString("tdesktops"));
// bars
for (int i=0; i<graphicalItems.count(); i++)
allKeys.append(graphicalItems[i]->name() + graphicalItems[i]->bar());
return allKeys; return allKeys;
} }
@ -299,7 +306,7 @@ QStringList AWKeys::getFanDevices()
} }
QStringList AWKeys::getHddDevices() QStringList AWKeys::getHddDevices(const bool needAbstract)
{ {
if (debug) qDebug() << PDEBUG; if (debug) qDebug() << PDEBUG;
@ -309,6 +316,11 @@ QStringList AWKeys::getHddDevices()
devices[i] = QString("/dev/") + devices[i]; devices[i] = QString("/dev/") + devices[i];
devices.sort(); devices.sort();
if (needAbstract) {
devices.insert(0, QString("disable"));
devices.insert(0, QString("auto"));
}
return devices; return devices;
} }
@ -347,7 +359,7 @@ QStringList AWKeys::getTempDevices()
} }
void AWKeys::setDataBySource(const QString sourceName, bool AWKeys::setDataBySource(const QString sourceName,
const QMap<QString, QVariant> data, const QMap<QString, QVariant> data,
const QMap<QString, QVariant> params) const QMap<QString, QVariant> params)
{ {
@ -355,8 +367,8 @@ void AWKeys::setDataBySource(const QString sourceName,
if (debug) qDebug() << PDEBUG << ":" << "Source" << sourceName; if (debug) qDebug() << PDEBUG << ":" << "Source" << sourceName;
// checking // checking
if (!checkKeys(data)) return; if (!checkKeys(data)) return false;
if (!ready) return; if (!ready) return false;
// regular expressions // regular expressions
QRegExp cpuRegExp = QRegExp(QString("cpu/cpu.*/TotalLoad")); QRegExp cpuRegExp = QRegExp(QString("cpu/cpu.*/TotalLoad"));
@ -416,7 +428,7 @@ void AWKeys::setDataBySource(const QString sourceName,
QString device = sourceName; QString device = sourceName;
device.remove(QString("/Rate/rblk")); device.remove(QString("/Rate/rblk"));
for (int i=0; i<diskDevices.count(); i++) for (int i=0; i<diskDevices.count(); i++)
if (params[QString("disk")].toString().split(QString("@@"))[i] == device) { if (diskDevices[i] == device) {
values[QString("hddr") + QString::number(i)] = QString("%1").arg(data[QString("value")].toFloat(), 5, 'f', 0); values[QString("hddr") + QString::number(i)] = QString("%1").arg(data[QString("value")].toFloat(), 5, 'f', 0);
break; break;
} }
@ -425,7 +437,7 @@ void AWKeys::setDataBySource(const QString sourceName,
QString device = sourceName; QString device = sourceName;
device.remove(QString("/Rate/wblk")); device.remove(QString("/Rate/wblk"));
for (int i=0; i<diskDevices.count(); i++) for (int i=0; i<diskDevices.count(); i++)
if (params[QString("disk")].toString().split(QString("@@"))[i] == device) { if (diskDevices[i] == device) {
values[QString("hddw") + QString::number(i)] = QString("%1").arg(data[QString("value")].toFloat(), 5, 'f', 0); values[QString("hddw") + QString::number(i)] = QString("%1").arg(data[QString("value")].toFloat(), 5, 'f', 0);
break; break;
} }
@ -441,7 +453,7 @@ void AWKeys::setDataBySource(const QString sourceName,
QString mount = sourceName; QString mount = sourceName;
mount.remove(QString("partitions")).remove(QString("/filllevel")); mount.remove(QString("partitions")).remove(QString("/filllevel"));
for (int i=0; i<mountDevices.count(); i++) for (int i=0; i<mountDevices.count(); i++)
if (params[QString("mount")].toString().split(QString("@@"))[i] == mount) { if (mountDevices[i] == mount) {
values[QString("hdd") + QString::number(i)] = QString("%1").arg(data[QString("value")].toFloat(), 5, 'f', 1); values[QString("hdd") + QString::number(i)] = QString("%1").arg(data[QString("value")].toFloat(), 5, 'f', 1);
break; break;
} }
@ -450,7 +462,7 @@ void AWKeys::setDataBySource(const QString sourceName,
QString mount = sourceName; QString mount = sourceName;
mount.remove(QString("partitions")).remove(QString("/freespace")); mount.remove(QString("partitions")).remove(QString("/freespace"));
for (int i=0; i<mountDevices.count(); i++) for (int i=0; i<mountDevices.count(); i++)
if (params[QString("mount")].toString().split(QString("@@"))[i] == mount) { if (mountDevices[i] == mount) {
values[QString("hddfreemb") + QString::number(i)] = QString("%1").arg( values[QString("hddfreemb") + QString::number(i)] = QString("%1").arg(
data[QString("value")].toFloat() / 1024.0, 5, 'f', 0); data[QString("value")].toFloat() / 1024.0, 5, 'f', 0);
values[QString("hddfreegb") + QString::number(i)] = QString("%1").arg( values[QString("hddfreegb") + QString::number(i)] = QString("%1").arg(
@ -462,7 +474,7 @@ void AWKeys::setDataBySource(const QString sourceName,
QString mount = sourceName; QString mount = sourceName;
mount.remove(QString("partitions")).remove(QString("/usedspace")); mount.remove(QString("partitions")).remove(QString("/usedspace"));
for (int i=0; i<mountDevices.count(); i++) for (int i=0; i<mountDevices.count(); i++)
if (params[QString("mount")].toString().split(QString("@@"))[i] == mount) { if (mountDevices[i] == mount) {
values[QString("hddmb") + QString::number(i)] = QString("%1").arg( values[QString("hddmb") + QString::number(i)] = QString("%1").arg(
data[QString("value")].toFloat() / 1024.0, 5, 'f', 0); data[QString("value")].toFloat() / 1024.0, 5, 'f', 0);
values[QString("hddgb") + QString::number(i)] = QString("%1").arg( values[QString("hddgb") + QString::number(i)] = QString("%1").arg(
@ -478,9 +490,10 @@ void AWKeys::setDataBySource(const QString sourceName,
} }
} else if (sourceName == QString("hddtemp")) { } else if (sourceName == QString("hddtemp")) {
// hdd temperature // hdd temperature
QStringList hddDevices = getHddDevices();
for (int i=0; i<data.keys().count(); i++) for (int i=0; i<data.keys().count(); i++)
for (int j=0; j<getHddDevices().count(); j++) for (int j=0; j<hddDevices.count(); j++)
if (data.keys()[i] == params[QString("hdd")].toString().split(QString("@@"))[j]) { if (hddDevices[j] == data.keys()[i]) {
values[QString("hddtemp") + QString::number(j)] = QString("%1").arg( values[QString("hddtemp") + QString::number(j)] = QString("%1").arg(
temperature(data[data.keys()[i]].toFloat(), params[QString("tempUnits")].toString()), 4, 'f', 1); temperature(data[data.keys()[i]].toFloat(), params[QString("tempUnits")].toString()), 4, 'f', 1);
break; break;
@ -513,6 +526,12 @@ void AWKeys::setDataBySource(const QString sourceName,
// download speed // download speed
QString device = sourceName; QString device = sourceName;
device.remove(QString("network/interfaces/")).remove(QString("/receiver/data")); device.remove(QString("network/interfaces/")).remove(QString("/receiver/data"));
QStringList allNetworkDevices = getNetworkDevices();
for (int i=0; i<allNetworkDevices.count(); i++)
if (allNetworkDevices[i] == device) {
values[QString("down") + QString::number(i)] = QString("%1").arg(data[QString("value")].toFloat(), 4, 'f', 0);
break;
}
if (device == networkDevice()) { if (device == networkDevice()) {
values[QString("down")] = QString("%1").arg(data[QString("value")].toFloat(), 4, 'f', 0); values[QString("down")] = QString("%1").arg(data[QString("value")].toFloat(), 4, 'f', 0);
toolTip->setData(QString("down"), data[QString("value")].toFloat()); toolTip->setData(QString("down"), data[QString("value")].toFloat());
@ -521,6 +540,12 @@ void AWKeys::setDataBySource(const QString sourceName,
// upload speed // upload speed
QString device = sourceName; QString device = sourceName;
device.remove(QString("network/interfaces/")).remove(QString("/transmitter/data")); device.remove(QString("network/interfaces/")).remove(QString("/transmitter/data"));
QStringList allNetworkDevices = getNetworkDevices();
for (int i=0; i<allNetworkDevices.count(); i++)
if (allNetworkDevices[i] == device) {
values[QString("up") + QString::number(i)] = QString("%1").arg(data[QString("value")].toFloat(), 4, 'f', 0);
break;
}
if (device == networkDevice()) { if (device == networkDevice()) {
values[QString("up")] = QString("%1").arg(data[QString("value")].toFloat(), 4, 'f', 0); values[QString("up")] = QString("%1").arg(data[QString("value")].toFloat(), 4, 'f', 0);
toolTip->setData(QString("up"), data[QString("value")].toFloat()); toolTip->setData(QString("up"), data[QString("value")].toFloat());
@ -562,13 +587,13 @@ void AWKeys::setDataBySource(const QString sourceName,
// temperature devices // temperature devices
if (data[QString("units")].toString() == QString("rpm")) { if (data[QString("units")].toString() == QString("rpm")) {
for (int i=0; i<fanDevices.count(); i++) for (int i=0; i<fanDevices.count(); i++)
if (sourceName == params[QString("fanDevice")].toString().split(QString("@@"))[i]) { if (sourceName == fanDevices[i]) {
values[QString("fan") + QString::number(i)] = QString("%1").arg(data[QString("value")].toFloat(), 4, 'f', 1); values[QString("fan") + QString::number(i)] = QString("%1").arg(data[QString("value")].toFloat(), 4, 'f', 1);
break; break;
} }
} else { } else {
for (int i=0; i<tempDevices.count(); i++) for (int i=0; i<tempDevices.count(); i++)
if (sourceName == params[QString("tempDevice")].toString().split(QString("@@"))[i]) { if (sourceName == tempDevices[i]) {
values[QString("temp") + QString::number(i)] = QString("%1").arg( values[QString("temp") + QString::number(i)] = QString("%1").arg(
temperature(data[QString("value")].toFloat(), params[QString("tempUnits")].toString()), 4, 'f', 1); temperature(data[QString("value")].toFloat(), params[QString("tempUnits")].toString()), 4, 'f', 1);
break; break;
@ -600,7 +625,12 @@ void AWKeys::setDataBySource(const QString sourceName,
values[QString("cuptime")].replace(QString("$h"), QString("%1").arg(hours)); values[QString("cuptime")].replace(QString("$h"), QString("%1").arg(hours));
values[QString("cuptime")].replace(QString("$mm"), QString("%1").arg(minutes, 2, 10, QChar('0'))); values[QString("cuptime")].replace(QString("$mm"), QString("%1").arg(minutes, 2, 10, QChar('0')));
values[QString("cuptime")].replace(QString("$m"), QString("%1").arg(minutes)); values[QString("cuptime")].replace(QString("$m"), QString("%1").arg(minutes));
} else {
if (debug) qDebug() << PDEBUG << ":" << "Source not found";
return false;
} }
return true;
} }

View File

@ -61,11 +61,11 @@ public:
Q_INVOKABLE QStringList dictKeys(); Q_INVOKABLE QStringList dictKeys();
Q_INVOKABLE QStringList getDiskDevices(); Q_INVOKABLE QStringList getDiskDevices();
Q_INVOKABLE QStringList getFanDevices(); Q_INVOKABLE QStringList getFanDevices();
Q_INVOKABLE QStringList getHddDevices(); Q_INVOKABLE QStringList getHddDevices(const bool needAbstract = false);
Q_INVOKABLE QStringList getMountDevices(); Q_INVOKABLE QStringList getMountDevices();
Q_INVOKABLE QStringList getNetworkDevices(); Q_INVOKABLE QStringList getNetworkDevices();
Q_INVOKABLE QStringList getTempDevices(); Q_INVOKABLE QStringList getTempDevices();
Q_INVOKABLE void setDataBySource(const QString sourceName, Q_INVOKABLE bool setDataBySource(const QString sourceName,
const QMap<QString, QVariant> data, const QMap<QString, QVariant> data,
const QMap<QString, QVariant> params); const QMap<QString, QVariant> params);
// values // values

View File

@ -32,12 +32,46 @@ AWToolTip::AWToolTip(QObject *parent,
QProcessEnvironment environment = QProcessEnvironment::systemEnvironment(); QProcessEnvironment environment = QProcessEnvironment::systemEnvironment();
QString debugEnv = environment.value(QString("DEBUG"), QString("no")); QString debugEnv = environment.value(QString("DEBUG"), QString("no"));
debug = (debugEnv == QString("yes")); debug = (debugEnv == QString("yes"));
toolTipScene = new QGraphicsScene();
toolTipView = new QGraphicsView(toolTipScene);
toolTipView->setStyleSheet(QString("background: transparent"));
toolTipView->setContentsMargins(0, 0, 0, 0);
toolTipView->setFrameShape(QFrame::NoFrame);
toolTipView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
toolTipView->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
m_counts += m_settings[QString("cpuTooltip")].toInt();
m_counts += m_settings[QString("cpuclTooltip")].toInt();
m_counts += m_settings[QString("memTooltip")].toInt();
m_counts += m_settings[QString("swapTooltip")].toInt();
m_counts += m_settings[QString("downTooltip")].toInt();
m_counts += m_settings[QString("batteryTooltip")].toInt();
boundaries[QString("cpu")] = 100.0;
boundaries[QString("cpucl")] = 4000.0;
boundaries[QString("mem")] = 100.0;
boundaries[QString("swap")] = 100.0;
boundaries[QString("down")] = 1.0;
boundaries[QString("up")] = 1.0;
boundaries[QString("bat")] = 100.0;
if (m_settings[QString("cpuTooltip")].toBool()) requiredKeys.append(QString("cpu"));
if (m_settings[QString("cpuclTooltip")].toBool()) requiredKeys.append(QString("cpucl"));
if (m_settings[QString("memTooltip")].toBool()) requiredKeys.append(QString("mem"));
if (m_settings[QString("swapTooltip")].toBool()) requiredKeys.append(QString("swap"));
if (m_settings[QString("downTooltip")].toBool()) requiredKeys.append(QString("down"));
if (m_settings[QString("upTooltip")].toBool()) requiredKeys.append(QString("up"));
if (m_settings[QString("batTooltip")].toBool()) requiredKeys.append(QString("bat"));
} }
AWToolTip::~AWToolTip() AWToolTip::~AWToolTip()
{ {
if (debug) qDebug() << PDEBUG; if (debug) qDebug() << PDEBUG;
delete toolTipView;
delete toolTipScene;
} }
@ -45,7 +79,44 @@ QPixmap AWToolTip::image()
{ {
if (debug) qDebug() << PDEBUG; if (debug) qDebug() << PDEBUG;
return QPixmap(); toolTipView->resize(100.0 * m_counts, 105.0);
// create image
toolTipScene->clear();
QPen pen = QPen();
// background
if (m_settings[QString("useTooltipBackground")].toBool())
toolTipScene->setBackgroundBrush(QColor(m_settings[QString("tooltipBackground")].toString()));
else
toolTipScene->setBackgroundBrush(QBrush(Qt::NoBrush));
bool down = false;
bool isBattery = false;
for (int i=0; i<requiredKeys.count(); i++) {
float normX = 100.0 / static_cast<float>(data[requiredKeys[i]].count());
float normY = 100.0 / (1.5 * boundaries[requiredKeys[i]]);
if (requiredKeys[i] == QString("bat"))
isBattery = true;
else
isBattery = false;
if (!isBattery) pen.setColor(QColor(m_settings[requiredKeys[i] + QString("Color")].toString()));
float shift = i * 100.0;
if (down) shift -= 100.0;
for (int j=0; j<data[requiredKeys[i]].count()-1; j++) {
float x1 = j * normX + shift;
float y1 = - fabs(data[requiredKeys[i]][j]) * normY + 5.0;
float x2 = (j + 1) * normX + shift;
float y2 = - fabs(data[requiredKeys[i]][j+1]) * normY + 5.0;
if (isBattery) {
if (data[requiredKeys[i]][j+1] > 0)
pen.setColor(QColor(m_settings[QString("batteryColor")].toString()));
else
pen.setColor(QColor(m_settings[QString("batteryInColor")].toString()));
}
toolTipScene->addLine(x1, y1, x2, y2, pen);
}
if (requiredKeys[i] == QString("down")) down = true;
}
return toolTipView->grab();
} }
@ -62,4 +133,15 @@ void AWToolTip::setData (const QString source, const float value, const bool ac)
data[source].append(value); data[source].append(value);
else else
data[source].append(-value); data[source].append(-value);
if ((source == QString("down")) || (source == QString("up"))) {
for (int i=0; i<data[QString("down")].count(); i++)
if (boundaries[QString("down")] < data[QString("down")][i])
boundaries[QString("down")] = data[QString("down")][i];
for (int i=0; i<data[QString("up")].count(); i++)
if (boundaries[QString("down")] < data[QString("up")][i])
boundaries[QString("down")] = data[QString("up")][i];
boundaries[QString("down")] *= 1.2;
boundaries[QString("up")] = boundaries[QString("down")];
}
} }

View File

@ -19,6 +19,8 @@
#ifndef AWTOOLTIP_H #ifndef AWTOOLTIP_H
#define AWTOOLTIP_H #define AWTOOLTIP_H
#include <QGraphicsScene>
#include <QGraphicsView>
#include <QMap> #include <QMap>
#include <QObject> #include <QObject>
#include <QPixmap> #include <QPixmap>
@ -39,10 +41,16 @@ public:
const bool ac = true); const bool ac = true);
private: private:
// ui
QGraphicsScene *toolTipScene = nullptr;
QGraphicsView *toolTipView = nullptr;
// variables // variables
bool debug = false; bool debug = false;
int m_counts = 0;
QMap<QString, QVariant> m_settings; QMap<QString, QVariant> m_settings;
QMap<QString, float> boundaries;
QMap<QString, QList<float>> data; QMap<QString, QList<float>> data;
QStringList requiredKeys;
}; };

View File

@ -261,8 +261,9 @@ QMap<QString, QString> ExtendedSysMon::updateConfiguration(QMap<QString, QString
(rawConfig[QString("GPUDEV")] != QString("nvidia"))) (rawConfig[QString("GPUDEV")] != QString("nvidia")))
rawConfig[QString("GPUDEV")] = getAutoGpu(); rawConfig[QString("GPUDEV")] = getAutoGpu();
// hdddev // hdddev
allHddDevices = getAllHdd().split(QChar(','), QString::SkipEmptyParts);
if (rawConfig[QString("HDDDEV")] == QString("all")) if (rawConfig[QString("HDDDEV")] == QString("all"))
rawConfig[QString("HDDDEV")] = getAllHdd(); rawConfig[QString("HDDDEV")] = allHddDevices.join(QChar(','));
else if (rawConfig[QString("HDDDEV")] == QString("disable")) else if (rawConfig[QString("HDDDEV")] == QString("disable"))
rawConfig[QString("HDDDEV")] = QString(""); rawConfig[QString("HDDDEV")] = QString("");
else { else {
@ -274,7 +275,7 @@ QMap<QString, QString> ExtendedSysMon::updateConfiguration(QMap<QString, QString
(diskRegexp.indexIn(deviceList[i]) > -1)) (diskRegexp.indexIn(deviceList[i]) > -1))
devices.append(deviceList[i]); devices.append(deviceList[i]);
if (devices.isEmpty()) if (devices.isEmpty())
rawConfig[QString("HDDDEV")] = getAllHdd(); rawConfig[QString("HDDDEV")] = allHddDevices.join(QChar(','));
else else
rawConfig[QString("HDDDEV")] = devices.join(QChar(',')); rawConfig[QString("HDDDEV")] = devices.join(QChar(','));
} }
@ -627,6 +628,9 @@ bool ExtendedSysMon::updateSourceEvent(const QString &source)
} else if (source == QString("gputemp")) { } else if (source == QString("gputemp")) {
setData(source, QString("value"), getGpuTemp(configuration[QString("GPUDEV")])); setData(source, QString("value"), getGpuTemp(configuration[QString("GPUDEV")]));
} else if (source == QString("hddtemp")) { } else if (source == QString("hddtemp")) {
// fill empty list
for (int i=0; i<allHddDevices.count(); i++)
setData(source, allHddDevices[i], 0.0);
QStringList deviceList = configuration[QString("HDDDEV")].split(QChar(','), QString::SkipEmptyParts); QStringList deviceList = configuration[QString("HDDDEV")].split(QChar(','), QString::SkipEmptyParts);
for (int i=0; i<deviceList.count(); i++) for (int i=0; i<deviceList.count(); i++)
setData(source, deviceList[i], setData(source, deviceList[i],

View File

@ -63,6 +63,7 @@ private:
// FIXME dirty hack to avoid update package information every second // FIXME dirty hack to avoid update package information every second
int pkgTimeUpdate = MSEC_IN_HOUR; int pkgTimeUpdate = MSEC_IN_HOUR;
// reread configuration // reread configuration
QStringList allHddDevices;
QString getAllHdd(); QString getAllHdd();
QString getAutoGpu(); QString getAutoGpu();
QString getAutoMpris(); QString getAutoMpris();