def __init__(self, ctrl, argv=None): QtInterface.__init__(self, ctrl, argv) self._status = QtStatus()
def __init__(self, ctrl, argv=None): QtInterface.__init__(self, ctrl, argv) self._changeset = None self._window = qt.QMainWindow() self._window.setCaption("Smart Package Manager %s" % VERSION) centerWindow(self._window) self._window.setMinimumSize(640, 480) app.connect(app, qt.SIGNAL('lastWindowClosed()'), app, qt.SLOT('quit()')) self._undo = [] self._redo = [] globals = {"self": self, "qt": qt} group = qt.QActionGroup(self._window, "Actions") self._actions = compileActions(group, ACTIONS, globals) class ToggleAction(qt.QAction): def __init__(self, group, name, label): qt.QAction.__init__(self, group, name) self.setToggleAction(True) self.setMenuText(label.replace("&","&&")) self._name = name def connect(self, signal, callback, userdata): self._callback = callback self._userdata = userdata qt.QObject.connect(self, qt.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.setOn(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 = qt.QPopupMenu(menubar) text = action.menuText() menubar.insertItem(text, m) for item in menu[1]: if isinstance(item, tuple): insertmenu(m, item) elif item: action = self._actions[item] #i = qt.QPopupMenu(m) #text = action.menuText() #m.insertItem(text, i) action.addTo(m) else: m.insertSeparator() insertmenu(self._menubar, MENU) self._toolbar = qt.QToolBar(self._window) for TOOL in TOOLBAR: def inserttool(toolbar, tool): if tool: action = self._actions[tool] #b = qt.QToolButton(toolbar, TOOL) #b.setTextLabel(action.toolTip()) pixmap = getPixmap(TOOLBARICONS[tool]) #b.setIconSet(qt.QIconSet(pixmap)) action.setIconSet(qt.QIconSet(pixmap)) action.addTo(toolbar) else: toolbar.addSeparator() inserttool(self._toolbar, TOOL) #self._window.add_accel_group(self._ui.get_accel_group()) self._actions["exec-changes"].setAccel(qt.QKeySequence("Ctrl+C")) self._actions["find"].setAccel(qt.QKeySequence("Ctrl+F")) self._actions["expand-all"].setAccel(qt.QKeySequence("Ctrl+O")) self._actions["collapse-all"].setAccel(qt.QKeySequence("Ctrl+W")) self._actions["summary-window"].setAccel(qt.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 = qt.QToolBar(self._window) self._searchbar.hide() label = qt.QLabel(_("Search:"), self._searchbar) label.show() self._searchentry = qt.QLineEdit(self._searchbar) qt.QObject.connect(self._searchentry, qt.SIGNAL("returnPressed()"), self.refreshPackages) self._searchentry.show() button = qt.QPushButton(self._searchbar) qt.QObject.connect(button, qt.SIGNAL("clicked()"), self.refreshPackages) pixmap = getPixmap("crystal-search") button.setIconSet(qt.QIconSet(pixmap)) button.show() buttongroup = qt.QButtonGroup(self._searchbar) buttongroup.hide() self._searchname = qt.QRadioButton(_("Automatic"), self._searchbar) self._searchname.setChecked(True) qt.QObject.connect(self._searchname, qt.SIGNAL("clicked()"), self.refreshPackages) buttongroup.insert(self._searchname) self._searchname.show() self._searchdesc = qt.QRadioButton(_("Description"), self._searchbar) self._searchdesc.setChecked(False) qt.QObject.connect(self._searchdesc, qt.SIGNAL("clicked()"), self.refreshPackages) self._searchdesc.show() buttongroup.insert(self._searchdesc) # Packages and information self._splitter = qt.QSplitter(qt.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() qt.QObject.connect(self._pv, qt.PYSIGNAL("packageSelected"), self._pi.setPackage) qt.QObject.connect(self._pv, qt.PYSIGNAL("packageActivated"), self.actOnPackages) qt.QObject.connect(self._pv, qt.PYSIGNAL("packagePopup"), self.packagePopup) self._status = self._window.statusBar() self._status.show() self._legend = QtLegend(self._window)