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
|
designer.bat
|
||||||
*.sh
|
*.sh
|
||||||
.vscode/
|
.vscode/
|
||||||
|
default_pics/
|
||||||
|
|||||||
24
artemis.py
@@ -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_())
|
||||||
|
|||||||
@@ -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>
|
||||||
|
|||||||
@@ -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
@@ -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>
|
<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>
|
||||||
|
|||||||
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"
|
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,18 +97,22 @@ 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 self.__theme_path != self.__current_theme:
|
if os.path.exists(theme_path):
|
||||||
self.__change()
|
if self.__theme_path != self.__current_theme:
|
||||||
self.__parent.display_specs(
|
self.__change()
|
||||||
item=self.__parent.result_list.currentItem(),
|
self.__parent.display_specs(
|
||||||
previous_item=None
|
item=self.__parent.result_list.currentItem(),
|
||||||
)
|
previous_item=None
|
||||||
self.__refresh_range_labels()
|
)
|
||||||
self.__parent.audio_widget.refresh_btns_colors(
|
self.__refresh_range_labels()
|
||||||
self.__parent.active_color,
|
self.__parent.audio_widget.refresh_btns_colors(
|
||||||
self.__parent.inactive_color
|
self.__parent.active_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,22 +124,26 @@ class ThemeManager:
|
|||||||
def __detect_themes(self):
|
def __detect_themes(self):
|
||||||
themes = []
|
themes = []
|
||||||
ag = QActionGroup(self.__parent, exclusive=True)
|
ag = QActionGroup(self.__parent, exclusive=True)
|
||||||
for theme_folder in os.listdir(ThemeConstants.FOLDER):
|
if os.path.exists(ThemeConstants.FOLDER):
|
||||||
relative_folder = os.path.join(ThemeConstants.FOLDER, theme_folder)
|
for theme_folder in os.listdir(ThemeConstants.FOLDER):
|
||||||
if os.path.isdir(os.path.abspath(relative_folder)):
|
|
||||||
relative_folder = os.path.join(ThemeConstants.FOLDER, theme_folder)
|
relative_folder = os.path.join(ThemeConstants.FOLDER, theme_folder)
|
||||||
themes.append(relative_folder)
|
if os.path.isdir(os.path.abspath(relative_folder)):
|
||||||
for theme_path in themes:
|
relative_folder = os.path.join(ThemeConstants.FOLDER, theme_folder)
|
||||||
theme_name = '&' + self.__pretty_name(os.path.basename(theme_path))
|
themes.append(relative_folder)
|
||||||
new_theme = ag.addAction(
|
for theme_path in themes:
|
||||||
QAction(
|
theme_name = '&' + self.__pretty_name(os.path.basename(theme_path))
|
||||||
theme_name,
|
new_theme = ag.addAction(
|
||||||
self.__parent, checkable=True
|
QAction(
|
||||||
|
theme_name,
|
||||||
|
self.__parent, checkable=True
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
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,15 +324,25 @@ 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))
|
||||||
self.__theme_names[theme_name].setChecked(True)
|
try:
|
||||||
self.__apply(theme_path)
|
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:
|
else:
|
||||||
self.__theme_names[
|
try:
|
||||||
self.__pretty_name(ThemeConstants.DEFAULT)
|
self.__theme_names[
|
||||||
].setChecked(True)
|
self.__pretty_name(ThemeConstants.DEFAULT)
|
||||||
self.__apply(
|
].setChecked(True)
|
||||||
os.path.join(
|
except Exception:
|
||||||
ThemeConstants.FOLDER,
|
pop_up(self.__parent, title=ThemeConstants.THEME_NOT_FOUND,
|
||||||
ThemeConstants.DEFAULT
|
text=ThemeConstants.MISSING_THEME).show()
|
||||||
|
else:
|
||||||
|
self.__apply(
|
||||||
|
os.path.join(
|
||||||
|
ThemeConstants.FOLDER,
|
||||||
|
ThemeConstants.DEFAULT
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
|
||||||
|
|||||||