diff --git a/README.asciidoc b/README.adoc similarity index 86% rename from README.asciidoc rename to README.adoc index 65cbdee..f669bc0 100644 --- a/README.asciidoc +++ b/README.adoc @@ -4,13 +4,12 @@ :lang: en +image:https://travis-ci.org/weechat/qweechat.svg?branch=master["Build Status", link="https://travis-ci.org/weechat/qweechat"] + QWeeChat is a Qt remote GUI for WeeChat written in Python. Homepage: https://weechat.org/ -image:https://travis-ci.org/weechat/qweechat.svg?branch=master["Build Status", link="https://travis-ci.org/weechat/qweechat"] - - == Features * Multi-platform (GNU/Linux, *BSD, Mac OS X, QNX, Windows & others). @@ -48,15 +47,15 @@ You have to add a relay port in WeeChat, for example on port 1234: In QWeeChat, click on connect and enter fields: -* 'server': the IP address or hostname of your machine with WeeChat running -* 'port': the relay port (defined in WeeChat) -* 'password': the relay password (defined in WeeChat) +* _server_: the IP address or hostname of your machine with WeeChat running +* _port_: the relay port (defined in WeeChat) +* _password_: the relay password (defined in WeeChat) -Options can be changed in file '~/.qweechat/qweechat.conf'. +Options can be changed in file _~/.qweechat/qweechat.conf_. == Copyright -Copyright (C) 2011-2015 Sébastien Helleu +Copyright (C) 2011-2016 Sébastien Helleu This file is part of QWeeChat, a Qt remote GUI for WeeChat. diff --git a/qweechat/__init__.py b/qweechat/__init__.py index 58dc130..e450ad5 100644 --- a/qweechat/__init__.py +++ b/qweechat/__init__.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # -# Copyright (C) 2011-2015 Sébastien Helleu +# Copyright (C) 2011-2016 Sébastien Helleu # # This file is part of QWeeChat, a Qt remote GUI for WeeChat. # diff --git a/qweechat/about.py b/qweechat/about.py index 94c0a66..bf3c75f 100644 --- a/qweechat/about.py +++ b/qweechat/about.py @@ -2,7 +2,7 @@ # # about.py - about dialog box # -# Copyright (C) 2011-2015 Sébastien Helleu +# Copyright (C) 2011-2016 Sébastien Helleu # # This file is part of QWeeChat, a Qt remote GUI for WeeChat. # @@ -21,6 +21,7 @@ # import qt_compat + QtCore = qt_compat.import_module('QtCore') QtGui = qt_compat.import_module('QtGui') diff --git a/qweechat/buffer.py b/qweechat/buffer.py index b5b4e51..eefb5e1 100644 --- a/qweechat/buffer.py +++ b/qweechat/buffer.py @@ -2,7 +2,7 @@ # # buffer.py - management of WeeChat buffers/nicklist # -# Copyright (C) 2011-2015 Sébastien Helleu +# Copyright (C) 2011-2016 Sébastien Helleu # # This file is part of QWeeChat, a Qt remote GUI for WeeChat. # @@ -22,12 +22,13 @@ from pkg_resources import resource_filename import qt_compat -QtCore = qt_compat.import_module('QtCore') -QtGui = qt_compat.import_module('QtGui') from chat import ChatTextEdit from input import InputLineEdit import weechat.color as color +QtCore = qt_compat.import_module('QtCore') +QtGui = qt_compat.import_module('QtGui') + class GenericListWidget(QtGui.QListWidget): """Generic QListWidget with dynamic size.""" diff --git a/qweechat/chat.py b/qweechat/chat.py index 5a7b66f..053a635 100644 --- a/qweechat/chat.py +++ b/qweechat/chat.py @@ -2,7 +2,7 @@ # # chat.py - chat area # -# Copyright (C) 2011-2015 Sébastien Helleu +# Copyright (C) 2011-2016 Sébastien Helleu # # This file is part of QWeeChat, a Qt remote GUI for WeeChat. # @@ -22,11 +22,12 @@ import datetime import qt_compat -QtCore = qt_compat.import_module('QtCore') -QtGui = qt_compat.import_module('QtGui') import config import weechat.color as color +QtCore = qt_compat.import_module('QtCore') +QtGui = qt_compat.import_module('QtGui') + class ChatTextEdit(QtGui.QTextEdit): """Chat area.""" diff --git a/qweechat/config.py b/qweechat/config.py index 4c3adcc..71760e6 100644 --- a/qweechat/config.py +++ b/qweechat/config.py @@ -2,7 +2,7 @@ # # config.py - configuration for QWeeChat (~/.qweechat/qweechat.conf) # -# Copyright (C) 2011-2015 Sébastien Helleu +# Copyright (C) 2011-2016 Sébastien Helleu # # This file is part of QWeeChat, a Qt remote GUI for WeeChat. # diff --git a/qweechat/connection.py b/qweechat/connection.py index 8e395b3..a38ebf9 100644 --- a/qweechat/connection.py +++ b/qweechat/connection.py @@ -2,7 +2,7 @@ # # connection.py - connection window # -# Copyright (C) 2011-2015 Sébastien Helleu +# Copyright (C) 2011-2016 Sébastien Helleu # # This file is part of QWeeChat, a Qt remote GUI for WeeChat. # @@ -21,6 +21,7 @@ # import qt_compat + QtGui = qt_compat.import_module('QtGui') diff --git a/qweechat/data/icons/README b/qweechat/data/icons/README index 5ec4dda..9f5afb9 100644 --- a/qweechat/data/icons/README +++ b/qweechat/data/icons/README @@ -2,9 +2,9 @@ Copyright and license for images ================================ -Files: weechat_icon_32.png, bullet_green_8x8.png, bullet_yellow_8x8.png +Files: weechat.png, bullet_green_8x8.png, bullet_yellow_8x8.png - Copyright (C) 2011-2015 Sébastien Helleu + Copyright (C) 2011-2016 Sébastien Helleu Released under GPLv3. diff --git a/qweechat/data/icons/weechat.png b/qweechat/data/icons/weechat.png new file mode 100644 index 0000000..7eca5c8 Binary files /dev/null and b/qweechat/data/icons/weechat.png differ diff --git a/qweechat/data/icons/weechat_icon_32.png b/qweechat/data/icons/weechat_icon_32.png deleted file mode 100644 index 692e6f8..0000000 Binary files a/qweechat/data/icons/weechat_icon_32.png and /dev/null differ diff --git a/qweechat/debug.py b/qweechat/debug.py index e8bf98c..67f7f3b 100644 --- a/qweechat/debug.py +++ b/qweechat/debug.py @@ -2,7 +2,7 @@ # # debug.py - debug window # -# Copyright (C) 2011-2015 Sébastien Helleu +# Copyright (C) 2011-2016 Sébastien Helleu # # This file is part of QWeeChat, a Qt remote GUI for WeeChat. # @@ -21,10 +21,11 @@ # import qt_compat -QtGui = qt_compat.import_module('QtGui') from chat import ChatTextEdit from input import InputLineEdit +QtGui = qt_compat.import_module('QtGui') + class DebugDialog(QtGui.QDialog): """Debug dialog.""" diff --git a/qweechat/input.py b/qweechat/input.py index c5eda9c..25c1592 100644 --- a/qweechat/input.py +++ b/qweechat/input.py @@ -2,7 +2,7 @@ # # input.py - input line for chat and debug window # -# Copyright (C) 2011-2015 Sébastien Helleu +# Copyright (C) 2011-2016 Sébastien Helleu # # This file is part of QWeeChat, a Qt remote GUI for WeeChat. # @@ -22,6 +22,7 @@ import qt_compat from inputlinespell import InputLineSpell + QtCore = qt_compat.import_module('QtCore') QtGui = qt_compat.import_module('QtGui') diff --git a/qweechat/inputlinespell.py b/qweechat/inputlinespell.py index 8ffdb43..ff8c80b 100644 --- a/qweechat/inputlinespell.py +++ b/qweechat/inputlinespell.py @@ -27,6 +27,7 @@ import qt_compat QtCore = qt_compat.import_module('QtCore') QtGui = qt_compat.import_module('QtGui') import config +import functools import re import weechat.color as color @@ -162,12 +163,12 @@ class InputLineSpell(QtGui.QTextEdit): suggestions = self.spelldict.suggest(text) if len(suggestions) != 0: popup_menu.insertSeparator(popup_menu.actions()[0]) - topAction = popup_menu.actions()[0] - for word in suggestions: - action = SpellAction(word, popup_menu) - action.correct.connect(self.correctWord) - popup_menu.insertAction(topAction, action) + topAction = popup_menu.actions()[0] + for suggestion in suggestions: + action = QtGui.QAction(suggestion, popup_menu) + action.connect(action, QtCore.SIGNAL("triggered()"), functools.partial(self.correctWord, word = suggestion)) + popup_menu.insertAction(topAction, action) popup_menu.insertSeparator(topAction) addAction = QtGui.QAction("Add to dictionary", self) addAction.triggered.connect(lambda: self.addWord(text)) @@ -222,18 +223,3 @@ class SpellHighlighter(QtGui.QSyntaxHighlighter): if not self.spelldict.check(word_object.group()): word_len = word_object.end() - word_object.start() self.setFormat(word_object.start(), word_len, format) - - -class SpellAction(QtGui.QAction): - - ''' - A special QAction that returns the text in a signal. - ''' - - correct = qt_compat.Signal(unicode) - - def __init__(self, *args): - QtGui.QAction.__init__(self, *args) - - self.triggered.connect(lambda x: self.correct.emit( - unicode(self.text()))) diff --git a/qweechat/network.py b/qweechat/network.py index 72137e3..46458a4 100644 --- a/qweechat/network.py +++ b/qweechat/network.py @@ -2,7 +2,7 @@ # # network.py - I/O with WeeChat/relay # -# Copyright (C) 2011-2015 Sébastien Helleu +# Copyright (C) 2011-2016 Sébastien Helleu # # This file is part of QWeeChat, a Qt remote GUI for WeeChat. # @@ -22,9 +22,10 @@ import struct import qt_compat +import config + QtCore = qt_compat.import_module('QtCore') QtNetwork = qt_compat.import_module('QtNetwork') -import config _PROTO_INIT_CMD = ['init password=%(password)s'] diff --git a/qweechat/qweechat.py b/qweechat/qweechat.py index 1925fe0..cf0bca3 100644 --- a/qweechat/qweechat.py +++ b/qweechat/qweechat.py @@ -2,7 +2,7 @@ # # qweechat.py - WeeChat remote GUI using Qt toolkit # -# Copyright (C) 2011-2015 Sébastien Helleu +# Copyright (C) 2011-2016 Sébastien Helleu # # This file is part of QWeeChat, a Qt remote GUI for WeeChat. # @@ -37,8 +37,6 @@ import sys import traceback from pkg_resources import resource_filename import qt_compat -QTCORE = qt_compat.import_module('QtCore') -QTGUI = qt_compat.import_module('QtGui') import config import weechat.protocol as protocol from network import Network @@ -48,6 +46,9 @@ from debug import DebugDialog from about import AboutDialog from version import qweechat_version +QtCore = qt_compat.import_module('QtCore') +QtGui = qt_compat.import_module('QtGui') + NAME = 'QWeeChat' AUTHOR = 'Sébastien Helleu' AUTHOR_MAIL = 'flashcode@flashtux.org' @@ -57,11 +58,11 @@ WEECHAT_SITE = 'https://weechat.org/' DEBUG_NUM_LINES = 50 -class MainWindow(QTGUI.QMainWindow): +class MainWindow(QtGui.QMainWindow): """Main window.""" def __init__(self, *args): - QTGUI.QMainWindow.__init__(*(self,) + args) + QtGui.QMainWindow.__init__(*(self,) + args) self.config = config.read() @@ -86,11 +87,11 @@ class MainWindow(QTGUI.QMainWindow): # default buffer self.buffers = [Buffer()] - self.stacked_buffers = QTGUI.QStackedWidget() + self.stacked_buffers = QtGui.QStackedWidget() self.stacked_buffers.addWidget(self.buffers[0].widget) # splitter with buffers + chat/input - splitter = QTGUI.QSplitter() + splitter = QtGui.QSplitter() splitter.addWidget(self.list_buffers) splitter.addWidget(self.stacked_buffers) @@ -125,8 +126,8 @@ class MainWindow(QTGUI.QMainWindow): } self.actions = {} for name, action in list(actions_def.items()): - self.actions[name] = QTGUI.QAction( - QTGUI.QIcon( + self.actions[name] = QtGui.QAction( + QtGui.QIcon( resource_filename(__name__, 'data/icons/%s' % action[0])), name.capitalize(), self) self.actions[name].setStatusTip(action[1]) @@ -145,19 +146,19 @@ class MainWindow(QTGUI.QMainWindow): menu_window.addAction(self.actions['debug']) menu_help = self.menu.addMenu('&Help') menu_help.addAction(self.actions['about']) - self.network_status = QTGUI.QLabel() + self.network_status = QtGui.QLabel() self.network_status.setFixedHeight(20) self.network_status.setFixedWidth(200) self.network_status.setContentsMargins(0, 0, 10, 0) - self.network_status.setAlignment(QTCORE.Qt.AlignRight) + self.network_status.setAlignment(QtCore.Qt.AlignRight) if hasattr(self.menu, 'setCornerWidget'): self.menu.setCornerWidget(self.network_status, - QTCORE.Qt.TopRightCorner) + QtCore.Qt.TopRightCorner) self.network_status_set(self.network.status_disconnected) # toolbar toolbar = self.addToolBar('toolBar') - toolbar.setToolButtonStyle(QTCORE.Qt.ToolButtonTextUnderIcon) + toolbar.setToolButtonStyle(QtCore.Qt.ToolButtonTextUnderIcon) toolbar.addActions([self.actions['connect'], self.actions['disconnect'], self.actions['debug'], @@ -245,7 +246,7 @@ class MainWindow(QTGUI.QMainWindow): def open_about_dialog(self): """Open a dialog with info about QWeeChat.""" messages = ['%s %s' % (NAME, qweechat_version()), - '© 2011-2014 %s <%s>' + '© 2011-2016 %s <%s>' % (AUTHOR, AUTHOR_MAIL, AUTHOR_MAIL), '', 'Running with %s' % ('PySide' if qt_compat.uses_pyside @@ -287,10 +288,10 @@ class MainWindow(QTGUI.QMainWindow): pal = self.network_status.palette() if status == self.network.status_connected: pal.setColor(self.network_status.foregroundRole(), - QTGUI.QColor('green')) + QtGui.QColor('green')) else: pal.setColor(self.network_status.foregroundRole(), - QTGUI.QColor('#aa0000')) + QtGui.QColor('#aa0000')) ssl = ' (SSL)' if status != self.network.status_disconnected \ and self.network.is_ssl() else '' self.network_status.setPalette(pal) @@ -543,12 +544,12 @@ class MainWindow(QTGUI.QMainWindow): if self.debug_dialog: self.debug_dialog.close() config.write(self.config) - QTGUI.QMainWindow.closeEvent(self, event) + QtGui.QMainWindow.closeEvent(self, event) -app = QTGUI.QApplication(sys.argv) -app.setStyle(QTGUI.QStyleFactory.create('Cleanlooks')) -app.setWindowIcon(QTGUI.QIcon( - resource_filename(__name__, 'data/icons/weechat_icon_32.png'))) +app = QtGui.QApplication(sys.argv) +app.setStyle(QtGui.QStyleFactory.create('Cleanlooks')) +app.setWindowIcon(QtGui.QIcon( + resource_filename(__name__, 'data/icons/weechat.png'))) main = MainWindow() sys.exit(app.exec_()) diff --git a/qweechat/version.py b/qweechat/version.py index 5f24e28..b262c0d 100644 --- a/qweechat/version.py +++ b/qweechat/version.py @@ -2,7 +2,7 @@ # # version.py - version of QWeeChat # -# Copyright (C) 2011-2015 Sébastien Helleu +# Copyright (C) 2011-2016 Sébastien Helleu # # This file is part of QWeeChat, a Qt remote GUI for WeeChat. # diff --git a/qweechat/weechat/__init__.py b/qweechat/weechat/__init__.py index 58dc130..e450ad5 100644 --- a/qweechat/weechat/__init__.py +++ b/qweechat/weechat/__init__.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # -# Copyright (C) 2011-2015 Sébastien Helleu +# Copyright (C) 2011-2016 Sébastien Helleu # # This file is part of QWeeChat, a Qt remote GUI for WeeChat. # diff --git a/qweechat/weechat/color.py b/qweechat/weechat/color.py index 1e77812..60fba96 100644 --- a/qweechat/weechat/color.py +++ b/qweechat/weechat/color.py @@ -2,7 +2,7 @@ # # color.py - remove/replace colors in WeeChat strings # -# Copyright (C) 2011-2015 Sébastien Helleu +# Copyright (C) 2011-2016 Sébastien Helleu # # This file is part of QWeeChat, a Qt remote GUI for WeeChat. # diff --git a/qweechat/weechat/protocol.py b/qweechat/weechat/protocol.py index ad95a55..31db088 100644 --- a/qweechat/weechat/protocol.py +++ b/qweechat/weechat/protocol.py @@ -2,7 +2,7 @@ # # protocol.py - decode binary messages received from WeeChat/relay # -# Copyright (C) 2011-2015 Sébastien Helleu +# Copyright (C) 2011-2016 Sébastien Helleu # # This file is part of QWeeChat, a Qt remote GUI for WeeChat. # @@ -232,7 +232,7 @@ class Protocol: type_values = self._obj_type() count = self._obj_int() hashtable = WeechatDict() - for i in range(0, count): + for _ in range(count): key = self._obj_cb[type_keys]() value = self._obj_cb[type_values]() hashtable[key] = value @@ -243,8 +243,8 @@ class Protocol: path = self._obj_str() keys = self._obj_str() count = self._obj_int() - list_path = path.split('/') - list_keys = keys.split(',') + list_path = path.split('/') if path else [] + list_keys = keys.split(',') if keys else [] keys_types = [] dict_keys = WeechatDict() for key in list_keys: @@ -252,11 +252,11 @@ class Protocol: keys_types.append(items) dict_keys[items[0]] = items[1] items = [] - for i in range(0, count): + for _ in range(count): item = WeechatDict() item['__path'] = [] pointers = [] - for p in range(0, len(list_path)): + for _ in enumerate(list_path): pointers.append(self._obj_ptr()) for key, objtype in keys_types: item[key] = self._obj_cb[objtype]() @@ -280,10 +280,10 @@ class Protocol: name = self._obj_str() count_items = self._obj_int() items = [] - for i in range(0, count_items): + for _ in range(count_items): count_vars = self._obj_int() variables = WeechatDict() - for v in range(0, count_vars): + for _ in range(count_vars): var_name = self._obj_str() var_type = self._obj_type() var_value = self._obj_cb[var_type]() @@ -299,7 +299,7 @@ class Protocol: type_values = self._obj_type() count_values = self._obj_int() values = [] - for i in range(0, count_values): + for _ in range(count_values): values.append(self._obj_cb[type_values]()) return values @@ -341,7 +341,7 @@ def hex_and_ascii(data, bytes_per_line=10): if num_lines == 0: return '' lines = [] - for i in range(0, num_lines): + for i in range(num_lines): str_hex = [] str_ascii = [] for char in data[i*bytes_per_line:(i*bytes_per_line)+bytes_per_line]: diff --git a/qweechat/weechat/testproto.py b/qweechat/weechat/testproto.py index 67b1e5d..3ef565a 100644 --- a/qweechat/weechat/testproto.py +++ b/qweechat/weechat/testproto.py @@ -2,7 +2,7 @@ # # testproto.py - command-line program for testing WeeChat/relay protocol # -# Copyright (C) 2013-2015 Sébastien Helleu +# Copyright (C) 2013-2016 Sébastien Helleu # # This file is part of QWeeChat, a Qt remote GUI for WeeChat. # diff --git a/setup.py b/setup.py index 3bb54a3..033c086 100644 --- a/setup.py +++ b/setup.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # -# Copyright (C) 2011-2015 Sébastien Helleu +# Copyright (C) 2011-2016 Sébastien Helleu # # This file is part of QWeeChat, a Qt remote GUI for WeeChat. #