diff --git a/artemis.py b/artemis.py index 1eb0689..de1d2f7 100644 --- a/artemis.py +++ b/artemis.py @@ -1,5 +1,4 @@ from collections import namedtuple -from itertools import chain from functools import partial import webbrowser import os @@ -31,8 +30,7 @@ from constants import (Constants, Database, ChecksumWhat, Messages, - Signal, - Colors,) + Signal,) from themes import Theme from utilities import (checksum_ok, uncheck_and_emit, @@ -64,6 +62,66 @@ class Artemis(QMainWindow, Ui_MainWindow): self.current_signal_name = '' self.signal_names = [] self.total_signals = 0 + self.switchable_r_labels = SwitchableLabelsIterable(self.r0_now_lbl, + self.r1_now_lbl, + self.r2_now_lbl, + self.r3_now_lbl, + self.r4_now_lbl, + self.r5_now_lbl,) + + self.switchable_s_labels = SwitchableLabelsIterable(self.s0_now_lbl, + self.s1_now_lbl, + self.s2_now_lbl, + self.s3_now_lbl, + self.s4_now_lbl, + self.s5_now_lbl,) + + self.switchable_g_now_labels = SwitchableLabelsIterable(self.g0_now_lbl, + self.g1_now_lbl, + self.g2_now_lbl, + self.g3_now_lbl, + self.g4_now_lbl, + self.g5_now_lbl) + + self.switchable_g_today_labels = SwitchableLabelsIterable(self.g0_today_lbl, + self.g1_today_lbl, + self.g2_today_lbl, + self.g3_today_lbl, + self.g4_today_lbl, + self.g5_today_lbl) + + self.k_storm_labels = SwitchableLabelsIterable(self.k_ex_sev_storm_lbl, + self.k_very_sev_storm_lbl, + self.k_sev_storm_lbl, + self.k_maj_storm_lbl, + self.k_min_storm_lbl, + self.k_active_lbl, + self.k_unsettled_lbl, + self.k_quiet_lbl, + self.k_very_quiet_lbl, + self.k_inactive_lbl) + + self.a_storm_labels = SwitchableLabelsIterable(self.a_sev_storm_lbl, + self.a_maj_storm_lbl, + self.a_min_storm_lbl, + self.a_active_lbl, + self.a_unsettled_lbl, + self.a_quiet_lbl) + + self.forecast_labels = (self.forecast_lbl_0, + self.forecast_lbl_1, + self.forecast_lbl_2, + self.forecast_lbl_3, + self.forecast_lbl_4, + self.forecast_lbl_5, + self.forecast_lbl_6, + self.forecast_lbl_7, + self.forecast_lbl_8) + + for lab in self.forecast_labels: + lab.set_default_stylesheet() + + self.forecast_label_container.labels = self.forecast_labels self.theme = Theme(self) # Manage frequency filters. @@ -377,92 +435,6 @@ class Artemis(QMainWindow, Ui_MainWindow): self.update_now_bar.set_idle() self.space_weather_data = SpaceWeatherData() self.space_weather_data.update_complete.connect(self.update_space_weather) - self.switchable_r_labels = SwitchableLabelsIterable(self.r0_now_lbl, - self.r1_now_lbl, - self.r2_now_lbl, - self.r3_now_lbl, - self.r4_now_lbl, - self.r5_now_lbl,) - self.switchable_s_labels = SwitchableLabelsIterable(self.s0_now_lbl, - self.s1_now_lbl, - self.s2_now_lbl, - self.s3_now_lbl, - self.s4_now_lbl, - self.s5_now_lbl,) - self.switchable_g_now_labels = SwitchableLabelsIterable(self.g0_now_lbl, - self.g1_now_lbl, - self.g2_now_lbl, - self.g3_now_lbl, - self.g4_now_lbl, - self.g5_now_lbl) - self.switchable_g_today_labels = SwitchableLabelsIterable(self.g0_today_lbl, - self.g1_today_lbl, - self.g2_today_lbl, - self.g3_today_lbl, - self.g4_today_lbl, - self.g5_today_lbl) - colors_array = [[Colors.WHITE_LIGHT, Colors.WHITE_DARK], - [Colors.BLUE_LIGHT, Colors.BLUE_DARK], - [Colors.GREEN_LIGHT, Colors.GREEN_DARK], - [Colors.YELLOW_LIGHT, Colors.YELLOW_DARK], - [Colors.ORANGE_LIGHT, Colors.ORANGE_DARK], - [Colors.RED_LIGHT, Colors.RED_DARK]] - - for lab, [light_color, dark_color] in zip(chain(self.switchable_r_labels, - self.switchable_s_labels, - self.switchable_g_now_labels, - self.switchable_g_today_labels), - colors_array * 4): - lab.set_colors(None, None) - - k_storms_colors = [[Colors.RED_LIGHT, Colors.RED_DARK], - [Colors.RED2_LIGHT, Colors.RED2_DARK], - [Colors.RED3_LIGHT, Colors.RED3_DARK], - [Colors.ORANGE2_LIGHT, Colors.ORANGE2_DARK], - [Colors.ORANGE_LIGHT, Colors.ORANGE_DARK], - [Colors.YELLOW_LIGHT, Colors.YELLOW_DARK], - [Colors.GREEN2_LIGHT, Colors.GREEN2_DARK], - [Colors.GREEN3_LIGHT, Colors.GREEN3_DARK], - [Colors.GREEN_LIGHT, Colors.GREEN_DARK], - [Colors.BLUE_LIGHT, Colors.BLUE_DARK]] - a_storm_colors = [[Colors.RED_LIGHT, Colors.RED_DARK], - [Colors.ORANGE2_LIGHT, Colors.ORANGE2_DARK], - [Colors.ORANGE_LIGHT, Colors.ORANGE_DARK], - [Colors.YELLOW_LIGHT, Colors.YELLOW_DARK], - [Colors.GREEN_LIGHT, Colors.GREEN_DARK], - [Colors.BLUE_LIGHT, Colors.BLUE_DARK]] - - self.k_storm_labels = SwitchableLabelsIterable(self.k_ex_sev_storm_lbl, - self.k_very_sev_storm_lbl, - self.k_sev_storm_lbl, - self.k_maj_storm_lbl, - self.k_min_storm_lbl, - self.k_active_lbl, - self.k_unsettled_lbl, - self.k_quiet_lbl, - self.k_very_quiet_lbl, - self.k_inactive_lbl) - self.a_storm_labels = SwitchableLabelsIterable(self.a_sev_storm_lbl, - self.a_maj_storm_lbl, - self.a_min_storm_lbl, - self.a_active_lbl, - self.a_unsettled_lbl, - self.a_quiet_lbl) - - for lab, [light_color, dark_color] in zip(chain(self.k_storm_labels, self.a_storm_labels), - chain(k_storms_colors, a_storm_colors)): - lab.set_colors(None, None) - - self.forecast_labels = (self.forecast_lbl_0, - self.forecast_lbl_1, - self.forecast_lbl_2, - self.forecast_lbl_3, - self.forecast_lbl_4, - self.forecast_lbl_5, - self.forecast_lbl_6, - self.forecast_lbl_7, - self.forecast_lbl_8) - self.forecast_label_container.labels = self.forecast_labels # Final operations. self.theme.initialize() @@ -580,37 +552,35 @@ class Artemis(QMainWindow, Ui_MainWindow): k_index_24_hmax = int(self.space_weather_data.geo_storm[6][index]) if k_index_24_hmax == 0: self.switchable_g_today_labels.switch_on(self.g0_today_lbl) - self.expected_noise_lbl.setText("S0 - S1 (<-120 dBm)") + self.expected_noise_lbl.setText(" S0 - S1 (<-120 dBm) ") elif k_index_24_hmax == 1: self.switchable_g_today_labels.switch_on(self.g0_today_lbl) - self.expected_noise_lbl.setText("S0 - S1 (<-120 dBm)") + self.expected_noise_lbl.setText(" S0 - S1 (<-120 dBm) ") elif k_index_24_hmax == 2: self.switchable_g_today_labels.switch_on(self.g0_today_lbl) - self.expected_noise_lbl.setText("S1 - S2 (-115 dBm)") + self.expected_noise_lbl.setText(" S1 - S2 (-115 dBm) ") elif k_index_24_hmax == 3: self.switchable_g_today_labels.switch_on(self.g0_today_lbl) - self.expected_noise_lbl.setText("S2 - S3 (-110 dBm)") + self.expected_noise_lbl.setText(" S2 - S3 (-110 dBm) ") elif k_index_24_hmax == 4: self.switchable_g_today_labels.switch_on(self.g0_today_lbl) - self.expected_noise_lbl.setText("S3 - S4 (-100 dBm)") + self.expected_noise_lbl.setText(" S3 - S4 (-100 dBm) ") elif k_index_24_hmax == 5: self.switchable_g_today_labels.switch_on(self.g1_today_lbl) - self.expected_noise_lbl.setText("S4 - S6 (-90 dBm)") + self.expected_noise_lbl.setText(" S4 - S6 (-90 dBm) ") elif k_index_24_hmax == 6: self.switchable_g_today_labels.switch_on(self.g2_today_lbl) - self.expected_noise_lbl.setText("S6 - S9 (-80 dBm)") + self.expected_noise_lbl.setText(" S6 - S9 (-80 dBm) ") elif k_index_24_hmax == 7: self.switchable_g_today_labels.switch_on(self.g3_today_lbl) - self.expected_noise_lbl.setText("S9 - S20 (>-60 dBm)") + self.expected_noise_lbl.setText(" S9 - S20 (>-60 dBm) ") elif k_index_24_hmax == 8: self.switchable_g_today_labels.switch_on(self.g4_today_lbl) - self.expected_noise_lbl.setText("S20 - S30 (>-60 dBm)") + self.expected_noise_lbl.setText(" S20 - S30 (>-60 dBm) ") elif k_index_24_hmax == 9: self.switchable_g_today_labels.switch_on(self.g5_today_lbl) - self.expected_noise_lbl.setText("S30+ (>>-60 dBm)") - self.expected_noise_lbl.setStyleSheet(f""" - color:#ffffff; - background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #4776e6 ,stop: 1 #8e54e9);""") + self.expected_noise_lbl.setText(" S30+ (>>-60 dBm) ") + self.expected_noise_lbl.switch_on() val = int(self.space_weather_data.ak_index[7][2].replace('.', '')) self.sfi_lbl.setText(f"{val}") @@ -618,10 +588,9 @@ class Artemis(QMainWindow, Ui_MainWindow): self.sn_lbl.setText(f"{val:d}") for label, pixmap in zip(self.forecast_labels, self.space_weather_data.images): - label.setText('') label.pixmap = pixmap - label.setPixmap(pixmap.scaled(label.size(), Qt.IgnoreAspectRatio, Qt.SmoothTransformation)) - label.setStyleSheet("background-color: transparent;") + label.make_transparent() + label.apply_pixmap() else: pop_up(self, title = Messages.BAD_DOWNLOAD, text = Messages.BAD_DOWNLOAD_MSG).show() @@ -998,8 +967,15 @@ class Artemis(QMainWindow, Ui_MainWindow): @pyqtSlot() def reset_mode_filters(self): uncheck_and_emit(self.apply_remove_mode_filter_btn) + parents = Constants.MODES.keys() + selected_children = [] for item in self.mode_tree_widget.selectedItems(): - item.setSelected(False) + if item.text(0) in parents: + item.setSelected(False) + else: + selected_children.append(item) + for children in selected_children: + children.setSelected(False) if self.include_unknown_modes_btn.isChecked(): self.include_unknown_modes_btn.setChecked(False) diff --git a/artemis.ui b/artemis.ui index 690fa4c..8b3f37a 100644 --- a/artemis.ui +++ b/artemis.ui @@ -4678,6 +4678,22 @@ www.qrg.globaltuners.com Now + + + + QFrame::Sunken + + + 1 + + + 0 + + + Qt::Vertical + + + @@ -5115,7 +5131,7 @@ background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,sto - - + N/A @@ -5160,7 +5176,7 @@ background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,sto - - + N/A @@ -5194,8 +5210,7 @@ background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,sto - color:#ffffff; -background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,stop: 1 #859398); + EXTREMELY SEVERE @@ -5222,8 +5237,7 @@ STORM - color:#ffffff; -background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,stop: 1 #859398); + VERY SEVERE STORM @@ -5249,8 +5263,7 @@ background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,sto - color:#ffffff; -background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,stop: 1 #859398); + SEVERE STORM @@ -5276,8 +5289,7 @@ background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,sto - color:#ffffff; -background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,stop: 1 #859398); + MAJOR STORM @@ -5303,8 +5315,7 @@ background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,sto - color:#ffffff; -background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,stop: 1 #859398); + MINOR STORM @@ -5330,8 +5341,7 @@ background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,sto - color:#ffffff; -background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,stop: 1 #859398); + ACTIVE @@ -5357,8 +5367,7 @@ background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,sto - color:#ffffff; -background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,stop: 1 #859398); + UNSETTLED @@ -5384,8 +5393,7 @@ background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,sto - color:#ffffff; -background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,stop: 1 #859398); + QUIET @@ -5411,8 +5419,7 @@ background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,sto - color:#ffffff; -background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,stop: 1 #859398); + VERY QUIET @@ -5438,8 +5445,7 @@ background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,sto - color:#ffffff; -background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,stop: 1 #859398); + INACTIVE @@ -5480,8 +5486,7 @@ background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,sto - color:#ffffff; -background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,stop: 1 #859398); + SEVERE STORM @@ -5507,8 +5512,7 @@ background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,sto - color:#ffffff; -background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,stop: 1 #859398); + MAJOR STORM @@ -5534,8 +5538,7 @@ background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,sto - color:#ffffff; -background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,stop: 1 #859398); + MINOR STORM @@ -5561,8 +5564,7 @@ background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,sto - color:#ffffff; -background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,stop: 1 #859398); + ACTIVE @@ -5588,8 +5590,7 @@ background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,sto - color:#ffffff; -background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,stop: 1 #859398); + UNSETTLED @@ -5615,8 +5616,7 @@ background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,sto - color:#ffffff; -background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,stop: 1 #859398); + QUIET @@ -5668,7 +5668,7 @@ background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,sto - - + N/A @@ -5713,7 +5713,7 @@ background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,sto - - + N/A @@ -6083,7 +6083,7 @@ background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,sto - - + N/A Qt::AlignCenter @@ -6095,22 +6095,6 @@ background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,sto - - - - QFrame::Sunken - - - 1 - - - 0 - - - Qt::Vertical - - - @@ -6136,478 +6120,530 @@ background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,sto - - - - 0 - 0 - - - - - 0 - - - - - - 0 - 0 - + + + + + + 0 + 0 + + + + + 9 - - - 11 - true - + + 0 - - E.M.E - - - - - - - - 0 - 0 - - - - - 11 - true - - - - Meteor Scatter - - - - - - - - 0 - 0 - - - - - 11 - true - - - - M.U.F. - - - - - - - - 0 - 0 - - - - - 11 - true - - - - Hystorical Index - - - - - - - - 0 - 0 - - - - - 11 - true - - - - 50 MHz in EU - - - - - - - - 0 - 0 - - - - - 11 - true - - - - 70 MHz in EU - - - - - - - - 0 - 0 - - - - - 11 - true - - - - 144 MHz in EU - - - - - - - - 0 - 0 - - - - - 11 - true - - - - 144 MHz in NA - - - - - - - - 0 - 0 - - - - - 11 - true - - - - VHF Aurora - - - - - - - - 0 - 0 - - - - - - - - 0 - 0 - - - - - 12 - 75 - true - - - - Qt::NoFocus - - - color:#ffffff; -background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,stop: 1 #859398); - - - OFF - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - 0 - - - 12 - - - - - - - - 0 - 0 - - - - - 12 - 75 - true - - - - color:#ffffff; -background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,stop: 1 #859398); - - - OFF - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - 12 - - - - - - - - 0 - 0 - - - - - 12 - 75 - true - - - - color:#ffffff; -background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,stop: 1 #859398); - - - OFF - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - 12 - - - - - - - - 0 - 0 - - - - - 12 - 75 - true - - - - color:#ffffff; -background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,stop: 1 #859398); - - - OFF - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - 12 - - - - - - - - 0 - 0 - - - - - 12 - 75 - true - - - - color:#ffffff; -background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,stop: 1 #859398); - - - OFF - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - 12 - - - - - - - - 0 - 0 - - - - - 12 - 75 - true - - - - color:#ffffff; -background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,stop: 1 #859398); - - - OFF - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - 12 - - - - - - - - 0 - 0 - - - - - 12 - 75 - true - - - - color:#ffffff; -background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,stop: 1 #859398); - - - OFF - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - 12 - - - - - - - - 0 - 0 - - - - - 12 - 75 - true - - - - color:#ffffff; -background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,stop: 1 #859398); - - - OFF - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - 12 - - - - - - - - 0 - 0 - - - - - 12 - 75 - true - - - - color:#ffffff; -background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,stop: 1 #859398); - - - OFF - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - 12 - - - - - - - - + + + + + 0 + 0 + + + + + 13 + false + + + + E.M.E→ + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + 15 + + + + + + + + 0 + 0 + + + + + 13 + false + + + + 50 MHz in EU→ + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + 15 + + + + + + + + 0 + 0 + + + + + 13 + false + + + + VHF Aurora→ + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + 15 + + + + + + + + 0 + 0 + + + + + 13 + false + + + + Hystorical Index→ + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + 15 + + + + + + + + 0 + 0 + + + + + 13 + false + + + + 144 MHz in EU→ + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + 15 + + + + + + + + 0 + 0 + + + + + 13 + false + + + + M.U.F.→ + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + 15 + + + + + + + + 0 + 0 + + + + + 13 + false + + + + Meteor Scatter→ + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + 15 + + + + + + + + 0 + 0 + + + + + 13 + false + + + + 144 MHz in NA→ + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + 15 + + + + + + + + 0 + 0 + + + + + 13 + false + + + + 70 MHz in EU→ + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + 15 + + + + + + + + 0 + 0 + + + + + + + + 0 + 0 + + + + + 12 + 75 + true + + + + Qt::NoFocus + + + + + + NO DATA + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + 0 + + + 12 + + + + + + + + 0 + 0 + + + + + 12 + 75 + true + + + + + + + NO DATA + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + 12 + + + + + + + + 0 + 0 + + + + + 12 + 75 + true + + + + + + + NO DATA + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + 12 + + + + + + + + 0 + 0 + + + + + 12 + 75 + true + + + + + + + NO DATA + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + 12 + + + + + + + + 0 + 0 + + + + + 12 + 75 + true + + + + + + + NO DATA + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + 12 + + + + + + + + 0 + 0 + + + + + 12 + 75 + true + + + + + + + NO DATA + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + 12 + + + + + + + + 0 + 0 + + + + + 12 + 75 + true + + + + + + + NO DATA + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + 12 + + + + + + + + 0 + 0 + + + + + 12 + 75 + true + + + + + + + NO DATA + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + 12 + + + + + + + + 0 + 0 + + + + + 12 + 75 + true + + + + + + + NO DATA + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + 12 + + + + + + + + + + @@ -6681,7 +6717,7 @@ background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,sto - + 0 @@ -6690,17 +6726,20 @@ background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,sto - 13 + 10 75 true - + N/A Qt::AlignCenter + + 0 + diff --git a/constants.py b/constants.py index d52c367..559dc47 100644 --- a/constants.py +++ b/constants.py @@ -66,30 +66,6 @@ class Database(object): Signal.SUP_BAND, Signal.CATEGORY_CODE,) -class Colors(object): - RED_DARK = "#4d0000" - RED_LIGHT = "#ff0000" - RED2_DARK = "#4c0c00" - RED2_LIGHT = "#ff2700" - RED3_DARK = "#4b1100" - RED3_LIGHT = "#ff3a00" - ORANGE_DARK = "#4d2e00" - ORANGE_LIGHT = "#ffad33" - ORANGE2_DARK = "#4c2000" - ORANGE2_LIGHT = "#ff6c00" - GREEN_DARK = "#003300" - GREEN_LIGHT = "#33ff33" - GREEN2_DARK = "#424d00" - GREEN2_LIGHT = "#dcff00" - GREEN3_DARK = "#344d00" - GREEN3_LIGHT = "#aeff00" - BLUE_DARK = "#000033" - BLUE_LIGHT = "#3333ff" - WHITE_DARK = "#333333" - WHITE_LIGHT = "#d9b3ff" - YELLOW_DARK = "#333300" - YELLOW_LIGHT = "#ffff33" - class Constants(object): CLICK_TO_UPDATE_STR = "Click to update" UPDATING_STR = "Updating..." @@ -117,6 +93,9 @@ class Constants(object): AUDIO_FOLDER = "Audio" ACTIVE = "active" INACTIVE = "inactive" + LABEL_ON_COLOR = "on" + LABEL_OFF_COLOR = "off" + TEXT_COLOR = "text" NOT_AVAILABLE = "spectrumnotavailable.png" NOT_SELECTED = "nosignalselected.png" __Band = namedtuple("Band", ["lower", "upper"]) diff --git a/fixed_aspect_ratio_label.py b/fixed_aspect_ratio_label.py index e73103f..2461c29 100644 --- a/fixed_aspect_ratio_label.py +++ b/fixed_aspect_ratio_label.py @@ -1,14 +1,27 @@ from PyQt5.QtWidgets import QLabel -from PyQt5.QtCore import QSize, Qt +from PyQt5.QtCore import Qt class FixedAspectRatioLabel(QLabel): def __init__(self, parent = None): super().__init__(parent) self.pixmap = None - def rescale(self, w, h): - self.resize(QSize(w, h)) + def set_default_stylesheet(self): + self.setStyleSheet(""" + color: #ffffff; + background-color: #666666; + """) + + def make_transparent(self): + self.setText('') + self.setStyleSheet("background-color: transparent;") + + def apply_pixmap(self): if self.pixmap: self.setPixmap( self.pixmap.scaled( self.size(), Qt.IgnoreAspectRatio, Qt.SmoothTransformation)) + + def rescale(self, size): + self.resize(size) + self.apply_pixmap() diff --git a/fixed_aspect_ratio_widget.py b/fixed_aspect_ratio_widget.py index a867899..71e78f9 100644 --- a/fixed_aspect_ratio_widget.py +++ b/fixed_aspect_ratio_widget.py @@ -1,4 +1,5 @@ from PyQt5.QtWidgets import QWidget +from PyQt5.QtCore import QSize class FixedAspectRatioWidget(QWidget): space = 10 @@ -16,4 +17,4 @@ class FixedAspectRatioWidget(QWidget): h_lbl = h / 9 - self.space for label in self.labels: - label.rescale(w_lbl, h_lbl) + label.rescale(QSize(w_lbl, h_lbl)) diff --git a/switchable_label.py b/switchable_label.py index 5d32e89..c4f6f12 100644 --- a/switchable_label.py +++ b/switchable_label.py @@ -3,32 +3,26 @@ from PyQt5.QtWidgets import QLabel class SwitchableLabel(QLabel): def __init__(self, parent = None): super().__init__(parent) - self.switch_on_color = None - self.switch_off_color = None - - def set_colors(self, on, off): - self.switch_on_color = on - self.switch_off_color = off + self.switch_on_colors = () + self.switch_off_colors = () + self.text_color = '' + self.is_on = False def switch_on(self): - if self.switch_on_color and self.switch_off_color: - self.setStyleSheet(f"""background-color: {self.switch_on_color}; - color:#000000;""") - else: - self.setStyleSheet(""" - color:#ffffff; - background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #4776e6 ,stop: 1 #8e54e9); - """) + self.is_on = True + self.__apply_colors(*self.switch_on_colors) def switch_off(self): - if self.switch_on_color and self.switch_off_color: - self.setStyleSheet(f"""background-color: {self.switch_off_color}; - color:#000000;""") - else: - self.setStyleSheet(""" - color:#ffffff; - background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,stop: 1 #859398); - """) + self.is_on = False + self.__apply_colors(*self.switch_off_colors) + + def __apply_colors(self, start, end): + self.setStyleSheet( + f""" + color:{self.text_color}; + background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 {start} ,stop: 1 {end}); + """ + ) class SwitchableLabelsIterable(object): @@ -49,3 +43,14 @@ class SwitchableLabelsIterable(object): def switch_off_all(self): for lab in self.labels: lab.switch_off() + + def set(self, attr, value): + for lab in self.labels: + setattr(lab, attr, value) + + def refresh(self): + for lab in self.labels: + if lab.is_on: + lab.switch_on() + else: + lab.switch_off() diff --git a/themes.py b/themes.py index 8d9f419..c3db60b 100644 --- a/themes.py +++ b/themes.py @@ -1,10 +1,12 @@ from functools import partial +from itertools import chain import os import re from PyQt5.QtWidgets import QAction, QActionGroup from PyQt5.QtCore import pyqtSlot from PyQt5.QtGui import QPixmap from constants import Constants +from switchable_label import SwitchableLabelsIterable from utilities import pop_up class ThemeConstants(object): @@ -15,8 +17,11 @@ class ThemeConstants(object): CURRENT = ".current_theme" COLORS = "colors.txt" COLOR_SEPARATOR = "=" - DEFAULT_ACTIVE_COLOR = "#39eaff" + DEFAULT_ACTIVE_COLOR = "#000000" DEFAULT_INACTIVE_COLOR = "#9f9f9f" + DEFAULT_OFF_COLORS = "#000000", "#434343" + DEFAULT_ON_COLORS = "#4b79a1", "#283e51" + DEFAULT_TEXT_COLOR = "#ffffff" THEME_NOT_FOUND = "Theme not found" MISSING_THEME = "Missing theme in '" + FOLDER + "' folder." @@ -25,10 +30,25 @@ class Theme(object): self.__parent = parent self.__parent.active_color = ThemeConstants.DEFAULT_ACTIVE_COLOR self.__parent.inactive_color = ThemeConstants.DEFAULT_INACTIVE_COLOR - self.__theme_path = ThemeConstants.DEFAULT + + self.__theme_path = "" + self.__current_theme = "" + self.__parent.default_images_folder = os.path.join(ThemeConstants.FOLDER, ThemeConstants.DEFAULT, ThemeConstants.ICONS_FOLDER) + + self.__forecast_labels = SwitchableLabelsIterable(*list(chain(self.__parent.switchable_r_labels, + self.__parent.switchable_s_labels, + self.__parent.switchable_g_now_labels, + self.__parent.switchable_g_today_labels, + self.__parent.k_storm_labels, + self.__parent.a_storm_labels, + [self.__parent.expected_noise_lbl]))) + + self.__forecast_labels.set("switch_on_colors", ThemeConstants.DEFAULT_ON_COLORS) + self.__forecast_labels.set("switch_off_colors", ThemeConstants.DEFAULT_OFF_COLORS) + self.__theme_names = {} self.__detect_themes() @@ -43,6 +63,7 @@ class Theme(object): self.__parent.upper_band_filter_unit, self.__parent.upper_band_confidence, self.__parent.band_range_lbl) + self.__parent.set_band_filter_label(self.__parent.activate_low_freq_filter_btn, self.__parent.lower_freq_spinbox, self.__parent.lower_freq_filter_unit, @@ -56,10 +77,12 @@ class Theme(object): @pyqtSlot() def __apply(self, theme_path): self.__theme_path = theme_path - self.__change() - self.__parent.display_specs(self.__parent.result_list.currentItem(), None) - self.__refresh_range_labels() - self.__parent.audio_widget.refresh_btns_colors(self.__parent.active_color, self.__parent.inactive_color) + if self.__theme_path != self.__current_theme: + self.__change() + self.__parent.display_specs(self.__parent.result_list.currentItem(), None) + self.__refresh_range_labels() + self.__parent.audio_widget.refresh_btns_colors(self.__parent.active_color, self.__parent.inactive_color) + self.__forecast_labels.refresh() def __pretty_name(self, bad_name): return ' '.join( @@ -135,28 +158,53 @@ class Theme(object): path_to_colors = os.path.join(self.__theme_path, ThemeConstants.COLORS) active_color_ok = False inactive_color_ok = False - valid_format = False - valid_file = False + switch_on_color_ok = False + switch_off_color_ok = False + text_color_ok = False + if os.path.exists(path_to_colors): - valid_file = True + is_valid_html_color = lambda colors : all([bool(re.match("#([a-zA-Z0-9]){6}", color)) for color in colors]) with open(path_to_colors, "r") as colors_file: for line in colors_file: if ThemeConstants.COLOR_SEPARATOR in line: - valid_format = True quality, color = line.split(ThemeConstants.COLOR_SEPARATOR) color = color.rstrip() - is_valid_html_color = lambda color : bool(re.match("#([a-zA-Z0-9]){6}", color)) - if quality.lower() == Constants.ACTIVE and is_valid_html_color(color): - self.__parent.active_color = color - active_color_ok = True - if quality.lower() == Constants.INACTIVE and is_valid_html_color(color): - self.__parent.inactive_color = color - inactive_color_ok = True + if ',' in color: + color = [c.rstrip().lstrip() for c in color.split(',')] + else: + color = [color] + if len(color) > 2: + break + if is_valid_html_color(color): + if quality.lower() == Constants.ACTIVE: + self.__parent.active_color = color[0] + active_color_ok = True + if quality.lower() == Constants.INACTIVE: + self.__parent.inactive_color = color[0] + inactive_color_ok = True + if quality.lower() == Constants.LABEL_ON_COLOR: + switch_on_color_ok = True + self.__forecast_labels.set("switch_on_colors", color) + if quality.lower() == Constants.LABEL_OFF_COLOR: + switch_off_color_ok = True + self.__forecast_labels.set("switch_off_colors", color) + if quality.lower() == Constants.TEXT_COLOR: + text_color_ok = True + self.__forecast_labels.set("text_color", color[0]) - if not all([valid_file, valid_format, active_color_ok, inactive_color_ok]): + if not (active_color_ok and inactive_color_ok): self.__parent.active_color = ThemeConstants.DEFAULT_ACTIVE_COLOR self.__parent.inactive_color = ThemeConstants.DEFAULT_INACTIVE_COLOR + if not (switch_on_color_ok and switch_off_color_ok): + for label in self.__forecast_labels: + label.switch_on_colors = ThemeConstants.DEFAULT_ON_COLORS + label.switch_off_colors = ThemeConstants.DEFAULT_OFF_COLORS + + if not text_color_ok: + self.__forecast_labels.set("text_color", ThemeConstants.DEFAULT_TEXT_COLOR) + self.__current_theme = self.__theme_path + try: with open(os.path.join(ThemeConstants.FOLDER, ThemeConstants.CURRENT), "w") as current_theme: @@ -171,7 +219,7 @@ class Theme(object): theme_path = current_theme_path.read() theme_name = self.__pretty_name(os.path.basename(theme_path)) self.__theme_names[theme_name].setChecked(True) - if theme_path != ThemeConstants.DEFAULT: - self.__apply(theme_path) + self.__apply(theme_path) else: self.__theme_names[self.__pretty_name(ThemeConstants.DEFAULT)].setChecked(True) + self.__apply(os.path.join(ThemeConstants.FOLDER, ThemeConstants.DEFAULT)) diff --git a/themes/2-dark/colors.txt b/themes/2-dark/colors.txt index 6050d7d..784707f 100644 --- a/themes/2-dark/colors.txt +++ b/themes/2-dark/colors.txt @@ -1,2 +1,5 @@ -active=#4da6ff +active=#4545e5 inactive=#546E7A +off=#283048,#859398 +on=#4776e6, #8e54e9 +text=#ffffff diff --git a/themes/3-material_design_dark/colors.txt b/themes/3-material_design_dark/colors.txt index 7c4ba0a..40ab6c1 100644 --- a/themes/3-material_design_dark/colors.txt +++ b/themes/3-material_design_dark/colors.txt @@ -1,2 +1,4 @@ active=#88cc00 inactive=#546E7A +off=#304352,#d7d2cc +on=#3ca55c,#b5ac49 diff --git a/themes/4-material_design_light/colors.txt b/themes/4-material_design_light/colors.txt index c1bccbe..29e38f6 100644 --- a/themes/4-material_design_light/colors.txt +++ b/themes/4-material_design_light/colors.txt @@ -1,2 +1,4 @@ active=#6ECE12 inactive=#b3b3cc +off=#948e99,#2e1437 +on=#b993d6,#8ca6db