From: Ed Page Date: Fri, 16 Jul 2010 01:10:36 +0000 (-0500) Subject: Polishing things up X-Git-Url: http://vcs.maemo.org/git/?p=ejpi;a=commitdiff_plain;h=25e75759f12c38abf6f93cc8c761d63f619c26c6;ds=sidebyside Polishing things up --- diff --git a/Makefile b/Makefile index 93aee70..c239d05 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ PROJECT_NAME=ejpi SOURCE_PATH=src SOURCE=$(shell find $(SOURCE_PATH) -iname "*.py") PROGRAM=$(SOURCE_PATH)/$(PROJECT_NAME).py -DATA_TYPES=*.ini *.map *.glade *.png +DATA_TYPES=*.ini *.png DATA=$(foreach type, $(DATA_TYPES), $(shell find $(SOURCE_PATH) -iname "$(type)")) OBJ=$(SOURCE:.py=.pyc) BUILD_PATH=./build diff --git a/src/constants.py b/src/constants.py index 9f9a330..6a76bf7 100644 --- a/src/constants.py +++ b/src/constants.py @@ -2,7 +2,7 @@ import os __pretty_app_name__ = "e**(j pi) + 1 = 0" __app_name__ = "ejpi" -__version__ = "0.9.8" +__version__ = "1.0.0" __build__ = 0 __app_magic__ = 0xdeadbeef _data_path_ = os.path.join(os.path.expanduser("~"), ".%s" % __app_name__) diff --git a/src/ejpi.py b/src/ejpi.py index e56c505..2a4d905 100755 --- a/src/ejpi.py +++ b/src/ejpi.py @@ -10,7 +10,7 @@ sys.path.append("/opt/ejpi/lib") import constants -import ejpi_glade +import ejpi_qt if __name__ == "__main__": @@ -27,4 +27,4 @@ if __name__ == "__main__": _moduleLogger.info("Kernel: %s (%s) for %s" % os.uname()[2:]) _moduleLogger.info("Hostname: %s" % os.uname()[1]) - ejpi_glade.run() + ejpi_qt.run() diff --git a/src/ejpi_qt.py b/src/ejpi_qt.py index 9684631..3c063cc 100755 --- a/src/ejpi_qt.py +++ b/src/ejpi_qt.py @@ -129,16 +129,20 @@ class QErrorDisplay(object): def __init__(self): self._messages = [] - icon = QtGui.QIcon.fromTheme("gtk-dialog-error") - self._severityIcon = icon.pixmap(32, 32) + errorIcon = QtGui.QIcon.fromTheme("app_install_error") + if errorIcon.isNull(): + errorIcon = QtGui.QIcon.fromTheme("gtk-dialog-error") + self._severityIcon = errorIcon.pixmap(32, 32) self._severityLabel = QtGui.QLabel() self._severityLabel.setPixmap(self._severityIcon) self._message = QtGui.QLabel() self._message.setText("Boo") - icon = QtGui.QIcon.fromTheme("gtk-close") - self._closeLabel = QtGui.QPushButton(icon, "") + closeIcon = QtGui.QIcon.fromTheme("general_close") + if closeIcon.isNull(): + closeIcon = QtGui.QIcon.fromTheme("gtk-close") + self._closeLabel = QtGui.QPushButton(closeIcon, "") self._closeLabel.clicked.connect(self._on_close) self._controlLayout = QtGui.QHBoxLayout() @@ -281,7 +285,7 @@ class MainWindow(object): maeqt.set_stackable(self._window, True) self._window.setWindowTitle("%s" % constants.__pretty_app_name__) self._window.setCentralWidget(centralWidget) - self._window.destroyed.connect(self._on_close_window) + self._window.destroyed.connect(self._on_window_closed) self._copyItemAction = QtGui.QAction(None) self._copyItemAction.setText("Copy") @@ -298,23 +302,11 @@ class MainWindow(object): self._closeWindowAction.setShortcut(QtGui.QKeySequence("CTRL+w")) self._closeWindowAction.triggered.connect(self._on_close_window) - if IS_MAEMO: - #fileMenu = self._window.menuBar().addMenu("&File") - - #viewMenu = self._window.menuBar().addMenu("&View") - - self._window.addAction(self._copyItemAction) - self._window.addAction(self._pasteItemAction) - self._window.addAction(self._closeWindowAction) - self._window.addAction(self._app.quitAction) - self._window.addAction(self._app.fullscreenAction) - else: - fileMenu = self._window.menuBar().addMenu("&Units") - fileMenu.addAction(self._closeWindowAction) - fileMenu.addAction(self._app.quitAction) - - viewMenu = self._window.menuBar().addMenu("&View") - viewMenu.addAction(self._app.fullscreenAction) + self._window.addAction(self._copyItemAction) + self._window.addAction(self._pasteItemAction) + self._window.addAction(self._closeWindowAction) + self._window.addAction(self._app.quitAction) + self._window.addAction(self._app.fullscreenAction) self._window.addAction(self._app.logAction) @@ -370,7 +362,6 @@ class MainWindow(object): self.set_fullscreen(self._app.fullscreenAction.isChecked()) self._window.show() - self._set_plugin_kb(0) @property def window(self): @@ -428,12 +419,6 @@ class MainWindow(object): else: self._keyboardTabs.addTab(pluginKeyboard.toplevel, icon, "") - def _set_plugin_kb(self, pluginIndex): - plugin = self._activeKeyboards[pluginIndex] - - # @todo Switch the keyboard tab - pluginKeyboard = plugin["pluginKeyboard"] - def _load_history(self): serialized = [] try: @@ -492,9 +477,13 @@ class MainWindow(object): self._history.clear() @misc_utils.log_exception(_moduleLogger) - def _on_close_window(self, checked = True): + def _on_window_closed(self, checked = True): self._save_history() + @misc_utils.log_exception(_moduleLogger) + def _on_close_window(self, checked = True): + self.close() + def run(): app = QtGui.QApplication([]) diff --git a/src/libraries/qtpie.py b/src/libraries/qtpie.py index e1af2c1..884d5ce 100755 --- a/src/libraries/qtpie.py +++ b/src/libraries/qtpie.py @@ -71,8 +71,8 @@ class QActionPieItem(object): class PieFiling(object): - INNER_RADIUS_DEFAULT = 32 - OUTER_RADIUS_DEFAULT = 128 + INNER_RADIUS_DEFAULT = 64 + OUTER_RADIUS_DEFAULT = 192 SELECTION_CENTER = -1 SELECTION_NONE = -2 @@ -192,7 +192,11 @@ class PieFiling(object): class PieArtist(object): - ICON_SIZE_DEFAULT = 32 + ICON_SIZE_DEFAULT = 48 + + SHAPE_CIRCLE = "circle" + SHAPE_SQUARE = "square" + DEFAULT_SHAPE = SHAPE_SQUARE def __init__(self, filing): self._filing = filing @@ -288,9 +292,24 @@ class PieArtist(object): painter = QtGui.QPainter(mask) painter.setPen(QtCore.Qt.color1) painter.setBrush(QtCore.Qt.color1) - painter.drawEllipse(mask.rect().adjusted(0, 0, -1, -1)) + if self.DEFAULT_SHAPE == self.SHAPE_SQUARE: + painter.drawRect(mask.rect()) + elif self.DEFAULT_SHAPE == self.SHAPE_CIRCLE: + painter.drawEllipse(mask.rect().adjusted(0, 0, -1, -1)) + else: + raise NotImplementedError(self.DEFAULT_SHAPE) def _paint_slice_background(self, painter, adjustmentRect, i, selectionIndex): + if self.DEFAULT_SHAPE == self.SHAPE_SQUARE: + currentWidth = adjustmentRect.width() + newWidth = math.sqrt(2) * currentWidth + dx = (newWidth - currentWidth) / 2 + adjustmentRect = adjustmentRect.adjusted(-dx, -dx, dx, dx) + elif self.DEFAULT_SHAPE == self.SHAPE_CIRCLE: + pass + else: + raise NotImplementedError(self.DEFAULT_SHAPE) + if i == selectionIndex and self._filing[i].isEnabled(): painter.setBrush(self.palette.highlight()) else: @@ -379,7 +398,7 @@ class PieArtist(object): painter.drawText(leftX, topY, text) def _paint_center_background(self, painter, adjustmentRect, selectionIndex): - dark = self.palette.dark().color() + dark = self.palette.mid().color() light = self.palette.light().color() if selectionIndex == PieFiling.SELECTION_CENTER and self._filing.center().isEnabled(): background = self.palette.highlight().color() @@ -403,16 +422,14 @@ class PieArtist(object): painter.setBrush(QtCore.Qt.NoBrush) painter.drawEllipse(innerRect) - painter.setPen(QtGui.QPen(dark, 1)) - painter.setBrush(QtCore.Qt.NoBrush) - painter.drawEllipse(adjustmentRect) - - r = QtCore.QRect(innerRect) - innerCenter = r.center() - innerRect.setLeft(innerCenter.x() + ((r.left() - innerCenter.x()) / 3) * 1) - innerRect.setRight(innerCenter.x() + ((r.right() - innerCenter.x()) / 3) * 1) - innerRect.setTop(innerCenter.y() + ((r.top() - innerCenter.y()) / 3) * 1) - innerRect.setBottom(innerCenter.y() + ((r.bottom() - innerCenter.y()) / 3) * 1) + if self.DEFAULT_SHAPE == self.SHAPE_SQUARE: + pass + elif self.DEFAULT_SHAPE == self.SHAPE_CIRCLE: + painter.setPen(QtGui.QPen(dark, 1)) + painter.setBrush(QtCore.Qt.NoBrush) + painter.drawEllipse(adjustmentRect) + else: + raise NotImplementedError(self.DEFAULT_SHAPE) def _paint_center_foreground(self, painter, selectionIndex): centerPos = self._canvas.rect().center() @@ -497,7 +514,6 @@ class QPieButton(QtGui.QWidget): self._buttonFiling = PieFiling() self._buttonFiling.set_center(buttonSlice) - # @todo Figure out how to make the button auto-fill to content self._buttonFiling.setOuterRadius(self.BUTTON_RADIUS) self._buttonArtist = PieArtist(self._buttonFiling) self._poppedUp = False @@ -549,9 +565,10 @@ class QPieButton(QtGui.QWidget): def setButtonRadius(self, radius): self._buttonFiling.setOuterRadius(radius) + self._buttonArtist.show(self.palette()) - def sizeHint(self): - return self._buttonArtist.pieSize() + def minimumSizeHint(self): + return self._buttonArtist.centerSize() @misc_utils.log_exception(_moduleLogger) def mousePressEvent(self, mouseEvent): @@ -582,7 +599,10 @@ class QPieButton(QtGui.QWidget): self._update_selection(lastMousePos) else: # Relative - self._update_selection(self._cachedCenterPosition + (lastMousePos - self._mousePosition)) + self._update_selection( + self._cachedCenterPosition + (lastMousePos - self._mousePosition), + ignoreOuter = True, + ) if lastSelection != self._selectionIndex: self.highlighted.emit(self._selectionIndex) @@ -604,7 +624,10 @@ class QPieButton(QtGui.QWidget): self._update_selection(lastMousePos) else: # Relative - self._update_selection(self._cachedCenterPosition + (lastMousePos - self._mousePosition)) + self._update_selection( + self._cachedCenterPosition + (lastMousePos - self._mousePosition), + ignoreOuter = True, + ) self._mousePosition = None self._activate_at(self._selectionIndex) @@ -646,6 +669,11 @@ class QPieButton(QtGui.QWidget): QtGui.QWidget.keyPressEvent(self, keyEvent) @misc_utils.log_exception(_moduleLogger) + def resizeEvent(self, resizeEvent): + self.setButtonRadius(min(resizeEvent.size().width(), resizeEvent.size().height()) / 2 - 1) + QtGui.QWidget.resizeEvent(self, resizeEvent) + + @misc_utils.log_exception(_moduleLogger) def showEvent(self, showEvent): self._buttonArtist.show(self.palette()) self._cachedCenterPosition = self.rect().center() @@ -660,6 +688,7 @@ class QPieButton(QtGui.QWidget): @misc_utils.log_exception(_moduleLogger) def paintEvent(self, paintEvent): + self.setButtonRadius(min(self.rect().width(), self.rect().height()) / 2 - 1) if self._poppedUp: canvas = self._buttonArtist.paint(PieFiling.SELECTION_CENTER) else: @@ -698,11 +727,11 @@ class QPieButton(QtGui.QWidget): def _select_at(self, index): self._selectionIndex = index - def _update_selection(self, lastMousePos): + def _update_selection(self, lastMousePos, ignoreOuter = False): radius = _radius_at(self._cachedCenterPosition, lastMousePos) if radius < self._filing.innerRadius(): self._select_at(PieFiling.SELECTION_CENTER) - elif radius <= self._filing.outerRadius(): + elif radius <= self._filing.outerRadius() or ignoreOuter: self._select_at(self.indexAt(lastMousePos)) else: self._select_at(PieFiling.SELECTION_NONE) diff --git a/src/plugins/images/newline.png b/src/plugins/images/newline.png index d0ed089..0ae2c53 100644 Binary files a/src/plugins/images/newline.png and b/src/plugins/images/newline.png differ diff --git a/src/qhistory.py b/src/qhistory.py index 822e098..c67e719 100644 --- a/src/qhistory.py +++ b/src/qhistory.py @@ -65,7 +65,10 @@ class QCalcHistory(history.AbstractHistory): def push(self, node): simpleNode = node.simplify() - icon = QtGui.QStandardItem(QtGui.QIcon.fromTheme("gtk-close"), "") + closeIcon = QtGui.QIcon.fromTheme("general_close") + if closeIcon.isNull(): + closeIcon = QtGui.QIcon.fromTheme("gtk-close") + icon = QtGui.QStandardItem(closeIcon, "") icon.setEditable(False) icon.setCheckable(False) equation = QtGui.QStandardItem(operation.render_operation(self._prettyRenderer, node)) diff --git a/support/builddeb.py b/support/builddeb.py index 1469e19..89991bd 100755 --- a/support/builddeb.py +++ b/support/builddeb.py @@ -27,7 +27,7 @@ __email__ = "eopage@byu.net" __version__ = constants.__version__ __build__ = constants.__build__ __changelog__ = """ -* Port to QT +* Port to Qt wtih misc fixes """.strip()