# HG changeset patch # User Dirk Olmes # Date 1411174237 -7200 # Node ID 71c9c315cfada424ff1106e62b8eefaced2e5182 # Parent fe8a1645b6323d34fb8032327f6cb47314102ee6 rename NewConnectionDialog to Connection dialog as the dialog is actually more general diff -r fe8a1645b632 -r 71c9c315cfad RemoteViewer/Connection.py --- 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): diff -r fe8a1645b632 -r 71c9c315cfad RemoteViewer/ConnectionDialog.py --- /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() diff -r fe8a1645b632 -r 71c9c315cfad RemoteViewer/ConnectionDialog.ui --- /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 @@ + + + ConnectionDialog + + + + 0 + 0 + 400 + 181 + + + + + + + + + + Type: + + + type + + + + + + + + + + Host: + + + hostname + + + + + + + + + + User: + + + username + + + + + + + Geometry: + + + geometry + + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + + type + hostname + username + geometry + buttonBox + + + + + buttonBox + accepted() + ConnectionDialog + accept() + + + 330 + 171 + + + 157 + 274 + + + + + buttonBox + rejected() + ConnectionDialog + reject() + + + 390 + 171 + + + 286 + 274 + + + + + + typeSelected(QString) + setHost(QString) + setUser(QString) + setGeometry(QString) + + diff -r fe8a1645b632 -r 71c9c315cfad RemoteViewer/NewConnectionDialog.py --- 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() diff -r fe8a1645b632 -r 71c9c315cfad RemoteViewer/NewConnectionDialog.ui --- 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 @@ - - - NewConnectionDialog - - - - 0 - 0 - 400 - 181 - - - - New Connection - - - - - - Type: - - - type - - - - - - - - - - Host: - - - hostname - - - - - - - - - - User: - - - username - - - - - - - Geometry: - - - geometry - - - - - - - - - - Qt::Horizontal - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - - - - - type - hostname - username - geometry - buttonBox - - - - - buttonBox - accepted() - NewConnectionDialog - accept() - - - 330 - 171 - - - 157 - 274 - - - - - buttonBox - rejected() - NewConnectionDialog - reject() - - - 390 - 171 - - - 286 - 274 - - - - - - typeSelected(QString) - setHost(QString) - setUser(QString) - setGeometry(QString) - - diff -r fe8a1645b632 -r 71c9c315cfad RemoteViewer/RemoteViewer.py --- 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_()