Global settings dialog

This commit is contained in:
Agnieszka Kostrzewa 2012-01-31 17:29:00 +01:00
parent e38f4df7fe
commit 49495d6444
5 changed files with 246 additions and 0 deletions

View File

@ -22,6 +22,7 @@ res:
pyuic4 -o qubesmanager/ui_settingsdlg.py settingsdlg.ui
pyuic4 -o qubesmanager/ui_restoredlg.py restoredlg.ui
pyuic4 -o qubesmanager/ui_backupdlg.py backupdlg.ui
pyuic4 -o qubesmanager/ui_globalsettingsdlg.py globalsettingsdlg.ui
update-repo-current:
ln -f $(RPMS_DIR)/x86_64/qubes-manager-*$(VERSION)*.rpm ../yum/current-release/current/dom0/rpm/

126
globalsettingsdlg.ui Normal file
View File

@ -0,0 +1,126 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>GlobalSettings</class>
<widget class="QDialog" name="GlobalSettings">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>568</width>
<height>342</height>
</rect>
</property>
<property name="windowTitle">
<string>Qubes Global Settings</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>UpdateVM:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="updateVMcombo"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>ClockVM:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="clockVMcombo"/>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Default netVM:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QComboBox" name="defaultNetVMcombo"/>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_4">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Default template:</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QComboBox" name="defaultTemplateVMCombo"/>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Default kernel:</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QComboBox" name="comboBox_5"/>
</item>
<item row="5" column="0" colspan="2">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>GlobalSettings</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>GlobalSettings</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@ -186,6 +186,7 @@
<property name="title">
<string>Options</string>
</property>
<addaction name="action_global_settings"/>
<addaction name="action_backup"/>
<addaction name="action_restore"/>
</widget>
@ -516,6 +517,11 @@
<string>Backup VMs</string>
</property>
</action>
<action name="action_global_settings">
<property name="text">
<string>Global settings</string>
</property>
</action>
</widget>
<resources>
<include location="resources.qrc"/>

View File

@ -0,0 +1,107 @@
#!/usr/bin/python2.6
#
# The Qubes OS Project, http://www.qubes-os.org
#
# Copyright (C) 2012 Agnieszka Kostrzewa <agnieszka.kostrzewa@gmail.com>
# Copyright (C) 2012 Marek Marczykowski <marmarek@mimuw.edu.pl>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
#
import sys
import os
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from qubes.qubes import QubesVmCollection
from qubes.qubes import QubesException
from qubes.qubes import QubesDaemonPidfile
from qubes.qubes import QubesHost
import qubesmanager.resources_rc
from pyinotify import WatchManager, Notifier, ThreadedNotifier, EventsCodes, ProcessEvent
import subprocess
import time
import threading
from operator import itemgetter
from ui_globalsettingsdlg import *
class GlobalSettingsWindow(Ui_GlobalSettings, QDialog):
def __init__(self, parent=None):
super(GlobalSettingsWindow, self).__init__(parent)
self.setupUi(self)
def reject(self):
self.done(0)
def save_and_apply(self):
pass
# Bases on the original code by:
# Copyright (c) 2002-2007 Pascal Varet <p.varet@gmail.com>
def handle_exception( exc_type, exc_value, exc_traceback ):
import sys
import os.path
import traceback
filename, line, dummy, dummy = traceback.extract_tb( exc_traceback ).pop()
filename = os.path.basename( filename )
error = "%s: %s" % ( exc_type.__name__, exc_value )
QMessageBox.critical(None, "Houston, we have a problem...",
"Whoops. A critical error has occured. This is most likely a bug "
"in Qubes Global Settings application.<br><br>"
"<b><i>%s</i></b>" % error +
"at <b>line %d</b> of file <b>%s</b>.<br/><br/>"
% ( line, filename ))
def main():
global qubes_host
qubes_host = QubesHost()
global app
app = QApplication(sys.argv)
app.setOrganizationName("The Qubes Project")
app.setOrganizationDomain("http://qubes-os.org")
app.setApplicationName("Qubes Global Settings")
sys.excepthook = handle_exception
qvm_collection = QubesVmCollection()
qvm_collection.lock_db_for_reading()
qvm_collection.load()
qvm_collection.unlock_db()
global global_window
global_window = GlobalSetingsWindow()
global_window.show()
app.exec_()
app.exit()
if __name__ == "__main__":
main()

View File

@ -42,6 +42,7 @@ from appmenu_select import AppmenuSelectWindow
from settings import VMSettingsWindow
from restore import RestoreVMsWindow
from backup import BackupVMsWindow
from global_settings import GlobalSettingsWindow
from firewall import EditFwRulesDlg, QubesFirewallRulesModel
@ -958,6 +959,11 @@ class VmManagerWindow(Ui_VmManagerWindow, QMainWindow):
if dialog.exec_():
model.apply_rules()
@pyqtSlot(name='on_action_global_settings_triggered')
def action_global_settings_triggered(self):
global_settings_window = GlobalSettingsWindow()
global_settings_window.exec_()
@pyqtSlot(name='on_action_restore_triggered')
def action_restore_triggered(self):