def start_client(): """ Creates the Qt application and shows the main window. """ # create app app = QtWidgets.QApplication([]) # TODO multiple screen support? # test for desktop availability desktop = app.desktop() rect = desktop.screenGeometry() if rect.width() < constants.MINIMAL_SCREEN_SIZE[0] or rect.height() < constants.MINIMAL_SCREEN_SIZE[1]: # noinspection PyTypeChecker QtWidgets.QMessageBox.warning(None, 'Warning', 'Actual screen size below minimal screen size {}.'.format(constants.MINIMAL_SCREEN_SIZE)) return # if no bounds are set, set resonable bounds if tools.get_option(constants.Opt.MAINWINDOW_BOUNDS) is None: tools.set_option(constants.Opt.MAINWINDOW_BOUNDS, desktop.availableGeometry().adjusted(50, 50, -100, -100)) tools.set_option(constants.Opt.MAINWINDOW_MAXIMIZED, True) tools.log_info('No previous bounds of the main window stored, start maximized') # load global stylesheet to app with open(constants.GLOBAL_STYLESHEET_FILE, 'r', encoding='utf-8') as file: style_sheet = file.read() app.setStyleSheet(style_sheet) # setup sound system audio.load_soundtrack_playlist() audio.setup_soundtrack_player() # start audio player if wished if not tools.get_option(constants.Opt.SOUNDTRACK_MUTE): audio.soundtrack_player.play() pass # create client object and switch to start screen client = Client() client.switch_to_start_screen() tools.log_info('client initialized, start Qt app execution') # TODO is this necessary to run as event? # QtCore.QTimer.singleShot(0, network_start) app.exec_()
def start(): """ Creates the Qt application and shows the main window. """ # create app app = QtGui.QApplication([]) # TODO multiple screen support? # test for desktop availability desktop = app.desktop() rect = desktop.screenGeometry() if rect.width() < c.Screen_Min_Size[0] or rect.height() < c.Screen_Min_Size[1]: # noinspection PyTypeChecker QtGui.QMessageBox.warning(None, 'Warning', 'Actual screen size below minimal screen size {}.'.format(c.Screen_Min_Size)) return # if no bounds are set, set resonable bounds if t.get_option(c.O.MW_BOUNDS) is None: t.set_option(c.O.MW_BOUNDS, desktop.availableGeometry().adjusted(50, 50, -100, -100)) t.set_option(c.O.MW_MAXIMIZED, True) t.log_info('No previous bounds of the main window stored, start maximized') # load global stylesheet to app with open(c.Global_Stylesheet, 'r', encoding='utf-8') as file: style_sheet = file.read() app.setStyleSheet(style_sheet) # create client object and switch to start screen client = Client() client.switch_to_start_screen() t.log_info('client initialized, start Qt app execution') # TODO is this necessary to run as event? QtCore.QTimer.singleShot(0, network_start) app.exec_()
if not c.Debug_Mode: sys.stdout = codecs.open(Log_File, encoding='utf-8', mode='w') sys.stderr = codecs.open(Error_File, encoding='utf-8', mode='w') # import some base libraries from base import constants as c from base import tools as t # search for existing options file, if not existing, save it once (should just save an empty dictionary Options_File = os.path.join(User_Folder, 'options.info') if not os.path.exists(Options_File): t.save_options(Options_File) # create single options object, load options and send a log message t.load_options(Options_File) t.log_info('options loaded from user folder ({})'.format(User_Folder)) # test for phonon availability if t.get_option(c.O.PHONON_SUPPORTED): try: from PySide.phonon import Phonon except ImportError: t.log_error('Phonon backend not available, no sound.') t.set_option(c.O.PHONON_SUPPORTED, False) # special case of some desktop environments under Linux where full screen mode does not work well if t.get_option(c.O.FULLSCREEN_SUPPORTED): desktop_session = os.environ.get("DESKTOP_SESSION") if desktop_session and (desktop_session.startswith('ubuntu') or 'xfce' in desktop_session or desktop_session.startswith('xubuntu')
if not c.Debug_Mode: sys.stdout = codecs.open(Log_File, encoding='utf-8', mode='w') sys.stderr = codecs.open(Error_File, encoding='utf-8', mode='w') # import some base libraries from base import constants as c from base import tools as t # search for existing options file, if not existing, save it once (should just save an empty dictionary Options_File = os.path.join(User_Folder, 'options.info') if not os.path.exists(Options_File): t.save_options(Options_File) # create single options object, load options and send a log message t.load_options(Options_File) t.log_info('options loaded from user folder ({})'.format(User_Folder)) # test for phonon availability if t.get_option(c.O.PHONON_SUPPORTED): try: from PySide.phonon import Phonon except ImportError: t.log_error('Phonon backend not available, no sound.') t.set_option(c.O.PHONON_SUPPORTED, False) # special case of some desktop environments under Linux where full screen mode does not work well if t.get_option(c.O.FULLSCREEN_SUPPORTED): desktop_session = os.environ.get("DESKTOP_SESSION") if desktop_session and (desktop_session.startswith('ubuntu') or 'xfce' in desktop_session or desktop_session.startswith('xubuntu') or 'gnome' in desktop_session): t.set_option(c.O.FULLSCREEN_SUPPORTED, False)