changeset 2:71c9c315cfad

rename NewConnectionDialog to Connection dialog as the dialog is actually more general
author Dirk Olmes <dirk@xanthippe.ping.de>
date Sat, 20 Sep 2014 02:50:37 +0200
parents fe8a1645b632
children 77fa82dcc956
files RemoteViewer/Connection.py RemoteViewer/ConnectionDialog.py RemoteViewer/ConnectionDialog.ui RemoteViewer/NewConnectionDialog.py RemoteViewer/NewConnectionDialog.ui RemoteViewer/RemoteViewer.py
diffstat 6 files changed, 166 insertions(+), 161 deletions(-) [+]
line wrap: on
line diff
--- a/RemoteViewer/Connection.py	Fri Sep 19 04:17:06 2014 +0200
+++ b/RemoteViewer/Connection.py	Sat Sep 20 02:50:37 2014 +0200
@@ -4,22 +4,26 @@
         self.geometry = None
         self.host = None
         self.title = None
-        self.type = 'rdp'
+        self.type = 'vnc'
         self.user = None
 
     def __str__(self):
         return 'connection "{}" of type {} to {} with user {} and geometry {}'.format(self.title, self.type,  self.host, self.user, self.geometry)
 
     def setType(self, type):
+        '''This method is connected to a slot in the GUI'''
         self.type = type
 
     def setHost(self, hostname):
+        '''This method is connected to a slot in the GUI'''
         self.host = hostname
 
     def setUser(self, user):
+        '''This method is connected to a slot in the GUI'''
         self.user= user
 
     def setGeometry(self, geometry):
+        '''This method is connected to a slot in the GUI'''
         self.geometry = geometry
 
     def validate(self):
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/RemoteViewer/ConnectionDialog.py	Sat Sep 20 02:50:37 2014 +0200
@@ -0,0 +1,29 @@
+from PyQt4.QtGui import QDialog
+from .Connection import Connection
+from .Ui_ConnectionDialog import Ui_ConnectionDialog
+
+class ConnectionDialog(QDialog):
+    def __init__(self):
+        super(QDialog, self).__init__()
+        self.__initDefaultValues()
+        self.__initUi()
+        self.__connectConnection()
+
+    def __initDefaultValues(self):
+        self.connection = Connection()
+
+    def __initUi(self):
+        self.ui = Ui_ConnectionDialog()
+        self.ui.setupUi(self)
+        self.ui.type.addItem('rdp')
+        self.ui.type.addItem('vnc')
+
+    def __connectConnection(self):
+        self.ui.type.activated[str].connect(self.connection.setType)
+        self.ui.hostname.textChanged.connect(self.connection.setHost)
+        self.ui.username.textChanged.connect(self.connection.setUser)
+        self.ui.geometry.textChanged.connect(self.connection.setGeometry)
+
+    def accept(self):
+        print(self.connection)
+        super(ConnectionDialog, self).accept()
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/RemoteViewer/ConnectionDialog.ui	Sat Sep 20 02:50:37 2014 +0200
@@ -0,0 +1,129 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>ConnectionDialog</class>
+ <widget class="QDialog" name="ConnectionDialog">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>400</width>
+    <height>181</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string/>
+  </property>
+  <layout class="QFormLayout" name="formLayout">
+   <item row="0" column="0">
+    <widget class="QLabel" name="label">
+     <property name="text">
+      <string>Type:</string>
+     </property>
+     <property name="buddy">
+      <cstring>type</cstring>
+     </property>
+    </widget>
+   </item>
+   <item row="0" column="1">
+    <widget class="QComboBox" name="type"/>
+   </item>
+   <item row="1" column="0">
+    <widget class="QLabel" name="label_2">
+     <property name="text">
+      <string>Host:</string>
+     </property>
+     <property name="buddy">
+      <cstring>hostname</cstring>
+     </property>
+    </widget>
+   </item>
+   <item row="1" column="1">
+    <widget class="QLineEdit" name="hostname"/>
+   </item>
+   <item row="2" column="0">
+    <widget class="QLabel" name="label_3">
+     <property name="text">
+      <string>User:</string>
+     </property>
+     <property name="buddy">
+      <cstring>username</cstring>
+     </property>
+    </widget>
+   </item>
+   <item row="3" column="0">
+    <widget class="QLabel" name="label_4">
+     <property name="text">
+      <string>Geometry:</string>
+     </property>
+     <property name="buddy">
+      <cstring>geometry</cstring>
+     </property>
+    </widget>
+   </item>
+   <item row="2" column="1">
+    <widget class="QLineEdit" name="username"/>
+   </item>
+   <item row="5" column="1">
+    <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>
+   <item row="3" column="1">
+    <widget class="QLineEdit" name="geometry"/>
+   </item>
+  </layout>
+ </widget>
+ <tabstops>
+  <tabstop>type</tabstop>
+  <tabstop>hostname</tabstop>
+  <tabstop>username</tabstop>
+  <tabstop>geometry</tabstop>
+  <tabstop>buttonBox</tabstop>
+ </tabstops>
+ <resources/>
+ <connections>
+  <connection>
+   <sender>buttonBox</sender>
+   <signal>accepted()</signal>
+   <receiver>ConnectionDialog</receiver>
+   <slot>accept()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>330</x>
+     <y>171</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>157</x>
+     <y>274</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>buttonBox</sender>
+   <signal>rejected()</signal>
+   <receiver>ConnectionDialog</receiver>
+   <slot>reject()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>390</x>
+     <y>171</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>286</x>
+     <y>274</y>
+    </hint>
+   </hints>
+  </connection>
+ </connections>
+ <slots>
+  <slot>typeSelected(QString)</slot>
+  <slot>setHost(QString)</slot>
+  <slot>setUser(QString)</slot>
+  <slot>setGeometry(QString)</slot>
+ </slots>
+</ui>
--- a/RemoteViewer/NewConnectionDialog.py	Fri Sep 19 04:17:06 2014 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,29 +0,0 @@
-from PyQt4.QtGui import QDialog
-from .Connection import Connection
-from .Ui_NewConnectionDialog import Ui_NewConnectionDialog
-
-class NewConnectionDialog(QDialog):
-    def __init__(self):
-        super(QDialog, self).__init__()
-        self.__initDefaultValues()
-        self.__initUi()
-        self.__connectConnection()
-
-    def __initDefaultValues(self):
-        self.connection = Connection()
-
-    def __initUi(self):
-        self.ui = Ui_NewConnectionDialog()
-        self.ui.setupUi(self)
-        self.ui.type.addItem('rdp')
-        self.ui.type.addItem('vnc')
-
-    def __connectConnection(self):
-        self.ui.type.activated[str].connect(self.connection.setType)
-        self.ui.hostname.textChanged.connect(self.connection.setHost)
-        self.ui.username.textChanged.connect(self.connection.setUser)
-        self.ui.geometry.textChanged.connect(self.connection.setGeometry)
-
-    def accept(self):
-        print(self.connection)
-        super(NewConnectionDialog, self).accept()
--- a/RemoteViewer/NewConnectionDialog.ui	Fri Sep 19 04:17:06 2014 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,129 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>NewConnectionDialog</class>
- <widget class="QDialog" name="NewConnectionDialog">
-  <property name="geometry">
-   <rect>
-    <x>0</x>
-    <y>0</y>
-    <width>400</width>
-    <height>181</height>
-   </rect>
-  </property>
-  <property name="windowTitle">
-   <string>New Connection</string>
-  </property>
-  <layout class="QFormLayout" name="formLayout">
-   <item row="0" column="0">
-    <widget class="QLabel" name="label">
-     <property name="text">
-      <string>Type:</string>
-     </property>
-     <property name="buddy">
-      <cstring>type</cstring>
-     </property>
-    </widget>
-   </item>
-   <item row="0" column="1">
-    <widget class="QComboBox" name="type"/>
-   </item>
-   <item row="1" column="0">
-    <widget class="QLabel" name="label_2">
-     <property name="text">
-      <string>Host:</string>
-     </property>
-     <property name="buddy">
-      <cstring>hostname</cstring>
-     </property>
-    </widget>
-   </item>
-   <item row="1" column="1">
-    <widget class="QLineEdit" name="hostname"/>
-   </item>
-   <item row="2" column="0">
-    <widget class="QLabel" name="label_3">
-     <property name="text">
-      <string>User:</string>
-     </property>
-     <property name="buddy">
-      <cstring>username</cstring>
-     </property>
-    </widget>
-   </item>
-   <item row="3" column="0">
-    <widget class="QLabel" name="label_4">
-     <property name="text">
-      <string>Geometry:</string>
-     </property>
-     <property name="buddy">
-      <cstring>geometry</cstring>
-     </property>
-    </widget>
-   </item>
-   <item row="2" column="1">
-    <widget class="QLineEdit" name="username"/>
-   </item>
-   <item row="5" column="1">
-    <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>
-   <item row="3" column="1">
-    <widget class="QLineEdit" name="geometry"/>
-   </item>
-  </layout>
- </widget>
- <tabstops>
-  <tabstop>type</tabstop>
-  <tabstop>hostname</tabstop>
-  <tabstop>username</tabstop>
-  <tabstop>geometry</tabstop>
-  <tabstop>buttonBox</tabstop>
- </tabstops>
- <resources/>
- <connections>
-  <connection>
-   <sender>buttonBox</sender>
-   <signal>accepted()</signal>
-   <receiver>NewConnectionDialog</receiver>
-   <slot>accept()</slot>
-   <hints>
-    <hint type="sourcelabel">
-     <x>330</x>
-     <y>171</y>
-    </hint>
-    <hint type="destinationlabel">
-     <x>157</x>
-     <y>274</y>
-    </hint>
-   </hints>
-  </connection>
-  <connection>
-   <sender>buttonBox</sender>
-   <signal>rejected()</signal>
-   <receiver>NewConnectionDialog</receiver>
-   <slot>reject()</slot>
-   <hints>
-    <hint type="sourcelabel">
-     <x>390</x>
-     <y>171</y>
-    </hint>
-    <hint type="destinationlabel">
-     <x>286</x>
-     <y>274</y>
-    </hint>
-   </hints>
-  </connection>
- </connections>
- <slots>
-  <slot>typeSelected(QString)</slot>
-  <slot>setHost(QString)</slot>
-  <slot>setUser(QString)</slot>
-  <slot>setGeometry(QString)</slot>
- </slots>
-</ui>
--- a/RemoteViewer/RemoteViewer.py	Fri Sep 19 04:17:06 2014 +0200
+++ b/RemoteViewer/RemoteViewer.py	Sat Sep 20 02:50:37 2014 +0200
@@ -1,7 +1,7 @@
 from PyQt4.QtGui import QMainWindow
 from PyQtLib.ExceptionSafeSlot import ExceptionSafeSlot
 
-from .NewConnectionDialog import NewConnectionDialog
+from .ConnectionDialog import ConnectionDialog
 from .Ui_RemoteViewer import Ui_RemoteViewer
 
 class RemoteViewer(QMainWindow):
@@ -12,5 +12,6 @@
 
     @ExceptionSafeSlot()
     def newConnection(self):
-        dialog = NewConnectionDialog()
+        dialog = ConnectionDialog()
+        dialog.setWindowTitle('New Connection')
         dialog.exec_()