Merge remote-tracking branch 'upstream/master' into advanced-input-spellcheck

This commit is contained in:
Ricky 2016-08-07 01:35:15 -07:00
commit 145f3aa134
21 changed files with 74 additions and 81 deletions

View File

@ -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 <flashcode@flashtux.org>
Copyright (C) 2011-2016 Sébastien Helleu <flashcode@flashtux.org>
This file is part of QWeeChat, a Qt remote GUI for WeeChat.

View File

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
#
# Copyright (C) 2011-2015 Sébastien Helleu <flashcode@flashtux.org>
# Copyright (C) 2011-2016 Sébastien Helleu <flashcode@flashtux.org>
#
# This file is part of QWeeChat, a Qt remote GUI for WeeChat.
#

View File

@ -2,7 +2,7 @@
#
# about.py - about dialog box
#
# Copyright (C) 2011-2015 Sébastien Helleu <flashcode@flashtux.org>
# Copyright (C) 2011-2016 Sébastien Helleu <flashcode@flashtux.org>
#
# 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')

View File

@ -2,7 +2,7 @@
#
# buffer.py - management of WeeChat buffers/nicklist
#
# Copyright (C) 2011-2015 Sébastien Helleu <flashcode@flashtux.org>
# Copyright (C) 2011-2016 Sébastien Helleu <flashcode@flashtux.org>
#
# 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."""

View File

@ -2,7 +2,7 @@
#
# chat.py - chat area
#
# Copyright (C) 2011-2015 Sébastien Helleu <flashcode@flashtux.org>
# Copyright (C) 2011-2016 Sébastien Helleu <flashcode@flashtux.org>
#
# 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."""

View File

@ -2,7 +2,7 @@
#
# config.py - configuration for QWeeChat (~/.qweechat/qweechat.conf)
#
# Copyright (C) 2011-2015 Sébastien Helleu <flashcode@flashtux.org>
# Copyright (C) 2011-2016 Sébastien Helleu <flashcode@flashtux.org>
#
# This file is part of QWeeChat, a Qt remote GUI for WeeChat.
#

View File

@ -2,7 +2,7 @@
#
# connection.py - connection window
#
# Copyright (C) 2011-2015 Sébastien Helleu <flashcode@flashtux.org>
# Copyright (C) 2011-2016 Sébastien Helleu <flashcode@flashtux.org>
#
# 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')

View File

@ -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 <flashcode@flashtux.org>
Copyright (C) 2011-2016 Sébastien Helleu <flashcode@flashtux.org>
Released under GPLv3.

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.9 KiB

View File

@ -2,7 +2,7 @@
#
# debug.py - debug window
#
# Copyright (C) 2011-2015 Sébastien Helleu <flashcode@flashtux.org>
# Copyright (C) 2011-2016 Sébastien Helleu <flashcode@flashtux.org>
#
# 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."""

View File

@ -2,7 +2,7 @@
#
# input.py - input line for chat and debug window
#
# Copyright (C) 2011-2015 Sébastien Helleu <flashcode@flashtux.org>
# Copyright (C) 2011-2016 Sébastien Helleu <flashcode@flashtux.org>
#
# 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')

View File

@ -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())))

View File

@ -2,7 +2,7 @@
#
# network.py - I/O with WeeChat/relay
#
# Copyright (C) 2011-2015 Sébastien Helleu <flashcode@flashtux.org>
# Copyright (C) 2011-2016 Sébastien Helleu <flashcode@flashtux.org>
#
# 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']

View File

@ -2,7 +2,7 @@
#
# qweechat.py - WeeChat remote GUI using Qt toolkit
#
# Copyright (C) 2011-2015 Sébastien Helleu <flashcode@flashtux.org>
# Copyright (C) 2011-2016 Sébastien Helleu <flashcode@flashtux.org>
#
# 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 = ['<b>%s</b> %s' % (NAME, qweechat_version()),
'&copy; 2011-2014 %s &lt;<a href="mailto:%s">%s</a>&gt;'
'&copy; 2011-2016 %s &lt;<a href="mailto:%s">%s</a>&gt;'
% (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_())

View File

@ -2,7 +2,7 @@
#
# version.py - version of QWeeChat
#
# Copyright (C) 2011-2015 Sébastien Helleu <flashcode@flashtux.org>
# Copyright (C) 2011-2016 Sébastien Helleu <flashcode@flashtux.org>
#
# This file is part of QWeeChat, a Qt remote GUI for WeeChat.
#

View File

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
#
# Copyright (C) 2011-2015 Sébastien Helleu <flashcode@flashtux.org>
# Copyright (C) 2011-2016 Sébastien Helleu <flashcode@flashtux.org>
#
# This file is part of QWeeChat, a Qt remote GUI for WeeChat.
#

View File

@ -2,7 +2,7 @@
#
# color.py - remove/replace colors in WeeChat strings
#
# Copyright (C) 2011-2015 Sébastien Helleu <flashcode@flashtux.org>
# Copyright (C) 2011-2016 Sébastien Helleu <flashcode@flashtux.org>
#
# This file is part of QWeeChat, a Qt remote GUI for WeeChat.
#

View File

@ -2,7 +2,7 @@
#
# protocol.py - decode binary messages received from WeeChat/relay
#
# Copyright (C) 2011-2015 Sébastien Helleu <flashcode@flashtux.org>
# Copyright (C) 2011-2016 Sébastien Helleu <flashcode@flashtux.org>
#
# 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]:

View File

@ -2,7 +2,7 @@
#
# testproto.py - command-line program for testing WeeChat/relay protocol
#
# Copyright (C) 2013-2015 Sébastien Helleu <flashcode@flashtux.org>
# Copyright (C) 2013-2016 Sébastien Helleu <flashcode@flashtux.org>
#
# This file is part of QWeeChat, a Qt remote GUI for WeeChat.
#

View File

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
#
# Copyright (C) 2011-2015 Sébastien Helleu <flashcode@flashtux.org>
# Copyright (C) 2011-2016 Sébastien Helleu <flashcode@flashtux.org>
#
# This file is part of QWeeChat, a Qt remote GUI for WeeChat.
#