Makes ThemeManager even more flexible. Also set 'Dark' as default

theme. Also remove ugly 'system' theme
This commit is contained in:
alessandro90
2019-05-18 15:47:03 +02:00
parent 7c0006e80a
commit f87df03147
57 changed files with 23670 additions and 11372 deletions

1
.gitignore vendored
View File

@@ -10,3 +10,4 @@ launch.bat
designer.bat designer.bat
*.sh *.sh
.vscode/ .vscode/
default_pics/

View File

@@ -43,7 +43,7 @@ from utilities import (checksum_ok,
format_numbers, format_numbers,
resource_path,) resource_path,)
# import icon_rc # import default_imgs_rc
qt_creator_file = resource_path("artemis.ui") qt_creator_file = resource_path("artemis.ui")
@@ -1363,7 +1363,7 @@ class Artemis(QMainWindow, Ui_MainWindow):
def display_spectrogram(self): def display_spectrogram(self):
default_pic = os.path.join( default_pic = os.path.join(
self.default_images_folder, Constants.DEFAULT_IMGS_FOLDER,
Constants.NOT_SELECTED Constants.NOT_SELECTED
) )
item = self.result_list.currentItem() item = self.result_list.currentItem()
@@ -1376,7 +1376,7 @@ class Artemis(QMainWindow, Ui_MainWindow):
) )
if not QFileInfo(path_spectr).exists(): if not QFileInfo(path_spectr).exists():
path_spectr = os.path.join( path_spectr = os.path.join(
self.default_images_folder, Constants.DEFAULT_IMGS_FOLDER,
Constants.NOT_AVAILABLE Constants.NOT_AVAILABLE
) )
else: else:
@@ -1441,14 +1441,14 @@ class Artemis(QMainWindow, Ui_MainWindow):
if __name__ == '__main__': if __name__ == '__main__':
my_app = QApplication(sys.argv) my_app = QApplication(sys.argv)
# img = QPixmap(":/icons/Artemis3.500px.png") img = QPixmap(":/icon/default_pics/Artemis3.500px.png")
# splash = QSplashScreen(img) splash = QSplashScreen(img)
# splash.show() splash.show()
# start= time() start= time()
# while time()-start < 2: while time() - start < 2:
# sleep(0.001) sleep(0.001)
# my_app.processEvents() my_app.processEvents()
# splash.close() splash.close()
artemis = Artemis() artemis = Artemis()
artemis.show() artemis.show()
sys.exit(my_app.exec_()) sys.exit(my_app.exec_())

View File

@@ -20,8 +20,8 @@
<string>ARTΣMIS 3.0</string> <string>ARTΣMIS 3.0</string>
</property> </property>
<property name="windowIcon"> <property name="windowIcon">
<iconset> <iconset resource="default_imgs.qrc">
<normaloff>:/icons/Artemis3.ico</normaloff>:/icons/Artemis3.ico</iconset> <normaloff>:/icon/default_pics/Artemis3.ico</normaloff>:/icon/default_pics/Artemis3.ico</iconset>
</property> </property>
<property name="styleSheet"> <property name="styleSheet">
<string notr="true"/> <string notr="true"/>
@@ -9542,7 +9542,7 @@ QSlider::handle:horizontal {
</customwidget> </customwidget>
</customwidgets> </customwidgets>
<resources> <resources>
<include location="icon.qrc"/> <include location="default_imgs.qrc"/>
</resources> </resources>
<connections/> <connections/>
</ui> </ui>

View File

@@ -1,5 +1,6 @@
from collections import namedtuple from collections import namedtuple
from enum import Enum, auto from enum import Enum, auto
import os.path
class Ftype: class Ftype:
@@ -154,3 +155,4 @@ class Constants:
UNKNOWN = "N/A" UNKNOWN = "N/A"
EXTRACTING_MSG = "Extracting..." EXTRACTING_MSG = "Extracting..."
EXTRACTING_CODE = -1 EXTRACTING_CODE = -1
DEFAULT_IMGS_FOLDER = os.path.join(":", "pics", "default_pics")

11
default_imgs.qrc Normal file
View File

@@ -0,0 +1,11 @@
<RCC>
<qresource prefix="icon">
<file>default_pics/Artemis3.500px.png</file>
<file>default_pics/Artemis3.ico</file>
<file>default_pics/Artemis3.png</file>
</qresource>
<qresource prefix="pics">
<file>default_pics/nosignalselected.png</file>
<file>default_pics/spectrumnotavailable.png</file>
</qresource>
</RCC>

23580
default_imgs_rc.py Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -7,15 +7,15 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>400</width> <width>400</width>
<height>157</height> <height>160</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>Download database</string> <string>Download database</string>
</property> </property>
<property name="windowIcon"> <property name="windowIcon">
<iconset> <iconset resource="default_imgs.qrc">
<normaloff>:/icons/Artemis3.ico</normaloff>:/icons/Artemis3.ico</iconset> <normaloff>:/icon/default_pics/Artemis3.ico</normaloff>:/icon/default_pics/Artemis3.ico</iconset>
</property> </property>
<property name="styleSheet"> <property name="styleSheet">
<string notr="true"/> <string notr="true"/>
@@ -99,7 +99,7 @@ Please wait...
</layout> </layout>
</widget> </widget>
<resources> <resources>
<include location="icon.qrc"/> <include location="default_imgs.qrc"/>
</resources> </resources>
<connections/> <connections/>
</ui> </ui>

View File

@@ -1,6 +0,0 @@
<RCC>
<qresource prefix="icons">
<file>Artemis3.500px.png</file>
<file>Artemis3.ico</file>
</qresource>
</RCC>

11310
icon_rc.py

File diff suppressed because it is too large Load Diff

View File

Before

Width:  |  Height:  |  Size: 270 B

After

Width:  |  Height:  |  Size: 270 B

View File

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

Before

Width:  |  Height:  |  Size: 820 B

After

Width:  |  Height:  |  Size: 820 B

View File

Before

Width:  |  Height:  |  Size: 2.9 KiB

After

Width:  |  Height:  |  Size: 2.9 KiB

View File

Before

Width:  |  Height:  |  Size: 916 B

After

Width:  |  Height:  |  Size: 916 B

View File

Before

Width:  |  Height:  |  Size: 2.9 KiB

After

Width:  |  Height:  |  Size: 2.9 KiB

View File

Before

Width:  |  Height:  |  Size: 2.0 KiB

After

Width:  |  Height:  |  Size: 2.0 KiB

View File

Before

Width:  |  Height:  |  Size: 827 B

After

Width:  |  Height:  |  Size: 827 B

View File

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 34 KiB

View File

Before

Width:  |  Height:  |  Size: 270 B

After

Width:  |  Height:  |  Size: 270 B

View File

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

Before

Width:  |  Height:  |  Size: 820 B

After

Width:  |  Height:  |  Size: 820 B

View File

Before

Width:  |  Height:  |  Size: 2.9 KiB

After

Width:  |  Height:  |  Size: 2.9 KiB

View File

Before

Width:  |  Height:  |  Size: 916 B

After

Width:  |  Height:  |  Size: 916 B

View File

Before

Width:  |  Height:  |  Size: 2.9 KiB

After

Width:  |  Height:  |  Size: 2.9 KiB

View File

Before

Width:  |  Height:  |  Size: 2.0 KiB

After

Width:  |  Height:  |  Size: 2.0 KiB

View File

Before

Width:  |  Height:  |  Size: 827 B

After

Width:  |  Height:  |  Size: 827 B

View File

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 17 KiB

View File

Before

Width:  |  Height:  |  Size: 270 B

After

Width:  |  Height:  |  Size: 270 B

View File

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

Before

Width:  |  Height:  |  Size: 820 B

After

Width:  |  Height:  |  Size: 820 B

View File

Before

Width:  |  Height:  |  Size: 2.9 KiB

After

Width:  |  Height:  |  Size: 2.9 KiB

View File

Before

Width:  |  Height:  |  Size: 916 B

After

Width:  |  Height:  |  Size: 916 B

View File

Before

Width:  |  Height:  |  Size: 2.9 KiB

After

Width:  |  Height:  |  Size: 2.9 KiB

View File

Before

Width:  |  Height:  |  Size: 2.0 KiB

After

Width:  |  Height:  |  Size: 2.0 KiB

View File

Before

Width:  |  Height:  |  Size: 827 B

After

Width:  |  Height:  |  Size: 827 B

View File

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 17 KiB

View File

@@ -14,7 +14,7 @@ class ThemeConstants:
FOLDER = "themes" FOLDER = "themes"
EXTENSION = ".qss" EXTENSION = ".qss"
ICONS_FOLDER = "icons" ICONS_FOLDER = "icons"
DEFAULT = "1-system" DEFAULT = "1-dark"
CURRENT = ".current_theme" CURRENT = ".current_theme"
COLORS = "colors.txt" COLORS = "colors.txt"
COLOR_SEPARATOR = "=" COLOR_SEPARATOR = "="
@@ -25,6 +25,8 @@ class ThemeConstants:
DEFAULT_TEXT_COLOR = "#ffffff" DEFAULT_TEXT_COLOR = "#ffffff"
THEME_NOT_FOUND = "Theme not found" THEME_NOT_FOUND = "Theme not found"
MISSING_THEME = "Missing theme in '" + FOLDER + "' folder." MISSING_THEME = "Missing theme in '" + FOLDER + "' folder."
MISSING_THEME_FOLDER = FOLDER + " folder not found.\nOnly the basic theme is available."
THEME_FOLDER_NOT_FOUND = FOLDER + " folder not found"
class ThemeManager: class ThemeManager:
def __init__(self, parent): def __init__(self, parent):
@@ -95,6 +97,7 @@ class ThemeManager:
@pyqtSlot() @pyqtSlot()
def __apply(self, theme_path): def __apply(self, theme_path):
self.__theme_path = theme_path self.__theme_path = theme_path
if os.path.exists(theme_path):
if self.__theme_path != self.__current_theme: if self.__theme_path != self.__current_theme:
self.__change() self.__change()
self.__parent.display_specs( self.__parent.display_specs(
@@ -107,6 +110,9 @@ class ThemeManager:
self.__parent.inactive_color self.__parent.inactive_color
) )
self.__space_weather_labels.refresh() self.__space_weather_labels.refresh()
else:
pop_up(self.__parent, title=ThemeConstants.THEME_NOT_FOUND,
text=ThemeConstants.MISSING_THEME).show()
def __pretty_name(self, bad_name): def __pretty_name(self, bad_name):
return ' '.join( return ' '.join(
@@ -118,6 +124,7 @@ class ThemeManager:
def __detect_themes(self): def __detect_themes(self):
themes = [] themes = []
ag = QActionGroup(self.__parent, exclusive=True) ag = QActionGroup(self.__parent, exclusive=True)
if os.path.exists(ThemeConstants.FOLDER):
for theme_folder in os.listdir(ThemeConstants.FOLDER): for theme_folder in os.listdir(ThemeConstants.FOLDER):
relative_folder = os.path.join(ThemeConstants.FOLDER, theme_folder) relative_folder = os.path.join(ThemeConstants.FOLDER, theme_folder)
if os.path.isdir(os.path.abspath(relative_folder)): if os.path.isdir(os.path.abspath(relative_folder)):
@@ -134,6 +141,9 @@ class ThemeManager:
self.__parent.menu_themes.addAction(new_theme) self.__parent.menu_themes.addAction(new_theme)
self.__theme_names[theme_name.lstrip('&')] = new_theme self.__theme_names[theme_name.lstrip('&')] = new_theme
new_theme.triggered.connect(partial(self.__apply, theme_path)) new_theme.triggered.connect(partial(self.__apply, theme_path))
else:
pop_up(self.__parent, title=ThemeConstants.THEME_FOLDER_NOT_FOUND,
text=ThemeConstants.MISSING_THEME_FOLDER).show()
def __is_valid_html_color(self, colors): def __is_valid_html_color(self, colors):
pattern = "#([a-zA-Z0-9]){6}" pattern = "#([a-zA-Z0-9]){6}"
@@ -314,12 +324,22 @@ class ThemeManager:
with open(current_theme_file, "r") as current_theme_path: with open(current_theme_file, "r") as current_theme_path:
theme_path = current_theme_path.read() theme_path = current_theme_path.read()
theme_name = self.__pretty_name(os.path.basename(theme_path)) theme_name = self.__pretty_name(os.path.basename(theme_path))
try:
self.__theme_names[theme_name].setChecked(True) self.__theme_names[theme_name].setChecked(True)
except Exception:
pop_up(self.__parent, title=ThemeConstants.THEME_NOT_FOUND,
text=ThemeConstants.MISSING_THEME).show()
else:
self.__apply(theme_path) self.__apply(theme_path)
else: else:
try:
self.__theme_names[ self.__theme_names[
self.__pretty_name(ThemeConstants.DEFAULT) self.__pretty_name(ThemeConstants.DEFAULT)
].setChecked(True) ].setChecked(True)
except Exception:
pop_up(self.__parent, title=ThemeConstants.THEME_NOT_FOUND,
text=ThemeConstants.MISSING_THEME).show()
else:
self.__apply( self.__apply(
os.path.join( os.path.join(
ThemeConstants.FOLDER, ThemeConstants.FOLDER,