Skip to content

Commit

Permalink
Basic Qt5 theming support
Browse files Browse the repository at this point in the history
  • Loading branch information
Sylvia van Os committed Jan 25, 2017
1 parent f720a5a commit 35c255f
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]
### Added
- Basic Qt5 theming support using installed system themes

### Changed
- Get list of installable modules from pext.hackerchick.me instead of pext.github.io

Expand Down
23 changes: 20 additions & 3 deletions pext/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
from PyQt5.QtWidgets import (QAction, QApplication, QDialog, QDialogButtonBox,
QInputDialog, QLabel, QLineEdit, QMainWindow,
QMenu, QMessageBox, QTextEdit, QVBoxLayout,
QSystemTrayIcon)
QStyleFactory, QSystemTrayIcon)
from PyQt5.Qt import QClipboard, QIcon, QObject, QQmlApplicationEngine, QQmlComponent, QQmlContext, QQmlProperty, QUrl


Expand Down Expand Up @@ -1391,6 +1391,8 @@ def _load_settings(argv: List[str]) -> Dict:
opts, _ = getopt.getopt(argv, "hc:m:p:", ["help",
"version",
"exit",
"list-styles",
"style=",
"clipboard=",
"module=",
"install-module=",
Expand All @@ -1411,10 +1413,17 @@ def _load_settings(argv: List[str]) -> Dict:
for opt, arg in opts:
if opt in ("-h", "--help"):
usage()
elif opt == "--exit":
sys.exit(0)
elif opt == "--version":
print("Pext {}".format(VersionRetriever.get_version()))
elif opt == "--exit":
sys.exit(0)
elif opt == "--list-styles":
for style in QStyleFactory().keys():
print(style)
elif opt == "--style":
settings['style'] = arg
# PyQt5 does not have bindings for QQuickStyle yet
os.environ["QT_QUICK_CONTROLS_STYLE"] = arg
elif opt in ("-b", "--binary"):
settings['binary'] = arg
elif opt in ("-c", "--clipboard"):
Expand Down Expand Up @@ -1479,6 +1488,12 @@ def usage() -> None:
--help : show this screen.
--style : sets a certain Qt system style for the UI.
--list-styles : print a list of loadable Qt system styles. Due to PyQt5
limitations, loadable QtQuick styles cannot currently be
listed.
--install-module : download and install a module from the given git URL.
--list-modules : list all installed modules.
Expand Down Expand Up @@ -1532,6 +1547,8 @@ def main() -> None:
# Get an app instance
app = QApplication(['Pext ({})'.format(settings['profile'])])
app.setWindowIcon(app_icon)
if 'style' in settings:
app.setStyle(QStyleFactory().create(settings['style']))

# Check if clipboard is supported
if settings['clipboard'] == 'selection' and not app.clipboard().supportsSelection():
Expand Down

0 comments on commit 35c255f

Please sign in to comment.