Beispiel #1
0
def setTranslationLocale():
    global locale
    lang = settings['Main'].get('lang')
    sysLocale = QLocale.system()
    if lang and lang == sysLocale.name():
        locale = sysLocale
    elif lang and lang != sysLocale.name():
        # special case: application language is different from system's
        locale = QLocale(lang)
        QLocale.setDefault(locale)
    else:
        locale = sysLocale
        lang = settings['Main']['lang'] = locale.name()
    langPath = os.path.join(appPath, 'lang')
    logging.info('set translation(%s)', lang)
    global _trans, _transQt  # avoid being collected
    _trans = QTranslator()
    _trans.load(lang, langPath)
    _transQt = QTranslator()
    ret = _transQt.load('qt_' + lang,
                        QLibraryInfo.location(QLibraryInfo.TranslationsPath))
    if not ret:  # frozen
        _transQt.load('qt_' + lang, langPath)
    for i in [_trans, _transQt]:
        QApplication.instance().installTranslator(i)

    global dateFmt, datetimeFmt, fullDatetimeFmt
    timeFmt = settings['Main'].get('timeFormat')
    dateFmt = settings['Main'].get('dateFormat', locale.dateFormat())
    datetimeFmt = (dateFmt + ' ' + timeFmt) if timeFmt else dateFmt
    # use hh:mm because locale.timeFormat will include seconds
    fullDatetimeFmt = dateFmt + ' ' + (timeFmt or 'hh:mm')
Beispiel #2
0
	def onLoad( self ):
		QLocale.setDefault(QLocale(QLocale.C))
		locale.setlocale(locale.LC_ALL, 'C')

		QCoreApplication.setOrganizationName("CloudTeam")
		QCoreApplication.setOrganizationDomain("cloudteam.pro")
		QCoreApplication.setApplicationName("juma-moai-editor")

		self.qtApp = QApplication( sys.argv )
		self.qtSetting = QSettings()
		
		self.setupMainWindow()		

		self.initialized = True
		self.running     = False

		return True
Beispiel #3
0
def main():

    # application specifics
    app = QApplication(sys.argv)

    # TODO: remove this, hardcoding it for testing
    QLocale.setDefault(QLocale(QLocale.Portuguese, QLocale.Brazil))

    # login dialog
    login_dialog = Login()
    if login_dialog.exec_() == QDialog.Accepted:
        # validation complete, open main interface
        window = MainWindow(login_dialog.get_user_data())
        window.showMaximized()
        # solves mainwindow focusing on windows/xfce
        app.setActiveWindow(window)
        # start main loop
        sys.exit(app.exec_())
Beispiel #4
0
def main():
    parser = argparse.ArgumentParser(
        description='Runs the inselect user-interface')
    parser.add_argument("file",
                        help='The inselect document to open',
                        nargs='?')
    parser.add_argument('-d',
                        '--debug',
                        action='store_true',
                        help='Show debug messages')
    parser.add_argument('-l',
                        '--locale',
                        action='store',
                        help='Use LOCALE; intended for testing purposes only')
    parser.add_argument('-v',
                        '--version',
                        action='version',
                        version='%(prog)s ' + inselect.__version__)
    args = parser.parse_args()

    # TODO LH A command-line switch to clear all QSettings

    inselect.lib.utils.DEBUG_PRINT = args.debug

    app = QApplication(sys.argv)

    debug_print(u'Settings stored in [{0}]'.format(QSettings().fileName()))

    if args.locale:
        debug_print('Will set locale to [{0}]'.format(args.locale))
        QLocale.setDefault(QLocale(args.locale))

    debug_print(u'Locale is [{0}]'.format(QLocale().name()))

    window = MainWindow(app)
    window.show_from_geometry_settings()

    if args.file:
        window.open_file(args.file)

    sys.exit(app.exec_())
Beispiel #5
0
def main(args):
    parser = argparse.ArgumentParser(description='Runs the inselect user-interface')
    parser.add_argument("file", help='The inselect document to open', nargs='?')
    parser.add_argument('-d', '--debug', action='store_true',
                        help='Show debug messages')
    parser.add_argument('-l', '--locale', action='store',
                        help='Use LOCALE; intended for testing purposes only')
    parser.add_argument('-v', '--version', action='version',
                        version='%(prog)s ' + inselect.__version__)
    parsed = parser.parse_args(args[1:])

    # TODO LH A command-line switch to clear all QSettings

    inselect.lib.utils.DEBUG_PRINT = parsed.debug

    # Only one instance of QApplication can be created per process. The single
    # instance is stored in QtGui.qApp. When test plans are being run it is
    # likely that the QApplication will have been created by a unittest.
    app = QtGui.qApp if QtGui.qApp else QtGui.QApplication(args)

    debug_print(u'Settings stored in [{0}]'.format(QSettings().fileName()))

    if parsed.locale:
        debug_print('Will set locale to [{0}]'.format(parsed.locale))
        QLocale.setDefault(QLocale(parsed.locale))
        locale.setlocale(locale.LC_ALL, parsed.locale)
    else:
        # Set Python's locale module to the user's default locale
        locale.setlocale(locale.LC_ALL, '')

    debug_print(u'Locale is [{0}]'.format(QLocale().name()))

    window = MainWindow(app)
    window.show_from_geometry_settings()

    if parsed.file:
        window.open_file(parsed.file)

    sys.exit(app.exec_())