From 66303a20762ce47601d1c428dfbe0c6f4fad71b8 Mon Sep 17 00:00:00 2001 From: Virgil Dupras Date: Wed, 30 Nov 2011 11:06:08 -0500 Subject: [PATCH] Fixed help.locale path references under Qt and fixed packaging to include the locale folder. --- package.py | 5 ++++- qt/base/app.py | 2 +- qt/base/platform.py | 12 +++++++++--- qt/base/platform_lnx.py | 11 ----------- qt/base/platform_osx.py | 13 ------------- qt/base/platform_win.py | 11 ----------- run_template_qt.py | 4 +++- 7 files changed, 17 insertions(+), 41 deletions(-) delete mode 100644 qt/base/platform_lnx.py delete mode 100644 qt/base/platform_osx.py delete mode 100644 qt/base/platform_win.py diff --git a/package.py b/package.py index dec8f77e..8f88cdc6 100644 --- a/package.py +++ b/package.py @@ -55,8 +55,11 @@ def package_windows(edition, dev): print_and_do("upx --best \"{0}\"".format(op.join(distdir, lib))) help_path = op.join('build', 'help') - print("Copying {0} to dist\\help".format(help_path)) + print("Copying {} to dist\\help".format(help_path)) shutil.copytree(help_path, op.join(distdir, 'help')) + locale_path = op.join('build', 'locale') + print("Copying {} to dist\\locale".format(locale_path)) + shutil.copytree(locale_path, op.join(distdir, 'locale')) # AdvancedInstaller.com has to be in your PATH # this is so we don'a have to re-commit installer.aip at every version change diff --git a/qt/base/app.py b/qt/base/app.py index 725ebf9b..4f20aa15 100644 --- a/qt/base/app.py +++ b/qt/base/app.py @@ -236,7 +236,7 @@ class DupeGuru(QObject): self.about_box.show() def showHelpTriggered(self): - base_path = platform.HELP_PATH.format(self.EDITION) + base_path = platform.HELP_PATH url = QUrl.fromLocalFile(op.abspath(op.join(base_path, 'index.html'))) QDesktopServices.openUrl(url) diff --git a/qt/base/platform.py b/qt/base/platform.py index 60529c17..4014284d 100644 --- a/qt/base/platform.py +++ b/qt/base/platform.py @@ -6,13 +6,19 @@ # which should be included with this package. The terms are also available at # http://www.hardcoded.net/licenses/bsd_license +import os.path as op from hscommon.plat import ISWINDOWS, ISOSX, ISLINUX +# We want to get the absolute path or our root folder. We know that in that folder we're inside +# qt/base, so we just fo back two levels. +BASE_PATH = op.abspath(op.join(op.dirname(__file__), '..', '..')) +HELP_PATH = op.join(BASE_PATH, 'help') + if ISWINDOWS: - from .platform_win import * + INITIAL_FOLDER_IN_DIALOGS = 'C:\\' elif ISOSX: - from .platform_osx import * + INITIAL_FOLDER_IN_DIALOGS = '/' elif ISLINUX: - from .platform_lnx import * + INITIAL_FOLDER_IN_DIALOGS = '/' else: pass # unsupported platform diff --git a/qt/base/platform_lnx.py b/qt/base/platform_lnx.py deleted file mode 100644 index e3e54d6d..00000000 --- a/qt/base/platform_lnx.py +++ /dev/null @@ -1,11 +0,0 @@ -# -*- coding: utf-8 -*- -# Created By: Virgil Dupras -# Created On: 2010-02-13 -# Copyright 2011 Hardcoded Software (http://www.hardcoded.net) -# -# This software is licensed under the "BSD" License as described in the "LICENSE" file, -# which should be included with this package. The terms are also available at -# http://www.hardcoded.net/licenses/bsd_license - -INITIAL_FOLDER_IN_DIALOGS = '/' -HELP_PATH = '/usr/share/dupeguru_{0}/help' diff --git a/qt/base/platform_osx.py b/qt/base/platform_osx.py deleted file mode 100644 index 24aad18d..00000000 --- a/qt/base/platform_osx.py +++ /dev/null @@ -1,13 +0,0 @@ -# -*- coding: utf-8 -*- -# Created By: Virgil Dupras -# Created On: 2009-10-14 -# Copyright 2011 Hardcoded Software (http://www.hardcoded.net) -# -# This software is licensed under the "BSD" License as described in the "LICENSE" file, -# which should be included with this package. The terms are also available at -# http://www.hardcoded.net/licenses/bsd_license - -# dummy unit to allow the app to run under OSX during development - -INITIAL_FOLDER_IN_DIALOGS = '/' -HELP_PATH = '' diff --git a/qt/base/platform_win.py b/qt/base/platform_win.py deleted file mode 100644 index 2f56b931..00000000 --- a/qt/base/platform_win.py +++ /dev/null @@ -1,11 +0,0 @@ -# -*- coding: utf-8 -*- -# Created By: Virgil Dupras -# Created On: 2009-08-31 -# Copyright 2011 Hardcoded Software (http://www.hardcoded.net) -# -# This software is licensed under the "BSD" License as described in the "LICENSE" file, -# which should be included with this package. The terms are also available at -# http://www.hardcoded.net/licenses/bsd_license - -INITIAL_FOLDER_IN_DIALOGS = 'C:\\' -HELP_PATH = 'help' diff --git a/run_template_qt.py b/run_template_qt.py index 427ab926..29fca5cb 100644 --- a/run_template_qt.py +++ b/run_template_qt.py @@ -6,6 +6,7 @@ # http://www.hardcoded.net/licenses/bsd_license import sys +import os.path as op import sip sip.setapi('QVariant', 1) @@ -28,7 +29,8 @@ if __name__ == "__main__": QCoreApplication.setApplicationVersion(__version__) settings = QSettings() lang = settings.value('Language').toString() - install_gettext_trans_under_qt(lang) + locale_folder = op.join(op.dirname(__file__), 'locale') + install_gettext_trans_under_qt(locale_folder, lang) # Many strings are translated at import time, so this is why we only import after the translator # has been installed from qt.{{edition}}.app import DupeGuru