summaryrefslogtreecommitdiff
path: root/portato/gui/qt
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--portato/gui/qt/tree.py2
-rw-r--r--portato/gui/qt/ui/MainWindow.ui98
-rw-r--r--portato/gui/qt/windows.py142
3 files changed, 225 insertions, 17 deletions
diff --git a/portato/gui/qt/tree.py b/portato/gui/qt/tree.py
index 3e64f09..fd616b6 100644
--- a/portato/gui/qt/tree.py
+++ b/portato/gui/qt/tree.py
@@ -33,7 +33,7 @@ class QtTree (Tree):
if update:
string += "(updating"
if version is not None:
- string += "from version %s" % version
+ string += " from version %s" % version
string += ")"
return [cpv, string]
diff --git a/portato/gui/qt/ui/MainWindow.ui b/portato/gui/qt/ui/MainWindow.ui
index f942ea7..2830291 100644
--- a/portato/gui/qt/ui/MainWindow.ui
+++ b/portato/gui/qt/ui/MainWindow.ui
@@ -80,7 +80,7 @@
</widget>
<widget class="QTabWidget" name="tabWidget" >
<property name="currentIndex" >
- <number>0</number>
+ <number>1</number>
</property>
<widget class="QWidget" name="pkgTab" >
<attribute name="title" >
@@ -170,8 +170,8 @@ p, li { white-space: pre-wrap; }
<widget class="UncheckBox" name="installedCheck" >
<property name="sizePolicy" >
<sizepolicy>
- <hsizetype>13</hsizetype>
- <vsizetype>13</vsizetype>
+ <hsizetype>3</hsizetype>
+ <vsizetype>5</vsizetype>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@@ -182,10 +182,7 @@ p, li { white-space: pre-wrap; }
</widget>
</item>
<item>
- <widget class="QCheckBox" name="testingCheck" >
- <property name="enabled" >
- <bool>true</bool>
- </property>
+ <widget class="QCheckBox" name="maskedCheck" >
<property name="sizePolicy" >
<sizepolicy>
<hsizetype>3</hsizetype>
@@ -195,12 +192,15 @@ p, li { white-space: pre-wrap; }
</sizepolicy>
</property>
<property name="text" >
- <string>Testing</string>
+ <string>Masked</string>
</property>
</widget>
</item>
<item>
- <widget class="QCheckBox" name="maskedCheck" >
+ <widget class="QCheckBox" name="testingCheck" >
+ <property name="enabled" >
+ <bool>true</bool>
+ </property>
<property name="sizePolicy" >
<sizepolicy>
<hsizetype>3</hsizetype>
@@ -210,7 +210,7 @@ p, li { white-space: pre-wrap; }
</sizepolicy>
</property>
<property name="text" >
- <string>Masked</string>
+ <string>Testing</string>
</property>
</widget>
</item>
@@ -224,6 +224,9 @@ p, li { white-space: pre-wrap; }
<property name="editTriggers" >
<set>QAbstractItemView::NoEditTriggers</set>
</property>
+ <property name="textElideMode" >
+ <enum>Qt::ElideNone</enum>
+ </property>
<property name="rootIsDecorated" >
<bool>true</bool>
</property>
@@ -388,7 +391,7 @@ p, li { white-space: pre-wrap; }
<x>0</x>
<y>0</y>
<width>466</width>
- <height>28</height>
+ <height>31</height>
</rect>
</property>
<widget class="QMenu" name="menuFile" >
@@ -403,7 +406,17 @@ p, li { white-space: pre-wrap; }
</property>
<addaction name="aboutAction" />
</widget>
+ <widget class="QMenu" name="menu_Emerge" >
+ <property name="title" >
+ <string>&amp;Emerge</string>
+ </property>
+ <addaction name="emergeAction" />
+ <addaction name="unmergeAction" />
+ <addaction name="updateAction" />
+ <addaction name="separator" />
+ </widget>
<addaction name="menuFile" />
+ <addaction name="menu_Emerge" />
<addaction name="menuHelp" />
</widget>
<widget class="QStatusBar" name="statusbar" >
@@ -427,6 +440,21 @@ p, li { white-space: pre-wrap; }
<string>&amp;About</string>
</property>
</action>
+ <action name="emergeAction" >
+ <property name="text" >
+ <string>&amp;Emerge</string>
+ </property>
+ </action>
+ <action name="unmergeAction" >
+ <property name="text" >
+ <string>&amp;Unmerge</string>
+ </property>
+ </action>
+ <action name="updateAction" >
+ <property name="text" >
+ <string>Update &amp;World</string>
+ </property>
+ </action>
</widget>
<customwidgets>
<customwidget>
@@ -469,5 +497,53 @@ p, li { white-space: pre-wrap; }
</hint>
</hints>
</connection>
+ <connection>
+ <sender>emergeAction</sender>
+ <signal>triggered()</signal>
+ <receiver>emergeBtn</receiver>
+ <slot>click()</slot>
+ <hints>
+ <hint type="sourcelabel" >
+ <x>-1</x>
+ <y>-1</y>
+ </hint>
+ <hint type="destinationlabel" >
+ <x>66</x>
+ <y>642</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>unmergeAction</sender>
+ <signal>triggered()</signal>
+ <receiver>unmergeBtn</receiver>
+ <slot>click()</slot>
+ <hints>
+ <hint type="sourcelabel" >
+ <x>-1</x>
+ <y>-1</y>
+ </hint>
+ <hint type="destinationlabel" >
+ <x>177</x>
+ <y>642</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>updateAction</sender>
+ <signal>triggered()</signal>
+ <receiver>updateBtn</receiver>
+ <slot>click()</slot>
+ <hints>
+ <hint type="sourcelabel" >
+ <x>-1</x>
+ <y>-1</y>
+ </hint>
+ <hint type="destinationlabel" >
+ <x>288</x>
+ <y>642</y>
+ </hint>
+ </hints>
+ </connection>
</connections>
</ui>
diff --git a/portato/gui/qt/windows.py b/portato/gui/qt/windows.py
index 46d9ec6..4c62d8f 100644
--- a/portato/gui/qt/windows.py
+++ b/portato/gui/qt/windows.py
@@ -38,6 +38,9 @@ def qCheck (check):
else:
return QtCore.Qt.Unchecked
+def qIsChecked (check):
+ return check == QtCore.Qt.Checked
+
class WindowMeta (sip.wrappertype, type):
def __new__ (cls, name, bases, dict):
@@ -57,6 +60,22 @@ class Window:
self._qt_base.__init__(self, parent)
self.setupUi(self)
+ @staticmethod
+ def watch_cursor (func):
+ """This is a decorator for functions being so time consuming, that it is appropriate to show the watch-cursor."""
+ def wrapper (*args, **kwargs):
+ ret = None
+
+ QtGui.QApplication.setOverrideCursor(QtCore.Qt.WaitCursor)
+ try:
+ ret = func(*args, **kwargs)
+ finally:
+ QtGui.QApplication.restoreOverrideCursor()
+
+ return ret
+
+ return wrapper
+
class AboutDialog (Window):
"""A window showing the "about"-informations."""
__metaclass__ = WindowMeta
@@ -111,14 +130,20 @@ class PackageDetails:
self.window.installedCheck.blockSignals(True)
+ # combo
QtCore.QObject.connect(self.window.versCombo, QtCore.SIGNAL("currentIndexChanged(int)"), self.cb_combo_changed)
+ # buttons
QtCore.QObject.connect(self.window.pkgEmergeBtn, QtCore.SIGNAL("clicked()"), self.cb_emerge_clicked)
QtCore.QObject.connect(self.window.pkgUnmergeBtn, QtCore.SIGNAL("clicked()"), self.cb_unmerge_clicked)
QtCore.QObject.connect(self.window.pkgRevertBtn, QtCore.SIGNAL("clicked()"), self.cb_revert_clicked)
- #QtCore.QObject.connect(self.window.maskedCheck, QtCore.SIGNAL("clicked(bool)"), self.cb_masked_clicked)
- #QtCore.QObject.connect(self.window.testingCheck, QtCore.SIGNAL("clicked(bool)"), self.cb_testing_clicked)
+ # checkboxes
+ QtCore.QObject.connect(self.window.maskedCheck, QtCore.SIGNAL("clicked(bool)"), self.cb_masked_clicked)
+ QtCore.QObject.connect(self.window.testingCheck, QtCore.SIGNAL("clicked(bool)"), self.cb_testing_clicked)
+
+ # useflags
+ QtCore.QObject.connect(self.window.useList, QtCore.SIGNAL("itemClicked(QTreeWidgetItem*, int)"), self.cb_use_flag_changed)
def update (self, cp, queue = None, version = None, doEmerge = True, instantChange = False):
"""Updates the table to show the contents for the package.
@@ -263,6 +288,79 @@ class PackageDetails:
if self.instantChange:
self._update_keywords(True, update = True)
return True
+
+ def cb_testing_clicked (self, status):
+ """Callback for toggled testing-checkbox."""
+ button = self.window.testingCheck
+
+ if self.actual_package().is_testing(use_keywords = False) == status:
+ return
+
+ if not self.actual_package().is_testing(use_keywords = True):
+ self.actual_package().set_testing(False)
+ button.setText("Testing")
+ button.setCheckState(qCheck(True))
+ else:
+ self.actual_package().set_testing(True)
+ if self.actual_package().is_testing(use_keywords=False):
+ button.setText("(Testing)")
+ button.setCheckState(qCheck(True))
+
+ if self.instantChange:
+ self._update_keywords(True, update = True)
+
+ def cb_masked_clicked (self, status):
+ """Callback for toggled masking-checkbox."""
+ pkg = self.actual_package()
+ button = self.window.maskedCheck
+
+ if pkg.is_masked(use_changed = False) == status and not pkg.is_locally_masked():
+ return
+
+ if pkg.is_locally_masked() and status:
+ return False
+
+ if not pkg.is_masked(use_changed = True):
+ pkg.set_masked(True)
+ if pkg.is_locally_masked():
+ button.setText("Masked by User")
+ else:
+ button.setText("Masked")
+
+ button.setCheckState(qCheck(True))
+
+ else:
+ locally = pkg.is_locally_masked()
+ pkg.set_masked(False)
+
+ if pkg.is_masked(use_changed=False) and not locally:
+ button.setText("(Masked)")
+ button.setCheckState(qCheck(True))
+ else:
+ button.setText("Masked")
+
+ if self.instantChange:
+ self._update_keywords(True, update = True)
+
+ return True
+
+ def cb_use_flag_changed (self, item, col):
+ if col != 0: return
+
+ flag = str(item.text(1))
+ pkg = self.actual_package()
+
+ if flag in pkg.get_global_settings("USE_EXPAND").split(" "): # ignore expanded flags
+ return
+
+ checked = qIsChecked(item.checkState(0))
+
+ prefix = ""
+ if not checked: prefix = "-"
+
+ pkg.set_use_flag(prefix+flag)
+ if self.instantChange:
+ self._update_keywords(True, update = True)
def cb_combo_changed (self):
"""Callback for the changed ComboBox.
@@ -305,7 +403,11 @@ class PackageDetails:
else:
self.window.maskedCheck.setText("Masked")
- self.window.maskedCheck.setCheckState(qCheck(pkg.is_masked(use_changed = False)))
+ if pkg.is_locally_masked():
+ self.window.maskedCheck.setText("Masked by User")
+ self.window.maskedCheck.setCheckState(qCheck(True))
+ else:
+ self.window.maskedCheck.setCheckState(qCheck(pkg.is_masked(use_changed = False)))
if pkg.is_testing(use_keywords = False) and not pkg.is_testing(use_keywords = True):
self.window.testingCheck.setText("(Testing)")
@@ -367,12 +469,13 @@ class MainWindow (Window):
self.consoleLayout.setSpacing(0)
self.consoleTab.setLayout(self.consoleLayout)
self.consoleLayout.addWidget(self.console)
+ QtCore.QObject.connect(self, QtCore.SIGNAL("doTitleUpdate"), self._title_update)
# build queueList
self.queueList.setHeaderLabels(["Package", "Additional infos"])
self.queueTree = QtTree(self.queueList)
-
- QtCore.QObject.connect(self, QtCore.SIGNAL("doTitleUpdate"), self._title_update)
+ QtCore.QObject.connect(self.queueList.model(), QtCore.SIGNAL("rowsInserted (const QModelIndex&, int, int)"), self.cb_queue_list_items_added)
+ QtCore.QObject.connect(self.queueList, QtCore.SIGNAL("expanded (const QModelIndex&)"), self.cb_queue_list_items_added)
# set emerge queue
self.queue = EmergeQueue(console = self.console, tree = self.queueTree, db = self.db, title_update = self.title_update)
@@ -414,6 +517,7 @@ class MainWindow (Window):
AboutDialog(self).exec_()
@QtCore.pyqtSignature("")
+ @Window.watch_cursor
def on_searchBtn_clicked (self):
"""Do a search."""
text = str(self.searchEdit.text())
@@ -478,6 +582,34 @@ class MainWindow (Window):
self.tabWidget.setCurrentIndex(self.CONSOLE_PAGE)
self.queue.unmerge(force = True)
+ @QtCore.pyqtSignature("")
+ @Window.watch_cursor
+ def on_updateBtn_clicked (self):
+ if not am_i_root():
+ not_root_dialog(self)
+
+ else:
+ updating = system.update_world(newuse = self.cfg.get_boolean("newuse_opt"), deep = self.cfg.get_boolean("deep_opt"))
+
+ debug("updating list:", [(x.get_cpv(), y.get_cpv()) for x,y in updating],"--> length:",len(updating))
+ try:
+ try:
+ for pkg, old_pkg in updating:
+ self.queue.append(pkg.get_cpv(), unmask = False)
+ except PackageNotFoundException, e:
+ if unmask_dialog(self, e[0]) == QtGui.QMessageBox.Yes:
+ for pkg, old_pkg in updating:
+ self.queue.append(pkg.get_cpv(), unmask = True)
+
+ except BlockedException, e:
+ blocked_dialog(self, e[0], e[1])
+ self.queue.remove_children(self.queue.emergeIt)
+
+ if len(updating): self.doUpdate = True
+
+ def cb_queue_list_items_added (self, *args):
+ self.queueList.resizeColumnToContents(0)
+
def cb_cat_list_selected (self, index, prev):
self.selCatName = str(index.data().toString())
self.fill_pkg_list(self.selCatName)