浏览代码

Log dialog with 'copy-clipboard-to-qubes-clipboard'(#543)

Agnieszka Kostrzewa 12 年之前
父节点
当前提交
7890aac8e8
共有 5 个文件被更改,包括 221 次插入26 次删除
  1. 1 0
      Makefile
  2. 122 0
      logdlg.ui
  3. 89 0
      qubesmanager/log_dialog.py
  4. 4 26
      qubesmanager/main.py
  5. 5 0
      rpm_spec/qmgr.spec

+ 1 - 0
Makefile

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

+ 122 - 0
logdlg.ui

@@ -0,0 +1,122 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>LogDialog</class>
+ <widget class="QDialog" name="LogDialog">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>750</width>
+    <height>450</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>Dialog</string>
+  </property>
+  <layout class="QVBoxLayout" name="verticalLayout">
+   <item>
+    <widget class="QTextBrowser" name="log_text">
+     <property name="toolTip">
+      <string>Copy Dom0 clipboard to Qubes clipboard</string>
+     </property>
+    </widget>
+   </item>
+   <item>
+    <layout class="QHBoxLayout" name="horizontalLayout">
+     <item>
+      <spacer name="horizontalSpacer">
+       <property name="orientation">
+        <enum>Qt::Horizontal</enum>
+       </property>
+       <property name="sizeHint" stdset="0">
+        <size>
+         <width>40</width>
+         <height>20</height>
+        </size>
+       </property>
+      </spacer>
+     </item>
+     <item>
+      <widget class="QPushButton" name="copy_to_qubes_clipboard">
+       <property name="sizePolicy">
+        <sizepolicy hsizetype="Minimum" vsizetype="Fixed">
+         <horstretch>0</horstretch>
+         <verstretch>0</verstretch>
+        </sizepolicy>
+       </property>
+       <property name="focusPolicy">
+        <enum>Qt::TabFocus</enum>
+       </property>
+       <property name="text">
+        <string>Copy clipboard to Qubes clipboard</string>
+       </property>
+       <property name="icon">
+        <iconset resource="resources.qrc">
+         <normaloff>:/copy.png</normaloff>:/copy.png</iconset>
+       </property>
+       <property name="iconSize">
+        <size>
+         <width>20</width>
+         <height>20</height>
+        </size>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QDialogButtonBox" name="buttonBox">
+       <property name="sizePolicy">
+        <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+         <horstretch>0</horstretch>
+         <verstretch>0</verstretch>
+        </sizepolicy>
+       </property>
+       <property name="orientation">
+        <enum>Qt::Horizontal</enum>
+       </property>
+       <property name="standardButtons">
+        <set>QDialogButtonBox::Ok</set>
+       </property>
+      </widget>
+     </item>
+    </layout>
+   </item>
+  </layout>
+ </widget>
+ <resources>
+  <include location="resources.qrc"/>
+ </resources>
+ <connections>
+  <connection>
+   <sender>buttonBox</sender>
+   <signal>rejected()</signal>
+   <receiver>LogDialog</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>
+  <connection>
+   <sender>buttonBox</sender>
+   <signal>accepted()</signal>
+   <receiver>LogDialog</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>
+ </connections>
+</ui>

+ 89 - 0
qubesmanager/log_dialog.py

@@ -0,0 +1,89 @@
+#!/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
+import fcntl
+from PyQt4.QtCore import *
+from PyQt4.QtGui import *
+
+from qubes.qubes import QubesException
+
+import qubesmanager.resources_rc
+
+from ui_logdlg import *
+
+
+class LogDialog(Ui_LogDialog, QDialog):
+
+    def __init__(self, app, log_path, parent=None):
+        super(LogDialog, self).__init__(parent)
+
+        self.app = app
+        self.log_path = log_path
+
+        self.setupUi(self)
+        self.setWindowTitle(log_path)
+ 
+        self.connect(self.copy_to_qubes_clipboard, SIGNAL("clicked()"), self.copy_to_qubes_clipboard_triggered)
+       
+        self.__init_log_text__()
+
+    def __init_log_text__(self):
+        log = open(self.log_path)
+        text = log.read()
+        log.close()
+        self.log_text.setText(text)
+
+
+    def copy_to_qubes_clipboard_triggered(self):
+        clipboard = self.app.clipboard().text()
+        copy_text_to_qubes_clipboard(clipboard)
+        
+########################COPY TEXT TO QUBES CLIPBOARD
+
+def copy_text_to_qubes_clipboard(text):
+    #inter-appviewer lock
+
+    try:
+        fd = os.open("/var/run/qubes/appviewer.lock", os.O_RDWR|os.O_CREAT, 0600);
+        fcntl.flock(fd, fcntl.LOCK_EX);
+    except IOError:
+        QMessageBox.warning (None, "Warning!", "Error while accessing Qubes clipboard!")
+        return
+
+    qubes_clipboard = open("/var/run/qubes/qubes_clipboard.bin", 'w')
+    qubes_clipboard.write(text)
+    qubes_clipboard.close()
+        
+    qubes_clip_source = open("/var/run/qubes/qubes_clipboard.bin.source", 'w')
+    qubes_clip_source.write("dom0")
+    qubes_clip_source.close()
+
+    try:
+        fcntl.flock(fd, fcntl.LOCK_UN)
+        os.close(fd)
+    except IOError:
+        QMessageBox.warning (None, "Warning!", "Error while writing to Qubes clipboard!")
+        return
+    

+ 4 - 26
qubesmanager/main.py

@@ -44,6 +44,7 @@ from settings import VMSettingsWindow
 from restore import RestoreVMsWindow
 from backup import BackupVMsWindow
 from global_settings import GlobalSettingsWindow
+from log_dialog import LogDialog, copy_text_to_qubes_clipboard
 from thread_monitor import *
 
 from pyinotify import WatchManager, Notifier, ThreadedNotifier, EventsCodes, ProcessEvent
@@ -1514,29 +1515,7 @@ class VmManagerWindow(Ui_VmManagerWindow, QMainWindow):
     @pyqtSlot(name='on_action_copy_clipboard_triggered')
     def action_copy_clipboard_triggered(self):
         clipboard = app.clipboard().text()
-
-        #inter-appviewer lock
-        try:
-            fd = os.open("/var/run/qubes/appviewer.lock", os.O_RDWR|os.O_CREAT, 0600);
-            fcntl.flock(fd, fcntl.LOCK_EX);
-        except IOError:
-            QMessageBox.warning (None, "Warning!", "Error while accessing Qubes clipboard!")
-            return
-
-        qubes_clipboard = open("/var/run/qubes/qubes_clipboard.bin", 'w')
-        qubes_clipboard.write(clipboard)
-        qubes_clipboard.close()
-            
-        qubes_clip_source = open("/var/run/qubes/qubes_clipboard.bin.source", 'w')
-        qubes_clip_source.write("dom0")
-        qubes_clip_source.close()
-
-        try:
-            fcntl.flock(fd, fcntl.LOCK_UN)
-            os.close(fd)
-        except IOError:
-            QMessageBox.warning (None, "Warning!", "Error while writing to Qubes clipboard!")
-            return
+        copy_text_to_qubes_clipboard(clipboard)
     
             
     def createPopupMenu(self):
@@ -1620,9 +1599,8 @@ class VmManagerWindow(Ui_VmManagerWindow, QMainWindow):
     @pyqtSlot('QAction *')
     def show_log(self, action):
         log = str(action.data().toString())
-        
-        cmd = ['kdialog', '--textbox', log, '700', '450', '--title', log]
-        subprocess.Popen(cmd)
+        log_dialog = LogDialog(app, log)
+        log_dialog.exec_()
 
 
     @pyqtSlot('QAction *')

+ 5 - 0
rpm_spec/qmgr.spec

@@ -44,6 +44,7 @@ cp qubesmanager/global_settings.py{,c,o} $RPM_BUILD_ROOT%{python_sitearch}/qubes
 cp qubesmanager/multiselectwidget.py{,c,o} $RPM_BUILD_ROOT%{python_sitearch}/qubesmanager
 cp qubesmanager/restore.py{,c,o} $RPM_BUILD_ROOT%{python_sitearch}/qubesmanager
 cp qubesmanager/settings.py{,c,o} $RPM_BUILD_ROOT%{python_sitearch}/qubesmanager
+cp qubesmanager/log_dialog.py{,c,o} $RPM_BUILD_ROOT%{python_sitearch}/qubesmanager
 cp qubesmanager/thread_monitor.py{,c,o} $RPM_BUILD_ROOT%{python_sitearch}/qubesmanager
 cp qubesmanager/resources_rc.py{,c,o} $RPM_BUILD_ROOT%{python_sitearch}/qubesmanager
 cp qubesmanager/__init__.py{,c,o} $RPM_BUILD_ROOT%{python_sitearch}/qubesmanager
@@ -56,6 +57,7 @@ cp qubesmanager/ui_newappvmdlg.py{,c,o} $RPM_BUILD_ROOT%{python_sitearch}/qubesm
 cp qubesmanager/ui_newfwruledlg.py{,c,o} $RPM_BUILD_ROOT%{python_sitearch}/qubesmanager
 cp qubesmanager/ui_restoredlg.py{,c,o} $RPM_BUILD_ROOT%{python_sitearch}/qubesmanager
 cp qubesmanager/ui_settingsdlg.py{,c,o} $RPM_BUILD_ROOT%{python_sitearch}/qubesmanager
+cp qubesmanager/ui_logdlg.py{,c,o} $RPM_BUILD_ROOT%{python_sitearch}/qubesmanager
 
 mkdir -p $RPM_BUILD_ROOT/usr/share/applications
 cp qubes-manager.desktop $RPM_BUILD_ROOT/usr/share/applications
@@ -139,6 +141,9 @@ rm -rf $RPM_BUILD_ROOT
 %{python_sitearch}/qubesmanager/ui_settingsdlg.py
 %{python_sitearch}/qubesmanager/ui_settingsdlg.pyc
 %{python_sitearch}/qubesmanager/ui_settingsdlg.pyo
+%{python_sitearch}/qubesmanager/ui_logdlg.py
+%{python_sitearch}/qubesmanager/ui_logdlg.pyc
+%{python_sitearch}/qubesmanager/ui_logdlg.pyo
 
 
 /usr/share/applications/qubes-manager.desktop