Window manager compliant window moving (required for Wayland) + hardcoded logging.ini file
This commit is contained in:
parent
345e358be8
commit
8a3ebd1d3f
6 changed files with 90 additions and 60 deletions
|
@ -1,15 +1,19 @@
|
||||||
# Changelog
|
# Changelog
|
||||||
(This document uses YYYY-MM-DD)
|
(This document uses YYYY-MM-DD)
|
||||||
|
|
||||||
## [v2.2.3] - 2022-04-11
|
## [v2.2.3] - 2022-05-04
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
- Excluded some more modules in build files, hopefully shouldn't cause any issues.
|
- Excluded some more modules in build files, hopefully shouldn't cause any issues.
|
||||||
- Added empty 'package' option to 'setup' in setup.py, setuptools v61.0.0 doesn't seem to like our project layout anymore.
|
- Added empty 'package' option to 'setup' in setup.py, setuptools v61.0.0 doesn't seem to like our project layout anymore.
|
||||||
|
- Qt's startSystemMove() is used to move Pesterchum's main window now. (system-specific move operation)
|
||||||
|
- This fixes click-and-drag on Wayland, which doesn't support setting window position via setPosition().
|
||||||
|
- Assuming this works on all systems we need to support, we can probably depreciate the MovingWindow class.
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
- Unreadable input on MacOS and certain linux distros for themes which didn't explicitly set input color (incl. pesterchum), input color is now black by default instead of being platform-dependent.
|
- Unreadable input on MacOS and certain linux distros for themes which didn't explicitly set input color (incl. pesterchum), input color is now black by default instead of being platform-dependent.
|
||||||
|
- Logging related crash.
|
||||||
|
|
||||||
## [v2.2.2] - 2022-04-11
|
## [v2.2.2] - 2022-04-11
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
16
generic.py
16
generic.py
|
@ -105,6 +105,9 @@ class MultiTextDialog(QtWidgets.QDialog):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
class MovingWindow(QtWidgets.QFrame):
|
class MovingWindow(QtWidgets.QFrame):
|
||||||
|
# Qt supports starting a system-specific move operation since 5.15, so we shouldn't need to manually set position like this anymore.
|
||||||
|
# https://doc.qt.io/qt-5/qwindow.html#startSystemMove
|
||||||
|
# This is also the only method that works on Wayland, which doesn't support setting position.
|
||||||
def __init__(self, *x, **y):
|
def __init__(self, *x, **y):
|
||||||
super(MovingWindow, self).__init__(*x, **y)
|
super(MovingWindow, self).__init__(*x, **y)
|
||||||
self.moving = None
|
self.moving = None
|
||||||
|
@ -118,8 +121,17 @@ class MovingWindow(QtWidgets.QFrame):
|
||||||
self.moveupdate = 0
|
self.moveupdate = 0
|
||||||
self.update()
|
self.update()
|
||||||
def mousePressEvent(self, event):
|
def mousePressEvent(self, event):
|
||||||
if event.button() == 1:
|
# Assuming everything is supported, we only need this function to call "self.windowHandle().startSystemMove()".
|
||||||
self.moving = event.globalPos() - self.pos()
|
# If not supported, startSystemMove() returns False and the legacy code runs anyway.
|
||||||
|
try:
|
||||||
|
if self.windowHandle().startSystemMove() != True:
|
||||||
|
if event.button() == 1:
|
||||||
|
self.moving = event.globalPos() - self.pos()
|
||||||
|
except AttributeError as e:
|
||||||
|
print("PyQt5 <= 5.14?")
|
||||||
|
print(str(e))
|
||||||
|
if event.button() == 1:
|
||||||
|
self.moving = event.globalPos() - self.pos()
|
||||||
def mouseReleaseEvent(self, event):
|
def mouseReleaseEvent(self, event):
|
||||||
if event.button() == 1:
|
if event.button() == 1:
|
||||||
self.update()
|
self.update()
|
||||||
|
|
|
@ -1,28 +0,0 @@
|
||||||
[loggers]
|
|
||||||
keys=root,pchumLogger
|
|
||||||
|
|
||||||
[handlers]
|
|
||||||
keys=consoleHandler
|
|
||||||
|
|
||||||
[formatters]
|
|
||||||
keys=simpleFormatter
|
|
||||||
|
|
||||||
[logger_root]
|
|
||||||
level=WARNING
|
|
||||||
handlers=consoleHandler
|
|
||||||
|
|
||||||
[logger_pchumLogger]
|
|
||||||
level=WARNING
|
|
||||||
handlers=consoleHandler
|
|
||||||
qualname=pchumLogger
|
|
||||||
propagate=0
|
|
||||||
|
|
||||||
[handler_consoleHandler]
|
|
||||||
class=StreamHandler
|
|
||||||
level=WARNING
|
|
||||||
formatter=simpleFormatter
|
|
||||||
args=(sys.stdout,)
|
|
||||||
|
|
||||||
[formatter_simpleFormatter]
|
|
||||||
format=%(asctime)s - %(levelname)s - %(module)s - %(threadName)s - %(message)s
|
|
||||||
datefmt=
|
|
92
pesterchum.py
Executable file → Normal file
92
pesterchum.py
Executable file → Normal file
|
@ -15,18 +15,19 @@ print("Use -h/--help to see the available options.\nLogging is configured in log
|
||||||
# Help
|
# Help
|
||||||
if ('--help' in sys.argv[1:]) or ('-h' in sys.argv[1:]):
|
if ('--help' in sys.argv[1:]) or ('-h' in sys.argv[1:]):
|
||||||
print("Possible arguments:")
|
print("Possible arguments:")
|
||||||
help_arguments = " -l, --logging\n Specify level of logging, possible values are:\n" + \
|
help_arguments = (" -l, --logging\n Specify level of logging, possible values are:\n"
|
||||||
" CRITICAL, ERROR, WARNING, INFO, DEBUG, NOTSET.\n" + \
|
+ " CRITICAL, ERROR, WARNING, INFO, DEBUG, NOTSET.\n"
|
||||||
" The default value is WARNING.\n" + \
|
+ " The default value is WARNING.\n"
|
||||||
" (See https://docs.python.org/3/library/logging.html)\n\n" + \
|
+ " (See https://docs.python.org/3/library/logging.html)\n\n"
|
||||||
" -s, --server\n Specify server override. (legacy)\n\n" + \
|
+ " -s, --server\n Specify server override. (legacy)\n\n"
|
||||||
" -p, --port\n Specify port override. (legacy)\n\n" + \
|
+ " -p, --port\n Specify port override. (legacy)\n\n"
|
||||||
" --advanced\n Enable advanced.\n\n" + \
|
+ " --advanced\n Enable advanced.\n\n"
|
||||||
" --no-honk\n Disable honking.\n"
|
+ " --no-honk\n Disable honking.\n")
|
||||||
print(help_arguments)
|
print(help_arguments)
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
import logging.config
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
import random
|
import random
|
||||||
import re
|
import re
|
||||||
|
@ -95,14 +96,41 @@ if not os.path.isdir(_datadir):
|
||||||
# data (profiles, logs, etc) from old location to new data directory.
|
# data (profiles, logs, etc) from old location to new data directory.
|
||||||
|
|
||||||
config = configparser.ConfigParser()
|
config = configparser.ConfigParser()
|
||||||
# Create logging.conf
|
# Create logging.ini
|
||||||
if os.path.exists(_datadir + "logging.ini") == False:
|
#if os.path.exists(_datadir + "logging.ini") == False:
|
||||||
config.read('logging.ini.example')
|
try:
|
||||||
|
config.read(_datadir + 'logging.ini')
|
||||||
|
|
||||||
|
# Test load
|
||||||
|
logging.config.fileConfig(_datadir + "logging.ini")
|
||||||
|
PchumLog = logging.getLogger('pchumLogger')
|
||||||
|
except:
|
||||||
|
#config.read('logging.ini.example')
|
||||||
|
config = configparser.ConfigParser()
|
||||||
|
|
||||||
|
# Default setup
|
||||||
|
config['loggers'] = {'keys': 'root,pchumLogger'}
|
||||||
|
config['handlers'] = {'keys': 'consoleHandler,FileHandler'}
|
||||||
|
config['formatters'] = {'keys': 'simpleFormatter'}
|
||||||
|
config['logger_root'] = {'level': 'WARNING',
|
||||||
|
'handlers': 'consoleHandler'}
|
||||||
|
config['handler_consoleHandler'] = {'class': 'StreamHandler',
|
||||||
|
'level': 'WARNING',
|
||||||
|
'formatter': 'simpleFormatter',
|
||||||
|
'args': '(sys.stdout,)'}
|
||||||
|
config['handler_FileHandler'] = {'class': 'FileHandler',
|
||||||
|
'level': 'WARNING',
|
||||||
|
'formatter': 'simpleFormatter'}
|
||||||
|
config['logger_pchumLogger'] = {'level': 'WARNING',
|
||||||
|
'handlers': 'consoleHandler,FileHandler',
|
||||||
|
'qualname': 'pchumLogger',
|
||||||
|
'propagate': '0'}
|
||||||
|
config['formatter_simpleFormatter'] = {'format': '%(levelname)s - %(module)s - %(message)s',
|
||||||
|
'datefmt': ''}
|
||||||
|
|
||||||
# Enable file logging
|
# Enable file logging
|
||||||
config['handlers']['keys'] = 'consoleHandler,FileHandler'
|
config['handlers']['keys'] = 'consoleHandler,FileHandler'
|
||||||
config['logger_pchumLogger']['handlers'] = 'consoleHandler,FileHandler'
|
config['logger_pchumLogger']['handlers'] = 'consoleHandler,FileHandler'
|
||||||
|
|
||||||
#(r'C:\Users\X\AppData\Local\pesterchum\pesterchum.log', 'a')
|
#(r'C:\Users\X\AppData\Local\pesterchum\pesterchum.log', 'a')
|
||||||
config['handler_FileHandler'] = {'class': 'FileHandler',
|
config['handler_FileHandler'] = {'class': 'FileHandler',
|
||||||
'level': 'WARNING',
|
'level': 'WARNING',
|
||||||
|
@ -110,8 +138,7 @@ if os.path.exists(_datadir + "logging.ini") == False:
|
||||||
'args': (_datadir + 'pesterchum.log', 'a')}
|
'args': (_datadir + 'pesterchum.log', 'a')}
|
||||||
|
|
||||||
print(config.sections())
|
print(config.sections())
|
||||||
else:
|
|
||||||
config.read(_datadir + 'logging.ini')
|
|
||||||
|
|
||||||
loglevel = "30"# Warning (Default)
|
loglevel = "30"# Warning (Default)
|
||||||
if ('--logging' in sys.argv[1:]) or ('-l' in sys.argv[1:]) & (False == ('--logging' in sys.argv[1:]) and ('-l' in sys.argv[1:])):
|
if ('--logging' in sys.argv[1:]) or ('-l' in sys.argv[1:]) & (False == ('--logging' in sys.argv[1:]) and ('-l' in sys.argv[1:])):
|
||||||
|
@ -170,7 +197,6 @@ with open(_datadir + "logging.ini", 'w') as configfile:
|
||||||
config.write(configfile)
|
config.write(configfile)
|
||||||
|
|
||||||
# Load logging.ini
|
# Load logging.ini
|
||||||
import logging.config
|
|
||||||
logging.config.fileConfig(_datadir + "logging.ini")
|
logging.config.fileConfig(_datadir + "logging.ini")
|
||||||
PchumLog = logging.getLogger('pchumLogger')
|
PchumLog = logging.getLogger('pchumLogger')
|
||||||
|
|
||||||
|
@ -1165,7 +1191,7 @@ class PesterWindow(MovingWindow):
|
||||||
self.tabmemo = None
|
self.tabmemo = None
|
||||||
self.shortcuts = AttrDict()
|
self.shortcuts = AttrDict()
|
||||||
|
|
||||||
self.setAutoFillBackground(True)
|
self.setAutoFillBackground(False)
|
||||||
self.setObjectName("main")
|
self.setObjectName("main")
|
||||||
self.config = userConfig(self)
|
self.config = userConfig(self)
|
||||||
# Trying to fix:
|
# Trying to fix:
|
||||||
|
@ -1534,7 +1560,8 @@ class PesterWindow(MovingWindow):
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
palette = QtGui.QPalette()
|
palette = QtGui.QPalette()
|
||||||
palette.setBrush(QtGui.QPalette.Window, QtGui.QBrush(self.backgroundImage))
|
brush = QtGui.QBrush(self.backgroundImage)
|
||||||
|
palette.setBrush(QtGui.QPalette.Window, brush)
|
||||||
self.setPalette(palette)
|
self.setPalette(palette)
|
||||||
|
|
||||||
@QtCore.pyqtSlot()
|
@QtCore.pyqtSlot()
|
||||||
|
@ -1843,10 +1870,23 @@ class PesterWindow(MovingWindow):
|
||||||
self.setWindowIcon(PesterIcon(theme["main/icon"]))
|
self.setWindowIcon(PesterIcon(theme["main/icon"]))
|
||||||
self.setWindowTitle(theme["main/windowtitle"])
|
self.setWindowTitle(theme["main/windowtitle"])
|
||||||
self.setStyleSheet("QtWidgets.QFrame#main { %s }" % (theme["main/style"]))
|
self.setStyleSheet("QtWidgets.QFrame#main { %s }" % (theme["main/style"]))
|
||||||
self.backgroundImage = QtGui.QPixmap(theme["main/background-image"])
|
|
||||||
self.backgroundMask = self.backgroundImage.mask()
|
# QPixmap::mask and setMask are legacy and should probably be replaced;
|
||||||
|
# https://doc.qt.io/qt-5/qpixmap.html#pixmap-information
|
||||||
|
# It's slow and this way we don't use antialiasing, leaving us with very ugly borders.
|
||||||
|
# + It breaks transparency on Wayland: https://bugreports-test.qt.io/browse/QTBUG-69906
|
||||||
|
self.backgroundImage = QtGui.QImage(theme["main/background-image"])
|
||||||
|
self.backgroundPixmap = QtGui.QPixmap.fromImage(self.backgroundImage)
|
||||||
|
self.backgroundMask = self.backgroundPixmap.mask()
|
||||||
self.setMask(self.backgroundMask)
|
self.setMask(self.backgroundMask)
|
||||||
self.menu.setStyleSheet("QMenuBar { background: transparent; %s } QMenuBar::item { background: transparent; %s } " % (theme["main/menubar/style"], theme["main/menu/menuitem"]) + "QMenu { background: transparent; %s } QMenu::item::selected { %s } QMenu::item::disabled { %s }" % (theme["main/menu/style"], theme["main/menu/selected"], theme["main/menu/disabled"]))
|
|
||||||
|
self.menu.setStyleSheet("QMenuBar { background: transparent; %s } QMenuBar::item { background: transparent; %s } "
|
||||||
|
% (theme["main/menubar/style"],
|
||||||
|
theme["main/menu/menuitem"])
|
||||||
|
+ "QMenu { background: transparent; %s } QMenu::item::selected { %s } QMenu::item::disabled { %s }"
|
||||||
|
% (theme["main/menu/style"],
|
||||||
|
theme["main/menu/selected"],
|
||||||
|
theme["main/menu/disabled"]))
|
||||||
newcloseicon = PesterIcon(theme["main/close/image"])
|
newcloseicon = PesterIcon(theme["main/close/image"])
|
||||||
self.closeButton.setIcon(newcloseicon)
|
self.closeButton.setIcon(newcloseicon)
|
||||||
self.closeButton.setIconSize(newcloseicon.realsize())
|
self.closeButton.setIconSize(newcloseicon.realsize())
|
||||||
|
@ -3165,11 +3205,15 @@ class PesterWindow(MovingWindow):
|
||||||
try:
|
try:
|
||||||
self.irc.quit_dc() # Actually send QUIT to server
|
self.irc.quit_dc() # Actually send QUIT to server
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
# Not connected.
|
# Not connected?
|
||||||
PchumLog.warning("QUIT failed: " + str(e))
|
PchumLog.warning("QUIT failed: " + str(e))
|
||||||
|
try:
|
||||||
self.parent.trayicon.hide() #
|
self.parent.trayicon.hide() #
|
||||||
self.app.quit() #
|
self.app.quit()
|
||||||
|
except AttributeError as e:
|
||||||
|
# Called from outside main Window?
|
||||||
|
PchumLog.warning("Unelegant quit: " + str(e))
|
||||||
|
sys.exit()
|
||||||
|
|
||||||
def passIRC(self, irc):
|
def passIRC(self, irc):
|
||||||
self.irc = irc
|
self.irc = irc
|
||||||
|
|
|
@ -102,8 +102,7 @@ add_data = ['quirks;quirks',
|
||||||
'LICENSE;.',
|
'LICENSE;.',
|
||||||
'CHANGELOG.md;.',
|
'CHANGELOG.md;.',
|
||||||
'PCskins.png;.',
|
'PCskins.png;.',
|
||||||
'Pesterchum.png;.',
|
'Pesterchum.png;.']
|
||||||
'logging.ini.example;.']
|
|
||||||
|
|
||||||
upx_exclude = ["qwindows.dll",
|
upx_exclude = ["qwindows.dll",
|
||||||
"Qt5Core.dll",
|
"Qt5Core.dll",
|
||||||
|
|
3
setup.py
3
setup.py
|
@ -33,8 +33,7 @@ includefiles = ["quirks",
|
||||||
"LICENSE",
|
"LICENSE",
|
||||||
"CHANGELOG.md",
|
"CHANGELOG.md",
|
||||||
"PCskins.png",
|
"PCskins.png",
|
||||||
"Pesterchum.png",
|
"Pesterchum.png"]
|
||||||
"logging.ini.example"]
|
|
||||||
build_exe_options = {
|
build_exe_options = {
|
||||||
"includes": ['PyQt5.QtCore',
|
"includes": ['PyQt5.QtCore',
|
||||||
'PyQt5.QtGui',
|
'PyQt5.QtGui',
|
||||||
|
|
Loading…
Reference in a new issue