~ubuntu-branches/ubuntu/saucy/hplip/saucy-proposed

« back to all changes in this revision

Viewing changes to ui4/queuesconf.py

  • Committer: Package Import Robot
  • Author(s): Mark Purcell
  • Date: 2012-05-26 11:20:39 UTC
  • mfrom: (1.5.6) (31.1.3 precise)
  • Revision ID: package-import@ubuntu.com-20120526112039-bevxczegxnbyr5m7
Tags: 3.12.4-1
* New upstream release
* Switch to source/format 3.0 (quilt) - drop dpatch
* Refreshed debian/patches
* dh_autoreconf debian/autogen.sh & set local-options single-debian-patch
* Update to debian/compat -> 9
* Fix "hardened build flags" patch from Moritz - thanks (Closes: #667828)
* Fix "duplex descriptor uninitialized" patch from Matej (Closes: #583273)
* Fix "please migrate to kde-runtime" patch from Pino (Closes: #666544)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- coding: utf-8 -*-
 
2
#
 
3
# (c) Copyright 2011-2014 Hewlett-Packard Development Company, L.P.
 
4
#
 
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.
 
9
#
 
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.
 
14
#
 
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
 
18
#
 
19
# Authors: Amarnath Chitumalla
 
20
#
 
21
 
 
22
#global
 
23
import os
 
24
import sys
 
25
 
 
26
# Local
 
27
from base.g import *
 
28
from base import utils
 
29
from prnt import cups
 
30
from base.codes import *
 
31
from ui_utils import *
 
32
 
 
33
 
 
34
# Qt
 
35
from PyQt4.QtCore import *
 
36
from PyQt4.QtGui import *
 
37
 
 
38
from PyQt4 import QtCore, QtGui
 
39
 
 
40
class Ui_Dialog(object):
 
41
    def setupUi(self, Dialog, printerName, device_uri,Error_msg):
 
42
        Dialog.setObjectName("Dialog")
 
43
        Dialog.resize(700, 180)
 
44
        self.printerName=printerName
 
45
        self.device_uri=device_uri
 
46
        self.Error_msg=Error_msg
 
47
        self.gridlayout = QtGui.QGridLayout(Dialog)
 
48
        self.gridlayout.setObjectName("gridlayout")
 
49
        self.StackedWidget = QtGui.QStackedWidget(Dialog)
 
50
        self.StackedWidget.setObjectName("StackedWidget")
 
51
        self.page = QtGui.QWidget()
 
52
        self.page.setObjectName("page")
 
53
        self.gridlayout1 = QtGui.QGridLayout(self.page)
 
54
        self.gridlayout1.setObjectName("gridlayout1")
 
55
        self.label = QtGui.QLabel(self.page)
 
56
        font = QtGui.QFont()
 
57
        font.setPointSize(16)
 
58
        self.label.setFont(font)
 
59
        self.label.setObjectName("label")
 
60
        self.gridlayout1.addWidget(self.label, 0, 0, 1, 1)
 
61
        self.line = QtGui.QFrame(self.page)
 
62
        self.line.setFrameShape(QtGui.QFrame.HLine)
 
63
        self.line.setFrameShadow(QtGui.QFrame.Sunken)
 
64
        self.line.setObjectName("line")
 
65
        self.gridlayout1.addWidget(self.line, 1, 0, 1, 2)
 
66
        self.TitleLabel = QtGui.QLabel(self.page)
 
67
        self.TitleLabel.setWordWrap(True)
 
68
        self.TitleLabel.setObjectName("TitleLabel")
 
69
        self.gridlayout1.addWidget(self.TitleLabel, 2, 0, 1, 2)
 
70
        spacerItem = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
 
71
        spacerItem2 = QtGui.QSpacerItem(200, 51, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
 
72
        self.gridlayout1.addItem(spacerItem2, 5, 1, 1, 1)
 
73
        self.StackedWidget.addWidget(self.page)
 
74
        self.gridlayout.addWidget(self.StackedWidget, 0, 0, 1, 5)
 
75
        self.line_2 = QtGui.QFrame(Dialog)
 
76
        self.line_2.setFrameShape(QtGui.QFrame.HLine)
 
77
        self.line_2.setFrameShadow(QtGui.QFrame.Sunken)
 
78
        self.line_2.setObjectName("line_2")
 
79
        self.gridlayout.addWidget(self.line_2, 1, 0, 1, 4)
 
80
        self.NextButton = QtGui.QPushButton(Dialog)
 
81
        self.NextButton.setObjectName("NextButton")
 
82
        self.gridlayout.addWidget(self.NextButton, 2, 3, 1, 1)
 
83
        self.CancelButton = QtGui.QPushButton(Dialog)
 
84
        self.CancelButton.setObjectName("CancelButton")
 
85
        self.gridlayout.addWidget(self.CancelButton, 2, 4, 1, 1)
 
86
 
 
87
        self.retranslateUi(Dialog)
 
88
        self.StackedWidget.setCurrentIndex(0)
 
89
        QtCore.QMetaObject.connectSlotsByName(Dialog)
 
90
 
 
91
    def retranslateUi(self, Dialog):
 
92
        Dialog.setWindowTitle(QtGui.QApplication.translate("Dialog", "HP Device Manager - Queues diagnose", None, QtGui.QApplication.UnicodeUTF8))
 
93
        if self.Error_msg == QUEUES_PAUSED:
 
94
            self.label.setText(QtGui.QApplication.translate("Dialog", "Print/Fax Queue is Paused", None, QtGui.QApplication.UnicodeUTF8))
 
95
        else:
 
96
            self.label.setText(QtGui.QApplication.translate("Dialog", "Queue needs to be reconfigured", None, QtGui.QApplication.UnicodeUTF8))
 
97
            
 
98
        if self.Error_msg == QUEUES_INCORRECT_PPD:
 
99
            text= "'"+ self.printerName + "' is using incorrect PPD file. Do you want to remove and reconfigure queue?"
 
100
        elif self.Error_msg == QUEUES_PAUSED:
 
101
            text="'"+ self.printerName + "' is paused. Do you want to enable queue?"
 
102
        elif self.Error_msg == QUEUES_CONFIG_ERROR:
 
103
            text="'"+ self.printerName + "' is not configured using hp-setup utility. Click 'Next' to remove and reconfigure queue."
 
104
 
 
105
        if self.Error_msg != QUEUES_MSG_SENDING:
 
106
            self.TitleLabel.setText(QtGui.QApplication.translate("Dialog", text, None, QtGui.QApplication.UnicodeUTF8))
 
107
            if self.Error_msg == QUEUES_PAUSED or self.Error_msg == QUEUES_INCORRECT_PPD:
 
108
                self.NextButton.setText(QtGui.QApplication.translate("Dialog", "Yes", None, QtGui.QApplication.UnicodeUTF8))
 
109
                self.CancelButton.setText(QtGui.QApplication.translate("Dialog", "No", None, QtGui.QApplication.UnicodeUTF8))
 
110
            else:
 
111
                self.NextButton.setText(QtGui.QApplication.translate("Dialog", "Next >", None, QtGui.QApplication.UnicodeUTF8))
 
112
                self.CancelButton.setText(QtGui.QApplication.translate("Dialog", "Cancel", None, QtGui.QApplication.UnicodeUTF8))
 
113
 
 
114
 
 
115
# Ui
 
116
 
 
117
class QueuesDiagnose(QDialog, Ui_Dialog):
 
118
    def __init__(self, parent, printerName, device_uri, Error_msg):
 
119
        QDialog.__init__(self, parent)
 
120
        self.result = False
 
121
        self.printerName = printerName
 
122
        self.device_uri = device_uri
 
123
        self.Error_msg = Error_msg
 
124
        self.setupUi(self, printerName, device_uri,Error_msg)
 
125
        self.user_settings = UserSettings()
 
126
        self.user_settings.load()
 
127
        self.user_settings.debug()
 
128
 
 
129
        self.initUi()
 
130
 
 
131
 
 
132
    def initUi(self):
 
133
        # connect signals/slots
 
134
        self.connect(self.CancelButton, SIGNAL("clicked()"), self.CancelButton_clicked)
 
135
        self.connect(self.NextButton, SIGNAL("clicked()"), self.NextButton_clicked)
 
136
 
 
137
        # Application icon
 
138
        self.setWindowIcon(QIcon(load_pixmap('hp_logo', '128x128')))
 
139
 
 
140
 
 
141
    #
 
142
    # Misc
 
143
    #
 
144
    def displayPage(self, page):
 
145
        self.updateStepText(page)
 
146
        self.StackedWidget.setCurrentIndex(page)
 
147
 
 
148
    def CancelButton_clicked(self):
 
149
        self.close()
 
150
 
 
151
 
 
152
    def NextButton_clicked(self):
 
153
        try:
 
154
            if  self.Error_msg != QUEUES_PAUSED:
 
155
                cups.delPrinter(self.printerName)
 
156
                msg="' "+self.printerName+" ' removed successfully.\nRe-configuring this printer by hp-setup..."
 
157
                log.debug(msg)
 
158
                path = utils.which('hp-setup')
 
159
                if path:
 
160
                    log.debug("Starting hp-setup")
 
161
                    utils.run('hp-setup')
 
162
 
 
163
            else:
 
164
                cups.enablePrinter(self.printerName)
 
165
                msg ="'"+self.printerName+"' is enabled successfully"
 
166
                SuccessUI(self, self.__tr(msg))
 
167
 
 
168
        finally:
 
169
            endWaitCursor()
 
170
        self.result = True
 
171
        self.close()
 
172
 
 
173
    def showMessage(self,msg):
 
174
        FailureUI(self, self.__tr(msg))
 
175
 
 
176
    def showSuccessMessage(self,msg):
 
177
        SuccessUI(self, self.__tr(msg))
 
178
 
 
179
    def __tr(self,s,c = None):
 
180
        return qApp.translate("PluginDialog",s,c)
 
181