diff options
-rw-r--r-- | extras/UI_Handeler.py | 5 | ||||
-rw-r--r-- | extras/config.ini | 10 | ||||
-rw-r--r-- | extras/config.py | 34 | ||||
-rw-r--r-- | main.py | 9 |
4 files changed, 45 insertions, 13 deletions
diff --git a/extras/UI_Handeler.py b/extras/UI_Handeler.py index fa2c3a8..a44cf1a 100644 --- a/extras/UI_Handeler.py +++ b/extras/UI_Handeler.py @@ -32,6 +32,11 @@ block_subscription_updates = False class UI_Handeler(MainWindow): + def fullscreen(self): + self.headerContainer.hide() + self.setAttribute(QtCore.Qt.WA_TranslucentBackground, False) + self.showFullScreen() + def display_sending_message(self): print("message sent") diff --git a/extras/config.ini b/extras/config.ini index 1c367f9..54e3424 100644 --- a/extras/config.ini +++ b/extras/config.ini @@ -1,5 +1,15 @@ [default] preferred-config=user-session +fullscreen-mode=true + +[user-session] +ip = +port = +protocol = +insecure = +tls_server_name = +token = default +cacert = default # [cutom-config-template] # ip=<ip address> diff --git a/extras/config.py b/extras/config.py index 48a63e2..1a10719 100644 --- a/extras/config.py +++ b/extras/config.py @@ -52,21 +52,17 @@ GRPC_TOKEN_PATHS = check_paths( ) config = ConfigParser() -config_path = next( - (path for path, exists in CONFIG_PATHS.items() if exists), None) +config_path = next((path for path, exists in CONFIG_PATHS.items() if exists), None) if config_path: config.read(config_path) CA_PATH = next((path for path, exists in CA_PATHS.items() if exists), None) -WS_TOKEN = next( - (path for path, exists in WS_TOKEN_PATHS.items() if exists), None) -GRPC_TOKEN = next( - (path for path, exists in GRPC_TOKEN_PATHS.items() if exists), None) +WS_TOKEN = next((path for path, exists in WS_TOKEN_PATHS.items() if exists), None) +GRPC_TOKEN = next((path for path, exists in GRPC_TOKEN_PATHS.items() if exists), None) KUKSA_CONFIG = {} KUKSA_TOKEN = None - def select_config(preferred_config): """ Selects a configuration from the config.ini file based on the preferred_config parameter. @@ -131,8 +127,6 @@ def save_session_config(session_config, auth_token, CA_File=None): """ save values to config.ini under [user-session] """ - if not config.has_section('user-session'): - config.add_section('user-session') config.set('user-session', 'ip', str(session_config['ip'])) config.set('user-session', 'port', str(session_config['port'])) @@ -140,15 +134,33 @@ def save_session_config(session_config, auth_token, CA_File=None): config.set('user-session', 'insecure', str(session_config['insecure'])) config.set('user-session', 'tls_server_name', str(session_config['tls_server_name'])) - if auth_token in WS_TOKEN_PATHS or auth_token in GRPC_TOKEN_PATHS: + if auth_token in WS_TOKEN_PATHS or auth_token in GRPC_TOKEN_PATHS or auth_token == 'default': config.set('user-session', 'token', 'default') else: config.set('user-session', 'token', str(auth_token)) - if CA_File in CA_PATHS: + if CA_File in CA_PATHS or CA_File == 'default': config.set('user-session', 'cacert', 'default') else: config.set('user-session', 'cacert', str(CA_File)) with open(config_path, 'w') as configfile: config.write(configfile) + + +def fullscreen_mode(): + return config.getboolean('default', 'fullscreen-mode') + + +if not config.has_section('user-session'): + config.add_section('user-session') + temp = { + 'ip': "", + 'port': "", + 'protocol': "", + 'insecure': "", + 'cacert': "", + 'token': "", + 'tls_server_name': "", + } + save_session_config(temp, 'default', 'default')
\ No newline at end of file @@ -28,6 +28,8 @@ from PyQt5 import QtSvg from PyQt5.QtSvg import * from PyQt5.QtGui import QIcon +import extras.config as config + current_dir = os.path.dirname(os.path.abspath(__file__)) Form, Base = uic.loadUiType(os.path.join(current_dir, "Main_Window.ui")) @@ -55,6 +57,10 @@ class MainWindow(Base, Form): self.setAttribute(QtCore.Qt.WA_TranslucentBackground) self.setStyle(QtWidgets.QStyleFactory.create('Fusion')) + # set fullscreen mode if enabled in config.ini + if config.fullscreen_mode(): + UI_Handeler.fullscreen(self) + self.current_page = None self.headerContainer = self.findChild(QWidget, 'headerContainer') @@ -98,9 +104,8 @@ class MainWindow(Base, Form): self.settingsBtn) steering_icon = ":/Images/Images/steering-wheel.svg" - getsize = QtSvg.QSvgRenderer(steering_icon) svg_widget = QtSvg.QSvgWidget(steering_icon) - svg_widget.setFixedSize(getsize.defaultSize()) + svg_widget.setFixedSize(QtSvg.QSvgRenderer(steering_icon).defaultSize()) svg_widget.setStyleSheet("background-color: transparent;") self.steeringCtrlButton.setIcon(QIcon(svg_widget.grab())) |