Makes ThemeManager even more flexible. Also set 'Dark' as default
theme. Also remove ugly 'system' theme
1
.gitignore
vendored
@@ -10,3 +10,4 @@ launch.bat
|
||||
designer.bat
|
||||
*.sh
|
||||
.vscode/
|
||||
default_pics/
|
||||
|
||||
22
artemis.py
@@ -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_())
|
||||
@@ -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>
|
||||
|
||||
@@ -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
@@ -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
@@ -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>
|
||||
|
||||
6
icon.qrc
@@ -1,6 +0,0 @@
|
||||
<RCC>
|
||||
<qresource prefix="icons">
|
||||
<file>Artemis3.500px.png</file>
|
||||
<file>Artemis3.ico</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
11310
icon_rc.py
|
Before Width: | Height: | Size: 270 B After Width: | Height: | Size: 270 B |
|
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 820 B After Width: | Height: | Size: 820 B |
|
Before Width: | Height: | Size: 2.9 KiB After Width: | Height: | Size: 2.9 KiB |
|
Before Width: | Height: | Size: 916 B After Width: | Height: | Size: 916 B |
|
Before Width: | Height: | Size: 2.9 KiB After Width: | Height: | Size: 2.9 KiB |
|
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 2.0 KiB |
|
Before Width: | Height: | Size: 827 B After Width: | Height: | Size: 827 B |
|
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 17 KiB |
|
Before Width: | Height: | Size: 21 KiB |
|
Before Width: | Height: | Size: 5.4 KiB |
|
Before Width: | Height: | Size: 22 KiB |
|
Before Width: | Height: | Size: 34 KiB |
|
Before Width: | Height: | Size: 270 B After Width: | Height: | Size: 270 B |
|
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 820 B After Width: | Height: | Size: 820 B |
|
Before Width: | Height: | Size: 2.9 KiB After Width: | Height: | Size: 2.9 KiB |
|
Before Width: | Height: | Size: 916 B After Width: | Height: | Size: 916 B |
|
Before Width: | Height: | Size: 2.9 KiB After Width: | Height: | Size: 2.9 KiB |
|
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 2.0 KiB |
|
Before Width: | Height: | Size: 827 B After Width: | Height: | Size: 827 B |
|
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 17 KiB |
|
Before Width: | Height: | Size: 270 B After Width: | Height: | Size: 270 B |
|
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 820 B After Width: | Height: | Size: 820 B |
|
Before Width: | Height: | Size: 2.9 KiB After Width: | Height: | Size: 2.9 KiB |
|
Before Width: | Height: | Size: 916 B After Width: | Height: | Size: 916 B |
|
Before Width: | Height: | Size: 2.9 KiB After Width: | Height: | Size: 2.9 KiB |
|
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 2.0 KiB |
|
Before Width: | Height: | Size: 827 B After Width: | Height: | Size: 827 B |
|
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 17 KiB |
@@ -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,18 +97,22 @@ class ThemeManager:
|
||||
@pyqtSlot()
|
||||
def __apply(self, theme_path):
|
||||
self.__theme_path = theme_path
|
||||
if self.__theme_path != self.__current_theme:
|
||||
self.__change()
|
||||
self.__parent.display_specs(
|
||||
item=self.__parent.result_list.currentItem(),
|
||||
previous_item=None
|
||||
)
|
||||
self.__refresh_range_labels()
|
||||
self.__parent.audio_widget.refresh_btns_colors(
|
||||
self.__parent.active_color,
|
||||
self.__parent.inactive_color
|
||||
)
|
||||
self.__space_weather_labels.refresh()
|
||||
if os.path.exists(theme_path):
|
||||
if self.__theme_path != self.__current_theme:
|
||||
self.__change()
|
||||
self.__parent.display_specs(
|
||||
item=self.__parent.result_list.currentItem(),
|
||||
previous_item=None
|
||||
)
|
||||
self.__refresh_range_labels()
|
||||
self.__parent.audio_widget.refresh_btns_colors(
|
||||
self.__parent.active_color,
|
||||
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,22 +124,26 @@ class ThemeManager:
|
||||
def __detect_themes(self):
|
||||
themes = []
|
||||
ag = QActionGroup(self.__parent, exclusive=True)
|
||||
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)):
|
||||
if os.path.exists(ThemeConstants.FOLDER):
|
||||
for theme_folder in os.listdir(ThemeConstants.FOLDER):
|
||||
relative_folder = os.path.join(ThemeConstants.FOLDER, theme_folder)
|
||||
themes.append(relative_folder)
|
||||
for theme_path in themes:
|
||||
theme_name = '&' + self.__pretty_name(os.path.basename(theme_path))
|
||||
new_theme = ag.addAction(
|
||||
QAction(
|
||||
theme_name,
|
||||
self.__parent, checkable=True
|
||||
if os.path.isdir(os.path.abspath(relative_folder)):
|
||||
relative_folder = os.path.join(ThemeConstants.FOLDER, theme_folder)
|
||||
themes.append(relative_folder)
|
||||
for theme_path in themes:
|
||||
theme_name = '&' + self.__pretty_name(os.path.basename(theme_path))
|
||||
new_theme = ag.addAction(
|
||||
QAction(
|
||||
theme_name,
|
||||
self.__parent, checkable=True
|
||||
)
|
||||
)
|
||||
)
|
||||
self.__parent.menu_themes.addAction(new_theme)
|
||||
self.__theme_names[theme_name.lstrip('&')] = new_theme
|
||||
new_theme.triggered.connect(partial(self.__apply, theme_path))
|
||||
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,15 +324,25 @@ 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))
|
||||
self.__theme_names[theme_name].setChecked(True)
|
||||
self.__apply(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:
|
||||
self.__theme_names[
|
||||
self.__pretty_name(ThemeConstants.DEFAULT)
|
||||
].setChecked(True)
|
||||
self.__apply(
|
||||
os.path.join(
|
||||
ThemeConstants.FOLDER,
|
||||
ThemeConstants.DEFAULT
|
||||
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,
|
||||
ThemeConstants.DEFAULT
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||