forked from openlp/openlp
Add dark theme from QDarkStyle. Part 1: Force the theme
This commit is contained in:
parent
2cfb03a606
commit
93fd4053b2
@ -45,11 +45,13 @@ from openlp.core.common.versionchecker import VersionThread, get_application_ver
|
||||
from openlp.core.lib import ScreenList
|
||||
from openlp.core.resources import qInitResources
|
||||
from openlp.core.ui import SplashScreen
|
||||
from openlp.core.ui.dark import HAS_DARK_STYLE, DARK_STYLESHEET
|
||||
from openlp.core.ui.exceptionform import ExceptionForm
|
||||
from openlp.core.ui.firsttimeform import FirstTimeForm
|
||||
from openlp.core.ui.firsttimelanguageform import FirstTimeLanguageForm
|
||||
from openlp.core.ui.mainwindow import MainWindow
|
||||
|
||||
|
||||
__all__ = ['OpenLP', 'main']
|
||||
|
||||
|
||||
@ -122,13 +124,16 @@ class OpenLP(OpenLPMixin, QtWidgets.QApplication):
|
||||
sys.exit()
|
||||
# Correct stylesheet bugs
|
||||
application_stylesheet = ''
|
||||
if not Settings().value('advanced/alternate rows'):
|
||||
base_color = self.palette().color(QtGui.QPalette.Active, QtGui.QPalette.Base)
|
||||
alternate_rows_repair_stylesheet = \
|
||||
'QTableWidget, QListWidget, QTreeWidget {alternate-background-color: ' + base_color.name() + ';}\n'
|
||||
application_stylesheet += alternate_rows_repair_stylesheet
|
||||
if is_win():
|
||||
application_stylesheet += WIN_REPAIR_STYLESHEET
|
||||
if HAS_DARK_STYLE:
|
||||
application_stylesheet = DARK_STYLESHEET
|
||||
else:
|
||||
if not Settings().value('advanced/alternate rows'):
|
||||
base_color = self.palette().color(QtGui.QPalette.Active, QtGui.QPalette.Base)
|
||||
alternate_rows_repair_stylesheet = \
|
||||
'QTableWidget, QListWidget, QTreeWidget {alternate-background-color: ' + base_color.name() + ';}\n'
|
||||
application_stylesheet += alternate_rows_repair_stylesheet
|
||||
if is_win():
|
||||
application_stylesheet += WIN_REPAIR_STYLESHEET
|
||||
if application_stylesheet:
|
||||
self.setStyleSheet(application_stylesheet)
|
||||
can_show_splash = Settings().value('core/show splash')
|
||||
|
32
openlp/core/ui/dark.py
Normal file
32
openlp/core/ui/dark.py
Normal file
@ -0,0 +1,32 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
|
||||
|
||||
###############################################################################
|
||||
# OpenLP - Open Source Lyrics Projection #
|
||||
# --------------------------------------------------------------------------- #
|
||||
# Copyright (c) 2008-2017 OpenLP Developers #
|
||||
# --------------------------------------------------------------------------- #
|
||||
# This program is free software; you can redistribute it and/or modify it #
|
||||
# under the terms of the GNU General Public License as published by the Free #
|
||||
# Software Foundation; version 2 of the License. #
|
||||
# #
|
||||
# This program is distributed in the hope that it will be useful, but WITHOUT #
|
||||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or #
|
||||
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for #
|
||||
# more details. #
|
||||
# #
|
||||
# You should have received a copy of the GNU General Public License along #
|
||||
# with this program; if not, write to the Free Software Foundation, Inc., 59 #
|
||||
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
||||
###############################################################################
|
||||
"""
|
||||
The :mod:`~openlp.core.ui.dark` module looks for and loads a dark theme
|
||||
"""
|
||||
|
||||
try:
|
||||
import qdarkstyle
|
||||
HAS_DARK_STYLE = True
|
||||
DARK_STYLESHEET = qdarkstyle.load_stylesheet_pyqt5()
|
||||
except:
|
||||
HAS_DARK_STYLE = False
|
||||
DARK_STYLESHEET = ''
|
@ -45,6 +45,7 @@ from openlp.core.lib import Renderer, PluginManager, ImageManager, PluginStatus,
|
||||
from openlp.core.lib.ui import create_action
|
||||
from openlp.core.ui import AboutForm, SettingsForm, ServiceManager, ThemeManager, LiveController, PluginForm, \
|
||||
ShortcutListForm, FormattingTagForm, PreviewController
|
||||
from openlp.core.ui.dark import HAS_DARK_STYLE
|
||||
from openlp.core.ui.firsttimeform import FirstTimeForm
|
||||
from openlp.core.ui.media import MediaController
|
||||
from openlp.core.ui.printserviceform import PrintServiceForm
|
||||
@ -155,7 +156,8 @@ class Ui_MainWindow(object):
|
||||
# Create the MediaManager
|
||||
self.media_manager_dock = OpenLPDockWidget(main_window, 'media_manager_dock',
|
||||
':/system/system_mediamanager.png')
|
||||
self.media_manager_dock.setStyleSheet(MEDIA_MANAGER_STYLE)
|
||||
if not HAS_DARK_STYLE:
|
||||
self.media_manager_dock.setStyleSheet(MEDIA_MANAGER_STYLE)
|
||||
# Create the media toolbox
|
||||
self.media_tool_box = QtWidgets.QToolBox(self.media_manager_dock)
|
||||
self.media_tool_box.setObjectName('media_tool_box')
|
||||
|
Loading…
Reference in New Issue
Block a user