From ee39ac92037818a0c9ec56acc7ef9eee2574263c Mon Sep 17 00:00:00 2001 From: arcan1s Date: Sat, 2 Aug 2014 17:49:25 +0400 Subject: [PATCH] add background settings to the tooltip --- sources/ptm/contents/code/configdef.py | 13 +++++- sources/ptm/contents/code/main.py | 2 + sources/ptm/contents/code/reinit.py | 1 + sources/ptm/contents/code/tooltip.py | 4 ++ sources/ptm/contents/code/tooltipconfig.py | 11 +++++- sources/ptm/contents/ui/tooltipconfig.ui | 46 ++++++++++++++++++++++ sources/ptm/contents/ui/widget.ui | 4 ++ 7 files changed, 78 insertions(+), 3 deletions(-) diff --git a/sources/ptm/contents/code/configdef.py b/sources/ptm/contents/code/configdef.py index 46a4766..ce05d62 100644 --- a/sources/ptm/contents/code/configdef.py +++ b/sources/ptm/contents/code/configdef.py @@ -88,6 +88,10 @@ class ConfigDefinition: settings.set('ac_offline', str(self.configpage['advanced'].ui.lineEdit_acOffline.text())) settings.set('tooltip_num', self.configpage['tooltip'].ui.spinBox_tooltipNum.value()) + if (self.configpage['tooltip'].checkBox_background.checkState() == 0): + settings.set("tooltip_background", "null") + else: + settings.set("tooltip_background", str(self.configpage['tooltip'].kcolorcombos["background"].color().name())) for label in ['cpu', 'cpuclock', 'mem', 'swap', 'down', 'up']: settings.set(self.defaults['confColor'][label], str(self.configpage['tooltip'].kcolorcombos[label].color().name())) @@ -216,6 +220,11 @@ class ConfigDefinition: self.configpage['advanced'].ui.lineEdit_acOffline.setText(str(settings.get('ac_offline', '( )'))) self.configpage['tooltip'].ui.spinBox_tooltipNum.setValue(settings.get('tooltip_num', 100).toInt()[0]) + if (str(settings.get('tooltip_background', 'null')) == "null"): + self.configpage['tooltip'].checkBox_background.setCheckState(0) + else: + self.configpage['tooltip'].checkBox_background.setCheckState(2) + self.configpage['tooltip'].ui.kcolorcombo_cpu.setColor(QColor(str(settings.get('tooltip_background', 'null')))) self.configpage['tooltip'].ui.kcolorcombo_cpu.setColor(QColor(str(settings.get('cpu_color', '#ff0000')))) self.configpage['tooltip'].ui.kcolorcombo_cpuclock.setColor(QColor(str(settings.get('cpuclock_color', '#00ff00')))) self.configpage['tooltip'].ui.kcolorcombo_mem.setColor(QColor(str(settings.get('mem_color', '#0000ff')))) @@ -253,8 +262,8 @@ class ConfigDefinition: self.configpage['dataengine'].ui.lineEdit_mpdaddress.setText(deSettings['MPDADDRESS']) self.configpage['dataengine'].ui.spinBox_mpdport.setValue(int(deSettings['MPDPORT'])) self.configpage['dataengine'].ui.spinBox_mpdport.setValue(int(deSettings['MPDPORT'])) - index = self.configpage['dataengine'].ui.comboBox_mpris.findText(deSettings['MPRIS']) - self.configpage['dataengine'].ui.comboBox_mpris.setCurrentIndex(index) + self.configpage['dataengine'].ui.comboBox_mpris.addItem(deSettings['MPRIS']) + self.configpage['dataengine'].ui.comboBox_mpris.setCurrentIndex(self.configpage['dataengine'].ui.comboBox_mpris.count()-1) self.configpage['dataengine'].ui.listWidget_pkgCommand.clear() for i in range(len(deSettings['PKGCMD'].split(','))): try: diff --git a/sources/ptm/contents/code/main.py b/sources/ptm/contents/code/main.py index da5d000..1393808 100644 --- a/sources/ptm/contents/code/main.py +++ b/sources/ptm/contents/code/main.py @@ -201,6 +201,8 @@ class pyTextWidget(plasmascript.Applet): # graphical tooltip self.tooltipScene = QGraphicsScene() self.tooltipView = QGraphicsView(self.tooltipScene) + self.tooltipView.setStyleSheet("background: transparent") + self.tooltipView.setContentsMargins(0, 0, 0, 0) self.tooltipView.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.tooltipView.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) # show tooltip diff --git a/sources/ptm/contents/code/reinit.py b/sources/ptm/contents/code/reinit.py index cc136f8..c47b484 100644 --- a/sources/ptm/contents/code/reinit.py +++ b/sources/ptm/contents/code/reinit.py @@ -72,6 +72,7 @@ class Reinit(): ptmVars['tooltip'] = {} ptmVars['tooltip']['colors'] = {} + ptmVars['tooltip']['colors']['background'] = str(settings.get('tooltip_background', 'null')) ptmVars['tooltip']['colors']['cpu'] = str(settings.get('cpu_color', '#ff0000')) ptmVars['tooltip']['colors']['cpuclock'] = str(settings.get('cpuclock_color', '#00ff00')) ptmVars['tooltip']['colors']['mem'] = str(settings.get('mem_color', '#0000ff')) diff --git a/sources/ptm/contents/code/tooltip.py b/sources/ptm/contents/code/tooltip.py index 6e2b21d..45989fa 100644 --- a/sources/ptm/contents/code/tooltip.py +++ b/sources/ptm/contents/code/tooltip.py @@ -47,6 +47,10 @@ class Tooltip(): values = ptmTooltip['values'] maxOne = [100.0, 100.0] bounds['down'] = 1.0 + if (colors['background'] != "null"): + widget.setBackgroundBrush(QColor(colors['background'])) + else: + widget.setBackgroundBrush(QBrush(Qt.NoBrush)) for value in values['down']: if (bounds['down'] < value): bounds['down'] = value diff --git a/sources/ptm/contents/code/tooltipconfig.py b/sources/ptm/contents/code/tooltipconfig.py index 7adac2d..6db7d1c 100644 --- a/sources/ptm/contents/code/tooltipconfig.py +++ b/sources/ptm/contents/code/tooltipconfig.py @@ -38,7 +38,16 @@ class TooltipWindow(QWidget): QWidget.__init__(self) self.ui = uic.loadUi(parent.package().filePath('ui', 'tooltipconfig.ui'), self) self.parent = parent - self.kcolorcombos = {'cpu':self.ui.kcolorcombo_cpu, + self.kcolorcombos = {'background':self.ui.kcolorcombo_background, 'cpu':self.ui.kcolorcombo_cpu, 'cpuclock':self.ui.kcolorcombo_cpuclock, 'down':self.ui.kcolorcombo_down, 'mem':self.ui.kcolorcombo_mem, 'swap':self.ui.kcolorcombo_swap, 'up':self.ui.kcolorcombo_up} + QObject.connect(self.ui.checkBox_background, SIGNAL("stateChanged(int)"), self.setBackground) + + + def setBackground(self, background=0): + """function to enable/disable background elements""" + if (background == 0): + self.kcolorcombos['background'].setDisabled(True) + else: + self.kcolorcombos['background'].setEnabled(True) diff --git a/sources/ptm/contents/ui/tooltipconfig.ui b/sources/ptm/contents/ui/tooltipconfig.ui index 3d4c00d..f61e6ee 100644 --- a/sources/ptm/contents/ui/tooltipconfig.ui +++ b/sources/ptm/contents/ui/tooltipconfig.ui @@ -115,6 +115,49 @@ + + + + + + + 200 + 0 + + + + Background + + + true + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 180 + 0 + + + + + + @@ -382,7 +425,10 @@ + scrollArea_tooltip spinBox_tooltipNum + checkBox_background + kcolorcombo_background kcolorcombo_cpuclock kcolorcombo_swap kcolorcombo_cpu diff --git a/sources/ptm/contents/ui/widget.ui b/sources/ptm/contents/ui/widget.ui index 4e01806..02c0972 100644 --- a/sources/ptm/contents/ui/widget.ui +++ b/sources/ptm/contents/ui/widget.ui @@ -1233,6 +1233,7 @@ $total - total number of desktops + scrollArea_settings checkBox_time lineEdit_time slider_time @@ -1287,6 +1288,9 @@ $total - total number of desktops checkBox_custom lineEdit_custom slider_custom + checkBox_desktop + lineEdit_desktop + slider_desktop