diff options
author | necoro <> | 2007-08-16 03:39:18 +0000 |
---|---|---|
committer | necoro <> | 2007-08-16 03:39:18 +0000 |
commit | eae9ec73ba26638e25d23ba2261422461150ad73 (patch) | |
tree | 8d1127678d2804c5db673394d203b0c20f7bcfdd | |
parent | 785aa0d72cefab1d6a2b4a27d4cef13d7cec9c58 (diff) | |
download | portato-eae9ec73ba26638e25d23ba2261422461150ad73.tar.gz portato-eae9ec73ba26638e25d23ba2261422461150ad73.tar.bz2 portato-eae9ec73ba26638e25d23ba2261422461150ad73.zip |
removed qt
-rw-r--r-- | portato/gui/qt/__init__.py | 39 | ||||
-rw-r--r-- | portato/gui/qt/dialogs.py | 44 | ||||
-rw-r--r-- | portato/gui/qt/helper.py | 35 | ||||
-rw-r--r-- | portato/gui/qt/highlighter.py | 168 | ||||
-rw-r--r-- | portato/gui/qt/terminal.py | 378 | ||||
-rw-r--r-- | portato/gui/qt/tree.py | 155 | ||||
-rw-r--r-- | portato/gui/qt/uncheckbox.py | 38 | ||||
-rw-r--r-- | portato/gui/qt/windows.py | 1125 | ||||
-rw-r--r-- | portato/gui/templates/ui/AboutDialog.ui | 111 | ||||
-rw-r--r-- | portato/gui/templates/ui/EbuildDialog.ui | 88 | ||||
-rw-r--r-- | portato/gui/templates/ui/LogDialog.ui | 88 | ||||
-rw-r--r-- | portato/gui/templates/ui/MainWindow.ui | 720 | ||||
-rw-r--r-- | portato/gui/templates/ui/PluginDialog.ui | 94 | ||||
-rw-r--r-- | portato/gui/templates/ui/PreferenceWindow.ui | 379 | ||||
-rw-r--r-- | portato/gui/templates/ui/SearchDialog.ui | 78 | ||||
-rw-r--r-- | portato/gui/templates/ui/UpdateDialog.ui | 108 | ||||
-rw-r--r-- | portato_qt.desktop | 7 |
17 files changed, 0 insertions, 3655 deletions
diff --git a/portato/gui/qt/__init__.py b/portato/gui/qt/__init__.py deleted file mode 100644 index 3f83aeb..0000000 --- a/portato/gui/qt/__init__.py +++ /dev/null @@ -1,39 +0,0 @@ -# -*- coding: utf-8 -*- -# -# File: portato/gui/qt/__init__.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 <necoro@necoro.net> - -from portato import plugin -from portato.backend import system - -from PyQt4.Qt import QApplication -from windows import MainWindow, EbuildDialog, SearchDialog - -def run(): - app = QApplication([]) - m = MainWindow() - app.exec_() - -def show_ebuild (pkg): - plugin.load_plugins("qt") - app = QApplication([]) - - def _show (pkg): - pkg = system.new_package(pkg) - hook = plugin.hook("open_ebuild", pkg, None) - - ew = hook(EbuildDialog)(None, pkg) - ew.setWindowTitle("Portato Ebuild Viewer - %s" % pkg.get_cpv()) - ew.exec_() - - s = SearchDialog(None, [x.get_cpv() for x in system.sort_package_list(system.find_all_packages(pkg, True))], _show) - s.setWindowTitle("Portato Ebuild Viewer - Search") - s.show() - app.exec_() diff --git a/portato/gui/qt/dialogs.py b/portato/gui/qt/dialogs.py deleted file mode 100644 index 6a80164..0000000 --- a/portato/gui/qt/dialogs.py +++ /dev/null @@ -1,44 +0,0 @@ -# -*- coding: utf-8 -*- -# -# File: portato/gui/qt/dialogs.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 <necoro@necoro.net> - -from PyQt4.QtGui import QMessageBox - -def queue_not_empty_dialog(parent): - return QMessageBox.question(parent, "Portato", "There are some packages in the emerge queue and/or an emerge process is running.\nDo you really want to quit?", QMessageBox.Ok | QMessageBox.Cancel) - -def io_ex_dialog (parent, ex): - string = ex.strerror - if ex.filename: - string = string+": "+ex.filename - - return QMessageBox.critical(parent, "Portato", string, QMessageBox.Ok) - -def nothing_found_dialog (parent): - return QMessageBox.information(parent, "Portato", "No packages found.", QMessageBox.Ok) - -def not_root_dialog (parent): - return QMessageBox.warning(parent, "Portato", "You are not root!", QMessageBox.Ok) - -def unmask_dialog (parent, cpv): - return QMessageBox.question(parent, "Portato", cpv+" seems to be masked.\nDo you want to unmask it and its dependencies?", QMessageBox.Yes | QMessageBox.No) - -def blocked_dialog (parent, blocked, blocks): - return QMessageBox.warning(parent, "Portato", blocked+" is blocked by "+blocks+".\nPlease unmerge the blocking package.", QMessageBox.Ok) - -def remove_deps_dialog (parent): - return QMessageBox.information(parent, "Portato", "You cannot remove dependencies. :)", QMessageBox.Ok) - -def remove_queue_dialog (parent): - return QMessageBox.question(parent, "Portato", "Do you really want to clear the whole queue?", QMessageBox.Yes | QMessageBox.No) - -def changed_flags_dialog (parent, what = "flags"): - return QMessageBox.information(parent, "Portato", "You have changed %s. Portato will write these changes into the appropriate files. Please backup them if you think it is necessairy." % what, QMessageBox.Ok) diff --git a/portato/gui/qt/helper.py b/portato/gui/qt/helper.py deleted file mode 100644 index fa1576a..0000000 --- a/portato/gui/qt/helper.py +++ /dev/null @@ -1,35 +0,0 @@ -# -*- 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 <necoro@necoro.net> - -from PyQt4 import Qt - -def qCheck (check): - """Maps True or False to Qt.Checked or Qt.Unchecked. - - @param check: boolean value - @type check: bool - @returns: CheckState-Constant - @rtype: int""" - - if check: - return Qt.Qt.Checked - else: - return Qt.Qt.Unchecked - -def qIsChecked (check): - """Maps Qt.Checked and Qt.Unchecked to True and False. - - @param check: CheckState-Constant - @type check: int - @returns: appropriate boolean value - @rtype: bool""" - return check == Qt.Qt.Checked diff --git a/portato/gui/qt/highlighter.py b/portato/gui/qt/highlighter.py deleted file mode 100644 index 74d9ac9..0000000 --- a/portato/gui/qt/highlighter.py +++ /dev/null @@ -1,168 +0,0 @@ -# -*- coding: utf-8 -*- -# -# File: portato/gui/qt/highlighter.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 <necoro@necoro.net> - -# The syntax is inspired by the gtksourceview syntax by -# Leonardo Ferreira Fontenelle <leo.fontenelle@gmail.com> - -from PyQt4 import Qt -from portato.helper import debug - -import re # prefer Python-Module over Qt-one - -class EbuildHighlighter (Qt.QSyntaxHighlighter): - """A QSyntaxHighlighter implementation for the use with ebuild-syntax.""" - - NORMAL_STATE = 0 - STRING_STATE = 1 - - def __init__ (self, edit): - """Constructor. - - @param edit: the EditWidget to use the highlighter with - @type edit: Qt.QTextEdit""" - - Qt.QSyntaxHighlighter.__init__(self, edit) - - # - # the regular expressions ... *muahahaha* - # - - # comments - self.comment = self.__create(r'#.*', color = "steelblue", italic = True) - - # bash variables - self.bashVar = self.__create(r'(\$\{.+?\})|(\$\w+)', color = "green") - - # a string - self.string = self.__create(r'(?<!\\)"', color = "fuchsia") - - # the syntax elements, which are checked in a loop - self.syntax = {} - - # bash syntax - self.syntax["bashSyn"] = self.__create(r'\b(case|do|done|elif|else|esac|exit|fi|for|function|if|in|local|read|return|select|shift|then|time|until|while)\b', color = "navy", underline = True) - - # special bash commands - self.syntax["bashCmd"] = self.__create(r'\b(make|awk|cat|cd|chmod|chown|cp|echo|env|export|grep|head|let|ln|mkdir|mv|rm|sed|set|tail|tar|touch|unset)\b', color = "navy", bold = True) - - # portage variables - self.syntax["portVar"] = self.__create(r'\b((ARCH|HOMEPAGE|DESCRIPTION|IUSE|SRC_URI|LICENSE|SLOT|KEYWORDS|FILESDIR|WORKDIR|(P|R)?DEPEND|PROVIDE|DISTDIR|RESTRICT|USERLAND)|(S|D|T|PV|PF|P|PN|A)|C(XX)?FLAGS|LDFLAGS|C(HOST|TARGET|BUILD))\b', color = "saddlebrown", bold = True) - - # portage commands - self.syntax["portCmd"] = self.__create(r'\b(e(begin|end|conf|install|make|warn|infon?|error|patch)|die|built_with_use|use(_(with|enable))?|inherit|hasq?|(has|best)_version|unpack|(do|new)(ins|s?bin|doc|lib(|\.so|\.a)|man|info|exe|initd|confd|envd|pam|menu|icon)|do(python|sed|dir|hard|sym|html|jar|mo)|keepdir|prepall(|docs|info|man|strip)|prep(info|lib|lib\.(so|a)|man|strip)|(|doc|ins|exe)into|f(owners|perms)|(exe|ins|dir)opts)\b', color = "saddlebrown", bold = True) - - # portage functions, i.e. the functions implemented by the ebuild - self.syntax["portFunc"] = self.__create(r'^(src_(unpack|compile|install|test)|pkg_(config|nofetch|setup|(pre|post)(inst|rm)))', color = "green") - - def do_reg_exp (self, syntaxTuple, string): - """Tries to match a regular expression and if this succeeds, - sets the text format. - - @param syntaxTuple: tuple holding regexp and format - @type sytaxTuple: (RE-object, Qt.QTextCharFormat) - @param string: the string to look in - @type string: string""" - - regexp, format = syntaxTuple - - match = regexp.search(string) - - while match is not None: - span = match.span() - length = span[1]-span[0] - - self.setFormat(span[0], length, format) - match = regexp.search(string, span[1]) - - def highlightBlock (self, string): - """This function is called, whenever the edit want to have some text checked. - - @param string: the text to check - @type string: Qt.QString""" - - string = str(string) # we got a QString here - - # check the normal syntax elements - for t in self.syntax.values(): - self.do_reg_exp(t, string) - - # reset to normal state :) - self.setCurrentBlockState(self.NORMAL_STATE) - - # look for strings - prevStart = 0 - foundEnd = False - stringMatch = self.string[0].search(string) - - if self.previousBlockState() == self.STRING_STATE: # we were in a string last time - if stringMatch is None: # and there is no end of string in this line - self.setFormat(0, len(string), self.string[1]) - self.setCurrentBlockState(self.STRING_STATE) - else: - foundEnd = True - - while stringMatch is not None: - - if foundEnd: # we know that the string will end in this block - self.setCurrentBlockState(self.NORMAL_STATE) - self.setFormat(prevStart, stringMatch.end() - prevStart, self.string[1]) - - # look for a possible start of another string - stringMatch = self.string[0].search(string, stringMatch.end()) - foundEnd = False - - else: # we have entered a new string - - prevStart = stringMatch.start() - stringMatch = self.string[0].search(string, stringMatch.end()) # the end of string - - if stringMatch is not None: - foundEnd = True - else: # no string end: mark the rest of the line as string - self.setCurrentBlockState(self.STRING_STATE) - self.setFormat(prevStart, len(string) - prevStart, self.string[1]) - - self.do_reg_exp(self.bashVar, string) # replace bashVars in strings - self.do_reg_exp(self.comment, string) # do comments last - - def __create (self, regexp, color = None, italic = False, bold = False, underline = False): - """This creates a syntax tuple. - - @param regexp: the regular expression - @type regexp: string - @param color: the color to take; if None, take standard color - @type color: string - @param italic: italic-flag - @type italic: bool - @param bold: bold-flag - @type bold: bool - @param underline: underline-flag - @type underline: bool - - @returns: the created syntax-tuple - @rtype: (RE-object, Qt.QTextCharFormat) - """ - - compRe = re.compile(regexp) - format = Qt.QTextCharFormat() - - font = Qt.QFont() - font.setItalic(italic) - font.setBold(bold) - font.setUnderline(underline) - format.setFont(font) - - if color is not None: - brush = Qt.QBrush(Qt.QColor(color)) - format.setForeground(brush) - - return (compRe, format) diff --git a/portato/gui/qt/terminal.py b/portato/gui/qt/terminal.py deleted file mode 100644 index a70e56b..0000000 --- a/portato/gui/qt/terminal.py +++ /dev/null @@ -1,378 +0,0 @@ -# -*- coding: utf-8 -*- -# -# File: portato/gui/qt/terminal.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 <necoro@necoro.net> - -from PyQt4 import Qt - -from Queue import Queue -from threading import Thread, currentThread -from os import read, close -import errno - -from portato.gui.wrapper import Console -from portato.helper import debug - -try: - from curses.ascii import ctrl -except ImportError: # emulate ctrl-behavior for known values - def ctrl (val): - if val == "H": return '\x08' - elif val == "W": return '\x17' - else: debug("unknown error passed to emulated ctrl: %s",val) - - -class WriteEvent (Qt.QEvent): - TYPE = Qt.QEvent.Type(1001) - - def __init__ (self, string): - Qt.QEvent.__init__(self, self.TYPE) - self.string = string - - def get_string(self): - return self.string - -class DeleteEvent (Qt.QEvent): - TYPE = Qt.QEvent.Type(1002) - (DEL_CHAR, DEL_WORD, DEL_LINE, DEL_LINE_REVERT) = range(4) - - def __init__ (self, type = DEL_CHAR): - Qt.QEvent.__init__(self, self.TYPE) - self.del_type = type - -class SetPtyEvent (Qt.QEvent): - TYPE = Qt.QEvent.Type(1003) - - def __init__ (self, pty): - Qt.QEvent.__init__(self, self.TYPE) - self.pty = pty - -class BoldFormat (Qt.QTextCharFormat): - - def __init__(self): - Qt.QTextCharFormat.__init__(self) - self.setFontWeight(Qt.QFont.Bold) - -class UnderlineFormat (Qt.QTextCharFormat): - - def __init__(self): - Qt.QTextCharFormat.__init__(self) - self.setFontUnderline(True) - -class ColorFormat (Qt.QTextCharFormat): - - def __init__(self, color): - Qt.QTextCharFormat.__init__(self) - - self.setForeground(Qt.QBrush(Qt.QColor(color))) - -# we only support a subset of the commands -esc_seq = ("\x1b", "[") -reset_seq = "39;49;00" -seq_end = "m" -seq_sep = ";" -backspace = ctrl("H") -backword = ctrl("W") -cr = "\r" - -title_seq = ("\x1b", "]") -title_end = "\x07" - -# the attributes -attr = {} -attr[0] = None # normal -attr[1] = BoldFormat() # bold -attr[4] = UnderlineFormat() # underline -attr[30] = ColorFormat("white") # should be black - but is inverted -attr[31] = ColorFormat("red") -attr[32] = ColorFormat("lime") # lime looks better on black than normal green -attr[33] = ColorFormat("yellow") -attr[34] = ColorFormat("blue") -attr[35] = ColorFormat("magenta") -attr[36] = ColorFormat("cyan") -attr[37] = ColorFormat("white") -attr[39] = None # default - use white too - -class QtConsole (Console, Qt.QTextEdit): - """Self implemented emulation of a terminal emulation. - This only supports a subset of instructions known to normal terminals.""" - - def __init__ (self, parent): - """Constructor. - - @param parent: parent widget - @type parent: Qt.QWidget""" - - Qt.QTextEdit.__init__(self, parent) - - self.pty = None - self.running = False - self.formatQueue = Queue() - self.title = None - self.writeQueue = "" - self.isNotWrapping = False - - self.setContextMenuPolicy(Qt.Qt.ActionsContextMenu) - - # set black bg - self.palette().setColor(Qt.QPalette.Base, Qt.QColor("black")) - - # set highlighting colors ... XXX: for some reasons this does not work ... Qt sucks - self.palette().setColor(Qt.QPalette.Highlight, Qt.QColor("white")) - self.palette().setColor(Qt.QPalette.HighlightedText, Qt.QColor("black")) - - self.setBackgroundRole(Qt.QPalette.Base) - self.setAutoFillBackground(True) - - # set standard char format to "white" - self.stdFormat = self.currentCharFormat() - self.stdFormat.merge(ColorFormat("white")) - self.setCurrentCharFormat(self.stdFormat) - - self.setReadOnly(True) - - def _deletePrev (self, type): - """Deletes the previous character/word.""" - if type == DeleteEvent.DEL_CHAR: # just the prev char - self.textCursor().deletePreviousChar() - - elif type == DeleteEvent.DEL_WORD: - self.textCursor().select(Qt.QTextCursor.WordUnderCursor) - self.textCursor().removeSelectedText() - - elif type == DeleteEvent.DEL_LINE: - self.moveCursor(Qt.QTextCursor.StartOfLine, Qt.QTextCursor.KeepAnchor) - self.textCursor().removeSelectedText() - self.setLineWrapMode(Qt.QTextEdit.NoWrap) - self.isNotWrapping = True - - elif type == DeleteEvent.DEL_LINE_REVERT: - self.setLineWrapMode(Qt.QTextEdit.WidgetWidth) - self.isNotWrapping = False - - def event (self, event): - if event.type() == WriteEvent.TYPE: - self._write(event.get_string()) - event.accept() - return True - - elif event.type() == DeleteEvent.TYPE: - self._deletePrev(event.del_type) - event.accept() - return True - - elif event.type() == SetPtyEvent.TYPE: - self.set_pty(event.pty) - event.accept() - return True - - event.ignore() - return False - - def _write (self, text): - """Writes some text. A text of "\\x1b" signals _write() to reload - the current char format. - - @param text: the text to print - @type text: string""" - - if text == esc_seq[0]: # \x1b -> reload format - self.setCurrentCharFormat(self.get_format()) - else: - if not self.textCursor().atEnd() and not self.isNotWrapping: # move cursor and re-set format - f = self.currentCharFormat() - self.moveCursor(Qt.QTextCursor.End) - self.setCurrentCharFormat(f) - - # insert the text - self.insertPlainText(text) - - # scroll down if needed - if not self.isNotWrapping: self.ensureCursorVisible() - - def write(self, text): - """Convenience function for emitting the writing signal.""" - - def send (text): - Qt.QCoreApplication.postEvent(self, WriteEvent(text)) - - if text is None: - send(self.writeQueue) - self.writeQueue = "" - - elif text == esc_seq[0]: - send(self.writeQueue) - send(text) - self.writeQueue = "" - - elif len(self.writeQueue) == 4: - send(self.writeQueue+text) - self.writeQueue = "" - - else: - self.writeQueue = self.writeQueue + text - - def start_new_thread (self): - """Starts a new thread, which will listen for some input. - @see: QtTerminal.__run()""" - self.run = True - self.current = Thread(target=self.__run, name="QtTerminal Listener") - self.current.setDaemon(True) # close application even if this thread is running - self.current.start() - - def set_pty (self, pty): - if currentThread().getName() != "MainThread": - Qt.QCoreApplication.postEvent(self, SetPtyEvent(pty)) - return - - if not self.running: - self.pty = pty - self.start_new_thread() - self.running = True - - else: # quit current thread - self.run = False - self.clear() - close(self.pty) - - self.pty = pty # set this after clearing to lose no chars :) - self.start_new_thread() - - def __run (self): - """This function is mainly a loop, which looks for some new input at the terminal, - and parses it for text attributes.""" - - got_cr = False - - while self.run: - try: - s = read(self.pty, 1) - except OSError, e: # bug in Python with the subprocess module - if e.errno == errno.EINTR: - continue - raise - - if s == "": break # nothing read -> finish - - if self.isNotWrapping and s == "\n": - self.write(None) - Qt.QCoreApplication.postEvent(self, DeleteEvent(DeleteEvent.DEL_LINE_REVERT)) - - if got_cr: - got_cr = False - if s == "\n": # got \r\n, which is ok - self.write(s) - continue - else: - self.write(None) - Qt.QCoreApplication.postEvent(self, DeleteEvent(DeleteEvent.DEL_LINE)) - - if s == backspace: # BS - self.write(None) - Qt.QCoreApplication.postEvent(self, DeleteEvent()) - - elif s == backword: - self.write(None) - Qt.QCoreApplication.postEvent(self, DeleteEvent(DeleteEvent.DEL_WORD)) - - elif s == cr: # CR -> make the line being deleted - got_cr = True - - elif s == esc_seq[0]: # -> 0x27 - s = read(self.pty, 1) - if s == esc_seq[1]: # -> [ - while True: - _s = read(self.pty, 1) - s += _s - if _s == seq_end: break - self.parse_seq(s[1:-1]) - - elif s == title_seq[1]: # -> ] - while True: - _s = read(self.pty, 1) - s += _s - if _s == title_end: break - - self.parse_title(s[1:-1]) - else: - self.write(esc_seq[0]+s) - - elif not got_cr: - self.write(s) - - self.write(None) - - def parse_seq (self, seq): - """Parses a sequence of bytes. - If a new attribute has been encountered, a new format is created and added - to the internal format queue. - - @param seq: sequence to parse - @type seq: string""" - - global attr # the dict of attributes - - format = self.virgin_format() - - if seq != reset_seq: # resettet -> done - seq = seq.split(seq_sep) - for s in seq: - try: - s = int(s) - except ValueError: - format = self.virgin_format() - break - - try: - if attr[s] is not None: - format.merge(attr[s]) - else: - format = self.virgin_format() - break - except KeyError: # no such attribute - format = self.virgin_format() - break - - self.add_format(format) - self.write(esc_seq[0]) # write \x1b to signal the occurence of a new format - - def parse_title (self, seq): - if not seq.startswith("0;"): - return - - self.title = seq[2:] - - def get_window_title (self): - return self.title - - def add_format (self, format): - """Adds a format to the queue. - We have to take a queue, because the write-signals might occur asynchronus, - so we set a format for the wrong characters. - - @param format: the format to add - @type format: Qt.QTextCharFormat""" - - self.formatQueue.put(format) - - def get_format (self): - """Returns a format from the queue. - We have to take a queue, because the write-signals might occur asynchronus, - so we set a format for the wrong characters. - - @returns: the popped format - @rtype: Qt.QTextCharFormat""" - - return self.formatQueue.get() - - def virgin_format (self): - """The normal standard format. It is necessary to create it as a new one for some - dubious reasons ... only Qt.QGod knows why.""" - return Qt.QTextCharFormat(self.stdFormat) diff --git a/portato/gui/qt/tree.py b/portato/gui/qt/tree.py deleted file mode 100644 index 7c0fa4c..0000000 --- a/portato/gui/qt/tree.py +++ /dev/null @@ -1,155 +0,0 @@ -# -*- coding: utf-8 -*- -# -# File: portato/gui/qt/tree.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 <necoro@necoro.net> - -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): - - self.tree = treeWidget - self.col = col - - 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 = "" - - if oneshot: - string += "(oneshot)" - if update: string += "; " - - if update: - string += "(updating" - if version is not None: - string += " from version %s" % version - string += ")" - - return [cpv, string] - - def get_emerge_it (self): - return self.emergeIt - - def get_unmerge_it (self): - return self.unmergeIt - - def is_in_emerge (self, it): - while self.iter_has_parent(it): - it = self.parent_iter(it) - return (it == self.emergeIt) - - def is_in_unmerge (self, it): - return not self.is_in_emerge(it) - - def iter_has_parent (self, it): - return (it.parent() != None) - - def parent_iter (self, it): - return it.parent() - - def first_child_iter (self, it): - return it.child(0) - - def iter_has_children (self, it): - return (it.childCount() > 0) - - def next_iter (self, it): - iter = Qt.QTreeWidgetItemIterator(it) - iter += 1 # next iter ... - - newIt = iter.value() - if not newIt or newIt.parent() != it.parent(): # stop if we left the current parent - return None - else: - return newIt - - def get_value (self, it, column): - return str(it.text(column)) - - def append (self, parent = None, values = None): - if values is None: - values = ["",""] - else: - for i in range(len(values)): - if values[i] is None: - values[i] = "" - - if parent is None: - parent = self.tree - - 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 - parent = it.parent() - index = parent.indexOfChild(it) - parent.takeChild(index) - - def get_original (self): - return self.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 = "<b>+%s</b>" % ("<br>+".join(enabled),) - if len(disabled) > 0: - string = string + "<br>" - - if disabled: - string = string+"<i>- %s</i>" % ("<br>- ".join(disabled),) - - if expanded: - string = string+"<br><br>"+"<br>".join(expanded) - - return string - diff --git a/portato/gui/qt/uncheckbox.py b/portato/gui/qt/uncheckbox.py deleted file mode 100644 index d87fb06..0000000 --- a/portato/gui/qt/uncheckbox.py +++ /dev/null @@ -1,38 +0,0 @@ -# -*- coding: utf-8 -*- -# -# File: portato/gui/qt/uncheckbox.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 <necoro@necoro.net> - -from PyQt4.QtGui import QCheckBox -from PyQt4.QtCore import Qt - -class UncheckBox (QCheckBox): - """A checkbox which looks like a normal one, but cannot be checked by the user. - Focusing and hovering are disabled too.""" - - def __init__ (self, *args): - QCheckBox.__init__(self, *args) - self.setFocusPolicy(Qt.NoFocus) - - def mousePressEvent (self, event): - if event.button() == Qt.LeftButton: # ignore leftbutton clicks - pass - else: - QCheckBox.mousePressEvent(self, event) - - def keyPressEvent (self, event): - if event.key() == Qt.Key_Space: # ignore space - pass - else: - QCheckBox.keyPressEvent(self, event) - - def enterEvent (self, event): - # disable hovering - this is set to True somewhere I cannot fix ;) - self.setAttribute(Qt.WA_Hover, False) diff --git a/portato/gui/qt/windows.py b/portato/gui/qt/windows.py deleted file mode 100644 index 539a0f7..0000000 --- a/portato/gui/qt/windows.py +++ /dev/null @@ -1,1125 +0,0 @@ -# -*- coding: utf-8 -*- -# -# File: portato/gui/qt/windows.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 <necoro@necoro.net> - -# qt4 -from PyQt4 import Qt, uic -import sip - -# our backend stuff -from portato.helper import * -from portato.constants import CONFIG_LOCATION, VERSION, DATA_DIR, APP_ICON -from portato.backend import flags, system -from portato.backend.exceptions import * - -from portato.gui.gui_helper import Database, Config, EmergeQueue - -# plugins -from portato import plugin - -# own GUI stuff -from terminal import QtConsole -from tree import QtTree -from highlighter import EbuildHighlighter -from dialogs import * -from helper import qCheck, qIsChecked - -import types, logging -from subprocess import Popen - -UI_DIR = DATA_DIR+"ui/" - -class WindowMeta (sip.wrappertype, type): - """This is the metaclass of all Qt-Windows. It automatically - sets the correct base classes, so they do not have to be set - by the programmer. - @attention: The class has to have the same name as the .ui-file.""" - - def __new__ (cls, name, bases, dict): - new_bases = uic.loadUiType(UI_DIR+name+".ui") - dict.update(_bases = new_bases) - dict.update(_qt_base = new_bases[1]) - return super(WindowMeta, cls).__new__(cls, name, new_bases+bases, dict) - - def __init__ (cls, name, bases, dict): - b = dict["_bases"] - del dict["_bases"] - super(WindowMeta, cls).__init__(name, b+bases, dict) - -class Window (object): - """Base class of all Qt-Windows. - Sets up the UI and provides the watch_cursor function.""" - - def __init__(self, parent = None): - self._qt_base.__init__(self, parent) - self.setupUi(self) - self.setWindowIcon(Qt.QIcon(APP_ICON)) - - @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 - - Qt.QApplication.setOverrideCursor(Qt.Qt.WaitCursor) - try: - try: - ret = func(*args, **kwargs) - finally: - Qt.QApplication.restoreOverrideCursor() - except TypeError: - pass # invalid signature called - - return ret - - return wrapper - -class PluginDialog (Window): - __metaclass__ = WindowMeta - - def __init__ (self, parent, plugins): - - Window.__init__(self, parent) - - self.pluginList.setHeaderLabels(["Plugin", "Author"]) - self.plugins = {} - self.changedPlugins = {} - - for p in plugins: - item = Qt.QTreeWidgetItem(self.pluginList, [p.name,p.author]) - item.setCheckState(0, qCheck(p.is_enabled())) - self.plugins.update({self.create_key(p.name,p.author) : p}) # create a list of plugins - - self.pluginList.resizeColumnToContents(0) - - Qt.QObject.connect(self.pluginList, Qt.SIGNAL("itemClicked(QTreeWidgetItem*, int)"), self.cb_plugin_toggled) < |