Skip to content

Commit

Permalink
Improve window manager compatibility and theme file picker dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
justin025 committed Dec 20, 2024
1 parent 1f8924a commit df334d4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 20 deletions.
31 changes: 12 additions & 19 deletions src/onthespot/gui/mainui.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,10 @@ def get_icon(self, name):

def open_theme_dialog(self):
colorpicker = QColorDialog(self)
colorpicker.setStyleSheet(config.get('theme'))
colorpicker.setWindowFlag(Qt.WindowType.WindowStaysOnTopHint, True)
colorpicker.setWindowFlag(Qt.WindowType.Dialog, True)
colorpicker.setWindowTitle("OnTheSpot - Notice")
colorpicker.setStyleSheet(config.get('theme'))

if colorpicker.exec() == QColorDialog.DialogCode.Accepted:
color = colorpicker.selectedColor()
Expand Down Expand Up @@ -176,8 +178,8 @@ def bind_button_inputs(self):

self.btn_progress_retry_all.clicked.connect(self.retry_all_failed_downloads)
self.btn_progress_cancel_all.clicked.connect(self.cancel_all_downloads)
self.btn_download_root_browse.clicked.connect(self.__select_dir)
self.btn_download_tmp_browse.clicked.connect(self.__select_tmp_dir)
self.btn_download_root_browse.clicked.connect(lambda: self.select_dir(self.inp_download_root))
self.btn_download_tmp_browse.clicked.connect(lambda: self.select_dir(self.inp_tmp_dl_root))
self.inp_tmp_dl_root.textChanged.connect(self.update_tmp_dir)
self.inp_search_term.returnPressed.connect(self.fill_search_table)
self.btn_progress_clear_complete.clicked.connect(self.remove_completed_from_download_list)
Expand Down Expand Up @@ -246,18 +248,13 @@ def reset_app_config(self):
self.__show_popup_dialog("The application setting was cleared successfully !\n Please restart the application.")


def __select_dir(self):
dir_path = QFileDialog.getExistingDirectory(None, 'Select a folder:', os.path.expanduser("~"))
def select_dir(self, output):
self.setStyleSheet(config.get('theme'))
dir_path = QFileDialog.getExistingDirectory(self, 'OnTheSpot - Notice', os.path.expanduser("~"))
if dir_path.strip() != '':
self.inp_download_root.setText(QDir.toNativeSeparators(dir_path))
output.setText(QDir.toNativeSeparators(dir_path))


def __select_tmp_dir(self):
dir_path = QFileDialog.getExistingDirectory(None, 'Select a folder:', os.path.expanduser("~"))
if dir_path.strip() != '':
temp_path = QDir.toNativeSeparators(dir_path)
self.inp_tmp_dl_root.setText(temp_path)
temp_download_path.append(temp_path)

def update_tmp_dir(self):
temp_download_path.clear()
Expand Down Expand Up @@ -703,14 +700,10 @@ def add_apple_music_account_worker(self):
session = None
self.lb_login_password.setDisabled(True)
self.btn_login_add.setDisabled(True)

file_path, _ = QFileDialog.getOpenFileName(self, 'Select a file:', os.path.expanduser("~"), "Text Files (*.txt);;All Files (*);;")
self.select_dir(self.inp_login_password)
file_path = self.inp_login_password.text()
if file_path:
try:
self.inp_login_password.setText(os.path.normpath(file_path.strip()))
session = apple_music_add_account(os.path.normpath(file_path.strip()))
except (TypeError, AttributeError):
pass
session = apple_music_add_account(file_path)

if session:
config.set_('parsing_acc_sn', len(account_pool))
Expand Down
6 changes: 5 additions & 1 deletion src/onthespot/gui/minidialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import re
from PyQt6 import uic
from PyQt6.QtCore import Qt
from PyQt6.QtGui import QIcon
from PyQt6.QtWidgets import QDialog
from ..otsconfig import config
from ..runtimedata import get_logger
Expand All @@ -16,8 +17,11 @@ def __init__(self, parent=None):
self.path = os.path.dirname(os.path.realpath(__file__))
uic.loadUi(os.path.join(self.path, 'qtui', 'notice.ui'), self)
self.btn_close.clicked.connect(self.hide)
logger.debug('Dialog item is ready..')
self.setWindowIcon(QIcon(os.path.join(config.app_root, 'resources', 'icons', f'onthespot.png')))
self.setWindowFlag(Qt.WindowType.WindowStaysOnTopHint, True)
self.setWindowFlag(Qt.WindowType.Dialog, True)
self.setStyleSheet(config.get('theme'))
logger.debug('Dialog item is ready..')

self.lb_main.mousePressEvent = self.on_label_click

Expand Down

0 comments on commit df334d4

Please sign in to comment.