import math
import simplejson
import logging
+import logging.handlers
-from PyQt4 import QtGui
-from PyQt4 import QtCore
+import util.qt_compat as qt_compat
+QtCore = qt_compat.QtCore
+QtGui = qt_compat.import_module("QtGui")
import constants
-import maeqt
+from util import qui_utils
from util import misc as misc_utils
import unit_data
self._favoritesWindow = None
self._inputUnitValue = QtGui.QLineEdit()
- maeqt.mark_numbers_preferred(self._inputUnitValue)
+ qui_utils.mark_numbers_preferred(self._inputUnitValue)
self._inputUnitValue.textEdited.connect(self._on_value_edited)
self._inputUnitSymbol = QtGui.QLabel()
self._outputUnitValue = QtGui.QLineEdit()
- maeqt.mark_numbers_preferred(self._outputUnitValue)
+ qui_utils.mark_numbers_preferred(self._outputUnitValue)
self._outputUnitValue.textEdited.connect(self._on_output_value_edited)
self._outputUnitSymbol = QtGui.QLabel()
self._categoryView = QtGui.QTreeWidget()
self._categoryView.setHeaderLabels(["Categories"])
self._categoryView.setHeaderHidden(False)
+ self._categoryView.setRootIsDecorated(False)
if not constants.IS_MAEMO:
self._categoryView.setAlternatingRowColors(True)
self._categoryView.setSelectionBehavior(QtGui.QAbstractItemView.SelectRows)
self._inputView.setHeaderLabels(["From", "Name"])
self._inputView.setHeaderHidden(False)
self._inputView.header().hideSection(1)
+ self._inputView.setRootIsDecorated(False)
if not constants.IS_MAEMO:
self._inputView.setAlternatingRowColors(True)
self._inputView.setSelectionBehavior(QtGui.QAbstractItemView.SelectRows)
self._outputView.setHeaderLabels(["To", "Name"])
self._outputView.setHeaderHidden(False)
self._outputView.header().hideSection(1)
+ self._outputView.setRootIsDecorated(False)
if not constants.IS_MAEMO:
self._outputView.setAlternatingRowColors(True)
self._outputView.setSelectionBehavior(QtGui.QAbstractItemView.SelectRows)
self._window = QtGui.QMainWindow(parent)
self._window.setAttribute(QtCore.Qt.WA_DeleteOnClose, True)
- maeqt.set_autorient(self._window, True)
- maeqt.set_stackable(self._window, True)
+ qui_utils.set_stackable(self._window, True)
self._window.setWindowTitle("%s - Quick Convert" % (constants.__pretty_app_name__, ))
self._window.setWindowIcon(QtGui.QIcon(app.appIconPath))
self._window.setCentralWidget(centralWidget)
for item in self._outputView.selectedItems()
]
if selectedNames:
- assert len(selectedNames) == 1
+ assert len(selectedNames) == 1, selectedNames
name = selectedNames[0]
self._select_output(name)
else:
self._categories.setHeaderLabels(["Categories"])
self._categories.itemClicked.connect(self._on_category_clicked)
self._categories.setHeaderHidden(True)
+ self._categories.setRootIsDecorated(False)
self._categories.setSelectionBehavior(QtGui.QAbstractItemView.SelectRows)
self._categories.setSelectionMode(QtGui.QAbstractItemView.SingleSelection)
if not constants.IS_MAEMO:
self._window = QtGui.QMainWindow(parent)
self._window.setAttribute(QtCore.Qt.WA_DeleteOnClose, True)
- maeqt.set_autorient(self._window, True)
- maeqt.set_stackable(self._window, True)
+ qui_utils.set_stackable(self._window, True)
self._window.setWindowTitle("%s - Categories" % constants.__pretty_app_name__)
self._window.setWindowIcon(QtGui.QIcon(self._app.appIconPath))
self._window.setCentralWidget(centralWidget)
self._selectedUnitName = QtGui.QLabel()
self._selectedUnitValue = QtGui.QLineEdit()
self._selectedUnitValue.textEdited.connect(self._on_value_edited)
- maeqt.mark_numbers_preferred(self._selectedUnitValue)
+ qui_utils.mark_numbers_preferred(self._selectedUnitValue)
self._selectedUnitSymbol = QtGui.QLabel()
self._updateDelayTimer = QtCore.QTimer()
self._updateDelayTimer.setInterval(100)
self._unitsView.setModel(self._unitsModel)
self._unitsView.setUniformRowHeights(True)
self._unitsView.setSortingEnabled(True)
+ self._unitsView.setRootIsDecorated(False)
self._unitsView.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
self._unitsView.setSelectionBehavior(QtGui.QAbstractItemView.SelectRows)
self._unitsView.setSelectionMode(QtGui.QAbstractItemView.SingleSelection)
self._window = QtGui.QMainWindow(parent)
self._window.setAttribute(QtCore.Qt.WA_DeleteOnClose, True)
- maeqt.set_autorient(self._window, True)
- maeqt.set_stackable(self._window, True)
+ qui_utils.set_stackable(self._window, True)
self._window.setWindowTitle("%s - %s" % (constants.__pretty_app_name__, category))
self._window.setWindowIcon(QtGui.QIcon(app.appIconPath))
self._window.setCentralWidget(centralWidget)
def run_gonvert():
+ try:
+ os.makedirs(constants._data_path_)
+ except OSError, e:
+ if e.errno != 17:
+ raise
+
+ logFormat = '(%(relativeCreated)5d) %(levelname)-5s %(threadName)s.%(name)s.%(funcName)s: %(message)s'
+ logging.basicConfig(level=logging.DEBUG, format=logFormat)
+ rotating = logging.handlers.RotatingFileHandler(constants._user_logpath_, maxBytes=512*1024, backupCount=1)
+ rotating.setFormatter(logging.Formatter(logFormat))
+ root = logging.getLogger()
+ root.addHandler(rotating)
+ _moduleLogger.info("%s %s-%s" % (constants.__app_name__, constants.__version__, constants.__build__))
+ _moduleLogger.info("OS: %s" % (os.uname()[0], ))
+ _moduleLogger.info("Kernel: %s (%s) for %s" % os.uname()[2:])
+ _moduleLogger.info("Hostname: %s" % os.uname()[1])
+
app = QtGui.QApplication([])
handle = Gonvert(app)
if constants.PROFILE_STARTUP:
if __name__ == "__main__":
import sys
- logging.basicConfig(level = logging.DEBUG)
- try:
- os.makedirs(constants._data_path_)
- except OSError, e:
- if e.errno != 17:
- raise
-
val = run_gonvert()
sys.exit(val)