def fileListView_rightButtonClicked(self, item, pos, col):
        popup = QPopupMenu(self)
        popup.insertItem(QIconSet(load_pixmap('list_add', '16x16')),
            self.__tr("Add File..."), self.addFile_clicked)

        if item is not None:
            popup.insertItem(QIconSet(load_pixmap('list_remove', '16x16')),
                self.__tr("Remove File"), self.removeFile_clicked)

            if self.fileListView.childCount() > 1:
                last_item = self.fileListView.firstChild()
                while last_item is not None and last_item.nextSibling():
                    last_item = last_item.nextSibling()

                if item is not self.fileListView.firstChild():
                    popup.insertItem(QIconSet(load_pixmap('up', '16x16')),
                        self.__tr("Move Up"), self.moveFileUp_clicked)

                if item is not last_item:
                    popup.insertItem(QIconSet(load_pixmap('down', '16x16')),
                        self.__tr("Move Down"), self.moveFileDown_clicked)

        popup.insertSeparator(-1)
        popup.insertItem(QIconSet(load_pixmap('mimetypes', '16x16')),
            self.__tr("Show File Types..."), self.showFileTypes_clicked)

        popup.popup(pos)
示例#2
0
    def __init__(self, cover_page_name='', preserve_formatting=False, parent=None, name=None, modal=0, fl=0):
        CoverpageForm_base.__init__(self, parent, name, modal, fl)

        self.preserve_formatting = preserve_formatting
        self.preserveFormattingCheckBox.setChecked(preserve_formatting)
        self.prevCoverpageButton.setPixmap(load_pixmap('prev', '16x16'))
        self.nextCoverpageButton.setPixmap(load_pixmap('next', '16x16'))
        self.coverpage_list = coverpages.COVERPAGES.keys()

        if cover_page_name:
            self.coverpage_index = self.coverpage_list.index(cover_page_name)
        else:    
            self.coverpage_index = 0

        self.setCoverpage()
示例#3
0
    def __init__(self, parent=None, name="",modal=0, fl=0,distro_type= 1,msg=""):
        UpgradeForm_base.__init__(self, parent,  name, modal, fl,distro_type, msg)

        self.msg = msg
        self.distro_type = distro_type
        self.setIcon(load_pixmap('hp_logo', '128x128'))
        self.initUi()
示例#4
0
    def addLoadPaper(self, paper_type=PAPER_TYPE_PLAIN):
        self.addGroupHeading("load_paper", self.__tr("Load Paper"))

        widget = self.getWidget()
        layout1 = QGridLayout(widget, 1, 2, 5, 10,"layout1")

        layout1.setColStretch(0, 1)
        layout1.setColStretch(1, 10)

        icon = QLabel(widget, "icon")
        icon.setSizePolicy(QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed, 0, 0,
            icon.sizePolicy().hasHeightForWidth()))

        icon.setScaledContents(1)
        layout1.addWidget(icon, 0, 0)

        textLabel = QLabel(widget, "textLabel")
        textLabel.setAlignment(QLabel.WordBreak)
        textLabel.setSizePolicy(QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Preferred, 0, 0,
            textLabel.sizePolicy().hasHeightForWidth()))        
        textLabel.setFrameShape(self.frame_shape)
        layout1.addWidget(textLabel, 0, 1)

        spacer1 = QSpacerItem(20, 20, QSizePolicy.Expanding, QSizePolicy.Minimum)
        layout1.addItem(spacer1, 0, 2)

        if paper_type == PAPER_TYPE_PLAIN:
            textLabel.setText(self.__tr("A page will be printed. Please load Letter/A4 <b>Plain Paper</b> into the printer."))
        elif paper_type == PAPER_TYPE_HP_ADV_PHOTO:
            textLabel.setText(self.__tr("A page will be printed. Please load Letter/A4 <b>HP Advanced Photo Paper - Glossy</b> into the printer."))

        icon.setPixmap(load_pixmap("load_paper", 'other'))

        self.addWidget(widget, "load_paper")
示例#5
0
    def __init__(self, parent=None, pixmap=None, disabled_pixmap=None, name='', subdir=None):
        QPushButton.__init__(self, parent, name)

        if subdir is None:
            subdir = '16x16'

        if type(pixmap) == type(''):
            self.pixmap = load_pixmap(pixmap, subdir)
        else:
            self.pixmap = pixmap

        if type(disabled_pixmap) == type(''):
            self.disabled_pixmap = load_pixmap(disabled_pixmap, subdir) 
        else:
            self.disabled_pixmap = disabled_pixmap

        self.pixmap_width, self.pixmap_height = self.pixmap.width(), self.pixmap.height()
        self.width_set = None
示例#6
0
    def __init__(self,parent = None,name = None,modal = 0,fl = 0):
        FaxAddrBookForm_base.__init__(self,parent,name,modal,fl)

        self.setIcon(load_pixmap('hp_logo', '128x128'))

        global db
        db =  fax.FaxAddressBook()
        self.init_problem = False

        QTimer.singleShot(0, self.InitialUpdate)
示例#7
0
    def __init__(self,
                 cover_page_name='',
                 preserve_formatting=False,
                 parent=None,
                 name=None,
                 modal=0,
                 fl=0):
        CoverpageForm_base.__init__(self, parent, name, modal, fl)

        self.preserve_formatting = preserve_formatting
        self.preserveFormattingCheckBox.setChecked(preserve_formatting)
        self.prevCoverpageButton.setPixmap(load_pixmap('prev', '16x16'))
        self.nextCoverpageButton.setPixmap(load_pixmap('next', '16x16'))
        self.coverpage_list = coverpages.COVERPAGES.keys()

        if cover_page_name:
            self.coverpage_index = self.coverpage_list.index(cover_page_name)
        else:
            self.coverpage_index = 0

        self.setCoverpage()
示例#8
0
    def __init__(self, pattern, align_type=ALIGN_TYPE_LBOW, parent = None, name = None, modal = 0, fl = 0):
        Align10Form_Base.__init__(self,parent,name,modal,fl)
        self.Icon.setPixmap(load_pixmap('align10'))

        self.controls = maint.align10and11Controls(pattern, align_type)

        for line in self.controls:
            if not self.controls[line][0]:
                eval('self.comboBox%s.setEnabled(False)' % line)
            else:
                for x in range(self.controls[line][1]):
                    eval('self.comboBox%s.insertItem("%s%d")' % (line, line, x+1))
示例#9
0
    def setCoverpage(self, inc=0):
        self.coverpage_index += inc

        if self.coverpage_index > len(self.coverpage_list) - 1:
            self.coverpage_index = 0

        elif self.coverpage_index < 0:
            self.coverpage_index = len(self.coverpage_list) - 1

        self.coverpage_name = self.coverpage_list[self.coverpage_index]
        self.data = coverpages.COVERPAGES[self.coverpage_name]

        self.coverpagePixmap.setPixmap(load_pixmap(self.data[1], 'other'))
示例#10
0
    def setCoverpage(self, inc=0):
        self.coverpage_index += inc

        if self.coverpage_index > len(self.coverpage_list) - 1:
            self.coverpage_index = 0

        elif self.coverpage_index < 0:
            self.coverpage_index = len(self.coverpage_list) - 1

        self.coverpage_name = self.coverpage_list[self.coverpage_index]
        self.data = coverpages.COVERPAGES[self.coverpage_name]

        self.coverpagePixmap.setPixmap(load_pixmap(self.data[1], 'other'))
示例#11
0
    def __init__(self,
                 parent=None,
                 name="",
                 modal=0,
                 fl=0,
                 distro_type=1,
                 msg=""):
        UpgradeForm_base.__init__(self, parent, name, modal, fl, distro_type,
                                  msg)

        self.msg = msg
        self.distro_type = distro_type
        self.setIcon(load_pixmap('hp_logo', '128x128'))
        self.initUi()
    def __init__(self, args, read_pipe):
        QApplication.__init__(self, args)

        self.read_pipe = read_pipe
        self.fmt = "80s80sI32sI80sf"
        self.fmt_size = struct.calcsize(self.fmt)

        self.tray_icon = SystrayIcon(load_pixmap("hp_logo", "32x32", (22, 22)))
        self.menu = QPopupMenu()

        title_item = TitleItem(load_pixmap('hp_logo', '16x16', (16, 16)),
                               "HP Status Service")
        i = self.menu.insertItem(title_item)
        self.menu.setItemEnabled(i, False)

        self.menu.insertSeparator()

        self.menu.insertItem(self.tr("HP Device Manager..."),
                             self.toolbox_triggered)

        # TODO:
        #icon2 = QIconSet(load_pixmap('settings', '16x16'))
        #self.menu.insertItem(icon2, self.tr("Options..."), self.preferences_triggered)

        self.menu.insertSeparator()

        icon3 = QIconSet(load_pixmap('quit', '16x16'))
        self.menu.insertItem(icon3, self.tr("Quit"), self.quit_triggered)

        self.tray_icon.show()

        notifier = QSocketNotifier(self.read_pipe, QSocketNotifier.Read)
        QObject.connect(notifier, SIGNAL("activated(int)"),
                        self.notifier_activated)

        QObject.connect(self.tray_icon,
                        PYSIGNAL("contextMenuRequested(const QPoint&)"),
                        self.menu_requested)

        self.icon_info = load_pixmap('info', '16x16')
        self.icon_warn = load_pixmap('warning', '16x16')
        self.icon_error = load_pixmap('error', '16x16')

        self.ERROR_STATE_TO_ICON = {
            ERROR_STATE_CLEAR: self.icon_info,
            ERROR_STATE_OK: self.icon_info,
            ERROR_STATE_WARNING: self.icon_warn,
            ERROR_STATE_ERROR: self.icon_error,
            ERROR_STATE_LOW_SUPPLIES: self.icon_warn,
            ERROR_STATE_BUSY: self.icon_warn,
            ERROR_STATE_LOW_PAPER: self.icon_warn,
            ERROR_STATE_PRINTING: self.icon_info,
            ERROR_STATE_SCANNING: self.icon_info,
            ERROR_STATE_PHOTOCARD: self.icon_info,
            ERROR_STATE_FAXING: self.icon_info,
            ERROR_STATE_COPYING: self.icon_info,
        }
示例#13
0
    def __init__(self,
                 parent=None,
                 pixmap=None,
                 disabled_pixmap=None,
                 name='',
                 subdir=None):
        QPushButton.__init__(self, parent, name)

        if subdir is None:
            subdir = '16x16'

        if type(pixmap) == type(''):
            self.pixmap = load_pixmap(pixmap, subdir)
        else:
            self.pixmap = pixmap

        if type(disabled_pixmap) == type(''):
            self.disabled_pixmap = load_pixmap(disabled_pixmap, subdir)
        else:
            self.disabled_pixmap = disabled_pixmap

        self.pixmap_width, self.pixmap_height = self.pixmap.width(
        ), self.pixmap.height()
        self.width_set = None
示例#14
0
    def __init__(self, msg_icon, title, msg, tray_icon):
        QDialog.__init__(
            self, tray_icon, "BalloonTip", False,
            Qt.WStyle_StaysOnTop | Qt.WStyle_Customize | Qt.WStyle_NoBorder
            | Qt.WStyle_Tool | Qt.WX11BypassWM)

        self.timerId = None
        self.bubbleActive = False

        QObject.connect(tray_icon, SIGNAL("destroyed()"), self.close)

        self.titleLabel = QLabel(self)
        self.titleLabel.installEventFilter(self)
        self.titleLabel.setText(title)
        f = self.titleLabel.font()
        f.setBold(True)
        self.titleLabel.setFont(f)
        self.titleLabel.setTextFormat(
            Qt.PlainText)  # to maintain compat with windows

        self.closeButton = QPushButton(self)
        self.closeButton.setPixmap(load_pixmap('close', '16x16'))
        self.closeButton.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
        self.closeButton.setFixedSize(18, 18)
        QObject.connect(self.closeButton, SIGNAL("clicked()"), self.close)

        self.msgLabel = QLabel(self)
        self.msgLabel.installEventFilter(self)
        self.msgLabel.setText(msg)
        self.msgLabel.setTextFormat(Qt.PlainText)
        self.msgLabel.setAlignment(Qt.AlignTop | Qt.AlignLeft)

        layout = QGridLayout(self)
        if msg_icon is not None:
            self.iconLabel = QLabel(self)
            self.iconLabel.setPixmap(msg_icon)
            self.iconLabel.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
            self.iconLabel.setMargin(2)
            layout.addWidget(self.iconLabel, 0, 0)
            layout.addWidget(self.titleLabel, 0, 1)
        else:
            layout.addMultiCellWidget(self.titleLabel, 0, 1, 0, 2)

        layout.addWidget(self.closeButton, 0, 3)
        layout.addMultiCellWidget(self.msgLabel, 1, 1, 0, 3)
        layout.setMargin(3)
        self.setPaletteBackgroundColor(QColor(255, 255, 224))
    def __init__(self, args, read_pipe):
        QApplication.__init__(self, args)

        self.read_pipe = read_pipe
        self.fmt = "80s80sI32sI80sf"
        self.fmt_size = struct.calcsize(self.fmt)

        self.tray_icon = SystrayIcon(load_pixmap("hp_logo", "32x32", (22, 22)))
        self.menu = QPopupMenu()

        title_item = TitleItem(load_pixmap('hp_logo', '16x16', (16, 16)), "HP Status Service")
        i = self.menu.insertItem(title_item)
        self.menu.setItemEnabled(i, False)

        self.menu.insertSeparator()

        self.menu.insertItem(self.tr("HP Device Manager..."), self.toolbox_triggered)

        # TODO:
        #icon2 = QIconSet(load_pixmap('settings', '16x16'))
        #self.menu.insertItem(icon2, self.tr("Options..."), self.preferences_triggered)

        self.menu.insertSeparator()

        icon3 = QIconSet(load_pixmap('quit', '16x16'))
        self.menu.insertItem(icon3, self.tr("Quit"),  self.quit_triggered)

        self.tray_icon.show()

        notifier = QSocketNotifier(self.read_pipe, QSocketNotifier.Read)
        QObject.connect(notifier, SIGNAL("activated(int)"), self.notifier_activated)

        QObject.connect(self.tray_icon, PYSIGNAL("contextMenuRequested(const QPoint&)"), self.menu_requested)

        self.icon_info = load_pixmap('info', '16x16')
        self.icon_warn = load_pixmap('warning', '16x16')
        self.icon_error = load_pixmap('error', '16x16')

        self.ERROR_STATE_TO_ICON = {
            ERROR_STATE_CLEAR: self.icon_info,
            ERROR_STATE_OK: self.icon_info,
            ERROR_STATE_WARNING: self.icon_warn,
            ERROR_STATE_ERROR: self.icon_error,
            ERROR_STATE_LOW_SUPPLIES: self.icon_warn,
            ERROR_STATE_BUSY: self.icon_warn,
            ERROR_STATE_LOW_PAPER: self.icon_warn,
            ERROR_STATE_PRINTING: self.icon_info,
            ERROR_STATE_SCANNING: self.icon_info,
            ERROR_STATE_PHOTOCARD: self.icon_info,
            ERROR_STATE_FAXING: self.icon_info,
            ERROR_STATE_COPYING: self.icon_info,
        }
示例#16
0
    def __init__(self, msg_icon, title, msg, tray_icon):
        QDialog.__init__(self, tray_icon, "BalloonTip", False,
        Qt.WStyle_StaysOnTop | Qt.WStyle_Customize | Qt.WStyle_NoBorder | Qt.WStyle_Tool | Qt.WX11BypassWM)

        self.timerId = None
        self.bubbleActive = False

        QObject.connect(tray_icon, SIGNAL("destroyed()"), self.close)

        self.titleLabel = QLabel(self)
        self.titleLabel.installEventFilter(self)
        self.titleLabel.setText(title)
        f = self.titleLabel.font()
        f.setBold(True)
        self.titleLabel.setFont(f)
        self.titleLabel.setTextFormat(Qt.PlainText) # to maintain compat with windows

        self.closeButton = QPushButton(self)
        self.closeButton.setPixmap(load_pixmap('close', '16x16'))
        self.closeButton.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
        self.closeButton.setFixedSize(18, 18)
        QObject.connect(self.closeButton, SIGNAL("clicked()"), self.close)

        self.msgLabel = QLabel(self)
        self.msgLabel.installEventFilter(self)
        self.msgLabel.setText(msg)
        self.msgLabel.setTextFormat(Qt.PlainText)
        self.msgLabel.setAlignment(Qt.AlignTop | Qt.AlignLeft)

        layout = QGridLayout(self)
        if msg_icon is not None:
            self.iconLabel = QLabel(self)
            self.iconLabel.setPixmap(msg_icon)
            self.iconLabel.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
            self.iconLabel.setMargin(2)
            layout.addWidget(self.iconLabel, 0, 0)
            layout.addWidget(self.titleLabel, 0, 1)
        else:
            layout.addMultiCellWidget(self.titleLabel, 0, 1, 0, 2)

        layout.addWidget(self.closeButton, 0, 3)
        layout.addMultiCellWidget(self.msgLabel, 1, 1, 0, 3)
        layout.setMargin(3)
        self.setPaletteBackgroundColor(QColor(255, 255, 224))
示例#17
0
    def __init__(self,
                 pattern,
                 align_type=ALIGN_TYPE_LBOW,
                 parent=None,
                 name=None,
                 modal=0,
                 fl=0):
        Align10Form_Base.__init__(self, parent, name, modal, fl)
        self.Icon.setPixmap(load_pixmap('align10'))

        self.controls = maint.align10and11and14Controls(pattern, align_type)

        for line in self.controls:
            if not self.controls[line][0]:
                eval('self.comboBox%s.setEnabled(False)' % line)
            else:
                for x in range(self.controls[line][1]):
                    eval('self.comboBox%s.insertItem("%s%d")' %
                         (line, line, x + 1))
示例#18
0
    def addLoadPaper(self, paper_type=PAPER_TYPE_PLAIN):
        self.addGroupHeading("load_paper", self.__tr("Load Paper"))

        widget = self.getWidget()
        layout1 = QGridLayout(widget, 1, 2, 5, 10, "layout1")

        layout1.setColStretch(0, 1)
        layout1.setColStretch(1, 10)

        icon = QLabel(widget, "icon")
        icon.setSizePolicy(
            QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed, 0, 0,
                        icon.sizePolicy().hasHeightForWidth()))

        icon.setScaledContents(1)
        layout1.addWidget(icon, 0, 0)

        textLabel = QLabel(widget, "textLabel")
        textLabel.setAlignment(QLabel.WordBreak)
        textLabel.setSizePolicy(
            QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Preferred, 0, 0,
                        textLabel.sizePolicy().hasHeightForWidth()))
        textLabel.setFrameShape(self.frame_shape)
        layout1.addWidget(textLabel, 0, 1)

        spacer1 = QSpacerItem(20, 20, QSizePolicy.Expanding,
                              QSizePolicy.Minimum)
        layout1.addItem(spacer1, 0, 2)

        if paper_type == PAPER_TYPE_PLAIN:
            textLabel.setText(
                self.__tr(
                    "A page will be printed. Please load Letter/A4 <b>Plain Paper</b> into the printer."
                ))
        elif paper_type == PAPER_TYPE_HP_ADV_PHOTO:
            textLabel.setText(
                self.__tr(
                    "A page will be printed. Please load Letter/A4 <b>HP Advanced Photo Paper - Glossy</b> into the printer."
                ))

        icon.setPixmap(load_pixmap("load_paper", 'other'))

        self.addWidget(widget, "load_paper")
示例#19
0
    def __init__(self, parent, dev, cleaning_level, name=None, modal=0, fl=0):
        CleaningForm_base.__init__(self, parent, name, modal, fl)
        self.dev = dev

        text = unicode(self.CleaningText.text())
        self.CleaningText.setText(text % str(cleaning_level + 1))

        text = unicode(self.Continue.text())
        self.Continue.setText(text % str(cleaning_level + 1))

        text = unicode(self.CleaningTitle.text())
        self.CleaningTitle.setText(text % str(cleaning_level))

        self.Icon.setPixmap(load_pixmap('clean.png', 'other'))

        self.check_timer = QTimer(self, "CheckTimer")
        self.connect(self.check_timer, SIGNAL('timeout()'), self.CheckTimerTimeout)

        self.check_timer.start(3000)
示例#20
0
    def __init__(self, parent, dev, cleaning_level, name=None, modal=0, fl=0):
        CleaningForm_base.__init__(self, parent, name, modal, fl)
        self.dev = dev

        text = unicode(self.CleaningText.text())
        self.CleaningText.setText(text % str(cleaning_level + 1))

        text = unicode(self.Continue.text())
        self.Continue.setText(text % str(cleaning_level + 1))

        text = unicode(self.CleaningTitle.text())
        self.CleaningTitle.setText(text % str(cleaning_level))

        self.Icon.setPixmap(load_pixmap('clean.png', 'other'))

        self.check_timer = QTimer(self, "CheckTimer")
        self.connect(self.check_timer, SIGNAL('timeout()'),
                     self.CheckTimerTimeout)

        self.check_timer.start(3000)
示例#21
0
    def __init__(self, bus, param, jd_port=1, parent=None, name=None, modal=0, fl=0):
        SetupForm_base.__init__(self, parent, name, modal, fl)

        self.start_page = self.ConnectionPage
        self.first_page = True

        if bus is None:
            self.bus = 'usb'
        else:
            self.bus = bus[0]
            self.start_page = self.ProbedDevicesPage

        if not prop.par_build:
            self.parRadioButton.setEnabled(False)

        if not prop.net_build:
            self.netRadioButton.setEnabled(False)

        if not prop.par_build and not prop.net_build:
            self.bus = 'usb'
            self.start_page = self.ProbedDevicesPage

        self.param = param
        self.jd_port = jd_port

        if self.param:
            # Validate param...
            device_uri, sane_uri, fax_uri = device.makeURI(self.param, self.jd_port)

            if device_uri:
                self.device_uri = device_uri
                self.start_page = self.PPDPage

            else:
                self.FailureUI(self.__tr("<b>Device not found.</b> <p>Please make sure your printer is properly connected and powered-on."))

        self.setIcon(load_pixmap('hp_logo', '128x128'))

        self.connectionTypeButtonGroup.setButton(0)
        self.device_uri = ''
        self.mq = {}
        self.prev_page = None
        self.probe_pat = re.compile(r'(.*?)\s"(.*?)"\s"(.*?)"\s"(.*?)"', re.IGNORECASE)
        self.printer_name = ''
        self.ppd_list = []
        self.location = ''
        self.desc = ''
        self.filter = []
        self.search = ''
        self.ttl = 4
        self.timeout = 5
        self.printer_name_ok = True
        self.fax_name_ok = True
        self.fax_number = ''
        self.fax_name = ''
        self.printer_fax_names_same = False
        self.fax_name_company = ''
        self.fax_location = ''
        self.fax_desc = ''
        self.print_test_page = True
        self.printerNameLineEdit.setValidator(PrinterNameValidator(self.printerNameLineEdit))
        self.faxNameLineEdit.setValidator(PrinterNameValidator(self.faxNameLineEdit))
        self.faxNumberLineEdit.setValidator(PhoneNumValidator(self.faxNumberLineEdit))
        self.setTitleFont(QFont("Helvetica", 16))
        self.setBackEnabled(self.FinishedPage, False)
        self.bg = self.printerNameLineEdit.paletteBackgroundColor()
        self.setHelpEnabled(self.ConnectionPage, False)
        self.setHelpEnabled(self.ProbedDevicesPage, False)
        self.setHelpEnabled(self.PPDPage, False)
        self.setHelpEnabled(self.PrinterNamePage, False)
        self.setHelpEnabled(self.FinishedPage, False)

        self.faxNameLineEdit.setMaxLength(50)
        self.printerNameLineEdit.setMaxLength(50)

        QToolTip.add(self.searchFiltersPushButton2,
            self.__tr('Current: Filter: [%2]  Search: "%3"  TTL: %4  Timeout: %5s').arg(','.join(self.filter)).arg(self.search or '').arg(self.ttl).arg(self.timeout))

        cups.setPasswordCallback(showPasswordUI)
示例#22
0
    def __init__(self, bus=['usb', 'par'], device_uri=None, printer_name=None,
                 parent=None, name=None, fl=0):

        QMainWindow.__init__(self,parent,name,fl)

        self.pc = None
        self.device_uri = device_uri
        self.printer_name = printer_name
        self.init_failed = False

        self.setIcon(load_pixmap('hp_logo', '128x128'))

        self.setCentralWidget(QWidget(self,"qt_central_widget"))
        self.FormLayout = QGridLayout(self.centralWidget(),1,1,11,6,"FormLayout")

        self.languageChange()

        self.resize(QSize(600,480).expandedTo(self.minimumSizeHint()))
        self.clearWState(Qt.WState_Polished)

        if self.device_uri and self.printer_name:
            log.error("You may not specify both a printer (-p) and a device (-d).")
            self.device_uri, self.printer_name = None, None

        if not self.device_uri and not self.printer_name:
            probed_devices = device.probeDevices(bus=bus, filter={'pcard-type': (operator.eq, 1)})
            cups_printers = cups.getPrinters()
            log.debug(probed_devices)
            log.debug(cups_printers)
            max_deviceid_size, x, devices = 0, 0, {}

            for d in probed_devices:
                if d.startswith('hp:'):
                    printers = []
                    for p in cups_printers:
                        if p.device_uri == d:
                            printers.append(p.name)
                    devices[x] = (d, printers)
                    x += 1
                    max_deviceid_size = max(len(d), max_deviceid_size)

            if x == 0:
                from nodevicesform import NoDevicesForm
                self.FailureUI(self.__tr("<p><b>No devices found that support photo card access.</b><p>Please make sure your device is properly installed and try again."))
                self.init_failed = True

            elif x == 1:
                log.info(log.bold("Using device: %s" % devices[0][0]))
                self.device_uri = devices[0][0]

            else:
                from choosedevicedlg import ChooseDeviceDlg
                dlg = ChooseDeviceDlg(devices)
                if dlg.exec_loop() == QDialog.Accepted:
                    self.device_uri = dlg.device_uri
                else:
                    self.init_failed = True

        self.dbus_avail, self.service, session_bus = device.init_dbus()

        self.UnloadView = ScrollUnloadView(self.service,
            self.centralWidget(), self, "UnloadView")

        self.FormLayout.addWidget(self.UnloadView,0,0)


        if not self.init_failed:
            try:
                self.cur_device = device.Device(device_uri=self.device_uri,
                                                 printer_name=self.printer_name)
            except Error, e:
                log.error("Invalid device URI or printer name.")
                self.FailureUI("<b>Invalid device URI or printer name.</b><p>Please check the parameters to hp-print and try again.")
                self.init_failed = True

            else:
                self.device_uri = self.cur_device.device_uri
                user_conf.set('last_used', 'device_uri', self.device_uri)

                log.debug(self.device_uri)

                self.statusBar().message(self.device_uri)
示例#23
0
 def __init__(self, parent=None, name=None, modal=0, fl=0):
     ColorCalForm2_base.__init__(self, parent, name, modal, fl)
     self.Icon.setPixmap(load_pixmap('color_adj', 'other'))
     self.value = 1
    def __init__(self, bus, param, jd_port=1, parent=None, name=None, modal=0, fl=0):
        SetupForm_base.__init__(self, parent, name, modal, fl)

        self.start_page = self.ConnectionPage
        self.first_page = True

        if bus is None:
            self.bus = 'usb'
        else:
            self.bus = bus[0]
            self.start_page = self.ProbedDevicesPage

        if not prop.par_build:
            self.parRadioButton.setEnabled(False)

        if not prop.net_build:
            self.netRadioButton.setEnabled(False)

        if not prop.par_build and not prop.net_build:
            self.bus = 'usb'
            self.start_page = self.ProbedDevicesPage

        self.param = param
        self.jd_port = jd_port

        if self.param:
            # Validate param...
            device_uri, sane_uri, fax_uri = device.makeURI(self.param, self.jd_port)

            if device_uri:
                self.device_uri = device_uri
                self.start_page = self.PPDPage

            else:
                self.FailureUI(self.__tr("<b>Device not found.</b> <p>Please make sure your printer is properly connected and powered-on."))

        self.setIcon(load_pixmap('hp_logo', '128x128'))

        self.connectionTypeButtonGroup.setButton(0)
        self.device_uri = ''
        self.mq = {}
        self.prev_page = None
        self.probe_pat = re.compile(r'(.*?)\s"(.*?)"\s"(.*?)"\s"(.*?)"', re.IGNORECASE)
        self.printer_name = ''
        self.ppd_list = []
        self.location = ''
        self.desc = ''
        self.filter = []
        self.search = ''
        self.ttl = 4
        self.timeout = 5
        self.printer_name_ok = True
        self.fax_name_ok = True
        self.fax_number = ''
        self.fax_name = ''
        self.printer_fax_names_same = False
        self.fax_name_company = ''
        self.fax_location = ''
        self.fax_desc = ''
        self.print_test_page = True
        self.printerNameLineEdit.setValidator(PrinterNameValidator(self.printerNameLineEdit))
        self.faxNameLineEdit.setValidator(PrinterNameValidator(self.faxNameLineEdit))
        self.faxNumberLineEdit.setValidator(PhoneNumValidator(self.faxNumberLineEdit))
        self.setTitleFont(QFont("Helvetica", 16))
        self.setBackEnabled(self.FinishedPage, False)
        self.bg = self.printerNameLineEdit.paletteBackgroundColor()
        self.setHelpEnabled(self.ConnectionPage, False)
        self.setHelpEnabled(self.ProbedDevicesPage, False)
        self.setHelpEnabled(self.PPDPage, False)
        self.setHelpEnabled(self.PrinterNamePage, False)
        self.setHelpEnabled(self.FinishedPage, False)

        self.faxNameLineEdit.setMaxLength(50)
        self.printerNameLineEdit.setMaxLength(50)

        QToolTip.add(self.searchFiltersPushButton2,
            self.__tr('Current: Filter: [%2]  Search: "%3"  TTL: %4  Timeout: %5s').arg(','.join(self.filter)).arg(self.search or '').arg(self.ttl).arg(self.timeout))

        cups.setPasswordCallback(showPasswordUI)
示例#25
0
    def __init__(self, parent=None, name=None, modal=0, fl=0):
        CleaningForm2_base.__init__(self, parent, name, modal, fl)

        self.Icon.setPixmap(load_pixmap('clean', 'other'))
示例#26
0
    def __init__(self, printer_name=None, args=None,
                 parent=None,name=None,modal=0,fl=0):

        QMainWindow.__init__(self,parent,name,fl)

        self.printer_name = printer_name
        self.file_list = []
        self.args = args
        self.init_failed = False

        self.statusBar()

        self.setIcon(load_pixmap('hp_logo', '128x128'))
        signal.signal(signal.SIGINT, signal.SIG_DFL)

        if not name:
            self.setName("PrinterForm")

        self.setCentralWidget(QWidget(self,"qt_central_widget"))
        self.FormLayout = QGridLayout(self.centralWidget(),1,1,11,6,"FormLayout")
        self.resize(QSize(600,480).expandedTo(self.minimumSizeHint()))
        self.clearWState(Qt.WState_Polished)
        self.languageChange()

        self.cups_printers = device.getSupportedCUPSPrinters()
        log.debug(self.cups_printers)

        if  not self.printer_name: # no -p provided
            t = device.probeDevices(['cups'])
            probed_devices = []

            for d in t:
                if d.startswith('hp:'):
                    probed_devices.append(d)

            log.debug(probed_devices)

            max_deviceid_size, x, devices = 0, 0, {}

            for d in probed_devices:
                printers = []
                for p in self.cups_printers:
                    if p.device_uri == d:
                        printers.append(p.name)
                devices[x] = (d, printers)
                x += 1
                max_deviceid_size = max(len(d), max_deviceid_size)

            if x == 0:
                from nodevicesform import NoDevicesForm
                self.FailureUI(self.__tr("<p><b>No devices found.</b><p>Please make sure your device is properly installed and try again."))
                self.init_failed = True

            elif x == 1:
                log.info(log.bold("Using device: %s" % devices[0][0]))
                self.device_uri = devices[0][0]

            else:
                from chooseprinterdlg import ChoosePrinterDlg
                dlg = ChoosePrinterDlg(self.cups_printers)
                if dlg.exec_loop() == QDialog.Accepted:
                    self.printer_name = dlg.printer_name
                    self.device_uri = dlg.device_uri
                else:
                    self.init_failed = True

        else: # -p provided
            for p in self.cups_printers:
                if p.name == self.printer_name:
                    self.device_uri = p.device_uri
                    break
            else:
                self.FailureUI("<b>Invalid printer name.</b><p>Please check the parameters to hp-print and try again.")
                self.init_failed = True


        if not self.init_failed:
            self.PrintView = ScrollPrintView(None, self.centralWidget(), self, "PrintView")
            self.FormLayout.addWidget(self.PrintView,0,0)

            try:
                self.cur_device = device.Device(device_uri=self.device_uri,
                                                 printer_name=self.printer_name)
            except Error, e:
                log.error("Invalid device URI or printer name.")
                self.FailureUI("<b>Invalid device URI or printer name.</b><p>Please check the parameters to hp-print and try again.")
                self.init_failed = True

            else:
                self.device_uri = self.cur_device.device_uri
                user_conf.set('last_used', 'device_uri', self.device_uri)

                log.debug(self.device_uri)

                self.statusBar().message(self.device_uri)
示例#27
0
    def __init__(self,parent = None,name = None,modal = 0,fl = 0):
        NoDevicesForm_base.__init__(self, parent, name, modal, fl)

        self.Icon.setPixmap(load_pixmap("warning.png", '32x32'))
示例#28
0
    def __init__(self,
                 device_uri,
                 printer_name,
                 args,
                 parent=None,
                 name=None,
                 modal=0,
                 fl=0):

        QMainWindow.__init__(self, parent, name, fl)

        self.setIcon(load_pixmap('hp_logo', '128x128'))

        self.init_failed = False
        self.device_uri = device_uri
        self.dev = None
        self.printer_name = printer_name
        bus = ['cups']
        self.filename = ''
        self.username = prop.username
        self.args = args
        self.setCentralWidget(QWidget(self, "qt_central_widget"))
        self.FormLayout = QGridLayout(self.centralWidget(), 1, 1, 11, 6,
                                      "FormLayout")
        self.resize(QSize(600, 480).expandedTo(self.minimumSizeHint()))
        self.clearWState(Qt.WState_Polished)
        self.languageChange()

        #        if self.device_uri and self.printer_name:
        #            log.error("You may not specify both a printer (-p) and a device (-d).")
        #            self.FailureUI(self.__tr("<p><b>You may not specify both a printer (-p) and a device (-d)."))
        #            self.device_uri, self.printer_name = None, None
        #            self.init_failed = True

        self.cups_printers = cups.getPrinters()
        log.debug(self.cups_printers)

        if self.printer_name:
            found = False
            for p in self.cups_printers:
                if p.name == printer_name:
                    self.device_uri = p.device_uri
                    found = True
                    break

            if not found:
                self.FailureUI(
                    self.__tr(
                        "<b>Unknown printer name: %1</b><p>Please check the printer name and try again."
                    ).arg(self.printer_name))

            if found and not p.device_uri.startswith('hpfax:/'):
                self.FailureUI(
                    self.__tr(
                        "You must specify a printer that has a device URI in the form 'hpfax:/...'"
                    ))
                self.init_failed = True

        if not self.device_uri and not self.printer_name:
            t = device.probeDevices(
                bus=bus, filter={'fax-type': (operator.gt, FAX_TYPE_NONE)})
            #print t
            probed_devices = []

            for d in t:
                probed_devices.append(d.replace('hp:/', 'hpfax:/'))

            #print probed_devices

            probed_devices = utils.uniqueList(probed_devices)
            log.debug(probed_devices)

            max_deviceid_size, x, devices = 0, 0, {}

            for d in probed_devices:
                printers = []
                for p in self.cups_printers:
                    #print p.device_uri, d
                    if p.device_uri == d:
                        #print "OK"
                        printers.append(p.name)

                devices[x] = (d, printers)
                x += 1
                max_deviceid_size = max(len(d), max_deviceid_size)

            x = len(devices)

            #print devices

            if x == 0:
                from nodevicesform import NoDevicesForm
                self.FailureUI(
                    self.__tr(
                        "<p><b>No devices found.</b><p>Please make sure your device is properly installed and try again."
                    ))
                self.init_failed = True

            elif x == 1:
                log.info(log.bold("Using device: %s" % devices[0][0]))
                self.device_uri = devices[0][0]

            else:
                from chooseprinterdlg import ChoosePrinterDlg
                dlg = ChoosePrinterDlg(self.cups_printers, ['hpfax'])

                if dlg.exec_loop() == QDialog.Accepted:
                    self.device_uri = dlg.device_uri
                else:
                    self.init_failed = True

        self.dbus_avail, self.service, session_bus = device.init_dbus()

        self.FaxView = ScrollFaxView(self.service, self.centralWidget(), self)
        self.FormLayout.addWidget(self.FaxView, 0, 0)

        if not self.init_failed:
            if not self.device_uri or not self.device_uri.startswith("hpfax:"):
                log.error("Invalid device URI: %s" % repr(device_uri))
                self.FailureUI(
                    self.__tr(
                        "<b>Invalid device URI %1.</b><p>Please check the parameters to hp-print and try again."
                    ).arg(repr(device_uri)))
                self.init_failed = True

            else:
                try:
                    self.cur_device = device.Device(
                        device_uri=self.device_uri,
                        printer_name=self.printer_name)
                except Error, e:
                    log.error("Invalid device URI or printer name.")
                    self.FailureUI(
                        "<b>Invalid device URI or printer name.</b><p>Please check the parameters to hp-print and try again."
                    )
                    self.init_failed = True

                else:
                    self.device_uri = self.cur_device.device_uri
                    user_conf.set('last_used', 'device_uri', self.device_uri)

                    log.debug(self.device_uri)

                    self.statusBar().message(self.device_uri)
示例#29
0
 def __init__(self,parent = None,name = None,modal = 0,fl = 0):
     ColorCalForm2_base.__init__(self,parent,name,modal,fl)
     self.Icon.setPixmap(load_pixmap('color_adj', 'other'))
     self.value = 1
示例#30
0
 def __init__(self, parent, line, name = None, modal = 0, fl = 0):
     ColorAdjForm_base.__init__(self,parent,name,modal,fl)
     self.Icon.setPixmap(load_pixmap('color_adj'))
     self.LineLabel.setText("""<b><font size="+1">%s</font></b>""" % line)
     self.value = 11
示例#31
0
    def __init__(self, device_uri, printer_name, args,
                 parent=None, name=None,
                 modal=0, fl=0):

        QMainWindow.__init__(self,parent,name,fl)

        self.setIcon(load_pixmap('hp_logo', '128x128'))

        self.init_failed = False
        self.device_uri = device_uri
        self.dev = None
        self.printer_name = printer_name
        bus = ['cups']
        self.filename = ''
        self.username = prop.username
        self.args = args
        self.setCentralWidget(QWidget(self,"qt_central_widget"))
        self.FormLayout = QGridLayout(self.centralWidget(),1,1,11,6,"FormLayout")
        self.resize(QSize(600,480).expandedTo(self.minimumSizeHint()))
        self.clearWState(Qt.WState_Polished)
        self.languageChange()

#        if self.device_uri and self.printer_name:
#            log.error("You may not specify both a printer (-p) and a device (-d).")
#            self.FailureUI(self.__tr("<p><b>You may not specify both a printer (-p) and a device (-d)."))
#            self.device_uri, self.printer_name = None, None
#            self.init_failed = True

        self.cups_printers = cups.getPrinters()
        log.debug(self.cups_printers)

        if self.printer_name:
            found = False
            for p in self.cups_printers:
                if p.name == printer_name:
                    self.device_uri = p.device_uri
                    found = True
                    break

            if not found:
                self.FailureUI(self.__tr("<b>Unknown printer name: %1</b><p>Please check the printer name and try again.").arg(self.printer_name))

            if found and not p.device_uri.startswith('hpfax:/'):
                self.FailureUI(self.__tr("You must specify a printer that has a device URI in the form 'hpfax:/...'"))
                self.init_failed = True

        if not self.device_uri and not self.printer_name:
            t = device.probeDevices(bus=bus, filter={'fax-type':(operator.gt, FAX_TYPE_NONE)})
            #print t
            probed_devices = []

            for d in t:
                probed_devices.append(d.replace('hp:/', 'hpfax:/'))

            #print probed_devices

            probed_devices = utils.uniqueList(probed_devices)
            log.debug(probed_devices)

            max_deviceid_size, x, devices = 0, 0, {}

            for d in probed_devices:
                printers = []
                for p in self.cups_printers:
                    #print p.device_uri, d
                    if p.device_uri == d:
                        #print "OK"
                        printers.append(p.name)

                devices[x] = (d, printers)
                x += 1
                max_deviceid_size = max(len(d), max_deviceid_size)

            x = len(devices)

            #print devices

            if x == 0:
                from nodevicesform import NoDevicesForm
                self.FailureUI(self.__tr("<p><b>No devices found.</b><p>Please make sure your device is properly installed and try again."))
                self.init_failed = True

            elif x == 1:
                log.info(log.bold("Using device: %s" % devices[0][0]))
                self.device_uri = devices[0][0]

            else:
                from chooseprinterdlg import ChoosePrinterDlg
                dlg = ChoosePrinterDlg(self.cups_printers, ['hpfax'])

                if dlg.exec_loop() == QDialog.Accepted:
                    self.device_uri = dlg.device_uri
                else:
                    self.init_failed = True

        self.dbus_avail, self.service, session_bus = device.init_dbus()

        self.FaxView = ScrollFaxView(self.service, self.centralWidget(), self)
        self.FormLayout.addWidget(self.FaxView,0,0)

        if not self.init_failed:
            if not self.device_uri or not self.device_uri.startswith("hpfax:"):
                log.error("Invalid device URI: %s" % repr(device_uri))
                self.FailureUI(self.__tr("<b>Invalid device URI %1.</b><p>Please check the parameters to hp-print and try again.").arg(repr(device_uri)));
                self.init_failed = True

            else:
                try:
                    self.cur_device = device.Device(device_uri=self.device_uri,
                                                     printer_name=self.printer_name)
                except Error, e:
                    log.error("Invalid device URI or printer name.")
                    self.FailureUI("<b>Invalid device URI or printer name.</b><p>Please check the parameters to hp-print and try again.")
                    self.init_failed = True

                else:
                    self.device_uri = self.cur_device.device_uri
                    user_conf.set('last_used', 'device_uri', self.device_uri)

                    log.debug(self.device_uri)

                    self.statusBar().message(self.device_uri)
示例#32
0
    def __init__(self, parent=None, name=None, modal=0, fl=0):
        NoDevicesForm_base.__init__(self, parent, name, modal, fl)

        self.Icon.setPixmap(load_pixmap("warning.png", '32x32'))
示例#33
0
    def __init__(self,parent = None,name = None,modal = 0,fl = 0):
        AboutDlg_base.__init__(self,parent,name,modal,fl)

        self.pyPixmap.setPixmap(load_pixmap('powered_by_python.png'))
        self.osiPixmap.setPixmap(load_pixmap('opensource-75x65.png'))
        self.logoPixmap.setPixmap(load_pixmap('hp-tux-printer.png'))
示例#34
0
    def __init__(self,parent = None,name = None,modal = 0,fl = 0):
        CleaningForm2_base.__init__(self,parent,name,modal,fl)

        self.Icon.setPixmap(load_pixmap('clean', 'other'))
示例#35
0
    def __init__(self, parent, line_id, orientation, colors, line_count, 
                 choice_count, name = None, modal = 0, fl = 0):
        QDialog.__init__(self, parent, name, modal, fl)

        # line_id: 'A', 'B', etc.
        # orientation: 'v' or 'h'
        # colors: 'k' or 'c' or 'kc'
        # line_count: 2 or 3
        # choice_count: 5, 7, 9, 11, etc. (odd)
        mid_point = (choice_count+1)/2

        if not name:
            self.setProperty("name", QVariant("AlignForm"))

        AlignFormLayout = QGridLayout(self,1,1,11,6,"AlignFormLayout")

        #self.helpButton = QPushButton(self,"helpButton")

        #AlignFormLayout.addWidget(self.helpButton,1,0)

        self.CancelButton = QPushButton(self,"CancelButton")

        AlignFormLayout.addWidget(self.CancelButton,1,2)

        self.ContinueButton = QPushButton(self,"ContinueButton")

        AlignFormLayout.addWidget(self.ContinueButton,1,3)
        spacer1 = QSpacerItem(270,20,QSizePolicy.Expanding,QSizePolicy.Minimum)
        AlignFormLayout.addItem(spacer1,1,1)

        self.buttonGroup = QButtonGroup(self,"buttonGroup")
        self.buttonGroup.setColumnLayout(0,Qt.Vertical)
        self.buttonGroup.layout().setSpacing(6)
        self.buttonGroup.layout().setMargin(11)

        buttonGroupLayout = QGridLayout(self.buttonGroup.layout())
        buttonGroupLayout.setAlignment(Qt.AlignTop)

        ChoiceLayout = QHBoxLayout(None,0,6,"ChoiceLayout")

        for x in range(1, choice_count+1):
            exec 'self.radioButton%d = QRadioButton( self.buttonGroup, "radioButton%d" )' % (x, x) 
            exec 'self.radioButton%d.setText( "%s%d" )' % (x, line_id, x) 
            if x == mid_point:
                exec 'self.radioButton%d.setChecked( 1 )' % x
            exec 'ChoiceLayout.addWidget( self.radioButton%d )' % x

        buttonGroupLayout.addMultiCellLayout(ChoiceLayout, 1, 1, 0, 1)

        self.Icon = QLabel(self.buttonGroup,"Icon")
        self.Icon.setProperty("sizePolicy",QVariant(QSizePolicy(QSizePolicy.Fixed,QSizePolicy.Fixed,0,0,self.Icon.sizePolicy().hasHeightForWidth())))
        self.Icon.setProperty("scaledContents",QVariant(QVariant(1,0)))

        buttonGroupLayout.addWidget(self.Icon,0,0)

        self.textLabel2_2 = QLabel(self.buttonGroup,"textLabel2_2")
        self.textLabel2_2.setProperty("alignment",QVariant(QLabel.WordBreak | QLabel.AlignVCenter))

        buttonGroupLayout.addWidget(self.textLabel2_2,0,1)

        AlignFormLayout.addMultiCellWidget(self.buttonGroup,0,0,0,3)

        self.languageChange()

        self.resize(QSize(608,222).expandedTo(self.minimumSizeHint()))
        self.clearWState(Qt.WState_Polished)

        self.connect(self.CancelButton,SIGNAL("clicked()"),self,SLOT("reject()"))
        self.connect(self.ContinueButton,SIGNAL("clicked()"),self,SLOT("accept()"))
        self.connect(self.buttonGroup,SIGNAL("clicked(int)"),self.buttonGroup_clicked)

        self.Icon.setPixmap(load_pixmap('%s-%s-%d.png' % (orientation, colors, line_count), 'other'))

        self.buttonGroup.setTitle(line_id)

        self.value = (choice_count + 1) / 2
示例#36
0
 def __init__(self, parent=None, name=None, modal=0, fl=0):
     ColorCal4Form_base.__init__(self, parent, name, modal, fl)
     
     self.gray_plot_png.setPixmap(load_pixmap('type4_gray_patch', 'other'))
     self.color_plot_png.setPixmap(load_pixmap('type4_color_patch', 'other'))
     self.values = [0, 0, 0, 0]
示例#37
0
    def __init__(self,
                 bus='cups',
                 device_uri=None,
                 printer_name=None,
                 num_copies=None,
                 contrast=None,
                 quality=None,
                 reduction=None,
                 fit_to_page=None,
                 parent=None,
                 name=None,
                 modal=0,
                 fl=0):

        QMainWindow.__init__(self, parent, name, fl)

        self.setIcon(load_pixmap('hp_logo', '128x128'))

        self.cur_device_uri = device_uri
        self.printer_name = printer_name
        self.init_failed = False
        self.num_copies = num_copies
        self.contrast = contrast
        self.quality = quality
        self.reduction = reduction
        self.fit_to_page = fit_to_page

        self.setCentralWidget(QWidget(self, "qt_central_widget"))
        self.FormLayout = QGridLayout(self.centralWidget(), 1, 1, 11, 6,
                                      "FormLayout")
        self.resize(QSize(600, 480).expandedTo(self.minimumSizeHint()))
        self.clearWState(Qt.WState_Polished)
        self.languageChange()

        if self.cur_device_uri and self.printer_name:
            log.error(
                "You may not specify both a printer (-p) and a device (-d).")
            self.FailureUI(
                self.__tr(
                    "<p><b>You may not specify both a printer (-p) and a device (-d)."
                ))
            self.cur_device_uri, self.printer_name = None, None
            self.init_failed = True

        self.cups_printers = cups.getPrinters()
        log.debug(self.cups_printers)

        if not self.cur_device_uri and not self.printer_name:
            t = device.probeDevices(bus=bus,
                                    filter={'copy-type': (operator.gt, 0)})
            probed_devices = []

            for d in t:
                if d.startswith('hp:'):
                    probed_devices.append(d)

            log.debug(probed_devices)

            max_deviceid_size, x, devices = 0, 0, {}

            for d in probed_devices:
                printers = []
                for p in self.cups_printers:
                    if p.device_uri == d:
                        printers.append(p.name)
                devices[x] = (d, printers)
                x += 1
                max_deviceid_size = max(len(d), max_deviceid_size)

            if x == 0:
                from nodevicesform import NoDevicesForm
                self.FailureUI(
                    self.__tr(
                        "<p><b>No devices found.</b><p>Please make sure your device is properly installed and try again."
                    ))
                self.init_failed = True

            elif x == 1:
                log.info(log.bold("Using device: %s" % devices[0][0]))
                self.cur_device_uri = devices[0][0]

            else:
                from choosedevicedlg import ChooseDeviceDlg
                dlg = ChooseDeviceDlg(devices)  #, ['hp'])

                if dlg.exec_loop() == QDialog.Accepted:
                    self.cur_device_uri = dlg.device_uri
                else:
                    self.init_failed = True

        self.CopyView = ScrollCopyView(None,
                                       num_copies=num_copies,
                                       contrast=contrast,
                                       quality=quality,
                                       reduction=reduction,
                                       fit_to_page=fit_to_page,
                                       parent=self.centralWidget(),
                                       form=self)

        self.FormLayout.addWidget(self.CopyView, 0, 0)

        self.cur_device = self.cur_device_uri

        if not self.init_failed:
            try:
                self.cur_device = copier.PMLCopyDevice(
                    device_uri=self.cur_device_uri,
                    printer_name=self.printer_name)
            except Error:
                log.error("Invalid device URI or printer name.")
                self.FailureUI(
                    "<b>Invalid device URI or printer name.</b><p>Please check the parameters to hp-print and try again."
                )
                self.init_failed = True

            else:

                if self.cur_device.copy_type == COPY_TYPE_NONE:
                    self.FailureUI(
                        self.__tr(
                            "<b>Sorry, make copies functionality is not implemented for this device.</b>"
                        ))
                    self.close()
                    return

                self.cur_device_uri = self.cur_device.device_uri
                user_conf.set('last_used', 'device_uri', self.cur_device_uri)

                log.debug(self.cur_device_uri)

                self.statusBar().message(self.cur_device.device_uri)

        QTimer.singleShot(0, self.InitialUpdate)
示例#38
0
    def __init__(self, parent=None, name=None, modal=0, fl=0):
        LoadPaperForm_base.__init__(self, parent, name, modal, fl)

        self.Icon.setPixmap(load_pixmap('load_paper', 'other'))
示例#39
0
    def __init__(self, args, read_pipe):
        QApplication.__init__(self, args)

        self.read_pipe = read_pipe
        self.fmt = "80s80sI32sI80sf"
        self.fmt_size = struct.calcsize(self.fmt)

        self.user_settings = utils.UserSettings()
        self.user_settings.load()
        self.user_settings.debug()

        self.tray_icon = SystrayIcon(load_pixmap("hp_logo", "32x32", (22, 22)))
        self.menu = QPopupMenu()

        title_item = TitleItem(load_pixmap('hp_logo', '16x16', (16, 16)),
                               "HP Status Service")
        i = self.menu.insertItem(title_item)
        self.menu.setItemEnabled(i, False)

        self.menu.insertSeparator()

        self.menu.insertItem(self.tr("HP Device Manager..."),
                             self.toolbox_triggered)

        # TODO:
        #icon2 = QIconSet(load_pixmap('settings', '16x16'))
        #self.menu.insertItem(icon2, self.tr("Options..."), self.preferences_triggered)

        self.menu.insertSeparator()

        icon3 = QIconSet(load_pixmap('quit', '16x16'))
        self.menu.insertItem(icon3, self.tr("Quit"), self.quit_triggered)

        self.tray_icon.show()

        notifier = QSocketNotifier(self.read_pipe, QSocketNotifier.Read)
        QObject.connect(notifier, SIGNAL("activated(int)"),
                        self.notifier_activated)

        QObject.connect(self.tray_icon,
                        PYSIGNAL("contextMenuRequested(const QPoint&)"),
                        self.menu_requested)

        self.icon_info = load_pixmap('info', '16x16')
        self.icon_warn = load_pixmap('warning', '16x16')
        self.icon_error = load_pixmap('error', '16x16')

        if "--ignore-update-firsttime" not in args:
            self.handle_hplip_updation()
        self.timer = QTimer()
        self.timer.connect(self.timer, SIGNAL("timeout()"),
                           self.handle_hplip_updation)
        self.timer.start(UPGRADE_CHECK_DELAY)

        # Cleans the /var/log/hp/tmp directory
        #self.handle_hplip_clean()

        #self.clean_timer = QTimer()
        #self.clean_timer.connect(self.clean_timer,SIGNAL("timeout()"),self.handle_hplip_clean)
        #self.clean_timer.start(CLEAN_EXEC_DELAY)

        self.ERROR_STATE_TO_ICON = {
            ERROR_STATE_CLEAR: self.icon_info,
            ERROR_STATE_OK: self.icon_info,
            ERROR_STATE_WARNING: self.icon_warn,
            ERROR_STATE_ERROR: self.icon_error,
            ERROR_STATE_LOW_SUPPLIES: self.icon_warn,
            ERROR_STATE_BUSY: self.icon_warn,
            ERROR_STATE_LOW_PAPER: self.icon_warn,
            ERROR_STATE_PRINTING: self.icon_info,
            ERROR_STATE_SCANNING: self.icon_info,
            ERROR_STATE_PHOTOCARD: self.icon_info,
            ERROR_STATE_FAXING: self.icon_info,
            ERROR_STATE_COPYING: self.icon_info,
        }
示例#40
0
    def __init__(self,
                 bus=['usb', 'par'],
                 device_uri=None,
                 printer_name=None,
                 parent=None,
                 name=None,
                 fl=0):

        QMainWindow.__init__(self, parent, name, fl)

        self.pc = None
        self.device_uri = device_uri
        self.printer_name = printer_name
        self.init_failed = False

        self.setIcon(load_pixmap('hp_logo', '128x128'))

        self.setCentralWidget(QWidget(self, "qt_central_widget"))
        self.FormLayout = QGridLayout(self.centralWidget(), 1, 1, 11, 6,
                                      "FormLayout")

        self.languageChange()

        self.resize(QSize(600, 480).expandedTo(self.minimumSizeHint()))
        self.clearWState(Qt.WState_Polished)

        if self.device_uri and self.printer_name:
            log.error(
                "You may not specify both a printer (-p) and a device (-d).")
            self.device_uri, self.printer_name = None, None

        if not self.device_uri and not self.printer_name:
            probed_devices = device.probeDevices(
                bus=bus, filter={'pcard-type': (operator.eq, 1)})
            cups_printers = cups.getPrinters()
            log.debug(probed_devices)
            log.debug(cups_printers)
            max_deviceid_size, x, devices = 0, 0, {}

            for d in probed_devices:
                if d.startswith('hp:'):
                    printers = []
                    for p in cups_printers:
                        if p.device_uri == d:
                            printers.append(p.name)
                    devices[x] = (d, printers)
                    x += 1
                    max_deviceid_size = max(len(d), max_deviceid_size)

            if x == 0:
                from nodevicesform import NoDevicesForm
                self.FailureUI(
                    self.__tr(
                        "<p><b>No devices found that support photo card access.</b><p>Please make sure your device is properly installed and try again."
                    ))
                self.init_failed = True

            elif x == 1:
                log.info(log.bold("Using device: %s" % devices[0][0]))
                self.device_uri = devices[0][0]

            else:
                from choosedevicedlg import ChooseDeviceDlg
                dlg = ChooseDeviceDlg(devices)
                if dlg.exec_loop() == QDialog.Accepted:
                    self.device_uri = dlg.device_uri
                else:
                    self.init_failed = True

        self.dbus_avail, self.service, session_bus = device.init_dbus()

        self.UnloadView = ScrollUnloadView(self.service, self.centralWidget(),
                                           self, "UnloadView")

        self.FormLayout.addWidget(self.UnloadView, 0, 0)

        if not self.init_failed:
            try:
                self.cur_device = device.Device(device_uri=self.device_uri,
                                                printer_name=self.printer_name)
            except Error, e:
                log.error("Invalid device URI or printer name.")
                self.FailureUI(
                    "<b>Invalid device URI or printer name.</b><p>Please check the parameters to hp-print and try again."
                )
                self.init_failed = True

            else:
                self.device_uri = self.cur_device.device_uri
                user_conf.set('last_used', 'device_uri', self.device_uri)

                log.debug(self.device_uri)

                self.statusBar().message(self.device_uri)
示例#41
0
    def __init__(self, parent=None, name=None, modal=0, fl=0):
        LoadPaperForm_base.__init__(self, parent, name, modal, fl)

        self.Icon.setPixmap(load_pixmap("load_paper", "other"))
示例#42
0
 def __init__(self,parent = None,name = None,modal = 0,fl = 0):
     PaperEdgeAlignForm_base.__init__(self,parent,name,modal,fl)
     self.Icon.setPixmap(load_pixmap("zca.png", 'other'))
     self.value = 1
示例#43
0
 def __init__(self, parent, line, name=None, modal=0, fl=0):
     ColorAdjForm_base.__init__(self, parent, name, modal, fl)
     self.Icon.setPixmap(load_pixmap('color_adj'))
     self.LineLabel.setText("""<b><font size="+1">%s</font></b>""" % line)
     self.value = 11
示例#44
0
    def __init__(self,
                 parent,
                 line_id,
                 orientation,
                 colors,
                 line_count,
                 choice_count,
                 name=None,
                 modal=0,
                 fl=0):
        QDialog.__init__(self, parent, name, modal, fl)

        # line_id: 'A', 'B', etc.
        # orientation: 'v' or 'h'
        # colors: 'k' or 'c' or 'kc'
        # line_count: 2 or 3
        # choice_count: 5, 7, 9, 11, etc. (odd)
        mid_point = (choice_count + 1) / 2

        if not name:
            self.setProperty("name", QVariant("AlignForm"))

        AlignFormLayout = QGridLayout(self, 1, 1, 11, 6, "AlignFormLayout")

        #self.helpButton = QPushButton(self,"helpButton")

        #AlignFormLayout.addWidget(self.helpButton,1,0)

        self.CancelButton = QPushButton(self, "CancelButton")

        AlignFormLayout.addWidget(self.CancelButton, 1, 2)

        self.ContinueButton = QPushButton(self, "ContinueButton")

        AlignFormLayout.addWidget(self.ContinueButton, 1, 3)
        spacer1 = QSpacerItem(270, 20, QSizePolicy.Expanding,
                              QSizePolicy.Minimum)
        AlignFormLayout.addItem(spacer1, 1, 1)

        self.buttonGroup = QButtonGroup(self, "buttonGroup")
        self.buttonGroup.setColumnLayout(0, Qt.Vertical)
        self.buttonGroup.layout().setSpacing(6)
        self.buttonGroup.layout().setMargin(11)

        buttonGroupLayout = QGridLayout(self.buttonGroup.layout())
        buttonGroupLayout.setAlignment(Qt.AlignTop)

        ChoiceLayout = QHBoxLayout(None, 0, 6, "ChoiceLayout")

        for x in range(1, choice_count + 1):
            exec 'self.radioButton%d = QRadioButton( self.buttonGroup, "radioButton%d" )' % (
                x, x)
            exec 'self.radioButton%d.setText( "%s%d" )' % (x, line_id, x)
            if x == mid_point:
                exec 'self.radioButton%d.setChecked( 1 )' % x
            exec 'ChoiceLayout.addWidget( self.radioButton%d )' % x

        buttonGroupLayout.addMultiCellLayout(ChoiceLayout, 1, 1, 0, 1)

        self.Icon = QLabel(self.buttonGroup, "Icon")
        self.Icon.setProperty(
            "sizePolicy",
            QVariant(
                QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed, 0, 0,
                            self.Icon.sizePolicy().hasHeightForWidth())))
        self.Icon.setProperty("scaledContents", QVariant(QVariant(1, 0)))

        buttonGroupLayout.addWidget(self.Icon, 0, 0)

        self.textLabel2_2 = QLabel(self.buttonGroup, "textLabel2_2")
        self.textLabel2_2.setProperty(
            "alignment", QVariant(QLabel.WordBreak | QLabel.AlignVCenter))

        buttonGroupLayout.addWidget(self.textLabel2_2, 0, 1)

        AlignFormLayout.addMultiCellWidget(self.buttonGroup, 0, 0, 0, 3)

        self.languageChange()

        self.resize(QSize(608, 222).expandedTo(self.minimumSizeHint()))
        self.clearWState(Qt.WState_Polished)

        self.connect(self.CancelButton, SIGNAL("clicked()"), self,
                     SLOT("reject()"))
        self.connect(self.ContinueButton, SIGNAL("clicked()"), self,
                     SLOT("accept()"))
        self.connect(self.buttonGroup, SIGNAL("clicked(int)"),
                     self.buttonGroup_clicked)

        self.Icon.setPixmap(
            load_pixmap('%s-%s-%d.png' % (orientation, colors, line_count),
                        'other'))

        self.buttonGroup.setTitle(line_id)

        self.value = (choice_count + 1) / 2
示例#45
0
    def __init__(self, args, read_pipe):
        QApplication.__init__(self, args)

        self.read_pipe = read_pipe
        self.fmt = "80s80sI32sI80sf"
        self.fmt_size = struct.calcsize(self.fmt)
        
        self.user_settings = utils.UserSettings()
        self.user_settings.load()
        self.user_settings.debug()

        self.tray_icon = SystrayIcon(load_pixmap("hp_logo", "32x32", (22, 22)))
        self.menu = QPopupMenu()

        title_item = TitleItem(load_pixmap('hp_logo', '16x16', (16, 16)), "HP Status Service")
        i = self.menu.insertItem(title_item)
        self.menu.setItemEnabled(i, False)

        self.menu.insertSeparator()

        self.menu.insertItem(self.tr("HP Device Manager..."), self.toolbox_triggered)

        # TODO:
        #icon2 = QIconSet(load_pixmap('settings', '16x16'))
        #self.menu.insertItem(icon2, self.tr("Options..."), self.preferences_triggered)

        self.menu.insertSeparator()

        icon3 = QIconSet(load_pixmap('quit', '16x16'))
        self.menu.insertItem(icon3, self.tr("Quit"),  self.quit_triggered)

        self.tray_icon.show()

        notifier = QSocketNotifier(self.read_pipe, QSocketNotifier.Read)
        QObject.connect(notifier, SIGNAL("activated(int)"), self.notifier_activated)

        QObject.connect(self.tray_icon, PYSIGNAL("contextMenuRequested(const QPoint&)"), self.menu_requested)

        self.icon_info = load_pixmap('info', '16x16')
        self.icon_warn = load_pixmap('warning', '16x16')
        self.icon_error = load_pixmap('error', '16x16')
        
        if "--ignore-update-firsttime" not in args:
            self.handle_hplip_updation()
        self.timer = QTimer()
        self.timer.connect(self.timer,SIGNAL("timeout()"),self.handle_hplip_updation)
        self.timer.start(UPGRADE_CHECK_DELAY)

        # Cleans the /var/log/hp/tmp directory
        #self.handle_hplip_clean()
        
        #self.clean_timer = QTimer()
        #self.clean_timer.connect(self.clean_timer,SIGNAL("timeout()"),self.handle_hplip_clean)
        #self.clean_timer.start(CLEAN_EXEC_DELAY)


        self.ERROR_STATE_TO_ICON = {
            ERROR_STATE_CLEAR: self.icon_info,
            ERROR_STATE_OK: self.icon_info,
            ERROR_STATE_WARNING: self.icon_warn,
            ERROR_STATE_ERROR: self.icon_error,
            ERROR_STATE_LOW_SUPPLIES: self.icon_warn,
            ERROR_STATE_BUSY: self.icon_warn,
            ERROR_STATE_LOW_PAPER: self.icon_warn,
            ERROR_STATE_PRINTING: self.icon_info,
            ERROR_STATE_SCANNING: self.icon_info,
            ERROR_STATE_PHOTOCARD: self.icon_info,
            ERROR_STATE_FAXING: self.icon_info,
            ERROR_STATE_COPYING: self.icon_info,
        }
示例#46
0
    def __init__(self, bus='cups', device_uri=None, printer_name=None,
                num_copies=None, contrast=None, quality=None,
                reduction=None, fit_to_page=None,
                parent=None, name=None, modal=0, fl=0):

        QMainWindow.__init__(self,parent,name,fl)

        self.setIcon(load_pixmap('hp_logo', '128x128'))

        self.cur_device_uri = device_uri
        self.printer_name = printer_name
        self.init_failed = False
        self.num_copies = num_copies
        self.contrast = contrast
        self.quality = quality
        self.reduction = reduction
        self.fit_to_page = fit_to_page

        self.setCentralWidget(QWidget(self,"qt_central_widget"))
        self.FormLayout = QGridLayout(self.centralWidget(),1,1,11,6,"FormLayout")
        self.resize(QSize(600,480).expandedTo(self.minimumSizeHint()))
        self.clearWState(Qt.WState_Polished)
        self.languageChange()

        if self.cur_device_uri and self.printer_name:
            log.error("You may not specify both a printer (-p) and a device (-d).")
            self.FailureUI(self.__tr("<p><b>You may not specify both a printer (-p) and a device (-d)."))
            self.cur_device_uri, self.printer_name = None, None
            self.init_failed = True

        self.cups_printers = cups.getPrinters()
        log.debug(self.cups_printers)

        if not self.cur_device_uri and not self.printer_name:
            t = device.probeDevices(bus=bus, filter={'copy-type': (operator.gt, 0)})
            probed_devices = []

            for d in t:
                if d.startswith('hp:'):
                    probed_devices.append(d)

            log.debug(probed_devices)

            max_deviceid_size, x, devices = 0, 0, {}

            for d in probed_devices:
                printers = []
                for p in self.cups_printers:
                    if p.device_uri == d:
                        printers.append(p.name)
                devices[x] = (d, printers)
                x += 1
                max_deviceid_size = max(len(d), max_deviceid_size)

            if x == 0:
                from nodevicesform import NoDevicesForm
                self.FailureUI(self.__tr("<p><b>No devices found.</b><p>Please make sure your device is properly installed and try again."))
                self.init_failed = True

            elif x == 1:
                log.info(log.bold("Using device: %s" % devices[0][0]))
                self.cur_device_uri = devices[0][0]


            else:
                from choosedevicedlg import ChooseDeviceDlg
                dlg = ChooseDeviceDlg(devices) #, ['hp'])

                if dlg.exec_loop() == QDialog.Accepted:
                    self.cur_device_uri = dlg.device_uri
                else:
                    self.init_failed = True


        self.CopyView = ScrollCopyView(None, num_copies=num_copies,
                                        contrast=contrast, quality=quality,
                                        reduction=reduction, fit_to_page=fit_to_page,
                                        parent=self.centralWidget(), form=self)

        self.FormLayout.addWidget(self.CopyView,0,0)

        self.cur_device = self.cur_device_uri

        if not self.init_failed:
            try:
                self.cur_device = copier.PMLCopyDevice(device_uri=self.cur_device_uri,
                                            printer_name=self.printer_name)
            except Error:
                log.error("Invalid device URI or printer name.")
                self.FailureUI("<b>Invalid device URI or printer name.</b><p>Please check the parameters to hp-print and try again.")
                self.init_failed = True

            else:

                if self.cur_device.copy_type == COPY_TYPE_NONE:
                    self.FailureUI(self.__tr("<b>Sorry, make copies functionality is not implemented for this device.</b>"))
                    self.close()
                    return

                self.cur_device_uri = self.cur_device.device_uri
                user_conf.set('last_used', 'device_uri',  self.cur_device_uri)

                log.debug(self.cur_device_uri)

                self.statusBar().message(self.cur_device.device_uri)


        QTimer.singleShot(0, self.InitialUpdate)