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
*.sh
.vscode/
default_pics/

View File

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

View File

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

View File

@@ -1,5 +1,6 @@
from collections import namedtuple
from enum import Enum, auto
import os.path
class Ftype:
@@ -154,3 +155,4 @@ class Constants:
UNKNOWN = "N/A"
EXTRACTING_MSG = "Extracting..."
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>
<y>0</y>
<width>400</width>
<height>157</height>
<height>160</height>
</rect>
</property>
<property name="windowTitle">
<string>Download database</string>
</property>
<property name="windowIcon">
<iconset>
<normaloff>:/icons/Artemis3.ico</normaloff>:/icons/Artemis3.ico</iconset>
<iconset resource="default_imgs.qrc">
<normaloff>:/icon/default_pics/Artemis3.ico</normaloff>:/icon/default_pics/Artemis3.ico</iconset>
</property>
<property name="styleSheet">
<string notr="true"/>
@@ -99,7 +99,7 @@ Please wait...
</layout>
</widget>
<resources>
<include location="icon.qrc"/>
<include location="default_imgs.qrc"/>
</resources>
<connections/>
</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"
EXTENSION = ".qss"
ICONS_FOLDER = "icons"
DEFAULT = "1-system"
DEFAULT = "1-dark"
CURRENT = ".current_theme"
COLORS = "colors.txt"
COLOR_SEPARATOR = "="
@@ -25,6 +25,8 @@ class ThemeConstants:
DEFAULT_TEXT_COLOR = "#ffffff"
THEME_NOT_FOUND = "Theme not found"
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:
def __init__(self, parent):
@@ -95,6 +97,7 @@ class ThemeManager:
@pyqtSlot()
def __apply(self, theme_path):
self.__theme_path = theme_path
if os.path.exists(theme_path):
if self.__theme_path != self.__current_theme:
self.__change()
self.__parent.display_specs(
@@ -107,6 +110,9 @@ class ThemeManager:
self.__parent.inactive_color
)
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):
return ' '.join(
@@ -118,6 +124,7 @@ class ThemeManager:
def __detect_themes(self):
themes = []
ag = QActionGroup(self.__parent, exclusive=True)
if os.path.exists(ThemeConstants.FOLDER):
for theme_folder in os.listdir(ThemeConstants.FOLDER):
relative_folder = os.path.join(ThemeConstants.FOLDER, theme_folder)
if os.path.isdir(os.path.abspath(relative_folder)):
@@ -134,6 +141,9 @@ class ThemeManager:
self.__parent.menu_themes.addAction(new_theme)
self.__theme_names[theme_name.lstrip('&')] = new_theme
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):
pattern = "#([a-zA-Z0-9]){6}"
@@ -314,12 +324,22 @@ class ThemeManager:
with open(current_theme_file, "r") as current_theme_path:
theme_path = current_theme_path.read()
theme_name = self.__pretty_name(os.path.basename(theme_path))
try:
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)
else:
try:
self.__theme_names[
self.__pretty_name(ThemeConstants.DEFAULT)
].setChecked(True)
except Exception:
pop_up(self.__parent, title=ThemeConstants.THEME_NOT_FOUND,
text=ThemeConstants.MISSING_THEME).show()
else:
self.__apply(
os.path.join(
ThemeConstants.FOLDER,