Skip to content

Commit

Permalink
Add drag move images
Browse files Browse the repository at this point in the history
Add remove item to context menu
  • Loading branch information
shootsoft committed Mar 31, 2018
1 parent 9e176bd commit 62e7f1c
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 0 deletions.
1 change: 1 addition & 0 deletions build_mac.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/bin/sh

rm -rf dist
pyinstaller -D -w mac_build.spec

# Multiple files, for debugging
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ opencv-python==3.3.0.9 # Latest version may not work well with Mac
numpy
Pillow
chardet
qdarkstyle

# Development
pyinstaller
Expand Down
3 changes: 3 additions & 0 deletions src/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,12 @@
from pluto.ui.qt.mvc.routers import Router
from pluto.ui.stitcher.controllers import ImageStitchingController
from pluto.ui.qt.qtutils import QtUtil
# import qdarkstyle

if __name__ == '__main__':
app = QApplication(sys.argv)
# setup stylesheet
# app.setStyleSheet(qdarkstyle.load_stylesheet_pyqt5())
app.setWindowIcon(QtGui.QIcon(QtUtil.resource_path(os.path.join('windows', 'pluto.png'))))
router = Router(app)
router.add_ctrl('player', PlayerController(router))
Expand Down
3 changes: 3 additions & 0 deletions src/pluto/ui/stitcher/controllers.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ def __bind(self, view):
view.tabWidget.tabBarClicked.connect(self.on_tab_clicked)
view.imageWidget.resizeEvent = self.on_item_preview_resize
view.previewWidget.resizeEvent = self.on_output_preview_resize
view.removeSelectedAction.triggered.connect(self.on_remove_item)
view.previewSelectedAction.triggered.connect(self.on_preview_selected)
view.previewAllAction.triggered.connect(self.on_preview_all)
view.saveSelectedAction.triggered.connect(self.on_save_selected)
Expand Down Expand Up @@ -68,6 +69,8 @@ def on_add_item(self):

def on_remove_item(self):
items = self.view.imageListWidget.selectedItems()
if len(items) == 0:
return
result = QMessageBox.question(self.view, 'Run Auto Snapshort', 'Remove selected [%s] items?' % len(items),
QMessageBox.Yes, QMessageBox.No)
if result == QMessageBox.Yes:
Expand Down
6 changes: 6 additions & 0 deletions src/pluto/ui/stitcher/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,20 @@ def __init__(self):
self.upImageLabel.setStyleSheet("QLabel { background-color : rgba(0,0,0,.8); opacity:0.3;}")
self.downImageLabel.setGeometry(0, 0, 0, 0)
self.downImageLabel.setStyleSheet("QLabel { background-color : rgba(0,0,0,.8); opacity:0.3;}")
self.zoomInButton.hide()
self.zoomOutButton.hide()
self.__init_context_menu()

def __init_context_menu(self):
self.contextMenu = QMenu()
self.removeSelectedAction = QAction("Delete selected", self)
self.previewSelectedAction = QAction("Preview selected", self)
self.previewAllAction = QAction("Preview all", self)
self.saveSelectedAction = QAction("Save selected", self)
self.saveAllAction = QAction("Save all", self)

self.contextMenu.addAction(self.removeSelectedAction)
self.contextMenu.addSeparator()
self.contextMenu.addAction(self.previewSelectedAction)
self.contextMenu.addAction(self.previewAllAction)
self.contextMenu.addAction(self.saveSelectedAction)
Expand Down
59 changes: 59 additions & 0 deletions src/windows/image_stitching_window.ui
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@
<property name="contextMenuPolicy">
<enum>Qt::CustomContextMenu</enum>
</property>
<property name="dragDropMode">
<enum>QAbstractItemView::InternalMove</enum>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::ExtendedSelection</enum>
</property>
Expand Down Expand Up @@ -226,6 +229,18 @@
<property name="enabled">
<bool>false</bool>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>32</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>32</height>
</size>
</property>
<property name="text">
<string>Zoom In</string>
</property>
Expand All @@ -236,6 +251,18 @@
<property name="enabled">
<bool>false</bool>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>32</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>32</height>
</size>
</property>
<property name="text">
<string>Zoom Out</string>
</property>
Expand Down Expand Up @@ -286,6 +313,22 @@
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>10</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="goBackButton">
<property name="text">
Expand Down Expand Up @@ -343,6 +386,22 @@
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>10</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
Expand Down

0 comments on commit 62e7f1c

Please sign in to comment.