129
136
QMessageBox.NoButton) == QMessageBox.Yes
131
138
if install_plugin:
132
ok = pkit.run_plugin_command(self.plugin_type == PLUGIN_REQUIRED)
139
ok, sudo_ok = pkit.run_plugin_command(self.plugin_type == PLUGIN_REQUIRED, self.parent.cur_device.mq['plugin-reason'])
134
141
QMessageBox.critical(self.parent,
135
142
self.parent.windowTitle(),
136
143
self.__tr("<b>Unable to find an appropriate su/sudo utility to run hp-plugin.</b><p>Install kdesu, gnomesu, or gksu.</p>"),
228
235
def initUI(self):
229
236
# Setup device icon list
230
237
self.DeviceList.setSortingEnabled(True)
238
self.DeviceList.setContextMenuPolicy(Qt.CustomContextMenu)
239
self.setDeviceListViewMode(QListView.IconMode)
241
self.connect(self.ViewAsIconsAction, SIGNAL("triggered()"), lambda: self.setDeviceListViewMode(QListView.IconMode))
242
self.connect(self.ViewAsListAction, SIGNAL("triggered()"), lambda: self.setDeviceListViewMode(QListView.ListMode))
244
self.connect(self.DeviceList, SIGNAL("customContextMenuRequested(const QPoint &)"), self.DeviceList_customContextMenuRequested)
232
246
# Setup main menu
233
247
self.DeviceRefreshAction.setIcon(QIcon(load_pixmap("refresh1", "16x16")))
511
525
self.rescanDevices()
528
def setDeviceListViewMode(self, mode):
529
if mode == QListView.ListMode:
530
self.DeviceList.setViewMode(QListView.ListMode)
531
self.ViewAsListAction.setEnabled(False)
532
self.ViewAsIconsAction.setEnabled(True)
534
self.DeviceList.setViewMode(QListView.IconMode)
535
self.ViewAsListAction.setEnabled(True)
536
self.ViewAsIconsAction.setEnabled(False)
514
539
def createDeviceIcon(self, dev=None):
516
541
dev = self.cur_device
822
846
# ***********************************************************************************
824
def DeviceList_rightButtonClicked(self, item, pos):
825
popup = QPopupMenu(self)
827
if item is not None and item is self.DeviceList.currentItem():
828
if self.cur_device.error_state != ERROR_STATE_ERROR:
829
if self.cur_device.device_type == DEVICE_TYPE_PRINTER:
830
popup.insertItem(self.__tr("Print..."), self.PrintButton_clicked)
832
if self.cur_device.scan_type:
833
popup.insertItem(self.__tr("Scan..."), self.ScanButton_clicked)
835
if self.cur_device.pcard_type:
836
popup.insertItem(self.__tr("Access Photo Cards..."), self.PCardButton_clicked)
838
if self.cur_device.copy_type:
839
popup.insertItem(self.__tr("Make Copies..."), self.MakeCopiesButton_clicked)
841
elif self.cur_device.device_type == DEVICE_TYPE_FAX:
842
if self.cur_device.fax_type:
843
popup.insertItem(self.__tr("Send Fax..."), self.SendFaxButton_clicked)
845
popup.insertSeparator()
848
def DeviceList_customContextMenuRequested(self, p):
852
avail = d.device_state != DEVICE_STATE_NOT_FOUND and d.supported
853
printer = d.device_type == DEVICE_TYPE_PRINTER and avail
855
fax = d.fax_type > FAX_TYPE_NONE and prop.fax_build and d.device_type == DEVICE_TYPE_FAX and \
856
sys.hexversion >= 0x020300f0 and avail
858
scan = d.scan_type > SCAN_TYPE_NONE and prop.scan_build and \
859
printer and self.user_settings.cmd_scan
861
cpy = d.copy_type > COPY_TYPE_NONE and printer
865
item = self.DeviceList.currentItem()
867
if self.cur_device.error_state != ERROR_STATE_ERROR:
869
popup.addAction(self.__tr("Print..."), lambda: self.contextMenuFunc(PrintDialog(self, self.cur_printer)))
872
popup.addAction(self.__tr("Scan..."), lambda: self.contextMenuFunc(self.user_settings.cmd_scan)) #self.ScanButton_clicked)
875
popup.addAction(self.__tr("Make Copies..."), lambda: MakeCopiesDialog(self, self.cur_device_uri)) #self.MakeCopiesButton_clicked)
877
else: # self.cur_device.device_type == DEVICE_TYPE_FAX:
879
popup.addAction(self.__tr("Send Fax..."), lambda: self.contextMenuFunc(SendFaxDialog(self, self.cur_printer, self.cur_device_uri))) #self.SendFaxButton_clicked)
883
if not self.updating:
884
popup.addAction(self.__tr("Refresh Device"), self.requestDeviceUpdate) #self.DeviceRefreshAction_activated)
847
886
if not self.updating:
848
popup.insertItem(self.__tr("Refresh Device"), self.DeviceRefreshAction_activated)
850
if not self.updating:
851
popup.insertItem(self.__tr("Refresh All"), self.RefreshAllAction_activated)
887
popup.addAction(self.__tr("Refresh All"), self.rescanDevices) #self.RefreshAllAction_activated)
891
if self.DeviceList.viewMode() == QListView.IconMode:
892
popup.addAction(self.__tr("View as List"), lambda: self.setDeviceListViewMode(QListView.ListMode))
894
popup.addAction(self.__tr("View as Icons"), lambda: self.setDeviceListViewMode(QListView.IconMode))
896
popup.exec_(self.DeviceList.mapToGlobal(p))
899
def contextMenuFunc(self, f):
900
self.sendMessage('', '', EVENT_DEVICE_STOP_POLLING)
904
except AttributeError:
907
if f.split(':')[0] in ('http', 'https', 'file'):
908
log.debug("Opening browser to: %s" % item.cmd)
911
self.runExternalCommand(f)
913
QTimer.singleShot(1000, self.unlockClick)
915
self.sendMessage('', '', EVENT_DEVICE_START_POLLING)
856
919
# ***********************************************************************************
908
973
if d is not None:
909
974
avail = d.device_state != DEVICE_STATE_NOT_FOUND and d.supported
910
fax = d.fax_type and prop.fax_build and d.device_type == DEVICE_TYPE_FAX and \
975
fax = d.fax_type > FAX_TYPE_NONE and prop.fax_build and d.device_type == DEVICE_TYPE_FAX and \
911
976
sys.hexversion >= 0x020300f0 and avail
912
977
printer = d.device_type == DEVICE_TYPE_PRINTER and avail
978
scan = d.scan_type > SCAN_TYPE_NONE and prop.scan_build and \
979
printer and self.user_settings.cmd_scan
980
cpy = d.copy_type > COPY_TYPE_NONE and printer
913
981
req_plugin = d.plugin == PLUGIN_REQUIRED
914
982
opt_plugin = d.plugin == PLUGIN_OPTIONAL
917
back_end, is_hp, bus, model, serial, dev_file, host, port = \
985
back_end, is_hp, bus, model, serial, dev_file, host, zc, port = \
918
986
device.parseDeviceURI(self.cur_device_uri)
960
1028
self.__tr("Print documents or files."), # Tooltip
961
1029
lambda : PrintDialog(self, self.cur_printer)), # command/action
963
(lambda : d.scan_type > SCAN_TYPE_NONE and prop.scan_build and \
964
printer and self.user_settings.cmd_scan,
965
1032
self.__tr("Scan"),
967
1034
self.__tr("Scan a document, image, or photograph.<br>"),
968
1035
self.user_settings.cmd_scan),
970
(lambda : d.copy_type and printer,
971
1038
self.__tr("Make Copies"),
973
1040
self.__tr("Make copies on the device controlled by the PC.<br>"),
1049
1116
self.__tr("Your printer can print a test page <br>to help diagnose print quality problems."),
1050
1117
lambda : PQDiagDialog(self, self.cur_device_uri)),
1119
(lambda: printer and d.wifi_config >= WIFI_CONFIG_USB_XML and bus == 'usb',
1120
self.__tr("Wireless/wifi setup using USB"),
1122
self.__tr("Configure your wireless capable printer using a temporary USB connection."),
1123
'hp-wificonfig -d %s' % self.cur_device_uri),
1054
1127
(lambda : printer and d.fw_download ,
1332
1404
self.TYPE_TO_PIX_MAP = {
1333
1405
AGENT_TYPE_UNSPECIFIED : [black],
1334
1406
AGENT_TYPE_BLACK: [black],
1407
AGENT_TYPE_BLACK_B8800: [black],
1335
1408
AGENT_TYPE_CMY: [cyan, magenta, yellow],
1336
1409
AGENT_TYPE_KCM: [light_cyan, light_magenta, light_yellow],
1337
1410
AGENT_TYPE_GGK: [dark_grey],
2033
2108
return qApp.translate("DevMgr5",s,c)
2111
# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
2036
2113
class PasswordDialog(QDialog):
2037
2114
def __init__(self, prompt, parent=None, name=None, modal=0, fl=0):
2038
2115
QDialog.__init__(self, parent)
2116
self.prompt = prompt
2040
2118
Layout= QGridLayout(self)
2041
2119
Layout.setMargin(11)