def run(self, command=None, argv=None): result = QtInterface.run(self, command, argv) self._status.wait() while self._log.isVisible(): time.sleep(0.1) while QtCore.QEventLoop().isRunning(): QtGui.QCoreApplication.eventLoop().processEvents(QtGui.QEventLoop.AllEvents) return result
def run(self, command=None, argv=None): result = QtInterface.run(self, command, argv) self._status.wait() while self._log.isVisible(): time.sleep(0.1) while QtGui.QApplication.eventLoop().hasPendingEvents(): QtGui.QApplication.eventLoop().processEvents(QtGui.QEventLoop.AllEvents) return result
def __init__(self, ctrl, argv=None): QtInterface.__init__(self, ctrl, argv) self._changeset = None self._window = QtGui.QMainWindow() self._window.setWindowTitle("Smart Package Manager %s" % VERSION) centerWindow(self._window) self._window.setMinimumSize(640, 480) app.connect(app, QtCore.SIGNAL('lastWindowClosed()'), app, QtCore.SLOT('quit()')) self._undo = [] self._redo = [] globals = {"self": self, "QtGui": QtGui, "QtCore": QtCore} #group = QtGui.QActionGroup(self._window, "Actions") group = QtGui.QActionGroup(self._window) self._actions = compileActions(group, ACTIONS, globals) class ToggleAction(QtGui.QAction): def __init__(self, group, name, label): QtGui.QAction.__init__(self, name, group) #self.setToggleAction(True) self.setCheckable(True) self.setText(label.replace("&","&&")) self._name = name def connect(self, signal, callback, userdata): self._callback = callback self._userdata = userdata QtCore.QObject.connect(self, QtCore.SIGNAL(signal), self.slot) def slot(self): self._callback(self._userdata) self._filters = {} for name, label in [("hide-non-upgrades", _("Hide Non-upgrades")), ("hide-installed", _("Hide Installed")), ("hide-uninstalled", _("Hide Uninstalled")), ("hide-unmarked", _("Hide Unmarked")), ("hide-unlocked", _("Hide Unlocked")), ("hide-requested", _("Hide Requested")), ("hide-old", _("Hide Old"))]: act = ToggleAction(None, name, label) act.connect("activated()", self.toggleFilter, name) self._actions[name] = act treestyle = sysconf.get("package-tree") for name, label in [("groups", _("Groups")), ("channels", _("Channels")), ("channels-groups", _("Channels & Groups")), ("none", _("None"))]: act = ToggleAction(group, "tree-style-"+name, label) if name == treestyle: act.setChecked(True) act.connect("activated()", self.setTreeStyle, name) self._actions["tree-style-"+name] = act self._menubar = self._window.menuBar() for MENU in MENUBAR: def insertmenu(menubar, menu): item = menu[0] action = self._actions[item] m = QtGui.QMenu(menubar) m.setTitle(action.text()) menubar.addMenu(m) for item in menu[1]: if isinstance(item, tuple): insertmenu(m, item) elif item: action = self._actions[item] #i = QtGui.QPopupMenu(m) i = QtGui.QMenu(m) #text = action.menuText() i.setTitle(action.text()) #m.insertItem(text, i) #action.addTo(m) m.addAction(action) else: m.addSeparator() insertmenu(self._menubar, MENU) self._toolbar = QtGui.QToolBar(self._window) for TOOL in TOOLBAR: def inserttool(toolbar, tool): if tool: action = self._actions[tool] pixmap = getPixmap(TOOLBARICONS[tool]) action.setIcon(QtGui.QIcon(pixmap)) toolbar.addAction(action) else: toolbar.addSeparator() inserttool(self._toolbar, TOOL) self._window.addToolBar( self._toolbar) #self._window.add_accel_group(self._ui.get_accel_group()) self._actions["exec-changes"].setShortcut(QtGui.QKeySequence("Ctrl+C")) self._actions["find"].setShortcut(QtGui.QKeySequence("Ctrl+F")) self._actions["expand-all"].setShortcut(QtGui.QKeySequence("Ctrl+O")) self._actions["collapse-all"].setShortcut(QtGui.QKeySequence("Ctrl+W")) self._actions["summary-window"].setShortcut(QtGui.QKeySequence("Ctrl+S")) self._actions["exec-changes"].setEnabled(False) self._actions["clear-changes"].setEnabled(False) self._actions["undo"].setEnabled(False) self._actions["redo"].setEnabled(False) # Search bar self._searchbar = QtGui.QToolBar(self._window) self._searchbar.hide() self._window.addToolBar(self._searchbar) label = QtGui.QLabel(_("Search:"), self._searchbar) label.show() self._searchbar.addWidget(label) self._searchentry = QtGui.QLineEdit(self._searchbar) QtCore.QObject.connect(self._searchentry, QtCore.SIGNAL("returnPressed()"), self.refreshPackages) self._searchentry.show() self._searchbar.addWidget(self._searchentry) button = QtGui.QPushButton(self._searchbar) QtCore.QObject.connect(button, QtCore.SIGNAL("clicked()"), self.refreshPackages) pixmap = getPixmap("crystal-search") button.setIcon(QtGui.QIcon(pixmap)) button.show() self._searchbar.addWidget(button) buttongroup = QtGui.QButtonGroup(self._searchbar) #buttongroup.hide() self._searchname = QtGui.QRadioButton(_("Automatic"), self._searchbar) self._searchname.setChecked(True) QtCore.QObject.connect(self._searchname, QtCore.SIGNAL("clicked()"), self.refreshPackages) buttongroup.addButton(self._searchname) self._searchbar.addWidget(self._searchname) self._searchname.show() self._searchdesc = QtGui.QRadioButton(_("Description"), self._searchbar) self._searchdesc.setChecked(False) QtCore.QObject.connect(self._searchdesc, QtCore.SIGNAL("clicked()"), self.refreshPackages) self._searchdesc.show() buttongroup.addButton(self._searchdesc) self._searchbar.addWidget(self._searchdesc) # Packages and information self._splitter = QtGui.QSplitter(QtCore.Qt.Vertical, self._window) self._window.setCentralWidget(self._splitter) self._pv = QtPackageView(self._splitter) self._pv.show() self._pi = QtPackageInfo(self._splitter) self._pi.show() QtCore.QObject.connect(self._pv, QtCore.SIGNAL("packageSelected"), self._pi.setPackage) QtCore.QObject.connect(self._pv, QtCore.SIGNAL("packageActivated"), self.actOnPackages) QtCore.QObject.connect(self._pv, QtCore.SIGNAL("packagePopup"), self.packagePopup) self._status = self._window.statusBar() self._status.show() self._legend = QtLegend(self._window)
def __init__(self, ctrl, argv=None): QtInterface.__init__(self, ctrl, argv) self._status = QtStatus()