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 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 = {

View File

@ -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.")

View File

@ -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):

View File

@ -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)

View File

@ -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

View File

@ -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)

View File

@ -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):

View File

@ -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):

View File

@ -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__":