Use the new hscommon.plat unit.

This commit is contained in:
Virgil Dupras 2011-09-22 09:32:09 -04:00
parent 43c4dcb267
commit 1fafe04f19
9 changed files with 26 additions and 23 deletions

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# Created By: Virgil Dupras # Created By: Virgil Dupras
# Created On: 2009-12-30 # Created On: 2009-12-30
# Copyright 2011 Hardcoded Software (http://www.hardcoded.net) # Copyright 2011 Hardcoded Software (http://www.hardcoded.net)
@ -11,11 +10,13 @@ import sys
from optparse import OptionParser from optparse import OptionParser
import json import json
from hscommon.plat import ISOSX
def main(edition, ui, dev): def main(edition, ui, dev):
if edition not in ('se', 'me', 'pe'): if edition not in {'se', 'me', 'pe'}:
edition = 'se' edition = 'se'
if ui not in ('cocoa', 'qt'): if ui not in {'cocoa', 'qt'}:
ui = 'cocoa' if sys.platform == 'darwin' else 'qt' ui = 'cocoa' if ISOSX else 'qt'
build_type = 'Dev' if dev else 'Release' build_type = 'Dev' if dev else 'Release'
print("Configuring dupeGuru {0} for UI {1} ({2})".format(edition.upper(), ui, build_type)) print("Configuring dupeGuru {0} for UI {1} ({2})".format(edition.upper(), ui, build_type))
conf = { conf = {

View File

@ -14,6 +14,7 @@ import compileall
import shutil import shutil
import json import json
from hscommon.plat import ISWINDOWS, ISLINUX
from hscommon.build import (build_dmg, add_to_pythonpath, print_and_do, copy_packages, from hscommon.build import (build_dmg, add_to_pythonpath, print_and_do, copy_packages,
build_debian_changelog, copy_qt_plugins, get_module_version) build_debian_changelog, copy_qt_plugins, get_module_version)
@ -26,7 +27,7 @@ def package_cocoa(edition):
build_dmg(app_path, '.') build_dmg(app_path, '.')
def package_windows(edition, dev): def package_windows(edition, dev):
if sys.platform != "win32": if not ISWINDOWS:
print("Qt packaging only works under Windows.") print("Qt packaging only works under Windows.")
return return
add_to_pythonpath('.') add_to_pythonpath('.')
@ -111,9 +112,9 @@ def main():
if ui == 'cocoa': if ui == 'cocoa':
package_cocoa(edition) package_cocoa(edition)
elif ui == 'qt': elif ui == 'qt':
if sys.platform == "win32": if ISWINDOWS:
package_windows(edition, dev) package_windows(edition, dev)
elif sys.platform == "linux2": elif ISLINUX:
package_debian(edition) package_debian(edition)
else: else:
print("Qt packaging only works under Windows or Linux.") print("Qt packaging only works under Windows or Linux.")

View File

@ -18,6 +18,7 @@ from PyQt4.QtGui import QDesktopServices, QFileDialog, QDialog, QMessageBox, QAp
from jobprogress import job from jobprogress import job
from jobprogress.qt import Progress from jobprogress.qt import Progress
from hscommon.trans import tr, trmsg from hscommon.trans import tr, trmsg
from hscommon.plat import ISLINUX
from core.app import JobType from core.app import JobType
@ -108,7 +109,7 @@ class DupeGuru(QObject):
] ]
createActions(ACTIONS, self) createActions(ACTIONS, self)
if sys.platform == 'linux2': if ISLINUX:
self.actionCheckForUpdate.setVisible(False) # This only works on Windows self.actionCheckForUpdate.setVisible(False) # This only works on Windows
def _setup_as_registered(self): def _setup_as_registered(self):

View File

@ -12,6 +12,7 @@ from PyQt4.QtCore import Qt, QUrl, QTimer
from PyQt4.QtGui import (QDialog, QDesktopServices, QApplication, QVBoxLayout, QHBoxLayout, QLabel, from PyQt4.QtGui import (QDialog, QDesktopServices, QApplication, QVBoxLayout, QHBoxLayout, QLabel,
QFont, QSpacerItem, QSizePolicy, QPushButton) QFont, QSpacerItem, QSizePolicy, QPushButton)
from hscommon.plat import ISLINUX
from hscommon.trans import tr as trbase, trmsg as trmsgbase from hscommon.trans import tr as trbase, trmsg as trmsgbase
tr = lambda s: trbase(s, "ExtraFairwareReminder") tr = lambda s: trbase(s, "ExtraFairwareReminder")
trmsg = lambda s: trmsgbase(s, "ExtraFairwareReminder") trmsg = lambda s: trmsgbase(s, "ExtraFairwareReminder")
@ -33,7 +34,7 @@ class ExtraFairwareReminder(QDialog):
def _setupUi(self): def _setupUi(self):
self.setWindowTitle(tr("Sorry, I must insist")) 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.resize(380, dlg_height)
self.verticalLayout = QVBoxLayout(self) self.verticalLayout = QVBoxLayout(self)
self.descLabel = QLabel(self) self.descLabel = QLabel(self)

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# Created By: Virgil Dupras # Created By: Virgil Dupras
# Created On: 2009-09-27 # Created On: 2009-09-27
# Copyright 2011 Hardcoded Software (http://www.hardcoded.net) # 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 # which should be included with this package. The terms are also available at
# http://www.hardcoded.net/licenses/bsd_license # http://www.hardcoded.net/licenses/bsd_license
import logging from hscommon.plat import ISWINDOWS, ISOSX, ISLINUX
import sys
if sys.platform == 'win32': if ISWINDOWS:
from .platform_win import * from .platform_win import *
elif sys.platform == 'darwin': elif ISOSX:
from .platform_osx import * from .platform_osx import *
elif sys.platform == 'linux2': elif ISLINUX:
from .platform_lnx import * from .platform_lnx import *
else: else:
pass # unsupported platform pass # unsupported platform

View File

@ -6,11 +6,11 @@
# which should be included with this package. The terms are also available at # which should be included with this package. The terms are also available at
# http://www.hardcoded.net/licenses/bsd_license # http://www.hardcoded.net/licenses/bsd_license
import sys
from PyQt4.QtCore import SIGNAL, Qt, QSize from PyQt4.QtCore import SIGNAL, Qt, QSize
from PyQt4.QtGui import (QDialog, QDialogButtonBox, QVBoxLayout, QHBoxLayout, QLabel, QComboBox, from PyQt4.QtGui import (QDialog, QDialogButtonBox, QVBoxLayout, QHBoxLayout, QLabel, QComboBox,
QSlider, QSizePolicy, QSpacerItem, QCheckBox, QLineEdit, QMessageBox) QSlider, QSizePolicy, QSpacerItem, QCheckBox, QLineEdit, QMessageBox)
from hscommon.plat import ISOSX, ISLINUX
from hscommon.trans import tr, trmsg from hscommon.trans import tr, trmsg
class PreferencesDialogBase(QDialog): class PreferencesDialogBase(QDialog):
@ -124,7 +124,7 @@ class PreferencesDialogBase(QDialog):
self.buttonBox = QDialogButtonBox(self) self.buttonBox = QDialogButtonBox(self)
self.buttonBox.setStandardButtons(QDialogButtonBox.Cancel|QDialogButtonBox.Ok|QDialogButtonBox.RestoreDefaults) self.buttonBox.setStandardButtons(QDialogButtonBox.Cancel|QDialogButtonBox.Ok|QDialogButtonBox.RestoreDefaults)
self.mainVLayout.addWidget(self.buttonBox) self.mainVLayout.addWidget(self.buttonBox)
if sys.platform not in {'darwin', 'linux2'}: if (not ISOSX) and (not ISLINUX):
self.mainVLayout.removeWidget(self.ignoreHardlinkMatches) self.mainVLayout.removeWidget(self.ignoreHardlinkMatches)
self.ignoreHardlinkMatches.setHidden(True) self.ignoreHardlinkMatches.setHidden(True)

View File

@ -6,13 +6,12 @@
# which should be included with this package. The terms are also available at # which should be included with this package. The terms are also available at
# http://www.hardcoded.net/licenses/bsd_license # http://www.hardcoded.net/licenses/bsd_license
import sys
from PyQt4.QtCore import Qt, SIGNAL, QUrl, QRect from PyQt4.QtCore import Qt, SIGNAL, QUrl, QRect
from PyQt4.QtGui import (QMainWindow, QMenu, QLabel, QHeaderView, QMessageBox, QInputDialog, from PyQt4.QtGui import (QMainWindow, QMenu, QLabel, QHeaderView, QMessageBox, QInputDialog,
QLineEdit, QDesktopServices, QFileDialog, QMenuBar, QWidget, QVBoxLayout, QAbstractItemView, QLineEdit, QDesktopServices, QFileDialog, QMenuBar, QWidget, QVBoxLayout, QAbstractItemView,
QStatusBar, QDialog) QStatusBar, QDialog)
from hscommon.plat import ISOSX, ISLINUX
from hscommon.trans import tr, trmsg from hscommon.trans import tr, trmsg
from hscommon.util import nonone from hscommon.util import nonone
from qtlib.util import moveToScreenCenter from qtlib.util import moveToScreenCenter
@ -72,7 +71,7 @@ class ResultWindow(QMainWindow):
self.actionDelta.setCheckable(True) self.actionDelta.setCheckable(True)
self.actionPowerMarker.setCheckable(True) self.actionPowerMarker.setCheckable(True)
if sys.platform not in {'darwin', 'linux2'}: if (not ISOSX) and (not ISLINUX):
self.actionHardlinkMarked.setVisible(False) self.actionHardlinkMarked.setVisible(False)
def _setupMenu(self): def _setupMenu(self):

View File

@ -11,6 +11,7 @@ from PyQt4.QtCore import QSize
from PyQt4.QtGui import (QVBoxLayout, QHBoxLayout, QLabel, QSizePolicy, QSpacerItem, QWidget, from PyQt4.QtGui import (QVBoxLayout, QHBoxLayout, QLabel, QSizePolicy, QSpacerItem, QWidget,
QLineEdit, QApplication) QLineEdit, QApplication)
from hscommon.plat import ISWINDOWS, ISLINUX
from hscommon.trans import tr from hscommon.trans import tr
from hscommon.util import tryint from hscommon.util import tryint
@ -76,11 +77,11 @@ class PreferencesDialog(PreferencesDialogBase):
def _setupUi(self): def _setupUi(self):
PreferencesDialogBase._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 # 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. # doesn't have enough space, so we make the pref pane higher to compensate.
self.resize(self.width(), 490) self.resize(self.width(), 490)
elif sys.platform == 'win32': elif ISWINDOWS:
self.resize(self.width(), 420) self.resize(self.width(), 420)
def _load(self, prefs, setchecked): def _load(self, prefs, setchecked):

View File

@ -12,12 +12,13 @@ sip.setapi('QVariant', 1)
from PyQt4.QtCore import QCoreApplication, QSettings from PyQt4.QtCore import QCoreApplication, QSettings
from PyQt4.QtGui import QApplication, QIcon, QPixmap from PyQt4.QtGui import QApplication, QIcon, QPixmap
from hscommon.plat import ISWINDOWS
from hscommon.trans import install_qt_trans from hscommon.trans import install_qt_trans
from qtlib.error_report_dialog import install_excepthook from qtlib.error_report_dialog import install_excepthook
from qt.base import dg_rc from qt.base import dg_rc
from core_{{edition}} import __version__, __appname__ from core_{{edition}} import __version__, __appname__
if sys.platform == 'win32': if ISWINDOWS:
import qt.base.cxfreeze_fix import qt.base.cxfreeze_fix
if __name__ == "__main__": if __name__ == "__main__":