2015-05-28 13:32:09 +12:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
2016-02-07 00:34:22 +13:00
|
|
|
import faulthandler
|
2016-03-30 05:39:33 +13:00
|
|
|
import os
|
2015-05-28 13:32:09 +12:00
|
|
|
import sys
|
2016-02-06 00:25:25 +13:00
|
|
|
|
2016-02-07 00:34:22 +13:00
|
|
|
from PyQt5.QtCore import QLocale, QTranslator, QSettings
|
2016-02-29 11:48:53 +13:00
|
|
|
from PyQt5.QtGui import QIcon
|
|
|
|
from PyQt5.QtWidgets import QApplication, qApp
|
|
|
|
|
2016-03-30 05:39:33 +13:00
|
|
|
from manuskript.functions import appPath, writablePath
|
2015-06-04 04:40:19 +12:00
|
|
|
|
2016-04-01 03:12:54 +13:00
|
|
|
_version = "0.3.0"
|
2015-05-28 13:32:09 +12:00
|
|
|
|
2015-06-25 04:39:38 +12:00
|
|
|
faulthandler.enable()
|
2015-06-22 05:37:13 +12:00
|
|
|
|
2015-06-23 07:34:11 +12:00
|
|
|
|
2015-06-08 08:06:57 +12:00
|
|
|
def run():
|
2015-05-28 13:32:09 +12:00
|
|
|
app = QApplication(sys.argv)
|
2015-06-19 00:38:26 +12:00
|
|
|
app.setOrganizationName("manuskript")
|
2015-05-28 13:32:09 +12:00
|
|
|
app.setOrganizationDomain("www.theologeek.ch")
|
2015-06-19 00:38:26 +12:00
|
|
|
app.setApplicationName("manuskript")
|
2016-02-06 00:25:25 +13:00
|
|
|
app.setApplicationVersion(_version)
|
2015-06-23 07:34:11 +12:00
|
|
|
|
2016-02-07 04:42:22 +13:00
|
|
|
icon = QIcon()
|
|
|
|
for i in [16, 31, 64, 128, 256, 512]:
|
|
|
|
icon.addFile(appPath("icons/Manuskript/icon-{}px.png".format(i)))
|
|
|
|
qApp.setWindowIcon(icon)
|
|
|
|
|
2015-06-07 00:21:48 +12:00
|
|
|
app.setStyle("Fusion")
|
2015-06-23 07:34:11 +12:00
|
|
|
|
2016-03-30 05:39:33 +13:00
|
|
|
# Load style from QSettings
|
|
|
|
settings = QSettings(app.organizationName(), app.applicationName())
|
|
|
|
if settings.contains("applicationStyle"):
|
|
|
|
style = settings.value("applicationStyle")
|
|
|
|
app.setStyle(style)
|
|
|
|
|
2016-02-06 00:25:25 +13:00
|
|
|
# Translation process
|
2015-06-08 12:10:18 +12:00
|
|
|
locale = QLocale.system().name()
|
2016-02-06 20:18:59 +13:00
|
|
|
|
2015-06-08 12:10:18 +12:00
|
|
|
appTranslator = QTranslator()
|
2016-03-30 05:39:33 +13:00
|
|
|
# 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):
|
2015-06-08 12:10:18 +12:00
|
|
|
app.installTranslator(appTranslator)
|
2016-03-30 05:39:33 +13:00
|
|
|
print(app.tr("Loaded translation: {}.").format(translation))
|
2015-06-23 07:34:11 +12:00
|
|
|
|
2016-03-30 05:39:33 +13:00
|
|
|
else:
|
|
|
|
print(app.tr("Warning: failed to load translator for locale {}...").format(locale))
|
2016-02-06 00:25:25 +13:00
|
|
|
|
2015-09-29 22:17:03 +13:00
|
|
|
QIcon.setThemeSearchPaths(QIcon.themeSearchPaths() + [appPath("icons")])
|
|
|
|
QIcon.setThemeName("NumixMsk")
|
2016-02-06 00:25:25 +13:00
|
|
|
# qApp.setWindowIcon(QIcon.fromTheme("im-aim"))
|
2015-06-23 07:34:11 +12:00
|
|
|
|
|
|
|
# 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()
|
|
|
|
|
|
|
|
|
2015-06-22 04:35:42 +12:00
|
|
|
def launch():
|
2016-02-07 00:34:22 +13:00
|
|
|
from .mainWindow import MainWindow
|
2015-06-23 07:34:11 +12:00
|
|
|
|
2015-05-28 13:32:09 +12:00
|
|
|
main = MainWindow()
|
|
|
|
main.show()
|
2015-06-23 07:34:11 +12:00
|
|
|
|
2015-06-22 04:35:42 +12:00
|
|
|
qApp.exec_()
|
|
|
|
qApp.deleteLater()
|
2015-06-23 07:34:11 +12:00
|
|
|
|
2015-06-08 08:06:57 +12:00
|
|
|
|
|
|
|
if __name__ == "__main__":
|
2015-06-23 07:07:38 +12:00
|
|
|
run()
|