Пример #1
0
    def __init__(self, package, parent, item):
        QtWidgets.QWidget.__init__(self, None)

        self.ui = Ui_ServiceItemWidget()
        self.ui.setupUi(self)

        self.busy = QProgressIndicator(self)
        self.busy.setMinimumSize(QtCore.QSize(32, 32))
        self.ui.mainLayout.insertWidget(0, self.busy)
        self.ui.spacer.hide()
        self.busy.hide()

        self.ui.labelName.setText(package)

        self.toggleButtons()

        self.ui.buttonStart.setIcon(QIcon.fromTheme("media-playback-start"))
        self.ui.buttonStop.setIcon(QIcon.fromTheme("media-playback-stop"))
        self.ui.buttonReload.setIcon(QIcon.fromTheme("view-refresh"))
        self.ui.buttonInfo.setIcon(QIcon.fromTheme("dialog-information"))

        self.toggled = False
        self.root = parent
        self.iface = parent.iface
        self.item = item
        self.package = package
        self.info = ServiceItemInfo(self)

        self.type = None
        self.desc = None
        self.ui.buttonStart.clicked.connect(self.setService)
        self.ui.buttonStop.clicked.connect(self.setService)
        self.ui.buttonReload.clicked.connect(self.setService)
        self.ui.checkStart.clicked.connect(self.setService)
        self.ui.buttonInfo.clicked.connect(self.info.showDescription)
Пример #2
0
    def __init__(self, package, parent, item):
        QtGui.QWidget.__init__(self, None)
        
        self.ui = Ui_ServiceItemWidget()
        self.ui.setupUi(self)

        self.busy = QProgressIndicator(self)
        self.busy.setMinimumSize(QtCore.QSize(32, 32))
        self.ui.mainLayout.insertWidget(0, self.busy)
        self.ui.spacer.hide()
        self.busy.hide()

        self.ui.labelName.setText(package)

        self.toggleButtons()

        self.ui.buttonStart.setIcon(KIcon("media-playback-start"))
        self.ui.buttonStop.setIcon(KIcon("media-playback-stop"))
        self.ui.buttonReload.setIcon(KIcon("view-refresh"))
        self.ui.buttonInfo.setIcon(KIcon("dialog-information"))

        self.toggled = False
        self.root = parent
        self.iface = parent.iface
        self.item = item
        self.package = package
        self.info = ServiceItemInfo(self)

        self.type = None
        self.desc = None
        self.connect(self.ui.buttonStart, SIGNAL("clicked()"), self.setService)
        self.connect(self.ui.buttonStop, SIGNAL("clicked()"), self.setService)
        self.connect(self.ui.buttonReload, SIGNAL("clicked()"), self.setService)
        self.connect(self.ui.checkStart, SIGNAL("clicked()"), self.setService)
        self.connect(self.ui.buttonInfo, SIGNAL("clicked()"), self.info.showDescription)
Пример #3
0
class ServiceItemWidget(QtGui.QWidget):
    def __init__(self, package, parent, item):
        QtGui.QWidget.__init__(self, None)

        self.ui = Ui_ServiceItemWidget()
        self.ui.setupUi(self)

        self.busy = QProgressIndicator(self)
        self.busy.setMinimumSize(QtCore.QSize(32, 32))
        self.ui.mainLayout.insertWidget(0, self.busy)
        self.ui.spacer.hide()
        self.busy.hide()

        self.ui.labelName.setText(package)

        self.toggleButtons()

        self.ui.buttonStart.setIcon(KIcon("media-playback-start"))
        self.ui.buttonStop.setIcon(KIcon("media-playback-stop"))
        self.ui.buttonReload.setIcon(KIcon("view-refresh"))
        self.ui.buttonInfo.setIcon(KIcon("dialog-information"))

        self.toggled = False
        self.root = parent
        self.iface = parent.iface
        self.item = item
        self.package = package
        self.info = ServiceItemInfo(self)

        self.type = None
        self.desc = None
        self.connect(self.ui.buttonStart, SIGNAL("clicked()"), self.setService)
        self.connect(self.ui.buttonStop, SIGNAL("clicked()"), self.setService)
        self.connect(self.ui.buttonReload, SIGNAL("clicked()"),
                     self.setService)
        self.connect(self.ui.checkStart, SIGNAL("clicked()"), self.setService)
        self.connect(self.ui.buttonInfo, SIGNAL("clicked()"),
                     self.info.showDescription)

    def updateService(self, data, firstRun):
        self.type, self.desc, serviceState = data
        self.setState(serviceState, firstRun)
        self.ui.labelDesc.setText(self.desc)

    def setState(self, state, firstRun=False):
        if not firstRun:
            # There is a raise condition, FIXME in System.Service
            time.sleep(1)
            state = self.iface.info(self.package)[2]
        if state in ('on', 'started', 'conditional_started'):
            self.running = True
            icon = 'flag-green'
        else:
            self.running = False
            icon = 'flag-black'

        self.ui.buttonStop.setEnabled(self.running)
        self.ui.buttonReload.setEnabled(self.running)

        self.ui.labelStatus.setPixmap(KIcon(icon).pixmap(32, 32))
        self.showStatus()
        self.runningAtStart = False
        if state in ('on', 'stopped'):
            self.runningAtStart = True
        elif state in ('off', 'started', 'conditional_started'):
            self.runningAtStart = False
        self.ui.checkStart.setChecked(self.runningAtStart)
        self._last_state = self.ui.checkStart.isChecked()
        # print self.package, state

    def setService(self):
        try:
            self.showBusy()
            self._last_state = not self.ui.checkStart.isChecked()
            if self.sender() == self.ui.buttonStart:
                self.iface.start(self.package)
            elif self.sender() == self.ui.buttonStop:
                self.iface.stop(self.package)
            elif self.sender() == self.ui.buttonReload:
                self.iface.restart(self.package)
            elif self.sender() == self.ui.checkStart:
                self.iface.setEnable(self.package,
                                     self.ui.checkStart.isChecked())
        except Exception, msg:
            self.showStatus()
            self.root.showFail(msg)
Пример #4
0
class ServiceItemWidget(QtGui.QWidget):

    def __init__(self, package, parent, item):
        QtGui.QWidget.__init__(self, None)
        
        self.ui = Ui_ServiceItemWidget()
        self.ui.setupUi(self)

        self.busy = QProgressIndicator(self)
        self.busy.setMinimumSize(QtCore.QSize(32, 32))
        self.ui.mainLayout.insertWidget(0, self.busy)
        self.ui.spacer.hide()
        self.busy.hide()

        self.ui.labelName.setText(package)

        self.toggleButtons()

        self.ui.buttonStart.setIcon(KIcon("media-playback-start"))
        self.ui.buttonStop.setIcon(KIcon("media-playback-stop"))
        self.ui.buttonReload.setIcon(KIcon("view-refresh"))
        self.ui.buttonInfo.setIcon(KIcon("dialog-information"))

        self.toggled = False
        self.root = parent
        self.iface = parent.iface
        self.item = item
        self.package = package
        self.info = ServiceItemInfo(self)

        self.type = None
        self.desc = None
        self.connect(self.ui.buttonStart, SIGNAL("clicked()"), self.setService)
        self.connect(self.ui.buttonStop, SIGNAL("clicked()"), self.setService)
        self.connect(self.ui.buttonReload, SIGNAL("clicked()"), self.setService)
        self.connect(self.ui.checkStart, SIGNAL("clicked()"), self.setService)
        self.connect(self.ui.buttonInfo, SIGNAL("clicked()"), self.info.showDescription)

    def updateService(self, data, firstRun):
        self.type, self.desc, serviceState = data
        self.setState(serviceState, firstRun)
        self.ui.labelDesc.setText(self.desc)

    def setState(self, state, firstRun=False):
        if not firstRun:
            # There is a raise condition, FIXME in System.Service
            time.sleep(1)
            state = self.iface.info(self.package)[2]
        if state in ('on', 'started', 'conditional_started'):
            self.running = True
            icon = 'flag-green'
        else:
            self.running = False
            icon = 'flag-black'

        self.ui.buttonStop.setEnabled(self.running)
        self.ui.buttonReload.setEnabled(self.running)

        self.ui.labelStatus.setPixmap(KIcon(icon).pixmap(32, 32))
        self.showStatus()
        self.runningAtStart = False
        if state in ('on', 'stopped'):
            self.runningAtStart = True
        elif state in ('off', 'started', 'conditional_started'):
            self.runningAtStart = False
        self.ui.checkStart.setChecked(self.runningAtStart)
        self._last_state = self.ui.checkStart.isChecked()
        # print self.package, state

    def setService(self):
        try:
            self.showBusy()
            self._last_state = not self.ui.checkStart.isChecked()
            if self.sender() == self.ui.buttonStart:
                self.iface.start(self.package)
            elif self.sender() == self.ui.buttonStop:
                self.iface.stop(self.package)
            elif self.sender() == self.ui.buttonReload:
                self.iface.restart(self.package)
            elif self.sender() == self.ui.checkStart:
                self.iface.setEnable(self.package, self.ui.checkStart.isChecked())
        except Exception, msg:
            self.showStatus()
            self.root.showFail(msg)