changeset 0:f889ad584f0a

initial import
author Dirk Olmes <dirk@xanthippe.ping.de>
date Fri, 19 Sep 2014 04:02:38 +0200
parents
children fe8a1645b632
files .hgignore RemoteViewer/Connection.py RemoteViewer/NewConnectionDialog.py RemoteViewer/NewConnectionDialog.ui RemoteViewer/RemoteViewer.py RemoteViewer/RemoteViewer.ui __init__.py __main__.py
diffstat 7 files changed, 380 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.hgignore	Fri Sep 19 04:02:38 2014 +0200
@@ -0,0 +1,5 @@
+.e4p
+.eric5project
+.pyc
+PyQtLib
+Ui_*
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/RemoteViewer/Connection.py	Fri Sep 19 04:02:38 2014 +0200
@@ -0,0 +1,14 @@
+
+class Connection(object):
+    def __init__(self):
+        self.geometry = None
+        self.host = None
+        self.title = None
+        self.type = 'rdp'
+        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 validate(self):
+        pass
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/RemoteViewer/NewConnectionDialog.py	Fri Sep 19 04:02:38 2014 +0200
@@ -0,0 +1,38 @@
+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):
+        pass
+
+    def typeSelected(self, type):
+        self.connection.type = type
+
+    def setHost(self, hostname):
+        self.connection.host = hostname
+
+    def setUser(self, user):
+        self.connection.user = user
+
+    def setGeometry(self, geometry):
+        self.connection.geometry = geometry
+
+    def accept(self):
+        print(self.connection)
+        super(NewConnectionDialog, self).accept()
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/RemoteViewer/NewConnectionDialog.ui	Fri Sep 19 04:02:38 2014 +0200
@@ -0,0 +1,193 @@
+<?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>
+  <connection>
+   <sender>type</sender>
+   <signal>activated(QString)</signal>
+   <receiver>NewConnectionDialog</receiver>
+   <slot>typeSelected(QString)</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>112</x>
+     <y>21</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>32</x>
+     <y>147</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>hostname</sender>
+   <signal>textChanged(QString)</signal>
+   <receiver>NewConnectionDialog</receiver>
+   <slot>setHost(QString)</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>102</x>
+     <y>52</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>64</x>
+     <y>160</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>username</sender>
+   <signal>textChanged(QString)</signal>
+   <receiver>NewConnectionDialog</receiver>
+   <slot>setUser(QString)</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>97</x>
+     <y>84</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>43</x>
+     <y>136</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>geometry</sender>
+   <signal>textChanged(QString)</signal>
+   <receiver>NewConnectionDialog</receiver>
+   <slot>setGeometry(QString)</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>121</x>
+     <y>118</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>41</x>
+     <y>176</y>
+    </hint>
+   </hints>
+  </connection>
+ </connections>
+ <slots>
+  <slot>typeSelected(QString)</slot>
+  <slot>setHost(QString)</slot>
+  <slot>setUser(QString)</slot>
+  <slot>setGeometry(QString)</slot>
+ </slots>
+</ui>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/RemoteViewer/RemoteViewer.py	Fri Sep 19 04:02:38 2014 +0200
@@ -0,0 +1,16 @@
+from PyQt4.QtGui import QMainWindow
+from PyQtLib.ExceptionSafeSlot import ExceptionSafeSlot
+
+from .NewConnectionDialog import NewConnectionDialog
+from .Ui_RemoteViewer import Ui_RemoteViewer
+
+class RemoteViewer(QMainWindow):
+    def __init__(self):
+        super(RemoteViewer,  self).__init__()
+        self.ui = Ui_RemoteViewer()
+        self.ui.setupUi(self)
+
+    @ExceptionSafeSlot()
+    def newConnection(self):
+        dialog = NewConnectionDialog()
+        dialog.exec_()
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/RemoteViewer/RemoteViewer.ui	Fri Sep 19 04:02:38 2014 +0200
@@ -0,0 +1,98 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>RemoteViewer</class>
+ <widget class="QMainWindow" name="RemoteViewer">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>439</width>
+    <height>410</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>Remote</string>
+  </property>
+  <widget class="QWidget" name="centralwidget">
+   <layout class="QVBoxLayout" name="verticalLayout">
+    <item>
+     <widget class="QListView" name="listView"/>
+    </item>
+   </layout>
+  </widget>
+  <widget class="QMenuBar" name="menubar">
+   <property name="geometry">
+    <rect>
+     <x>0</x>
+     <y>0</y>
+     <width>439</width>
+     <height>23</height>
+    </rect>
+   </property>
+   <widget class="QMenu" name="menuFile">
+    <property name="title">
+     <string>File</string>
+    </property>
+    <addaction name="actionNew"/>
+    <addaction name="separator"/>
+    <addaction name="actionQuit"/>
+   </widget>
+   <addaction name="menuFile"/>
+  </widget>
+  <widget class="QStatusBar" name="statusbar"/>
+  <action name="actionQuit">
+   <property name="text">
+    <string>Quit</string>
+   </property>
+   <property name="shortcut">
+    <string>Ctrl+Q</string>
+   </property>
+  </action>
+  <action name="actionNew">
+   <property name="text">
+    <string>New</string>
+   </property>
+   <property name="shortcut">
+    <string>Ctrl+N</string>
+   </property>
+  </action>
+ </widget>
+ <resources/>
+ <connections>
+  <connection>
+   <sender>actionQuit</sender>
+   <signal>triggered()</signal>
+   <receiver>RemoteViewer</receiver>
+   <slot>close()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>-1</x>
+     <y>-1</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>399</x>
+     <y>299</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>actionNew</sender>
+   <signal>triggered()</signal>
+   <receiver>RemoteViewer</receiver>
+   <slot>newConnection()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>-1</x>
+     <y>-1</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>219</x>
+     <y>204</y>
+    </hint>
+   </hints>
+  </connection>
+ </connections>
+ <slots>
+  <slot>newConnection()</slot>
+ </slots>
+</ui>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/__main__.py	Fri Sep 19 04:02:38 2014 +0200
@@ -0,0 +1,16 @@
+#!/usr/bin/env python3
+
+# see http://stackoverflow.com/questions/6238193/pyqt-new-api-with-python-2
+import sip
+sip.setapi('QString', 2)
+sip.setapi('QVariant', 2)
+
+import sys
+from PyQt4.QtGui import QApplication
+from RemoteViewer.RemoteViewer import RemoteViewer
+
+if __name__ == '__main__':
+    app = QApplication(sys.argv)
+    window = RemoteViewer()
+    window.show()
+    sys.exit(app.exec_())