From 7d757db73d862b368c57aed2da769a53b3e1e920 Mon Sep 17 00:00:00 2001
From: necoro <>
Date: Thu, 5 Jul 2007 02:40:39 +0000
Subject: added ability to disable/enable plugins in qt too; added shutdown
plugin
---
portato/gui/qt/windows.py | 66 +++++++++++----
portato/gui/templates/ui/AboutDialog.ui | 144 ++++++++++++--------------------
portato/gui/templates/ui/MainWindow.ui | 18 ++--
portato/plugins/shutdown.py | 17 ++++
4 files changed, 133 insertions(+), 112 deletions(-)
create mode 100644 portato/plugins/shutdown.py
(limited to 'portato')
diff --git a/portato/gui/qt/windows.py b/portato/gui/qt/windows.py
index abb69ad..7c1726e 100644
--- a/portato/gui/qt/windows.py
+++ b/portato/gui/qt/windows.py
@@ -81,20 +81,60 @@ class Window (object):
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)
+
+ def create_key (self, name, author):
+ return str(name + "_" + author)
+
+ def cb_plugin_toggled (self, item, col):
+ if col != 0:
+ return
+
+ self.changedPlugins.update({ \
+ self.create_key(str(item.text(0)), str(item.text(1))) : \
+ qIsChecked(item.checkState(0))\
+ })
+
+ @Qt.pyqtSignature("")
+ def on_buttonBox_accepted(self):
+ for pluginKey, value in self.changedPlugins.iteritems():
+ self.plugins[pluginKey].set_enabled(value)
+
+ self.accept()
+
class AboutDialog (Window):
"""A window showing the "about"-informations."""
__metaclass__ = WindowMeta
- def __init__ (self, parent = None, plugins = []):
+ def __init__ (self, parent = None):
"""Constructor.
@param parent: the parent window
- @type parent: Qt.QWidget
- @param plugins: The list of plugins (author,name) to show in the "Plugins"-Tab.
- @type plugins: (string, string)[]"""
+ @type parent: Qt.QWidget"""
Window.__init__(self, parent)
+ self.pix = Qt.QPixmap(APP_ICON)
+ self.imgLabel.setPixmap(self.pix) # yes we have to use a label for the image ...
+
self.label.setText("""
Portato v.%s
A Portage-GUI
@@ -104,15 +144,7 @@ Copyright (C) 2006-2007 René 'Necoro' Neumann <necoro@necoro.net>
Icon created by P4R4D0X""" % VERSION)
- self.pluginList.setHeaderLabels(["Plugin", "Author"])
- for p in plugins:
- Qt.QTreeWidgetItem(self.pluginList, list(p))
-
- self.pluginList.resizeColumnToContents(0)
-
- self.adjustSize()
-
class SearchDialog (Window):
"""A window showing the results of a search process."""
__metaclass__ = WindowMeta
@@ -805,13 +837,15 @@ class MainWindow (Window):
@Qt.pyqtSignature("")
def on_aboutAction_triggered (self):
- queue = plugin.get_plugin_queue()
+ AboutDialog(self).exec_()
+
+ @Qt.pyqtSignature("")
+ def on_pluginAction_triggered (self):
+ queue = plugin.get_plugin_queue().get_plugins()
if queue is None:
queue = []
- else:
- queue = queue.get_plugin_data()
- AboutDialog(self, queue).exec_()
+ PluginDialog(self, queue).exec_()
@Qt.pyqtSignature("")
def on_prefAction_triggered (self):
diff --git a/portato/gui/templates/ui/AboutDialog.ui b/portato/gui/templates/ui/AboutDialog.ui
index b4064dd..ce89b44 100644
--- a/portato/gui/templates/ui/AboutDialog.ui
+++ b/portato/gui/templates/ui/AboutDialog.ui
@@ -8,8 +8,8 @@
0
0
- 369
- 270
+ 400
+ 300
@@ -23,93 +23,41 @@
6
-
-
-
- 0
+
+
+
+
+
+ Qt::AlignCenter
+
+
+
+ -
+
+
+ TextLabel
+
+
+ Qt::AlignCenter
+
+
+ true
-
-
- About
-
-
-
- 9
-
-
- 6
-
-
-
-
-
- TextLabel
-
-
- Qt::AlignCenter
-
-
- true
-
-
-
- -
-
-
- Qt::Vertical
-
-
-
- 20
- 40
-
-
-
-
-
-
-
-
- Plugins
-
-
-
- 9
-
-
- 6
-
- -
-
-
- QAbstractItemView::NoEditTriggers
-
-
- false
-
-
- true
-
-
- false
-
-
- 2
-
-
-
- 1
-
-
-
-
- 1
-
-
-
-
-
-
+ -
+
+
+ Qt::Vertical
+
+
+
+ 20
+ 40
+
+
+
+
-
@@ -134,12 +82,28 @@
accept()
- 174
- 252
+ 248
+ 254
+
+
+ 157
+ 274
+
+
+
+
+ buttonBox
+ rejected()
+ AboutDialog
+ reject()
+
+
+ 316
+ 260
- 176
- 197
+ 286
+ 274
diff --git a/portato/gui/templates/ui/MainWindow.ui b/portato/gui/templates/ui/MainWindow.ui
index e2eb0dc..9a3e15e 100644
--- a/portato/gui/templates/ui/MainWindow.ui
+++ b/portato/gui/templates/ui/MainWindow.ui
@@ -428,12 +428,6 @@ p, li { white-space: pre-wrap; }
-
+
@@ -540,6 +541,11 @@ p, li { white-space: pre-wrap; }
Show &new packages
+
+
+ Plugins
+
+
diff --git a/portato/plugins/shutdown.py b/portato/plugins/shutdown.py
new file mode 100644
index 0000000..a29ee6f
--- /dev/null
+++ b/portato/plugins/shutdown.py
@@ -0,0 +1,17 @@
+# -*- coding: utf-8 -*-
+#
+# File: portato/plugins/shutdown.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
+
+import os
+
+def shutdown (*args):
+ """Shutdown the computer. May not work if not root."""
+ os.system("shutdown -h now")
--
cgit v1.2.3-70-g09d2