def __init__(self,
                 config,
                 credential_file=None,
                 cookie_persistence=False,
                 authentication_success_callback=None,
                 authentication_failure_callback=None,
                 log_level=logging.INFO):
        super(AuthWindow, self).__init__()
        self.config = config
        self.log_level = log_level
        self.credential_file = credential_file if credential_file else DEFAULT_CREDENTIAL_FILE
        self.cookie_persistence = cookie_persistence
        self.authentication_success_callback = \
            self.successCallback if not authentication_success_callback else authentication_success_callback
        self.authentication_failure_callback = \
            self.failureCallback if not authentication_failure_callback else authentication_failure_callback
        self.window_icon = QIcon(":/images/keys.png")
        qApp.setWindowIcon(QIcon(self.window_icon))
        self.systemTrayIcon = QSystemTrayIcon(self)
        self.systemTrayIcon.setIcon(self.window_icon)
        self.systemTrayIcon.setVisible(True)
        self.systemTrayIcon.activated.connect(self.on_systemTrayIcon_activated)

        if not self.config:
            self.config = read_config(DEFAULT_CONFIG_FILE,
                                      create_default=True,
                                      default=DEFAULT_CONFIG)
        self.ui = AuthWindowUI(self)
        self.hide()
        self.populateServerList()
        self.show()
        self.on_actionLogin_triggered()
        qApp.aboutToQuit.connect(self.logout)
示例#2
0
 def __init__(self, settings: QSettings, parent=None):
     super(TVLinker, self).__init__(parent)
     self.firstrun = True
     self.rows, self.cols = 0, 0
     self.parent = parent
     self.settings = settings
     self.taskbar = TaskbarProgress(self)
     self.init_styles()
     self.init_settings()
     self.init_icons()
     if sys.platform.startswith('linux'):
         notify.init(qApp.applicationName())
     layout = QVBoxLayout()
     layout.setSpacing(0)
     layout.setContentsMargins(15, 15, 15, 0)
     form_groupbox = QGroupBox(self, objectName='mainForm')
     form_groupbox.setLayout(self.init_form())
     self.table = TVLinkerTable(0, 4, self)
     self.table.doubleClicked.connect(self.show_hosters)
     layout.addWidget(form_groupbox)
     layout.addWidget(self.table)
     layout.addLayout(self.init_metabar())
     self.setLayout(layout)
     qApp.setWindowIcon(self.icon_app)
     self.resize(FixedSettings.windowSize)
     self.show()
     self.start_scraping()
     self.firstrun = False
示例#3
0
 def init_cutter(self) -> None:
     self.cutter = VideoCutter(self)
     self.cutter.errorOccurred.connect(self.errorHandler)
     # qApp.setWindowIcon(QIcon(':/images/vidcutter.png'))
     qApp.setWindowIcon(
         QIcon.fromTheme(qApp.applicationName().lower(),
                         QIcon(':/images/vidcutter.png')))
     self.setCentralWidget(self.cutter)
示例#4
0
    def __init__(self):
        icon_path = os.path.join(RESOURCES_DIR, 'icons', 'app_icon.png')
        qApp.setWindowIcon(QtGui.QIcon(icon_path))

        if not os.path.exists(PROJECTS_DIR):
            os.mkdir(PROJECTS_DIR)
        if not os.path.exists(SETTINGS_DIR):
            self.createSettingsFile()

        self.loadSettings()
        self.sw = StarterWindow(self)
        self.mw = None
示例#5
0
def qinputbox_string(text, resource=":/reusingcode/qmessagebox"):
    m = QInputDialog()
    qApp.setWindowIcon(
        QIcon(resource)
    )  #In windows m.setWindowIcon fails, so I need o set qApp window
    text, ok_pressed = m.getText(
        None, QApplication.translate("Reusing", "Enter a string"), text,
        QLineEdit.Normal)
    if ok_pressed is True:
        return text
    else:
        return None
示例#6
0
def run():
    app = QApplication(sys.argv)
    app.setOrganizationName("manuskript")
    app.setOrganizationDomain("www.theologeek.ch")
    app.setApplicationName("manuskript")
    app.setApplicationVersion(_version)

    icon = QIcon()
    for i in [16, 31, 64, 128, 256, 512]:
        icon.addFile(appPath("icons/Manuskript/icon-{}px.png".format(i)))
    qApp.setWindowIcon(icon)

    app.setStyle("Fusion")

    # Load style from QSettings
    settings = QSettings(app.organizationName(), app.applicationName())
    if settings.contains("applicationStyle"):
        style = settings.value("applicationStyle")
        app.setStyle(style)

    # Translation process
    locale = QLocale.system().name()

    appTranslator = QTranslator()
    # By default: locale
    translation = appPath(
        os.path.join("i18n", "manuskript_{}.qm".format(locale)))

    # Load translation from settings
    if settings.contains("applicationTranslation"):
        translation = appPath(
            os.path.join("i18n", settings.value("applicationTranslation")))
        print("Found translation in settings:", translation)

    if appTranslator.load(translation):
        app.installTranslator(appTranslator)
        print(app.tr("Loaded translation: {}.").format(translation))

    else:
        print(
            app.tr("Warning: failed to load translator for locale {}...").
            format(locale))

    QIcon.setThemeSearchPaths(QIcon.themeSearchPaths() + [appPath("icons")])
    QIcon.setThemeName("NumixMsk")
    # qApp.setWindowIcon(QIcon.fromTheme("im-aim"))

    # Seperating launch to avoid segfault, so it seem.
    # Cf. http://stackoverflow.com/questions/12433491/is-this-pyqt-4-python-bug-or-wrongly-behaving-code
    launch()
示例#7
0
def qinputbox_decimal(text, resource=":/reusingcode/qmessagebox"):
    while True:
        m = QInputDialog()
        qApp.setWindowIcon(
            QIcon(resource)
        )  #In windows m.setWindowIcon fails, so I need o set qApp window
        text, ok_pressed = m.getText(
            None, QApplication.translate("Reusing", "Enter a number"), text,
            QLineEdit.Normal)
        if ok_pressed is True:
            try:
                return Decimal(text)
            except:
                pass
        else:
            return None
示例#8
0
def run():
    app = QApplication(sys.argv)
    app.setOrganizationName("manuskript")
    app.setOrganizationDomain("www.theologeek.ch")
    app.setApplicationName("manuskript")
    app.setApplicationVersion(_version)

    icon = QIcon()
    for i in [16, 31, 64, 128, 256, 512]:
        icon.addFile(appPath("icons/Manuskript/icon-{}px.png".format(i)))
    qApp.setWindowIcon(icon)

    app.setStyle("Fusion")

    # Load style from QSettings
    settings = QSettings(app.organizationName(), app.applicationName())
    if settings.contains("applicationStyle"):
        style = settings.value("applicationStyle")
        app.setStyle(style)

    # Translation process
    locale = QLocale.system().name()

    appTranslator = QTranslator()
    # By default: locale
    translation = appPath(os.path.join("i18n", "manuskript_{}.qm".format(locale)))

    # Load translation from settings
    if settings.contains("applicationTranslation"):
        translation = appPath(os.path.join("i18n", settings.value("applicationTranslation")))
        print("Found translation in settings:", translation)

    if appTranslator.load(translation):
        app.installTranslator(appTranslator)
        print(app.tr("Loaded translation: {}.").format(translation))

    else:
        print(app.tr("Warning: failed to load translator for locale {}...").format(locale))

    QIcon.setThemeSearchPaths(QIcon.themeSearchPaths() + [appPath("icons")])
    QIcon.setThemeName("NumixMsk")
    # qApp.setWindowIcon(QIcon.fromTheme("im-aim"))

    # Seperating launch to avoid segfault, so it seem.
    # Cf. http://stackoverflow.com/questions/12433491/is-this-pyqt-4-python-bug-or-wrongly-behaving-code
    launch()
示例#9
0
 def init_cutter(self) -> None:
     self.cutter = VideoCutter(self)
     self.cutter.errorOccurred.connect(self.errorHandler)
     self.setCentralWidget(self.cutter)
     qApp.setWindowIcon(VideoCutter.getAppIcon(encoded=False))
示例#10
0
def prepare(tests=False):
    app = QApplication(sys.argv)
    app.setOrganizationName("manuskript" + ("_tests" if tests else ""))
    app.setOrganizationDomain("www.theologeek.ch")
    app.setApplicationName("manuskript" + ("_tests" if tests else ""))
    app.setApplicationVersion(getVersion())

    print("Running manuskript version {}.".format(getVersion()))
    icon = QIcon()
    for i in [16, 32, 64, 128, 256, 512]:
        icon.addFile(appPath("icons/Manuskript/icon-{}px.png".format(i)))
    qApp.setWindowIcon(icon)

    app.setStyle("Fusion")

    # Load style from QSettings
    settings = QSettings(app.organizationName(), app.applicationName())
    if settings.contains("applicationStyle"):
        style = settings.value("applicationStyle")
        app.setStyle(style)

    # Translation process
    appTranslator = QTranslator(app)

    # By default: locale

    def tryLoadTranslation(translation, source):
        """Tries to load and activate a given translation for use."""
        if appTranslator.load(translation, appPath("i18n")):
            app.installTranslator(appTranslator)
            print("Loaded translation: {}".format(translation))
            # Note: QTranslator.load() does some fancy heuristics where it simplifies
            #   the given locale until it is 'close enough' if the given filename does
            #   not work out. For example, if given 'i18n/manuskript_en_US.qm', it tries:
            #      * i18n/manuskript_en_US.qm.qm
            #      * i18n/manuskript_en_US.qm
            #      * i18n/manuskript_en_US
            #      * i18n/manuskript_en.qm
            #      * i18n/manuskript_en
            #      * i18n/manuskript.qm
            #      * i18n/manuskript
            #   We have no way to determining what it eventually went with, so mind your
            #   filenames when you observe strange behaviour with the loaded translations.
            return True
        else:
            print("No translation found or loaded. ({})".format(translation))
            return False

    def activateTranslation(translation, source):
        """Loads the most suitable translation based on the available information."""
        using_builtin_translation = True

        if (translation !=
                ""):  # empty string == 'no translation, use builtin'
            if isinstance(translation, str):
                if tryLoadTranslation(translation, source):
                    using_builtin_translation = False
            else:  # A list of language codes to try. Once something works, we're done.
                # This logic is loosely based on the working of QTranslator.load(QLocale, ...);
                # it allows us to more accurately detect the language used for the user interface.
                for language_code in translation:
                    lc = language_code.replace('-', '_')
                    if lc.lower() == 'en_US'.lower():
                        break
                    if tryLoadTranslation("manuskript_{}.qm".format(lc),
                                          source):
                        using_builtin_translation = False
                        break

        if using_builtin_translation:
            print("Using the builtin translation.")

    # Load application translation
    translation = ""
    source = "default"
    if settings.contains("applicationTranslation"):
        # Use the language configured by the user.
        translation = settings.value("applicationTranslation")
        source = "user setting"
    else:
        # Auto-detect based on system locale.
        translation = QLocale().uiLanguages()
        source = "available ui languages"

    print("Preferred translation: {} (based on {})".format(
        ("builtin" if translation == "" else translation), source))
    activateTranslation(translation, source)

    def respectSystemDarkThemeSetting():
        """Adjusts the Qt theme to match the OS 'dark theme' setting configured by the user."""
        if platform.system() is not 'Windows':
            return

        # Basic Windows 10 Dark Theme support.
        # Source: https://forum.qt.io/topic/101391/windows-10-dark-theme/4
        themeSettings = QSettings(
            "HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize",
            QSettings.NativeFormat)
        if themeSettings.value("AppsUseLightTheme") == 0:
            darkPalette = QPalette()
            darkColor = QColor(45, 45, 45)
            disabledColor = QColor(127, 127, 127)
            darkPalette.setColor(QPalette.Window, darkColor)
            darkPalette.setColor(QPalette.WindowText, Qt.GlobalColor.white)
            darkPalette.setColor(QPalette.Base, QColor(18, 18, 18))
            darkPalette.setColor(QPalette.AlternateBase, darkColor)
            darkPalette.setColor(QPalette.ToolTipBase, Qt.GlobalColor.white)
            darkPalette.setColor(QPalette.ToolTipText, Qt.GlobalColor.white)
            darkPalette.setColor(QPalette.Text, Qt.GlobalColor.white)
            darkPalette.setColor(QPalette.Disabled, QPalette.Text,
                                 disabledColor)
            darkPalette.setColor(QPalette.Button, darkColor)
            darkPalette.setColor(QPalette.ButtonText, Qt.GlobalColor.white)
            darkPalette.setColor(QPalette.Disabled, QPalette.ButtonText,
                                 disabledColor)
            darkPalette.setColor(QPalette.BrightText, Qt.GlobalColor.red)
            darkPalette.setColor(QPalette.Link, QColor(42, 130, 218))

            darkPalette.setColor(QPalette.Highlight, QColor(42, 130, 218))
            darkPalette.setColor(QPalette.HighlightedText,
                                 Qt.GlobalColor.black)
            darkPalette.setColor(QPalette.Disabled, QPalette.HighlightedText,
                                 disabledColor)

            # Fixes ugly (not to mention hard to read) disabled menu items.
            # Source: https://bugreports.qt.io/browse/QTBUG-10322?focusedCommentId=371060#comment-371060
            darkPalette.setColor(QPalette.Disabled, QPalette.Light,
                                 Qt.GlobalColor.transparent)

            app.setPalette(darkPalette)

            # This broke the Settings Dialog at one point... and then it stopped breaking it.
            # TODO: Why'd it break? Check if tooltips look OK... and if not, make them look OK.
            #app.setStyleSheet("QToolTip { color: #ffffff; background-color: #2a82da; border: 1px solid white; }")

    respectSystemDarkThemeSetting()

    QIcon.setThemeSearchPaths(QIcon.themeSearchPaths() + [appPath("icons")])
    QIcon.setThemeName("NumixMsk")

    # Font siue
    if settings.contains("appFontSize"):
        f = qApp.font()
        f.setPointSize(settings.value("appFontSize", type=int))
        app.setFont(f)

    # Main window
    from manuskript.mainWindow import MainWindow

    MW = MainWindow()
    # We store the system default cursor flash time to be able to restore it
    # later if necessary
    MW._defaultCursorFlashTime = qApp.cursorFlashTime()

    # Command line project
    if len(sys.argv) > 1 and sys.argv[1][-4:] == ".msk":
        if os.path.exists(sys.argv[1]):
            path = os.path.abspath(sys.argv[1])
            MW._autoLoadProject = path

    return app, MW
示例#11
0
文件: main.py 项目: sb7297/manuskript
def prepare(tests=False):
    app = QApplication(sys.argv)
    app.setOrganizationName("manuskript"+("_tests" if tests else ""))
    app.setOrganizationDomain("www.theologeek.ch")
    app.setApplicationName("manuskript"+("_tests" if tests else ""))
    app.setApplicationVersion(getVersion())

    print("Running manuskript version {}.".format(getVersion()))
    icon = QIcon()
    for i in [16, 32, 64, 128, 256, 512]:
        icon.addFile(appPath("icons/Manuskript/icon-{}px.png".format(i)))
    qApp.setWindowIcon(icon)

    app.setStyle("Fusion")

    # Load style from QSettings
    settings = QSettings(app.organizationName(), app.applicationName())
    if settings.contains("applicationStyle"):
        style = settings.value("applicationStyle")
        app.setStyle(style)

    # Translation process
    locale = QLocale.system().name()

    appTranslator = QTranslator(app)
    # By default: locale

    def extractLocale(filename):
        # len("manuskript_") = 13, len(".qm") = 3
        return filename[11:-3] if len(filename) >= 16 else ""

    def tryLoadTranslation(translation, source):
        if appTranslator.load(appPath(os.path.join("i18n", translation))):
            app.installTranslator(appTranslator)
            print(app.tr("Loaded translation from {}: {}.").format(source, translation))
            return True
        else:
            print(app.tr("Note: No translator found or loaded from {} for locale {}.").
                  format(source, extractLocale(translation)))
            return False

    # Load translation from settings
    translation = ""
    if settings.contains("applicationTranslation"):
        translation = settings.value("applicationTranslation")
        print("Found translation in settings:", translation)

    if (translation != "" and not tryLoadTranslation(translation, "settings")) or translation == "":
        # load from settings failed or not set, fallback
        translation = "manuskript_{}.qm".format(locale)
        tryLoadTranslation(translation, "system locale")

    QIcon.setThemeSearchPaths(QIcon.themeSearchPaths() + [appPath("icons")])
    QIcon.setThemeName("NumixMsk")

    # Font siue
    if settings.contains("appFontSize"):
        f = qApp.font()
        f.setPointSize(settings.value("appFontSize", type=int))
        app.setFont(f)

    # Main window
    from manuskript.mainWindow import MainWindow

    MW = MainWindow()
    # We store the system default cursor flash time to be able to restore it
    # later if necessary
    MW._defaultCursorFlashTime = qApp.cursorFlashTime()

    # Command line project
    if len(sys.argv) > 1 and sys.argv[1][-4:] == ".msk":
        if os.path.exists(sys.argv[1]):
            path = os.path.abspath(sys.argv[1])
            MW._autoLoadProject = path

    return app, MW
示例#12
0
文件: songeditor.py 项目: wugi/pyktv
#!/usr/bin/env python
"""Editor for the db

copyleft quekky
"""

import os
import sys

from PyQt5.QtGui import QIcon
from PyQt5.QtWidgets import QApplication, qApp

import settings
from editorui import EditorWindow

if __name__ == '__main__':
    settings.__init__()
    app = QApplication(sys.argv)
    qApp.setOrganizationName('pyktv')
    qApp.setApplicationName('songeditor')
    qApp.setWindowIcon(
        QIcon(os.path.join(settings.programDir, 'themes/pyktv.ico')))
    editor = EditorWindow()
    sys.exit(app.exec_())
示例#13
0
 def init_cutter(self) -> None:
     self.cutter = VideoCutter(self)
     qApp.setWindowIcon(self.cutter.appIcon)
     self.setCentralWidget(self.cutter)
示例#14
0
    def settings(self):
        return self._settings


# Main Function
if __name__ == '__main__':
    # Create main app
    sys.argv += ['--style', 'fusion']
    myApp = QGuiApplication(sys.argv)
    # Setting the application name and organisation
    # so that the default constructor of QSettings will
    # create an INI file on disk
    qApp.setApplicationName('Hamster-QML')
    qApp.setApplicationVersion(cVERSION)
    qApp.setOrganizationName('cjc')
    qApp.setWindowIcon(QIcon('../Resources/Images/hamster-gray_256.png'))
    # Setting the defaultf format for QSettins to be INI files.
    # I don't like stuff writing to the Registry on Windows...
    QSettings.setDefaultFormat(QSettings.IniFormat)
    # Register the Python type. Its URI is 'SortFilterModelPyQt', it's v1.0 and the type
    # will be called 'SortFilterModelPyQt' in QML.
    qmlRegisterType(SortFilterModelPyQt, 'SortFilterModelPyQt', 1, 0,
                    'SortFilterModelPyQt')
    # Create the QML Engine
    engine = QQmlApplicationEngine()
    engine.addImageProvider("images", ImageProvider())
    context = engine.rootContext()
    # Add the namespace as 'py' in the QML context. If this is done, one can
    # clearly see which objects are accessed from the python side.
    py = Namespace()
    context.setContextProperty('py', py)