def slotSetUnread(self, unread): cfg = config.PMConfig() if not cfg.systemTray(): return if config.PMConfig().hideTrayIfThereIsNoUpdate() and unread == 0: self.setToolTip("package-manager", i18n("Package Manager"), i18n("All packages are up to date")) self.setStatus(KStatusNotifierItem.Passive) else: if unread > 0: self.setToolTip( "package-manager", i18n("Package Manager"), i18n("There are <b>%1</b> updates available!", unread)) else: self.setToolTip("package-manager", i18n("Package Manager"), i18n("All packages are up to date")) self.setStatus(KStatusNotifierItem.Active) if self.unread == unread: return self.unread = unread if unread == 0: self.setIconByPixmap(self.defaultIcon) self.lastIcon = self.defaultIcon else: countStr = "%s" % unread f = QtGui.qApp.font() f.setBold(True) pointSize = f.pointSizeF() fm = QtGui.QFontMetrics(f) w = fm.width(countStr) if w > 19: pointSize *= float(19) / float(w) f.setPointSizeF(pointSize) overlayImg = QtGui.QPixmap(self.countIcon.pixmap(22)) p = QtGui.QPainter(overlayImg) p.setFont(f) scheme = QtGui.QBrush() p.setBrush(scheme) p.setOpacity(0.6) p.setPen(QtGui.QColor('white')) # shadow for i in range(20, 24): p.drawText(QRect(0, 0, i, i), Qt.AlignCenter, countStr) p.setOpacity(1.0) p.setPen(QtGui.QColor('black')) p.drawText(overlayImg.rect(), Qt.AlignCenter, countStr) p.end() self.lastIcon = QtGui.QIcon(overlayImg) self.setIconByPixmap(self.lastIcon)
def showPopup(self): upgrades = backend.pm.Iface().getUpdates() self.slotSetUnread(len(upgrades)) if config.PMConfig().installUpdatesAutomatically(): if not self.appWindow.isVisible() and not backend.pm.Iface( ).operationInProgress(): backend.pm.Iface().upgradePackages(upgrades) return newUpgrades = set(upgrades) - set(self.lastUpgrades) self.lastUpgrades = upgrades if not len(upgrades) or not newUpgrades: return if self.notification: self.notification.close() self.notification = KNotification("Updates") self.notification.setText( i18n("There are <b>%1</b> updates available!", len(upgrades))) self.notification.setActions( QStringList((i18n("Show Updates"), i18n("Ignore")))) self.notification.setFlags(KNotification.Persistent) self.notification.setComponentData( KComponentData("package-manager", "package-manager")) self.connect(self.notification, SIGNAL("action1Activated()"), lambda: self.emit(SIGNAL("showUpdatesSelected()"))) self.notification.sendEvent()
def showPackageDetails(self, package, installed, summary='', description=''): self.packageName.setText(package) self.key = config.PMConfig().getOpenDesktopKey() self.filesList.clear() self.webView.loadFinished.connect(lambda x: \ self._sync_template(x, package, summary, description)) if network_available(): set_proxy_settings() self.webWidget.hide() self.busy.show() self.busy.startAnimation() params = {'p': package} if self.key: params['k'] = self.key self.webView.load(QUrl('%s/?%s' % (self._as, urlencode(params)))) else: self._sync_template(status=False) self.tabWidget.insertTab(0, self.packageFiles, i18n('Package Files')) self.tabWidget.currentChanged.connect(self._tabSwitched) if not installed: self.tabWidget.removeTab(0) self.tabWidget.currentChanged.disconnect(self._tabSwitched) self.animate(start=BOTCENTER, stop=MIDCENTER)
def __init__(self, settings): QObject.__init__(self) self.settings = settings self.config = config.PMConfig() self.iface = backend.pm.Iface() self.setupUi() self.connectSignals() self.changed = False
def saveSettings(self): for settings in [ self.generalSettings, self.cacheSettings, self.repositorySettings, self.proxySettings ]: if settings.changed: settings.save() self.config = config.PMConfig()
def slotSetUnread(self, unread): if config.PMConfig().hideTrayIfThereIsNoUpdate() and unread == 0: self.hide() elif config.PMConfig().systemTray(): self.show() if self.unread == unread: return self.unread = unread if unread == 0: self.setIcon(self.defaultIcon) self.lastIcon = self.defaultIcon else: countStr = "%s" % unread f = QtGui.QFont(Pds.settings('font','Sans')) f.setBold(True) pointSize = f.pointSizeF() fm = QtGui.QFontMetrics(f) w = fm.width(countStr) if w > (19): pointSize *= float(19) / float(w) f.setPointSizeF(pointSize) overlayImg = QtGui.QPixmap(self.countIcon.pixmap(22)) p = QtGui.QPainter(overlayImg) p.setFont(f) scheme = QtGui.QBrush() p.setBrush(scheme) p.setOpacity(0.6) p.setPen(QtGui.QColor('white')) # shadow for i in range(20,24): p.drawText(QRect(0, 0, i, i), Qt.AlignCenter, countStr) p.setOpacity(1.0) p.setPen(QtGui.QColor('black')) p.drawText(overlayImg.rect(), Qt.AlignCenter, countStr) p.end() self.lastIcon = QtGui.QIcon(overlayImg) self.setIcon(self.lastIcon)
def settingsChanged(self): cfg = config.PMConfig() if cfg.systemTray(): self.show() QTimer.singleShot(1, self.updateTrayUnread) else: self.hide() QtWidgets.qApp.setQuitOnLastWindowClosed(not cfg.systemTray()) self.updateInterval(cfg.updateCheckInterval())
def settingsChanged(self): cfg = config.PMConfig() if cfg.systemTray(): self.setCategory(KStatusNotifierItem.ApplicationStatus) QTimer.singleShot(1, self.updateTrayUnread) else: self.setStatus(KStatusNotifierItem.Passive) QtGui.qApp.setQuitOnLastWindowClosed(not cfg.systemTray()) self.updateInterval(cfg.updateCheckInterval())
def settingsChanged(self): cfg = config.PMConfig() if cfg.systemTray(): self.show() noUpgrades = len(backend.pm.Iface().getUpdates()) self.slotSetUnread(noUpgrades) else: self.hide() self.updateInterval(cfg.updateCheckInterval())
def _ready_to_popup(self): upgrades = self.iface.getUpdates() self.slotSetUnread(len(upgrades)) if config.PMConfig().installUpdatesAutomatically(): if not self.appWindow.isVisible() and not self.iface.operationInProgress(): self.iface.upgradePackages(upgrades) return False newUpgrades = set(upgrades) - set(self.lastUpgrades) self.lastUpgrades = upgrades if not len(upgrades) or not newUpgrades: return False return True
def newInstance(self): args = KCmdLineArgs.parsedArgs() component = None if args.isSet("select-component"): component = str(args.getOption("select-component")) self.manager.cw.selectComponent(component) # Check if show-mainwindow used in sys.args to show mainWindow if args.isSet("show-mainwindow"): self.manager.show() # If system tray disabled show mainwindow at first if not config.PMConfig().systemTray(): self.manager.show() return super(PmApp, self).newInstance()
def queryClose(self): if config.PMConfig().systemTray(): self.hide() return False return True
def initializeTimer(self): self.timer = QTimer() self.timer.timeout.connect(self.checkUpdate) self.interval = config.PMConfig().updateCheckInterval() self.updateInterval(self.interval)
def __init__(self, settings): self.settings = settings self.config = config.PMConfig() self.setupUi() self.connectSignals() self.changed = False
def queryClose(self): if config.PMConfig().systemTray( ) and not KApplication.kApplication().sessionSaving(): self.hide() return False return True
def handleException(exception, value, tb): logger.error("".join(traceback.format_exception(exception, value, tb))) if __name__ == '__main__': KCmdLineArgs.init(sys.argv, aboutData) options = KCmdLineOptions() options.add("show-mainwindow", ki18n("Show main window")) KCmdLineArgs.addCmdLineOptions(options) app = KUniqueApplication(True, True) args = KCmdLineArgs.parsedArgs() if not dbus.get_default_main_loop(): from dbus.mainloop.qt import DBusQtMainLoop DBusQtMainLoop(set_as_default = True) manager = MainWindow() if not config.PMConfig().systemTray(): manager.show() else: if args.isSet("show-mainwindow"): manager.show() sys.excepthook = handleException setSystemLocale() app.exec_()
self.proxySettings = ProxySettings(self) def connectSignals(self): self.connect(self.buttonOk, SIGNAL("clicked()"), self.saveSettings) self.connect(self.buttonCancel, SIGNAL("clicked()"), self.cancelSettings) self.connect(self.buttonHelp, SIGNAL("clicked()"), self.showHelp) def cancelSettings(self): for tab in (self.generalSettings, self.cacheSettings, \ self.repositorySettings, self.proxySettings): tab.initialize() self.reject() def saveSettings(self): for settings in [self.generalSettings, self.cacheSettings, self.repositorySettings, self.proxySettings]: try: if settings.changed: settings.save() except Exception, e: self.parent.cw.exceptionCaught(str(e)) finally: if settings.changed: settings.initialize() settings.changed = False self.config = config.PMConfig() def showHelp(self): helpDialog = helpdialog.HelpDialog(self, helpdialog.PREFERENCES) helpDialog.show()
def onlyGuiInState(self): pmConfig = config.PMConfig() return pmConfig.showOnlyGuiApp()
def onlyGuiInState(self): return config.PMConfig().showOnlyGuiApp()
DBusQtMainLoop(set_as_default=True) # Use raster to make it faster QApplication.setGraphicsSystem('raster') pid = os.fork() if pid: os._exit(0) app = QUniqueApplication(sys.argv, catalog='package-manager') setSystemLocale() # Set application font from system font = Pds.settings('font', 'Sans,10').split(',') app.setFont(QFont(font[0], int(font[1]))) manager = MainWindow(app) app.setMainWindow(manager) if config.PMConfig().systemTray(): app.setQuitOnLastWindowClosed(False) if not config.PMConfig().systemTray() or "--show-mainwindow" in sys.argv: manager.show() # Set exception handler sys.excepthook = handleException # Run the Package Manager app.exec_()
pid = os.fork() if pid: os._exit(0) app = QUniqueApplication(sys.argv, catalog='package-manager') setSystemLocale() # Set application font from system font = Pds.settings('font','Sans,10').split(',') app.setFont(QFont(font[0], int(font[1]))) manager = MainWindow(app) app.setMainWindow(manager) if config.PMConfig().systemTray(): app.setQuitOnLastWindowClosed(False) #if not config.PMConfig().systemTray() or "--show-mainwindow" in sys.argv: # manager.show() # Arrange arguments parser = OptionParser() parser.add_option("--show-mainwindow", action="store_false", help="Show main window.") parser.add_option("--add-repository", help="Add repository. Needs argument.") opts, args = parser.parse_args()