From 35d7c73cf74e891b6ead631444e4e470b3a7a941 Mon Sep 17 00:00:00 2001
From: necoro <>
Date: Mon, 16 Apr 2007 16:35:39 +0000
Subject: added preferences for Qt-Frontend
---
portato/gui/gtk/glade/portato.glade | 382 +++++++++++++++++-----------------
portato/gui/gtk/windows.py | 4 +-
portato/gui/qt/__init__.py | 4 +-
portato/gui/qt/helper.py | 22 ++
portato/gui/qt/terminal.py | 34 +--
portato/gui/qt/tree.py | 63 +++++-
portato/gui/qt/ui/MainWindow.ui | 18 +-
portato/gui/qt/ui/PreferenceWindow.ui | 273 ++++++++++++++++++++++++
portato/gui/qt/windows.py | 189 ++++++++++++-----
9 files changed, 710 insertions(+), 279 deletions(-)
create mode 100644 portato/gui/qt/helper.py
create mode 100644 portato/gui/qt/ui/PreferenceWindow.ui
(limited to 'portato/gui')
diff --git a/portato/gui/gtk/glade/portato.glade b/portato/gui/gtk/glade/portato.glade
index f862b79..0ac888e 100644
--- a/portato/gui/gtk/glade/portato.glade
+++ b/portato/gui/gtk/glade/portato.glade
@@ -401,72 +401,48 @@
4
2
-
+
True
- GTK_POLICY_AUTOMATIC
- GTK_POLICY_AUTOMATIC
+ 1
+ True
-
+
True
+ True
+ Installed
+ True
+
+
+ False
+
-
-
- 2
- 2
- 3
- 5
- 5
-
-
-
-
- True
-
+
+ True
+ True
+ Masked
+ True
+
+
+
+ False
+ 1
+
+
+
+
+ True
+ True
+ Testing
+ True
+
+
+
+ False
+ 2
+
-
-
- 1
- 2
- GTK_FILL
- 5
-
-
-
-
- True
- GTK_JUSTIFY_CENTER
- True
-
-
- 2
- GTK_FILL
-
- 10
-
-
-
-
- True
- True
- <span foreground='red'><b>MISSING KEYWORD</b></span>
- True
-
-
- 1
- 2
- 1
- 2
- GTK_FILL
-
-
-
-
- True
- True
- <b>Installed, but not in portage anymore</b>
- True
1
@@ -531,55 +507,79 @@
-
+
+ True
+ True
+ <b>Installed, but not in portage anymore</b>
+ True
+
+
+ 1
+ 2
+ 1
+ 2
+ GTK_FILL
+
+
+
+
+ True
+ True
+ <span foreground='red'><b>MISSING KEYWORD</b></span>
+ True
+
+
+ 1
+ 2
+ 1
+ 2
+ GTK_FILL
+
+
+
+
+ True
+ GTK_JUSTIFY_CENTER
+ True
+
+
+ 2
+ GTK_FILL
+
+ 10
+
+
+
+
True
- 1
- True
-
-
- True
- True
- Installed
- True
-
-
-
- False
-
-
-
- True
- True
- Masked
- True
-
-
-
- False
- 1
-
+
+
+
+ 1
+ 2
+ GTK_FILL
+ 5
+
+
+
+
+ True
+ GTK_POLICY_AUTOMATIC
+ GTK_POLICY_AUTOMATIC
-
+
True
- True
- Testing
- True
-
-
- False
- 2
-
- 1
2
- 1
- 2
- GTK_FILL
+ 2
+ 3
+ 5
+ 5
@@ -1090,186 +1090,186 @@
-
- True
- 0
- 5
- <u><i>Masking Keywords</i></u>
- True
- True
-
-
- 7
- 8
- 5
-
-
-
-
+
True
- 0
- 5
- <u><i>Testing Keywords</i></u>
- True
- True
- 4
- 5
- 5
+ 1
+ 2
+ 3
+ 4
-
+
True
0
- 5
- <u><i>Use-Flags</i></u>
- True
+ File name to use, if package.use is a directory:
True
- 1
- 2
- 6
+ 3
+ 4
-
+
True
-
-
- True
- 0
- GTK_SHADOW_OUT
-
-
- True
- 0
- <u>You may use the following placeholders:</u>
-
- <i>$(cat)</i>: category
- <i>$(pkg)</i>: package name
- <i>$(cat-1)/$(cat-2)</i>: first/second part of the category
- True
-
-
-
-
-
- label_item
-
-
-
-
+ Add only exact version to package.use
+ True
2
+ 2
+ 3
-
+
True
- Add only exact version to package.mask/package.unmask
+ Add only exact version to package.keywords
True
2
- 8
- 9
+ 5
+ 6
-
+
True
0
- File name to use, if package.mask/package.unmask is a directory:
+ File name to use, if package.keywords is a directory:
True
- 9
- 10
+ 6
+ 7
-
+
True
1
2
- 9
- 10
+ 6
+ 7
-
+
True
1
2
- 6
- 7
+ 9
+ 10
-
+
True
0
- File name to use, if package.keywords is a directory:
+ File name to use, if package.mask/package.unmask is a directory:
True
- 6
- 7
+ 9
+ 10
-
+
True
- Add only exact version to package.keywords
+ Add only exact version to package.mask/package.unmask
True
2
- 5
- 6
+ 8
+ 9
-
+
True
- Add only exact version to package.use
- True
+
+
+ True
+ 0
+ GTK_SHADOW_OUT
+
+
+ True
+ 0
+ <u>You may use the following placeholders:</u>
+
+<i>$(cat)</i>: category
+<i>$(pkg)</i>: package name
+<i>$(cat-1)/$(cat-2)</i>: first/second part of the category
+ True
+
+
+
+
+
+ label_item
+
+
+
+
2
- 2
- 3
-
+
True
0
- File name to use, if package.use is a directory:
+ 5
+ <u><i>Use-Flags</i></u>
+ True
True
- 3
- 4
+ 1
+ 2
+ 6
-
+
True
+ 0
+ 5
+ <u><i>Testing Keywords</i></u>
+ True
+ True
- 1
- 2
- 3
- 4
+ 4
+ 5
+ 5
+
+
+
+
+ True
+ 0
+ 5
+ <u><i>Masking Keywords</i></u>
+ True
+ True
+
+
+ 7
+ 8
+ 5
diff --git a/portato/gui/gtk/windows.py b/portato/gui/gtk/windows.py
index f70d2bb..d2151ab 100644
--- a/portato/gui/gtk/windows.py
+++ b/portato/gui/gtk/windows.py
@@ -932,8 +932,8 @@ class MainWindow (Window):
store = self.queueTree
if len(path) > 1:
iterator = store.get_original().get_iter(path)
- if store.is_in_emerge(iterator):
- package = store.get_value(iterator, 0)
+ if store.iter_has_parent(iterator):
+ package = store.get_value(iterator, store.get_cpv_column())
cat, name, vers, rev = system.split_cpv(package)
if rev != "r0": vers = vers+"-"+rev
self.show_package(cat+"/"+name, queue = self.queue, version = vers, instantChange = True, doEmerge = False)
diff --git a/portato/gui/qt/__init__.py b/portato/gui/qt/__init__.py
index c714757..df49473 100644
--- a/portato/gui/qt/__init__.py
+++ b/portato/gui/qt/__init__.py
@@ -10,8 +10,10 @@
#
# Written by René 'Necoro' Neumann
+from PyQt4.Qt import QApplication
from windows import MainWindow
def run():
+ app = QApplication([])
m = MainWindow()
- m.main()
+ app.exec_()
diff --git a/portato/gui/qt/helper.py b/portato/gui/qt/helper.py
new file mode 100644
index 0000000..1b7dbdc
--- /dev/null
+++ b/portato/gui/qt/helper.py
@@ -0,0 +1,22 @@
+# -*- coding: utf-8 -*-
+#
+# File: portato/gui/qt/helper.py
+# This file is part of the Portato-Project, a graphical portage-frontend.
+#
+# Copyright (C) 2007 René 'Necoro' Neumann
+# This is free software. You may redistribute copies of it under the terms of
+# the GNU General Public License version 2.
+# There is NO WARRANTY, to the extent permitted by law.
+#
+# Written by René 'Necoro' Neumann
+
+from PyQt4 import Qt
+
+def qCheck (check):
+ if check:
+ return Qt.Qt.Checked
+ else:
+ return Qt.Qt.Unchecked
+
+def qIsChecked (check):
+ return check == Qt.Qt.Checked
diff --git a/portato/gui/qt/terminal.py b/portato/gui/qt/terminal.py
index eabe467..fd01e05 100644
--- a/portato/gui/qt/terminal.py
+++ b/portato/gui/qt/terminal.py
@@ -10,7 +10,7 @@
#
# Written by René 'Necoro' Neumann
-from PyQt4 import QtGui, QtCore
+from PyQt4 import Qt
from threading import Thread, Lock
from os import read
@@ -18,24 +18,24 @@ from os import read
from portato.gui.wrapper import Console
from portato.helper import debug
-class BoldFormat (QtGui.QTextCharFormat):
+class BoldFormat (Qt.QTextCharFormat):
def __init__(self):
- QtGui.QTextCharFormat.__init__(self)
- self.setFontWeight(QtGui.QFont.Bold)
+ Qt.QTextCharFormat.__init__(self)
+ self.setFontWeight(Qt.QFont.Bold)
-class UnderlineFormat (QtGui.QTextCharFormat):
+class UnderlineFormat (Qt.QTextCharFormat):
def __init__(self):
- QtGui.QTextCharFormat.__init__(self)
+ Qt.QTextCharFormat.__init__(self)
self.setFontUnderline(True)
-class ColorFormat (QtGui.QTextCharFormat):
+class ColorFormat (Qt.QTextCharFormat):
def __init__(self, color):
- QtGui.QTextCharFormat.__init__(self)
+ Qt.QTextCharFormat.__init__(self)
- self.setForeground(QtGui.QBrush(QtGui.QColor(color)))
+ self.setForeground(Qt.QBrush(Qt.QColor(color)))
# we only support a subset of the commands
esc_seq = ("\x1b", "[")
@@ -60,10 +60,10 @@ attr[36] = ColorFormat("cyan")
attr[37] = ColorFormat("white")
attr[39] = None # default
-class QtConsole (Console, QtGui.QTextEdit):
+class QtConsole (Console, Qt.QTextEdit):
def __init__ (self, parent):
- QtGui.QTextEdit.__init__(self, parent)
+ Qt.QTextEdit.__init__(self, parent)
self.pty = None
self.running = False
@@ -74,8 +74,8 @@ class QtConsole (Console, QtGui.QTextEdit):
self.setReadOnly(True)
- QtCore.QObject.connect(self, QtCore.SIGNAL("doSomeWriting"), self._write)
- QtCore.QObject.connect(self, QtCore.SIGNAL("deletePrevChar()"), self._deletePrev)
+ Qt.QObject.connect(self, Qt.SIGNAL("doSomeWriting"), self._write)
+ Qt.QObject.connect(self, Qt.SIGNAL("deletePrevChar()"), self._deletePrev)
def _deletePrev (self):
self.textCursor().deletePreviousChar()
@@ -87,7 +87,7 @@ class QtConsole (Console, QtGui.QTextEdit):
if not self.textCursor().atEnd(): # move cursor and re-set format
f = self.currentCharFormat()
- self.moveCursor(QtGui.QTextCursor.End)
+ self.moveCursor(Qt.QTextCursor.End)
self.setCurrentCharFormat(f)
# insert the text
@@ -97,7 +97,7 @@ class QtConsole (Console, QtGui.QTextEdit):
self.ensureCursorVisible()
def write(self, text):
- self.emit(QtCore.SIGNAL("doSomeWriting"), text)
+ self.emit(Qt.SIGNAL("doSomeWriting"), text)
def start_new_thread (self):
self.run = True
@@ -126,7 +126,7 @@ class QtConsole (Console, QtGui.QTextEdit):
if s == "": break
if ord(s) == backspace:
- self.emit(QtCore.SIGNAL("deletePrevChar()"))
+ self.emit(Qt.SIGNAL("deletePrevChar()"))
continue
if s == esc_seq[0]: # -> 0x27
@@ -198,4 +198,4 @@ class QtConsole (Console, QtGui.QTextEdit):
return f
def virgin_format (self):
- return QtGui.QTextCharFormat(self.stdFormat)
+ return Qt.QTextCharFormat(self.stdFormat)
diff --git a/portato/gui/qt/tree.py b/portato/gui/qt/tree.py
index fd616b6..a8c3e66 100644
--- a/portato/gui/qt/tree.py
+++ b/portato/gui/qt/tree.py
@@ -10,9 +10,12 @@
#
# Written by René 'Necoro' Neumann
-from PyQt4 import QtGui, QtCore
+from PyQt4 import Qt
from portato.gui.wrapper import Tree
+from portato.helper import debug
+from portato.backend import system # for the tooltips
+
class QtTree (Tree):
def __init__ (self, treeWidget, col = 0):
@@ -20,8 +23,8 @@ class QtTree (Tree):
self.tree = treeWidget
self.col = col
- self.emergeIt = QtGui.QTreeWidgetItem(self.tree, ["Emerge", ""])
- self.unmergeIt = QtGui.QTreeWidgetItem(self.tree, ["Unmerge", ""])
+ self.emergeIt = Qt.QTreeWidgetItem(self.tree, ["Emerge", ""])
+ self.unmergeIt = Qt.QTreeWidgetItem(self.tree, ["Unmerge", ""])
def build_append_value (self, cpv, oneshot = False, update = False, version = None):
string = ""
@@ -65,7 +68,7 @@ class QtTree (Tree):
return (it.childCount() > 0)
def next_iter (self, it):
- iter = QtGui.QTreeWidgetItemIterator(it)
+ iter = Qt.QTreeWidgetItemIterator(it)
iter += 1 # next iter ...
return iter.value()
@@ -82,8 +85,10 @@ class QtTree (Tree):
if parent is None:
parent = self.tree
-
- return QtGui.QTreeWidgetItem(parent, values)
+
+ item = Qt.QTreeWidgetItem(parent, values)
+ self.make_tooltip(item)
+ return item
def remove (self, it):
# a somehow strange approach ;) - go to the parent and delete the child
@@ -96,4 +101,50 @@ class QtTree (Tree):
def get_cpv_column (self):
return self.col
+
+ def make_tooltip (self, item):
+ tooltip = self.__get_flags(str(item.text(0)))
+ item.setToolTip(self.col, tooltip)
+
+ def __get_flags(self, cpv):
+
+ try:
+ pkg = system.new_package(cpv)
+ except ValueError: # no CPV
+ return ""
+
+ enabled = []
+ disabled = []
+ expanded = set()
+
+ pkg_flags = pkg.get_all_use_flags()
+ if not pkg_flags: # no flags - stop here
+ return ""
+
+ pkg_flags.sort()
+ for use in pkg_flags:
+ exp = pkg.use_expanded(use)
+ if exp:
+ expanded.add(exp)
+
+ else:
+ if pkg.is_use_flag_enabled(use):
+ enabled.append(use)
+ else:
+ disabled.append(use)
+
+ string = ""
+
+ if enabled:
+ string = "+%s" % ("
+".join(enabled),)
+ if len(disabled) > 0:
+ string = string + "
"
+
+ if disabled:
+ string = string+"- %s" % ("
- ".join(disabled),)
+
+ if expanded:
+ string = string+"
"+"
".join(expanded)
+
+ return string
diff --git a/portato/gui/qt/ui/MainWindow.ui b/portato/gui/qt/ui/MainWindow.ui
index 2830291..14127c9 100644
--- a/portato/gui/qt/ui/MainWindow.ui
+++ b/portato/gui/qt/ui/MainWindow.ui
@@ -394,12 +394,6 @@ p, li { white-space: pre-wrap; }
31
-
+
@@ -455,6 +456,11 @@ p, li { white-space: pre-wrap; }
Update &World
+
+
+ &Preferences
+
+
diff --git a/portato/gui/qt/ui/PreferenceWindow.ui b/portato/gui/qt/ui/PreferenceWindow.ui
new file mode 100644
index 0000000..f65c2fa
--- /dev/null
+++ b/portato/gui/qt/ui/PreferenceWindow.ui
@@ -0,0 +1,273 @@
+
+ PreferencesWindow
+
+
+
+ 0
+ 0
+ 582
+ 706
+
+
+
+ Preferences
+
+
+
+ 9
+
+
+ 6
+
+ -
+
+
+ General Options
+
+
+ Qt::AlignLeading
+
+
+
+ 9
+
+
+ 0
+
+
-
+
+
+ Debug
+
+
+
+
+
+
+ -
+
+
+ Sync Options
+
+
+
+ 9
+
+
+ 6
+
+
-
+
+
+ Sync command:
+
+
+
+ -
+
+
+
+
+
+ -
+
+
+ Update World Options
+
+
+
+ 9
+
+
+ 0
+
+
-
+
+
+ --deep
+
+
+
+ -
+
+
+ --newuse
+
+
+
+
+
+
+ -
+
+
+ Use Flag and Keyword Options
+
+
+
+ 9
+
+
+ 6
+
+
-
+
+
+ <u><i>Masking Keywords</u></i>
+
+
+
+ -
+
+
+ <i><u>Use Flags</u></i>
+
+
+
+ -
+
+
+ portato
+
+
+
+ -
+
+
+ Add only exact version to package.keywords
+
+
+
+ -
+
+
+ File name to use, if package.keywords is a directory
+
+
+
+ -
+
+
+ File name to use if package.mask/.unmask is a directory
+
+
+
+ -
+
+
+ Add only exact version to package.use
+
+
+
+ -
+
+
+ portato
+
+
+
+ -
+
+
+ <i><u>Testing Keywords</u></i>
+
+
+
+ -
+
+
+ File name to use, if package.use is a directory
+
+
+
+ -
+
+
+ Add only exact version to package.mask/.unmask
+
+
+
+ -
+
+
+ portato
+
+
+
+ -
+
+
+ true
+
+
+ QFrame::StyledPanel
+
+
+ QFrame::Raised
+
+
+ <html><head><meta name="qrichtext" content="1" /><style type="text/css">
+p, li { white-space: pre-wrap; }
+</style></head><body style=" font-family:'Sans Serif'; font-size:11pt; font-weight:400; font-style:normal; text-decoration:none;">
+<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" text-decoration: underline;">You may use the following placeholders:</span> </p>
+<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"></p>
+<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-style:italic;">$(cat)</span>: category</p>
+<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-style:italic;">$(pkg)</span>: package name</p>
+<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-style:italic;">$(cat-1)/$(cat-2)</span>: first/second part of the category</p></body></html>
+
+
+
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+ QDialogButtonBox::Cancel|QDialogButtonBox::NoButton|QDialogButtonBox::Ok
+
+
+ true
+
+
+
+
+
+
+
+
+ buttonBox
+ accepted()
+ PreferencesWindow
+ accept()
+
+
+ 227
+ 676
+
+
+ 157
+ 274
+
+
+
+
+ buttonBox
+ rejected()
+ PreferencesWindow
+ reject()
+
+
+ 295
+ 682
+
+
+ 286
+ 274
+
+
+
+
+
diff --git a/portato/gui/qt/windows.py b/portato/gui/qt/windows.py
index 4c62d8f..3b1de2b 100644
--- a/portato/gui/qt/windows.py
+++ b/portato/gui/qt/windows.py
@@ -11,7 +11,7 @@
# Written by René 'Necoro' Neumann
# qt4
-from PyQt4 import QtGui, uic, QtCore
+from PyQt4 import Qt, uic
import sip
# our backend stuff
@@ -26,20 +26,11 @@ from portato.gui.gui_helper import Database, Config, EmergeQueue
from terminal import QtConsole
from tree import QtTree
from dialogs import *
+from helper import qCheck, qIsChecked
-UI_DIR = DATA_DIR+"ui/"
-
-#XXX: global variables are bad
-app = QtGui.QApplication([])
+import types
-def qCheck (check):
- if check:
- return QtCore.Qt.Checked
- else:
- return QtCore.Qt.Unchecked
-
-def qIsChecked (check):
- return check == QtCore.Qt.Checked
+UI_DIR = DATA_DIR+"ui/"
class WindowMeta (sip.wrappertype, type):
@@ -54,7 +45,7 @@ class WindowMeta (sip.wrappertype, type):
del dict["_bases"]
super(WindowMeta, cls).__init__(name, b+bases, dict)
-class Window:
+class Window (object):
def __init__(self, parent = None):
self._qt_base.__init__(self, parent)
@@ -66,11 +57,11 @@ class Window:
def wrapper (*args, **kwargs):
ret = None
- QtGui.QApplication.setOverrideCursor(QtCore.Qt.WaitCursor)
+ Qt.QApplication.setOverrideCursor(Qt.Qt.WaitCursor)
try:
ret = func(*args, **kwargs)
finally:
- QtGui.QApplication.restoreOverrideCursor()
+ Qt.QApplication.restoreOverrideCursor()
return ret
@@ -102,7 +93,7 @@ class SearchDialog (Window):
"""Constructor.
@param parent: parent-window
- @type parent: QtGui.QWidget
+ @type parent: Qt.QWidget
@param list: list of results to show
@type list: string[]
@param jumpTo: function to call if "OK"-Button is hit
@@ -114,13 +105,87 @@ class SearchDialog (Window):
self.comboBox.setCurrentIndex(0)
self.jumpTo = jumpTo
- QtCore.QObject.connect(self, QtCore.SIGNAL("accepted()"), self.finish)
+ Qt.QObject.connect(self, Qt.SIGNAL("accepted()"), self.finish)
def finish (self):
s = str(self.comboBox.currentText())
self.done(0)
self.jumpTo(s)
+class PreferenceWindow (Window):
+ """Window displaying some preferences."""
+
+ __metaclass__ = WindowMeta
+
+ # all checkboxes in the window
+ # widget name -> option name
+ checkboxes = {
+ "debugCheck" : "debug_opt",
+ "deepCheck" : "deep_opt",
+ "newUseCheck" : "newuse_opt",
+ "maskCheck" : "maskPerVersion_opt",
+ "useCheck" : "usePerVersion_opt",
+ "testingCheck" : "testingPerVersion_opt"
+ }
+
+ # all edits in the window
+ # widget name -> option name
+ edits = {
+ "maskEdit" : "maskFile_opt",
+ "testingEdit" : "testingFile_opt",
+ "useEdit" : "useFile_opt",
+ "syncCmdEdit" : "syncCmd_opt"
+ }
+
+ def __init__ (self, parent, cfg):
+
+ Window.__init__(self, parent)
+
+ self.cfg = cfg
+
+ palette = self.hintLabel.palette()
+ palette.setColor(Qt.QPalette.Active, Qt.QPalette.Window, Qt.QColor(Qt.Qt.yellow))
+ self.hintLabel.setPalette(palette)
+
+ # the checkboxes
+ for box in self.checkboxes:
+ val = self.checkboxes[box]
+ box = self.__getattribute__(box)
+ if type(val) == types.TupleType:
+ box.setCheckState(qCheck(self.cfg.get_boolean(val[0], section = self.cfg.const[val[1]])))
+ else:
+ box.setCheckState(qCheck(self.cfg.get_boolean(val)))
+
+ # the edits
+ for edit in self.edits:
+ _edit = self.__getattribute__(edit)
+ _edit.setText(self.cfg.get(self.edits[edit]))
+
+ Qt.QObject.connect(self, Qt.SIGNAL("accepted()"), self.finish)
+
+ def _save (self):
+ """Sets all options in the Config-instance."""
+
+ for box in self.checkboxes:
+ val = self.checkboxes[box]
+ box = self.__getattribute__(box)
+ if type(val) == types.TupleType:
+ self.cfg.set_boolean(val[0], qIsChecked(box.checkState()), section = self.cfg.const[val[1]])
+ else:
+ self.cfg.set_boolean(val, qIsChecked(box.checkState()))
+
+ for edit in self.edits:
+ _edit = self.__getattribute__(edit)
+ self.cfg.set(self.edits[edit], _edit.text())
+
+ def finish (self):
+ """Saves and writes to config-file."""
+ self._save()
+ try:
+ self.cfg.write()
+ except IOError, e:
+ io_ex_dialog(self, e)
+
class PackageDetails:
def __init__ (self, window):
@@ -131,21 +196,21 @@ class PackageDetails:
self.window.installedCheck.blockSignals(True)
# combo
- QtCore.QObject.connect(self.window.versCombo, QtCore.SIGNAL("currentIndexChanged(int)"), self.cb_combo_changed)
+ Qt.QObject.connect(self.window.versCombo, Qt.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)
+ Qt.QObject.connect(self.window.pkgEmergeBtn, Qt.SIGNAL("clicked()"), self.cb_emerge_clicked)
+ Qt.QObject.connect(self.window.pkgUnmergeBtn, Qt.SIGNAL("clicked()"), self.cb_unmerge_clicked)
+ Qt.QObject.connect(self.window.pkgRevertBtn, Qt.SIGNAL("clicked()"), self.cb_revert_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)
+ Qt.QObject.connect(self.window.maskedCheck, Qt.SIGNAL("clicked(bool)"), self.cb_masked_clicked)
+ Qt.QObject.connect(self.window.testingCheck, Qt.SIGNAL("clicked(bool)"), self.cb_testing_clicked)
# useflags
- QtCore.QObject.connect(self.window.useList, QtCore.SIGNAL("itemClicked(QTreeWidgetItem*, int)"), self.cb_use_flag_changed)
+ Qt.QObject.connect(self.window.useList, Qt.SIGNAL("itemClicked(QTreeWidgetItem*, int)"), self.cb_use_flag_changed)
- def update (self, cp, queue = None, version = None, doEmerge = True, instantChange = False):
+ def update (self, cp, queue = None, version = None, doEmerge = True, instantChange = None):
"""Updates the table to show the contents for the package.
@param cp: the selected package
@@ -156,8 +221,8 @@ class PackageDetails:
@type version: string
@param doEmerge: if False, the emerge buttons are disabled
@type doEmerge: False
- @param instantChange: if True the changed keywords are updated instantly
- @type instantChange: boolean"""
+ @param instantChange: if not None, the item given is updated immediatly
+ @type instantChange: Qt.QTreeWidgetItem"""
self.cp = cp
self.version = version
@@ -227,13 +292,13 @@ class PackageDetails:
exp = pkg.use_expanded(use, suggest = actual_exp)
if exp is not None:
if exp != actual_exp:
- actual_exp_it = QtGui.QTreeWidgetItem(self.window.useList, ["", exp, ""])
+ actual_exp_it = Qt.QTreeWidgetItem(self.window.useList, ["", exp, ""])
actual_exp = exp
else:
actual_exp_it = self.window.useList
actual_exp = None
- item = QtGui.QTreeWidgetItem(actual_exp_it, ["", use, system.get_use_desc(use, self.cp)])
+ item = Qt.QTreeWidgetItem(actual_exp_it, ["", use, system.get_use_desc(use, self.cp)])
item.setCheckState(0, qCheck(pkg.is_use_flag_enabled(use)))
def _update_keywords (self, emerge, update = False):
@@ -242,7 +307,7 @@ class PackageDetails:
try:
self.queue.append(self.actual_package().get_cpv(), unmerge = False, update = update)
except PackageNotFoundException, e:
- if unmask_dialog(self.window, e[0]) == QtGui.QMessageBox.Yes :
+ if unmask_dialog(self.window, e[0]) == Qt.QMessageBox.Yes :
self.queue.append(self.actual_package().get_cpv(), unmerge = False, unmask = True, update = update)
except BlockedException, e:
blocked_dialog(self.window, e[0], e[1])
@@ -361,6 +426,7 @@ class PackageDetails:
pkg.set_use_flag(prefix+flag)
if self.instantChange:
self._update_keywords(True, update = True)
+ self.window.queueTree.make_tooltip(self.instantChange)
def cb_combo_changed (self):
"""Callback for the changed ComboBox.
@@ -370,8 +436,8 @@ class PackageDetails:
self.build_use_list()
pkg = self.actual_package()
- shown = QtGui.QSizePolicy(QtGui.QSizePolicy.MinimumExpanding, QtGui.QSizePolicy.Fixed)
- hidden = QtGui.QSizePolicy(QtGui.QSizePolicy.Ignored, QtGui.QSizePolicy.Fixed)
+ shown = Qt.QSizePolicy(Qt.QSizePolicy.MinimumExpanding, Qt.QSizePolicy.Fixed)
+ hidden = Qt.QSizePolicy(Qt.QSizePolicy.Ignored, Qt.QSizePolicy.Fixed)
#
# rebuild the buttons and checkboxes in all the different manners which are possible
@@ -459,23 +525,25 @@ class MainWindow (Window):
# the two lists
self.build_pkg_list()
self.build_cat_list()
- QtCore.QObject.connect(self.selCatListModel, QtCore.SIGNAL("currentChanged(QModelIndex, QModelIndex)"), self.cb_cat_list_selected)
- QtCore.QObject.connect(self.selPkgListModel, QtCore.SIGNAL("currentChanged(QModelIndex, QModelIndex)"), self.cb_pkg_list_selected)
+ Qt.QObject.connect(self.selCatListModel, Qt.SIGNAL("currentChanged(QModelIndex, QModelIndex)"), self.cb_cat_list_selected)
+ Qt.QObject.connect(self.selPkgListModel, Qt.SIGNAL("currentChanged(QModelIndex, QModelIndex)"), self.cb_pkg_list_selected)
# build console
self.console = QtConsole(self.consoleTab)
- self.consoleLayout = QtGui.QVBoxLayout()
+ self.consoleLayout = Qt.QVBoxLayout()
self.consoleLayout.setMargin(0)
self.consoleLayout.setSpacing(0)
self.consoleTab.setLayout(self.consoleLayout)
self.consoleLayout.addWidget(self.console)
- QtCore.QObject.connect(self, QtCore.SIGNAL("doTitleUpdate"), self._title_update)
+ Qt.QObject.connect(self, Qt.SIGNAL("doTitleUpdate"), self._title_update)
# build queueList
self.queueList.setHeaderLabels(["Package", "Additional infos"])
self.queueTree = QtTree(self.queueList)
- 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)
+ Qt.QObject.connect(self.queueList.model(), Qt.SIGNAL("rowsInserted (const QModelIndex&, int, int)"), self.cb_queue_list_items_added)
+ Qt.QObject.connect(self.queueList, Qt.SIGNAL("expanded (const QModelIndex&)"), self.cb_queue_list_items_added)
+ Qt.QObject.connect(self.queueList, Qt.SIGNAL("itemActivated (QTreeWidgetItem*, int)"), self.cb_queue_list_item_selected)
+ Qt.QObject.connect(self.queueList, Qt.SIGNAL("itemDoubleClicked (QTreeWidgetItem*, int)"), self.cb_queue_list_item_selected)
# set emerge queue
self.queue = EmergeQueue(console = self.console, tree = self.queueTree, db = self.db, title_update = self.title_update)
@@ -483,7 +551,7 @@ class MainWindow (Window):
self.show()
def title_update (self, title):
- self.emit(QtCore.SIGNAL("doTitleUpdate"), title)
+ self.emit(Qt.SIGNAL("doTitleUpdate"), title)
def _title_update (self, title):
if title == None: title = "Console"
@@ -499,24 +567,28 @@ class MainWindow (Window):
self.pkgListModel.setStringList([name for (name,inst) in self.db.get_cat(cat)])
def build_pkg_list (self):
- self.pkgListModel = QtGui.QStringListModel([])
+ self.pkgListModel = Qt.QStringListModel([])
self.pkgListModel.sort(0)
- self.selPkgListModel = QtGui.QItemSelectionModel(self.pkgListModel)
+ self.selPkgListModel = Qt.QItemSelectionModel(self.pkgListModel)
self.pkgList.setModel(self.pkgListModel)
self.pkgList.setSelectionModel(self.selPkgListModel)
def build_cat_list (self):
- self.catListModel = QtGui.QStringListModel(system.list_categories())
+ self.catListModel = Qt.QStringListModel(system.list_categories())
self.catListModel.sort(0)
- self.selCatListModel = QtGui.QItemSelectionModel(self.catListModel)
+ self.selCatListModel = Qt.QItemSelectionModel(self.catListModel)
self.catList.setModel(self.catListModel)
self.catList.setSelectionModel(self.selCatListModel)
- @QtCore.pyqtSignature("")
+ @Qt.pyqtSignature("")
def on_aboutAction_triggered (self):
AboutDialog(self).exec_()
- @QtCore.pyqtSignature("")
+ @Qt.pyqtSignature("")
+ def on_prefAction_triggered (self):
+ PreferenceWindow(self, self.cfg).exec_()
+
+ @Qt.pyqtSignature("")
@Window.watch_cursor
def on_searchBtn_clicked (self):
"""Do a search."""
@@ -532,7 +604,7 @@ class MainWindow (Window):
else:
SearchDialog(self, packages, self.jump_to).exec_()
- @QtCore.pyqtSignature("")
+ @Qt.pyqtSignature("")
def on_removeBtn_clicked (self):
"""Removes a selected item in the (un)emerge-queue if possible."""
selected = self.queueList.currentItem()
@@ -540,7 +612,7 @@ class MainWindow (Window):
if selected:
if not selected.parent(): # top-level
if self.queueTree.iter_has_children(selected): # and has children which can be removed :)
- if remove_queue_dialog(self) == QtGui.QMessageBox.Yes :
+ if remove_queue_dialog(self) == Qt.QMessageBox.Yes :
self.queue.remove_children(selected)
self.doUpdate = False
@@ -550,7 +622,7 @@ class MainWindow (Window):
self.queue.remove_with_children(selected)
self.doUpdate = False
- @QtCore.pyqtSignature("")
+ @Qt.pyqtSignature("")
def on_emergeBtn_clicked (self):
"""Do emerge."""
@@ -575,14 +647,14 @@ class MainWindow (Window):
self.queue.update_world(force=True, newuse = self.cfg.get_boolean("newuse_opt"), deep = self.cfg.get_boolean("deep_opt"), options = ["--nospinner"])
self.doUpdate = False
- @QtCore.pyqtSignature("")
+ @Qt.pyqtSignature("")
def on_unmergeBtn_clicked (self):
"""Do unmerge."""
self.tabWidget.setCurrentIndex(self.CONSOLE_PAGE)
self.queue.unmerge(force = True)
- @QtCore.pyqtSignature("")
+ @Qt.pyqtSignature("")
@Window.watch_cursor
def on_updateBtn_clicked (self):
if not am_i_root():
@@ -597,7 +669,7 @@ class MainWindow (Window):
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:
+ if unmask_dialog(self, e[0]) == Qt.QMessageBox.Yes:
for pkg, old_pkg in updating:
self.queue.append(pkg.get_cpv(), unmask = True)
@@ -607,6 +679,15 @@ class MainWindow (Window):
if len(updating): self.doUpdate = True
+ def cb_queue_list_item_selected (self, item, col):
+ if col == -1: return # nothing selected
+
+ if self.queueTree.iter_has_parent(item):
+ package = self.queueTree.get_value(item, self.queueTree.get_cpv_column())
+ cat, name, vers, rev = system.split_cpv(package)
+ if rev != "r0": vers = vers+"-"+rev
+ self.pkgDetails.update(cat+"/"+name, queue = self.queue, version = vers, instantChange = item, doEmerge = False)
+
def cb_queue_list_items_added (self, *args):
self.queueList.resizeColumnToContents(0)
@@ -616,7 +697,3 @@ class MainWindow (Window):
def cb_pkg_list_selected (self, index, prev):
self.pkgDetails.update(self.selCatName+"/"+str(index.data().toString()), self.queue)
-
- def main (self):
- app.exec_()
-
--
cgit v1.2.3-54-g00ecf