Example #1
0
def main():
    if lock_file_validation:  # if lock_file is existed , it means persepolis is still running!
        # setting color_scheme and style
        # see palettes.py and setting.py

        persepolis_download_manager = PersepolisApplication(sys.argv)

        # setting organization name and domain and apllication name
        QCoreApplication.setOrganizationName('persepolis_download_manager')
        QCoreApplication.setApplicationName('persepolis')

        # Persepolis setting
        persepolis_download_manager.setting = QSettings()

        # getting user's desired font and style , ... from setting
        custom_font = persepolis_download_manager.setting.value(
            'settings/custom-font')
        font = persepolis_download_manager.setting.value('settings/font')
        font_size = int(
            persepolis_download_manager.setting.value('settings/font-size'))
        style = persepolis_download_manager.setting.value('settings/style')
        color_scheme = persepolis_download_manager.setting.value(
            'settings/color-scheme')

        persepolis_download_manager.setPersepolisStyle(style)

        persepolis_download_manager.setPersepolisFont(font, font_size,
                                                      custom_font)

        persepolis_download_manager.setPersepolisColorScheme(color_scheme)

        try:
            mainwindow = MainWindow(start_in_tray, persepolis_download_manager,
                                    persepolis_download_manager.setting)
            if start_in_tray == 'yes':
                mainwindow.hide()
            else:
                mainwindow.show()

        except Exception:
            from persepolis.scripts import logger
            error_message = str(traceback.format_exc())
            logger.sendToLog(error_message, "ERROR")

            # Resetting persepolis
            error_window = ErrorWindow(error_message)
            error_window.show()

        sys.exit(persepolis_download_manager.exec_())

    else:
        print('persepolis is still running')
        # this section warns user that program is still running and no need to run it again
        # and creating a file to notify mainwindow for showing
        if not ('link' in add_link_dictionary):
            show_window_file = os.path.join(persepolis_tmp, 'show-window')
            f = open(show_window_file, 'w')
            f.close()
        sys.exit(0)
Example #2
0
def main():
    # if lock_file is existed , it means persepolis is still running!
    if lock_file_validation:
        # run mainwindow

        # set color_scheme and style
        # see palettes.py and setting.py

        persepolis_download_manager = PersepolisApplication(sys.argv)

        # Enable High DPI display with PyQt5
        try:
            persepolis_download_manager.setAttribute(
                Qt.AA_EnableHighDpiScaling)
            if hasattr(QStyleFactory, 'AA_UseHighDpiPixmaps'):
                persepolis_download_manager.setAttribute(
                    Qt.AA_UseHighDpiPixmaps)
        except:
            from persepolis.scripts import logger

            # write error_message in log file.
            logger.sendToLog('Qt.AA_UseHighDpiPixmaps is not available!',
                             "ERROR")

        # set organization name and domain and apllication name
        QCoreApplication.setOrganizationName('persepolis_download_manager')
        QCoreApplication.setApplicationName('persepolis')

        # Persepolis setting
        persepolis_download_manager.setting = QSettings()

        # get user's desired font and style , ... from setting
        custom_font = persepolis_download_manager.setting.value(
            'settings/custom-font')
        font = persepolis_download_manager.setting.value('settings/font')
        font_size = int(
            persepolis_download_manager.setting.value('settings/font-size'))
        style = persepolis_download_manager.setting.value('settings/style')
        color_scheme = persepolis_download_manager.setting.value(
            'settings/color-scheme')
        ui_direction = persepolis_download_manager.setting.value(
            'ui_direction')

        # set style
        persepolis_download_manager.setPersepolisStyle(style)

        # set font
        persepolis_download_manager.setPersepolisFont(font, font_size,
                                                      custom_font)

        # set color_scheme
        persepolis_download_manager.setPersepolisColorScheme(color_scheme)

        # set ui direction
        if ui_direction == 'rtl':
            persepolis_download_manager.setLayoutDirection(Qt.RightToLeft)

        elif ui_direction in 'ltr':
            persepolis_download_manager.setLayoutDirection(Qt.LeftToRight)

        # run mainwindow
        try:
            mainwindow = MainWindow(start_in_tray, persepolis_download_manager,
                                    persepolis_download_manager.setting)
            if start_in_tray:
                mainwindow.hide()
            else:
                mainwindow.show()

        except Exception:
            from persepolis.scripts import logger
            error_message = str(traceback.format_exc())

            # write error_message in log file.
            logger.sendToLog(error_message, "ERROR")

            # Reset persepolis
            error_window = ErrorWindow(error_message)
            error_window.show()

        sys.exit(persepolis_download_manager.exec_())

    else:

        # this section warns user that program is still running and no need to run it again
        # and creating a file to notify mainwindow for showing itself!
        # (see CheckingThread in mainwindow.py for more information)
        if len(plugin_list) == 0:

            show_window_file = os.path.join(persepolis_tmp, 'show-window')
            f = open(show_window_file, 'w')
            f.close()

        sys.exit(0)
Example #3
0
def main():
    # if lock_file is existed , it means persepolis is still running!
    if lock_file_validation and (not (
        (args.parent_window or unkownargs) and browser_url == False) or
                                 ((args.parent_window or unkownargs)
                                  and start_persepolis_if_browser_executed)):

        # set QT_AUTO_SCREEN_SCALE_FACTOR to 1 for "high DPI displays"
        os.environ['QT_AUTO_SCREEN_SCALE_FACTOR'] = '1'

        # run mainwindow

        # set color_scheme and style
        # see palettes.py and setting.py

        # this line is added fot fixing persepolis view in HighDpi displays
        # more information at: https://doc.qt.io/qt-5/highdpi.html
        try:
            QApplication.setAttribute(Qt.AA_EnableHighDpiScaling)
        except:
            from persepolis.scripts import logger

            # write error_message in log file.
            logger.sendToLog('Qt.AA_EnableHighDpiScaling is not available!',
                             "ERROR")

        # create QApplication
        persepolis_download_manager = PersepolisApplication(sys.argv)

        # setQuitOnLastWindowClosed(False) is needed to prevent persepolis exiting,
        # when it's minimized in system tray.
        persepolis_download_manager.setQuitOnLastWindowClosed(False)

        # Enable High DPI display with PyQt5
        try:
            if hasattr(QStyleFactory, 'AA_UseHighDpiPixmaps'):
                persepolis_download_manager.setAttribute(
                    Qt.AA_UseHighDpiPixmaps)
        except:
            from persepolis.scripts import logger

            # write error_message in log file.
            logger.sendToLog('Qt.AA_UseHighDpiPixmaps is not available!',
                             "ERROR")

        # set organization name and domain and application name
        QCoreApplication.setOrganizationName('persepolis_download_manager')
        QCoreApplication.setApplicationName('persepolis')

        # Persepolis setting
        persepolis_download_manager.setting = QSettings()

        # get user's desired font and style , ... from setting
        custom_font = persepolis_download_manager.setting.value(
            'settings/custom-font')
        font = persepolis_download_manager.setting.value('settings/font')
        font_size = int(
            persepolis_download_manager.setting.value('settings/font-size'))
        style = persepolis_download_manager.setting.value('settings/style')
        color_scheme = persepolis_download_manager.setting.value(
            'settings/color-scheme')
        ui_direction = persepolis_download_manager.setting.value(
            'ui_direction')

        # set style
        persepolis_download_manager.setPersepolisStyle(style)

        # set font
        persepolis_download_manager.setPersepolisFont(font, font_size,
                                                      custom_font)

        # set color_scheme
        persepolis_download_manager.setPersepolisColorScheme(color_scheme)

        # set ui direction
        if ui_direction == 'rtl':
            persepolis_download_manager.setLayoutDirection(Qt.RightToLeft)

        elif ui_direction in 'ltr':
            persepolis_download_manager.setLayoutDirection(Qt.LeftToRight)

        # run mainwindow
        try:
            mainwindow = MainWindow(start_in_tray, persepolis_download_manager,
                                    persepolis_download_manager.setting)
            if start_in_tray:
                mainwindow.hide()
            else:
                mainwindow.show()

        except Exception:
            from persepolis.scripts import logger
            error_message = str(traceback.format_exc())

            # write error_message in log file.
            logger.sendToLog(error_message, "ERROR")

            # Reset persepolis
            error_window = ErrorWindow(error_message)
            error_window.show()

        sys.exit(persepolis_download_manager.exec_())

    elif not ((args.parent_window or unkownargs)):

        # this section warns user that program is still running and no need to run it again
        # and creating a file to notify mainwindow for showing itself!
        # (see CheckingThread in mainwindow.py for more information)
        if len(plugin_list) == 0:

            show_window_file = os.path.join(persepolis_tmp, 'show-window')
            f = open(show_window_file, 'w')
            f.close()

        sys.exit(0)
Example #4
0
def main():
    # if lock_file is existed , it means persepolis is still running!
    if lock_file_validation:  
        # run mainwindow

        # set color_scheme and style
        # see palettes.py and setting.py

        persepolis_download_manager = PersepolisApplication(sys.argv)

        # Enable High DPI display with PyQt5
        try:
            persepolis_download_manager.setAttribute(Qt.AA_EnableHighDpiScaling)
            if hasattr(QStyleFactory, 'AA_UseHighDpiPixmaps'):
                persepolis_download_manager.setAttribute(Qt.AA_UseHighDpiPixmaps)
        except:
            from persepolis.scripts import logger

            # write error_message in log file.
            logger.sendToLog('Qt.AA_UseHighDpiPixmaps is not available!', "ERROR")

        # set organization name and domain and apllication name
        QCoreApplication.setOrganizationName('persepolis_download_manager')
        QCoreApplication.setApplicationName('persepolis')

        # Persepolis setting
        persepolis_download_manager.setting = QSettings()


        # get user's desired font and style , ... from setting
        custom_font = persepolis_download_manager.setting.value('settings/custom-font')
        font = persepolis_download_manager.setting.value('settings/font')
        font_size = int(persepolis_download_manager.setting.value('settings/font-size'))
        style = persepolis_download_manager.setting.value('settings/style')
        color_scheme = persepolis_download_manager.setting.value('settings/color-scheme')
        ui_direction = persepolis_download_manager.setting.value('ui_direction')


        # set style
        persepolis_download_manager.setPersepolisStyle(style)

        # set font
        persepolis_download_manager.setPersepolisFont(font, font_size, custom_font)

        # set color_scheme
        persepolis_download_manager.setPersepolisColorScheme(color_scheme)

        
        # set ui direction
        if ui_direction == 'rtl':
            persepolis_download_manager.setLayoutDirection(Qt.RightToLeft)
        
        elif ui_direction in 'ltr':
            persepolis_download_manager.setLayoutDirection(Qt.LeftToRight)

        # run mainwindow
        try:
            mainwindow = MainWindow(start_in_tray, persepolis_download_manager, persepolis_download_manager.setting)
            if start_in_tray:
                mainwindow.hide()
            else:
                mainwindow.show()

        except Exception:
            from persepolis.scripts import logger
            error_message = str(traceback.format_exc())

            # write error_message in log file.
            logger.sendToLog(error_message, "ERROR")

            # Reset persepolis
            error_window = ErrorWindow(error_message)
            error_window.show()
         
        sys.exit(persepolis_download_manager.exec_())

    else:

    # this section warns user that program is still running and no need to run it again
    # and creating a file to notify mainwindow for showing itself!
    # (see CheckingThread in mainwindow.py for more information)
        if len(plugin_list) == 0:

            show_window_file = os.path.join(persepolis_tmp, 'show-window')
            f = open(show_window_file, 'w')
            f.close()

        sys.exit(0)
def main():
# if lock_file is existed , it means persepolis is still running!
    if lock_file_validation:  
    # run mainwindow

    # set color_scheme and style
    # see palettes.py and setting.py

        persepolis_download_manager = PersepolisApplication(sys.argv)

        # set organization name and domain and apllication name
        QCoreApplication.setOrganizationName('persepolis_download_manager')
        QCoreApplication.setApplicationName('persepolis')

        # Persepolis setting
        persepolis_download_manager.setting = QSettings()


        # get user's desired font and style , ... from setting
        custom_font = persepolis_download_manager.setting.value('settings/custom-font')
        font = persepolis_download_manager.setting.value('settings/font')
        font_size = int(persepolis_download_manager.setting.value('settings/font-size'))
        style = persepolis_download_manager.setting.value('settings/style')
        color_scheme = persepolis_download_manager.setting.value('settings/color-scheme')


        # set style
        persepolis_download_manager.setPersepolisStyle(style)

        # set font
        persepolis_download_manager.setPersepolisFont(font, font_size, custom_font)

        # set color_scheme
        persepolis_download_manager.setPersepolisColorScheme(color_scheme)

        # run mainwindow
        try:
            mainwindow = MainWindow(start_in_tray, persepolis_download_manager, persepolis_download_manager.setting)
            if start_in_tray == 'yes':
                mainwindow.hide()
            else:
                mainwindow.show()

        except Exception:
            from persepolis.scripts import logger
            error_message = str(traceback.format_exc())

            # write error_message in log file.
            logger.sendToLog(error_message, "ERROR")

            # Reset persepolis
            error_window = ErrorWindow(error_message)
            error_window.show()
         
        sys.exit(persepolis_download_manager.exec_())

    else:
        print('persepolis is still running')


    # this section warns user that program is still running and no need to run it again
    # and creating a file to notify mainwindow for showing itself!
    # (see CheckingThread in mainwindow.py for more information)
        if not('link' in add_link_dictionary):
            show_window_file = os.path.join(persepolis_tmp, 'show-window')
            f = open(show_window_file, 'w')
            f.close()

        sys.exit(0)