Merge pull request #808 from pypeclub/feature/settings_in_tray

Settings in tray
This commit is contained in:
Milan Kolar 2020-12-14 10:37:09 +01:00 committed by GitHub
commit 30f843839b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 70 additions and 10 deletions

View file

@ -7,7 +7,7 @@ from .base import (
ModulesManager,
TrayModulesManager
)
from .settings_module import SettingsModule
from .rest_api import (
RestApiModule,
IRestApi
@ -44,6 +44,8 @@ __all__ = (
"ModulesManager",
"TrayModulesManager",
"SettingsModule",
"UserModule",
"IUserModule",

View file

@ -390,7 +390,8 @@ class TrayModulesManager(ModulesManager):
"Avalon",
"Clockify",
"Standalone Publish",
"Logging"
"Logging",
"settings"
)
def __init__(self):

View file

@ -0,0 +1,53 @@
from . import PypeModule, ITrayModule
class SettingsModule(PypeModule, ITrayModule):
name = "settings"
def initialize(self, _modules_settings):
# This module is always enabled
self.enabled = True
# User role
# TODO should be changeable
self.user_role = "developer"
# Tray attributes
self.settings_window = None
def connect_with_modules(self, *_a, **_kw):
return
def create_settings_window(self):
if self.settings_window:
return
from pype.tools.settings import MainWidget
self.settings_window = MainWidget(self.user_role)
def show_settings_window(self):
if not self.settings_window:
raise AssertionError("Window is not initialized.")
self.settings_window.show()
# Pull window to the front.
self.settings_window.raise_()
self.settings_window.activateWindow()
def tray_init(self):
self.create_settings_window()
def tray_menu(self, tray_menu):
"""Add **change credentials** option to tray menu."""
from Qt import QtWidgets
# Actions
action = QtWidgets.QAction("Settings", tray_menu)
action.triggered.connect(self.show_settings_window)
tray_menu.addAction(action)
def tray_start(self):
return
def tray_exit(self):
return

View file

@ -80,10 +80,12 @@ def reset_default_settings():
def get_default_settings():
global _DEFAULT_SETTINGS
if _DEFAULT_SETTINGS is None:
_DEFAULT_SETTINGS = load_jsons_from_dir(DEFAULTS_DIR)
return copy.deepcopy(_DEFAULT_SETTINGS)
# TODO add cacher
return load_jsons_from_dir(DEFAULTS_DIR)
# global _DEFAULT_SETTINGS
# if _DEFAULT_SETTINGS is None:
# _DEFAULT_SETTINGS = load_jsons_from_dir(DEFAULTS_DIR)
# return copy.deepcopy(_DEFAULT_SETTINGS)
def load_json_file(fpath):

View file

@ -6,9 +6,6 @@ from Qt import QtWidgets, QtGui
if __name__ == "__main__":
app = QtWidgets.QApplication(sys.argv)
stylesheet = settings.style.load_stylesheet()
app.setStyleSheet(stylesheet)
app.setWindowIcon(QtGui.QIcon(settings.style.app_icon_path()))
_develop = "-d" in sys.argv or "--develop" in sys.argv

View file

@ -1,5 +1,6 @@
from Qt import QtWidgets
from Qt import QtWidgets, QtGui
from .base import SystemWidget, ProjectWidget
from .. import style
class MainWidget(QtWidgets.QWidget):
@ -13,6 +14,10 @@ class MainWidget(QtWidgets.QWidget):
self.resize(self.widget_width, self.widget_height)
stylesheet = style.load_stylesheet()
self.setStyleSheet(stylesheet)
self.setWindowIcon(QtGui.QIcon(style.app_icon_path()))
header_tab_widget = QtWidgets.QTabWidget(parent=self)
studio_widget = SystemWidget(user_role, header_tab_widget)