diff --git a/configure.py b/configure.py index 7e638692..02aefe9c 100644 --- a/configure.py +++ b/configure.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Created By: Virgil Dupras # Created On: 2009-12-30 # Copyright 2011 Hardcoded Software (http://www.hardcoded.net) @@ -11,11 +10,13 @@ import sys from optparse import OptionParser import json +from hscommon.plat import ISOSX + def main(edition, ui, dev): - if edition not in ('se', 'me', 'pe'): + if edition not in {'se', 'me', 'pe'}: edition = 'se' - if ui not in ('cocoa', 'qt'): - ui = 'cocoa' if sys.platform == 'darwin' else 'qt' + if ui not in {'cocoa', 'qt'}: + ui = 'cocoa' if ISOSX else 'qt' build_type = 'Dev' if dev else 'Release' print("Configuring dupeGuru {0} for UI {1} ({2})".format(edition.upper(), ui, build_type)) conf = { diff --git a/package.py b/package.py index 9908d307..dec8f77e 100644 --- a/package.py +++ b/package.py @@ -14,6 +14,7 @@ import compileall import shutil import json +from hscommon.plat import ISWINDOWS, ISLINUX from hscommon.build import (build_dmg, add_to_pythonpath, print_and_do, copy_packages, build_debian_changelog, copy_qt_plugins, get_module_version) @@ -26,7 +27,7 @@ def package_cocoa(edition): build_dmg(app_path, '.') def package_windows(edition, dev): - if sys.platform != "win32": + if not ISWINDOWS: print("Qt packaging only works under Windows.") return add_to_pythonpath('.') @@ -111,9 +112,9 @@ def main(): if ui == 'cocoa': package_cocoa(edition) elif ui == 'qt': - if sys.platform == "win32": + if ISWINDOWS: package_windows(edition, dev) - elif sys.platform == "linux2": + elif ISLINUX: package_debian(edition) else: print("Qt packaging only works under Windows or Linux.") diff --git a/qt/base/app.py b/qt/base/app.py index 531a6842..95392266 100644 --- a/qt/base/app.py +++ b/qt/base/app.py @@ -18,6 +18,7 @@ from PyQt4.QtGui import QDesktopServices, QFileDialog, QDialog, QMessageBox, QAp from jobprogress import job from jobprogress.qt import Progress from hscommon.trans import tr, trmsg +from hscommon.plat import ISLINUX from core.app import JobType @@ -108,7 +109,7 @@ class DupeGuru(QObject): ] createActions(ACTIONS, self) - if sys.platform == 'linux2': + if ISLINUX: self.actionCheckForUpdate.setVisible(False) # This only works on Windows def _setup_as_registered(self): diff --git a/qt/base/extra_fairware_reminder.py b/qt/base/extra_fairware_reminder.py index 2cfe2ea0..6116dd3c 100644 --- a/qt/base/extra_fairware_reminder.py +++ b/qt/base/extra_fairware_reminder.py @@ -12,6 +12,7 @@ from PyQt4.QtCore import Qt, QUrl, QTimer from PyQt4.QtGui import (QDialog, QDesktopServices, QApplication, QVBoxLayout, QHBoxLayout, QLabel, QFont, QSpacerItem, QSizePolicy, QPushButton) +from hscommon.plat import ISLINUX from hscommon.trans import tr as trbase, trmsg as trmsgbase tr = lambda s: trbase(s, "ExtraFairwareReminder") trmsg = lambda s: trmsgbase(s, "ExtraFairwareReminder") @@ -33,7 +34,7 @@ class ExtraFairwareReminder(QDialog): def _setupUi(self): self.setWindowTitle(tr("Sorry, I must insist")) - dlg_height = 410 if sys.platform == 'linux2' else 330 + dlg_height = 410 if ISLINUX else 330 self.resize(380, dlg_height) self.verticalLayout = QVBoxLayout(self) self.descLabel = QLabel(self) diff --git a/qt/base/platform.py b/qt/base/platform.py index 32cc5e2e..60529c17 100644 --- a/qt/base/platform.py +++ b/qt/base/platform.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Created By: Virgil Dupras # Created On: 2009-09-27 # Copyright 2011 Hardcoded Software (http://www.hardcoded.net) @@ -7,14 +6,13 @@ # which should be included with this package. The terms are also available at # http://www.hardcoded.net/licenses/bsd_license -import logging -import sys +from hscommon.plat import ISWINDOWS, ISOSX, ISLINUX -if sys.platform == 'win32': +if ISWINDOWS: from .platform_win import * -elif sys.platform == 'darwin': +elif ISOSX: from .platform_osx import * -elif sys.platform == 'linux2': +elif ISLINUX: from .platform_lnx import * else: pass # unsupported platform diff --git a/qt/base/preferences_dialog.py b/qt/base/preferences_dialog.py index eb450915..37ad6dcf 100644 --- a/qt/base/preferences_dialog.py +++ b/qt/base/preferences_dialog.py @@ -6,11 +6,11 @@ # which should be included with this package. The terms are also available at # http://www.hardcoded.net/licenses/bsd_license -import sys from PyQt4.QtCore import SIGNAL, Qt, QSize from PyQt4.QtGui import (QDialog, QDialogButtonBox, QVBoxLayout, QHBoxLayout, QLabel, QComboBox, QSlider, QSizePolicy, QSpacerItem, QCheckBox, QLineEdit, QMessageBox) +from hscommon.plat import ISOSX, ISLINUX from hscommon.trans import tr, trmsg class PreferencesDialogBase(QDialog): @@ -124,7 +124,7 @@ class PreferencesDialogBase(QDialog): self.buttonBox = QDialogButtonBox(self) self.buttonBox.setStandardButtons(QDialogButtonBox.Cancel|QDialogButtonBox.Ok|QDialogButtonBox.RestoreDefaults) self.mainVLayout.addWidget(self.buttonBox) - if sys.platform not in {'darwin', 'linux2'}: + if (not ISOSX) and (not ISLINUX): self.mainVLayout.removeWidget(self.ignoreHardlinkMatches) self.ignoreHardlinkMatches.setHidden(True) diff --git a/qt/base/result_window.py b/qt/base/result_window.py index 29ea8d6b..e5a0ce5d 100644 --- a/qt/base/result_window.py +++ b/qt/base/result_window.py @@ -6,13 +6,12 @@ # which should be included with this package. The terms are also available at # http://www.hardcoded.net/licenses/bsd_license -import sys - from PyQt4.QtCore import Qt, SIGNAL, QUrl, QRect from PyQt4.QtGui import (QMainWindow, QMenu, QLabel, QHeaderView, QMessageBox, QInputDialog, QLineEdit, QDesktopServices, QFileDialog, QMenuBar, QWidget, QVBoxLayout, QAbstractItemView, QStatusBar, QDialog) +from hscommon.plat import ISOSX, ISLINUX from hscommon.trans import tr, trmsg from hscommon.util import nonone from qtlib.util import moveToScreenCenter @@ -72,7 +71,7 @@ class ResultWindow(QMainWindow): self.actionDelta.setCheckable(True) self.actionPowerMarker.setCheckable(True) - if sys.platform not in {'darwin', 'linux2'}: + if (not ISOSX) and (not ISLINUX): self.actionHardlinkMarked.setVisible(False) def _setupMenu(self): diff --git a/qt/se/preferences_dialog.py b/qt/se/preferences_dialog.py index 54280ef0..ec2d10ab 100644 --- a/qt/se/preferences_dialog.py +++ b/qt/se/preferences_dialog.py @@ -11,6 +11,7 @@ from PyQt4.QtCore import QSize from PyQt4.QtGui import (QVBoxLayout, QHBoxLayout, QLabel, QSizePolicy, QSpacerItem, QWidget, QLineEdit, QApplication) +from hscommon.plat import ISWINDOWS, ISLINUX from hscommon.trans import tr from hscommon.util import tryint @@ -76,11 +77,11 @@ class PreferencesDialog(PreferencesDialogBase): def _setupUi(self): PreferencesDialogBase._setupUi(self) - if sys.platform == 'linux2': + if ISLINUX: # Under linux, whether it's a Qt layout bug or something else, the size threshold text edit # doesn't have enough space, so we make the pref pane higher to compensate. self.resize(self.width(), 490) - elif sys.platform == 'win32': + elif ISWINDOWS: self.resize(self.width(), 420) def _load(self, prefs, setchecked): diff --git a/run_template_qt.py b/run_template_qt.py index c1124bab..c3897d1c 100644 --- a/run_template_qt.py +++ b/run_template_qt.py @@ -12,12 +12,13 @@ sip.setapi('QVariant', 1) from PyQt4.QtCore import QCoreApplication, QSettings from PyQt4.QtGui import QApplication, QIcon, QPixmap +from hscommon.plat import ISWINDOWS from hscommon.trans import install_qt_trans from qtlib.error_report_dialog import install_excepthook from qt.base import dg_rc from core_{{edition}} import __version__, __appname__ -if sys.platform == 'win32': +if ISWINDOWS: import qt.base.cxfreeze_fix if __name__ == "__main__":