From b548a19e678f3c88d3a7bbde74afc938c65c6316 Mon Sep 17 00:00:00 2001 From: howaboutudance Date: Sat, 27 Jul 2013 17:36:47 +0200 Subject: [PATCH] Add entry "Save connection" in File menu --- AUTHORS | 1 + src/qweechat/network.py | 6 ++++++ src/qweechat/qweechat.py | 21 ++++++++++++++------- 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/AUTHORS b/AUTHORS index 2281299..7c3cb0b 100644 --- a/AUTHORS +++ b/AUTHORS @@ -16,6 +16,7 @@ Alphabetically: * Florian Besser (Banton) * Gryllida A (gry) +* howaboutudance Contact diff --git a/src/qweechat/network.py b/src/qweechat/network.py index 5f4a50d..8690c5a 100644 --- a/src/qweechat/network.py +++ b/src/qweechat/network.py @@ -143,3 +143,9 @@ class Network(QtCore.QObject): self.status_connecting: 'dialog-close.png', self.status_connected: 'dialog-ok-apply.png'} return icon.get(status, '') + + def get_options(self): + return {'server': self._server, + 'port': self._port, + 'ssl': 'on' if self._ssl else 'off', + 'password': self._password} diff --git a/src/qweechat/qweechat.py b/src/qweechat/qweechat.py index 1aac616..9f611c3 100755 --- a/src/qweechat/qweechat.py +++ b/src/qweechat/qweechat.py @@ -91,12 +91,13 @@ class MainWindow(QtGui.QMainWindow): self.statusBar().visible = True # actions for menu and toolbar - actions_def = {'connect' : ['network-connect.png', 'Connect to WeeChat', 'Ctrl+O', self.open_connection_dialog], - 'disconnect' : ['network-disconnect.png', 'Disconnect from WeeChat', 'Ctrl+D', self.network.disconnect_weechat], - 'debug' : ['edit-find.png', 'Debug console window', 'Ctrl+B', self.open_debug_dialog], - 'preferences': ['preferences-other.png', 'Preferences', 'Ctrl+P', self.open_preferences_dialog], - 'about' : ['help-about.png', 'About', 'Ctrl+H', self.open_about_dialog], - 'quit' : ['application-exit.png', 'Quit application', 'Ctrl+Q', self.close], + actions_def = {'connect' : ['network-connect.png', 'Connect to WeeChat', 'Ctrl+O', self.open_connection_dialog], + 'disconnect' : ['network-disconnect.png', 'Disconnect from WeeChat', 'Ctrl+D', self.network.disconnect_weechat], + 'debug' : ['edit-find.png', 'Debug console window', 'Ctrl+B', self.open_debug_dialog], + 'preferences' : ['preferences-other.png', 'Preferences', 'Ctrl+P', self.open_preferences_dialog], + 'about' : ['help-about.png', 'About', 'Ctrl+H', self.open_about_dialog], + 'save connection': ['', 'Save connection configuration', 'Ctrl+S', self.save_connection], + 'quit' : ['application-exit.png', 'Quit application', 'Ctrl+Q', self.close], } self.actions = {} for name, action in list(actions_def.items()): @@ -109,7 +110,7 @@ class MainWindow(QtGui.QMainWindow): self.menu = self.menuBar() menu_file = self.menu.addMenu('&File') menu_file.addActions([self.actions['connect'], self.actions['disconnect'], - self.actions['preferences'], self.actions['quit']]) + self.actions['preferences'], self.actions['save connection'], self.actions['quit']]) menu_window = self.menu.addMenu('&Window') menu_window.addAction(self.actions['debug']) menu_help = self.menu.addMenu('&Help') @@ -159,6 +160,12 @@ class MainWindow(QtGui.QMainWindow): def open_preferences_dialog(self): pass # TODO + def save_connection(self): + if self.network: + options = self.network.get_options() + for option in options.keys(): + self.config.set('relay', option, options[option]) + def debug_display(self, *args, **kwargs): self.debug_lines.append((args, kwargs)) self.debug_lines = self.debug_lines[-DEBUG_NUM_LINES:]