1 # -*- coding: utf-8 -*-
3 # (c) Copyright 2001-2009 Hewlett-Packard Development Company, L.P.
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 from base.codes import *
25 from ui_utils import *
28 from PyQt4.QtCore import *
29 from PyQt4.QtGui import *
32 class SystrayFrame(QFrame):
33 def __init__(self, parent):
34 QFrame.__init__(self, parent)
37 def initUi(self, systray_visible, polling, polling_interval, device_list, systray_messages,upgrade_notify,
38 upgrade_postpone_time, upgrade_msg):
40 self.systray_visible = systray_visible
41 self.polling = polling
42 self.polling_interval = polling_interval
43 self.device_list = device_list
44 self.systray_messages = systray_messages
45 self.upgrade_notify = upgrade_notify
46 self.upgrade_postpone_time =upgrade_postpone_time
47 self.upgrade_msg = upgrade_msg
49 self.gridlayout = QGridLayout(self)
51 self.frame = QFrame(self)
52 self.frame.setFrameShape(QFrame.StyledPanel)
53 self.frame.setFrameShadow(QFrame.Raised)
55 self.gridlayout1 = QGridLayout(self.frame)
57 self.groupBox_2 = QGroupBox(self.frame)
59 self.gridlayout2 = QGridLayout(self.groupBox_2)
61 self.ShowAlwaysRadioButton = QRadioButton(self.groupBox_2)
62 self.gridlayout2.addWidget(self.ShowAlwaysRadioButton,0,0,1,1)
64 self.HideWhenInactiveRadioButton = QRadioButton(self.groupBox_2)
65 self.gridlayout2.addWidget(self.HideWhenInactiveRadioButton,1,0,1,1)
67 self.HideAlwaysRadioButton = QRadioButton(self.groupBox_2)
68 self.gridlayout2.addWidget(self.HideAlwaysRadioButton,2,0,1,1)
70 self.gridlayout1.addWidget(self.groupBox_2,0,0,1,1)
72 self.groupBox_3 = QGroupBox(self.frame)
74 self.gridlayout3 = QGridLayout(self.groupBox_3)
76 self.label_2 = QLabel(self.groupBox_3)
77 self.gridlayout3.addWidget(self.label_2,0,0,1,1)
79 self.MessageShowComboBox = QComboBox(self.groupBox_3)
80 self.gridlayout3.addWidget(self.MessageShowComboBox,1,0,1,1)
82 self.MessageShowComboBox.addItem(self.__tr("All"), QVariant(SYSTRAY_MESSAGES_SHOW_ALL))
83 self.MessageShowComboBox.addItem(self.__tr("Errors and Warnings"), QVariant(SYSTRAY_MESSAGES_SHOW_ERRORS_AND_WARNINGS))
84 self.MessageShowComboBox.addItem(self.__tr("Errors Only"), QVariant(SYSTRAY_MESSAGES_SHOW_ERRORS_ONLY))
85 self.MessageShowComboBox.addItem(self.__tr("None"), QVariant(SYSTRAY_MESSAGES_SHOW_NONE))
87 spacerItem = QSpacerItem(20,40,QSizePolicy.Minimum,QSizePolicy.Minimum)
88 self.gridlayout3.addItem(spacerItem,2,0,1,1)
89 self.gridlayout1.addWidget(self.groupBox_3,0,1,1,1)
91 self.MonitorGroupBox = QGroupBox(self.frame)
92 self.MonitorGroupBox.setCheckable(True)
94 self.MonitorGroupBox.setEnabled(False)
96 self.gridlayout4 = QGridLayout(self.MonitorGroupBox)
98 self.label = QLabel(self.MonitorGroupBox)
99 self.gridlayout4.addWidget(self.label,0,0,1,1)
101 self.listWidget = QListWidget(self.MonitorGroupBox)
102 self.gridlayout4.addWidget(self.listWidget,1,0,1,1)
103 self.gridlayout1.addWidget(self.MonitorGroupBox,1,0,1,2)
106 #UpdategroupBox is same as "gridlayout5"
107 self.groupBox_4 = QGroupBox(self.frame)
108 self.UpdategroupBox = QGridLayout(self.groupBox_4)
109 self.UpdategroupBox.setObjectName("UpdategroupBox")
110 self.UpdatecheckBox = QCheckBox(self.groupBox_4)
111 self.UpdatecheckBox.setObjectName("UpdatecheckBox")
112 self.UpdategroupBox.addWidget(self.UpdatecheckBox,0,0,1,4)
113 self.label_5 = QLabel(self.groupBox_4)
114 self.label_5.setObjectName("label_5")
115 self.UpdategroupBox.addWidget(self.label_5, 1, 0, 1, 4)
116 self.textEdit = QTextEdit(self.groupBox_4)
117 self.textEdit.setObjectName("textEdit")
118 self.textEdit.setReadOnly(True)
119 self.UpdategroupBox.addWidget(self.textEdit, 2, 0, 1, 4)
120 self.gridlayout1.addWidget(self.groupBox_4,2,0,1,2)
122 self.gridlayout.addWidget(self.frame,0,0,1,1)
126 self.setWindowTitle(QApplication.translate("self", "self", None, QApplication.UnicodeUTF8))
127 self.groupBox_2.setTitle(QApplication.translate("self", "System tray icon visibility", None, QApplication.UnicodeUTF8))
128 self.ShowAlwaysRadioButton.setText(QApplication.translate("self", "Always show", None, QApplication.UnicodeUTF8))
129 self.HideWhenInactiveRadioButton.setText(QApplication.translate("self", "Hide when inactive", None, QApplication.UnicodeUTF8))
130 self.HideAlwaysRadioButton.setText(QApplication.translate("self", "Always hide", None, QApplication.UnicodeUTF8))
131 self.groupBox_3.setTitle(QApplication.translate("self", "System tray icon messages", None, QApplication.UnicodeUTF8))
132 self.label_2.setText(QApplication.translate("self", "Messages to show:", None, QApplication.UnicodeUTF8))
133 self.MonitorGroupBox.setTitle(QApplication.translate("self", "Monitor button presses on devices", None, QApplication.UnicodeUTF8))
134 self.label.setText(QApplication.translate("self", "Devices to monitor:", None, QApplication.UnicodeUTF8))
137 self.groupBox_4.setTitle(QApplication.translate("Dialog", "Update Settings", None, QApplication.UnicodeUTF8))
138 self.UpdatecheckBox.setText(QApplication.translate("Dialog", "Check and notify HPLIP updates", None, QApplication.UnicodeUTF8))
139 self.label_5.setText(QApplication.translate("Dialog", "Status:", None, QApplication.UnicodeUTF8))
140 self.textEdit.setPlainText(self.upgrade_msg)
143 self.connect(self.ShowAlwaysRadioButton, SIGNAL("clicked(bool)"), self.ShowAlwaysRadioButton_clicked)
144 self.connect(self.HideWhenInactiveRadioButton, SIGNAL("clicked(bool)"), self.HideWhenInactiveRadioButton_clicked)
145 self.connect(self.HideAlwaysRadioButton, SIGNAL("clicked(bool)"), self.HideAlwaysRadioButton_clicked)
146 self.connect(self.MessageShowComboBox, SIGNAL("activated(int)"), self.MessageShowComboBox_activated)
147 self.connect(self.UpdatecheckBox, SIGNAL("clicked(bool)"), self.UpdatecheckBox_clicked)
152 def UpdatecheckBox_clicked(self, b):
153 log.debug("Update HPLIP val =%d "%b)
155 self.upgrade_notify = False
157 self.upgrade_notify = True
160 self.updateVisibility()
161 self.updateMessages()
162 self.updateDeviceList()
163 self.updateUpgradeSettings()
166 def updateVisibility(self):
167 if self.systray_visible == SYSTRAY_VISIBLE_SHOW_ALWAYS:
168 self.ShowAlwaysRadioButton.setChecked(True)
170 elif self.systray_visible == SYSTRAY_VISIBLE_HIDE_WHEN_INACTIVE:
171 self.HideWhenInactiveRadioButton.setChecked(True)
173 else: # SYSTRAY_VISIBLE_HIDE_ALWAYS
174 self.HideAlwaysRadioButton.setChecked(True)
177 def ShowAlwaysRadioButton_clicked(self, b):
178 if b: self.systray_visible = SYSTRAY_VISIBLE_SHOW_ALWAYS
181 def HideWhenInactiveRadioButton_clicked(self, b):
182 if b: self.systray_visible = SYSTRAY_VISIBLE_HIDE_WHEN_INACTIVE
185 def HideAlwaysRadioButton_clicked(self, b):
186 if b: self.systray_visible = SYSTRAY_VISIBLE_HIDE_ALWAYS
189 def updateMessages(self):
190 i = self.MessageShowComboBox.findData(QVariant(self.systray_messages))
192 self.MessageShowComboBox.setCurrentIndex(i)
195 def MessageShowComboBox_activated(self, i):
196 sender = self.sender()
197 mode, ok = sender.itemData(i).toInt()
199 self.systray_messages = mode
202 def updateDeviceList(self):
205 def updateUpgradeSettings(self):
206 if self.upgrade_notify is True:
207 self.UpdatecheckBox.setChecked(True)
209 self.UpdatecheckBox.setChecked(False)
214 def __tr(self, s, c=None):
215 return QApplication.translate("SystrayFrame", s, c, QApplication.UnicodeUTF8)