Skip to content

Commit

Permalink
Merge pull request #7 from shootsoft/1.4.3_drapmove
Browse files Browse the repository at this point in the history
1.4.3
  • Loading branch information
shootsoft committed Apr 7, 2018
2 parents 30695f1 + 8689ed2 commit 22f2336
Show file tree
Hide file tree
Showing 13 changed files with 315 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -102,4 +102,4 @@ ENV/
.mypy_cache/

.idea/

/*.dmg
2 changes: 2 additions & 0 deletions build_mac.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/bin/sh

rm -rf dist
pyinstaller -D -w mac_build.spec
dmgbuild -s dmg_settings.py "PlutoVideoSnapshoter Volume" PlutoVideoSnapshoter.dmg

# Multiple files, for debugging

Expand Down
172 changes: 172 additions & 0 deletions dmg_settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

import biplist
import os.path

# Use like this: dmgbuild -s settings.py "Test Volume" test.dmg

# You can actually use this file for your own application (not just TextEdit)
# by doing e.g.
#
# dmgbuild -s settings.py -D app=/path/to/My.app "My Application" MyApp.dmg

# .. Useful stuff ..............................................................

application = defines.get('app', 'dist/PlutoVideoSnapshoter.app')
appname = os.path.basename(application)


def icon_from_app(app_path):
plist_path = os.path.join(app_path, 'Contents', 'Info.plist')
plist = biplist.readPlist(plist_path)
icon_name = plist['CFBundleIconFile']
icon_root, icon_ext = os.path.splitext(icon_name)
if not icon_ext:
icon_ext = '.icns'
icon_name = icon_root + icon_ext
return os.path.join(app_path, 'Contents', 'Resources', icon_name)


# .. Basics ....................................................................

# Uncomment to override the output filename
# filename = 'test.dmg'

# Uncomment to override the output volume name
# volume_name = 'Test'

# Volume format (see hdiutil create -help)
format = defines.get('format', 'UDBZ')

# Volume size
size = defines.get('size', None)

# Files to include
files = [application]

# Symlinks to create
symlinks = {'Applications': '/Applications'}

# Volume icon
#
# You can either define icon, in which case that icon file will be copied to the
# image, *or* you can define badge_icon, in which case the icon file you specify
# will be used to badge the system's Removable Disk icon
#
# icon = '/path/to/icon.icns'
badge_icon = icon_from_app(application)

# Where to put the icons
icon_locations = {
appname: (140, 120),
'Applications': (500, 120)
}

# .. Window configuration ......................................................

# Background
#
# This is a STRING containing any of the following:
#
# #3344ff - web-style RGB color
# #34f - web-style RGB color, short form (#34f == #3344ff)
# rgb(1,0,0) - RGB color, each value is between 0 and 1
# hsl(120,1,.5) - HSL (hue saturation lightness) color
# hwb(300,0,0) - HWB (hue whiteness blackness) color
# cmyk(0,1,0,0) - CMYK color
# goldenrod - X11/SVG named color
# builtin-arrow - A simple built-in background with a blue arrow
# /foo/bar/baz.png - The path to an image file
#
# The hue component in hsl() and hwb() may include a unit; it defaults to
# degrees ('deg'), but also supports radians ('rad') and gradians ('grad'
# or 'gon').
#
# Other color components may be expressed either in the range 0 to 1, or
# as percentages (e.g. 60% is equivalent to 0.6).
background = 'builtin-arrow'

show_status_bar = False
show_tab_view = False
show_toolbar = False
show_pathbar = False
show_sidebar = False
sidebar_width = 180

# Window position in ((x, y), (w, h)) format
window_rect = ((100, 100), (640, 280))

# Select the default view; must be one of
#
# 'icon-view'
# 'list-view'
# 'column-view'
# 'coverflow'
#
default_view = 'icon-view'

# General view configuration
show_icon_preview = False

# Set these to True to force inclusion of icon/list view settings (otherwise
# we only include settings for the default view)
include_icon_view_settings = 'auto'
include_list_view_settings = 'auto'

# .. Icon view configuration ...................................................

arrange_by = None
grid_offset = (0, 0)
grid_spacing = 100
scroll_position = (0, 0)
label_pos = 'bottom' # or 'right'
text_size = 16
icon_size = 128

# .. List view configuration ...................................................

# Column names are as follows:
#
# name
# date-modified
# date-created
# date-added
# date-last-opened
# size
# kind
# label
# version
# comments
#
list_icon_size = 16
list_text_size = 12
list_scroll_position = (0, 0)
list_sort_by = 'name'
list_use_relative_dates = True
list_calculate_all_sizes = False,
list_columns = ('name', 'date-modified', 'size', 'kind', 'date-added')
list_column_widths = {
'name': 300,
'date-modified': 181,
'date-created': 181,
'date-added': 181,
'date-last-opened': 181,
'size': 97,
'kind': 115,
'label': 100,
'version': 75,
'comments': 300,
}
list_column_sort_directions = {
'name': 'ascending',
'date-modified': 'descending',
'date-created': 'descending',
'date-added': 'descending',
'date-last-opened': 'descending',
'size': 'descending',
'kind': 'ascending',
'label': 'ascending',
'version': 'ascending',
'comments': 'ascending',
}
4 changes: 2 additions & 2 deletions file_version_info.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ VSVersionInfo(
u'040904e4',
[StringStruct(u'CompanyName', u'Shoot Sun Studio'),
StringStruct(u'FileDescription', u'Pluto Video Snapshoter'),
StringStruct(u'FileVersion', u'1.2.0'),
StringStruct(u'FileVersion', u'1.4.3'),
StringStruct(u'InternalName', u'https://github.com/shootsoft/PlutoVidoeSnapshoter'),
StringStruct(u'LegalCopyright', u'Copyright (C) 2000-2018 Shoot Sun Studio All Rights Reserved'),
StringStruct(u'OriginalFilename', u'PlutoVideoSnapshoter.exe'),
StringStruct(u'ProductName', u'Pluto Video Snapshoter'),
StringStruct(u'ProductVersion', u'1.2.0')])
StringStruct(u'ProductVersion', u'1.4.3')])
]),
VarFileInfo([VarStruct(u'Translation', [1033, 1252])])
]
Expand Down
2 changes: 1 addition & 1 deletion mac_build.spec
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@ app = BUNDLE(coll,
icon='res/pluto.icns',
bundle_identifier=None,
info_plist={
'CFBundleShortVersionString': '1.4.1'
'CFBundleShortVersionString': '1.4.3'
},
)
3 changes: 3 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@ opencv-python==3.3.0.9 # Latest version may not work well with Mac
numpy
Pillow
chardet
qdarkstyle

# Development
pyinstaller
nose
coverage
python-coveralls
biplist
dmgbuild
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
5 changes: 5 additions & 0 deletions src/pluto/ui/player/controllers.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,18 @@ def on_set_subtitle(self):
self.view.autoSnapshotButton.setEnabled(True)

def on_stitch_snapshots(self):
if self.model.isPlaying:
self.on_play()
self.go('image')

def set_video(self, file_name, width, height):
self.view.mediaPlayer.setMedia(QMediaContent(QUrl.fromLocalFile(file_name)))
QtUtil.central(self.view.videoWidget, self.view.videoBackgroundWidget, width, height, 2, 2)
self.on_play()

def on_media_state_changed(self, state):
# TODO: find a method to update view instead of these tricks
# After pause, the video will re-scale to original size, this is used to fix this.
QtUtil.central(self.view.videoWidget, self.view.videoBackgroundWidget,
self.snapshot.width, self.snapshot.height, 2, 2)
if state == 0:
Expand Down
7 changes: 5 additions & 2 deletions src/pluto/ui/player/views.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
# -*- coding: utf-8 -*-
from PyQt5 import Qt

from PyQt5.QtMultimedia import QMediaPlayer
from PyQt5.QtMultimediaWidgets import QVideoWidget
from PyQt5.QtWidgets import QLabel
from PyQt5.QtWidgets import QLabel, QVBoxLayout, QWidget

from pluto.ui.qt.mvc.views import View


class PlayerWindow(View):
def __init__(self):
super(PlayerWindow, self).__init__(ui_file="video_player_window.ui")
self.mediaPlayer = QMediaPlayer(None, QMediaPlayer.VideoSurface)
self.videoWidget = QVideoWidget(self.videoBackgroundWidget)
self.mediaPlayer = QMediaPlayer(None, QMediaPlayer.VideoSurface)
self.mediaPlayer.setVideoOutput(self.videoWidget)
self.videoBackgroundWidget.setStyleSheet("QWidget { background-color : black;}")
self.progressLabel = QLabel("00:00:00")
self.statusbar.addWidget(self.progressLabel)
self.messageLabel = QLabel("")
self.statusbar.addWidget(self.messageLabel)


18 changes: 13 additions & 5 deletions src/pluto/ui/stitcher/controllers.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from PyQt5.QtCore import QDir, Qt
from PyQt5.QtGui import QIcon
from PyQt5.QtWidgets import (QFileDialog, QMessageBox)
from PyQt5.QtWidgets import (QFileDialog, QMessageBox, QApplication)

from pluto.common.media.TextDetector import TextDetector
from pluto.common.utils import ImageUtil, TempFileUtil
Expand Down Expand Up @@ -39,6 +39,9 @@ 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.addAction.triggered.connect(self.on_add_item)
view.autoDetectSelectedAction.triggered.connect(self.on_auto_detect)
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 +71,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 Expand Up @@ -115,10 +120,6 @@ def on_item_selected(self):
item = items[0]
image = item.get_storage()
self.current_image = image
self.view.upVerticalSlider.setRange(0, image.height)
self.view.downVerticalSlider.setRange(0, image.height)
self.view.upVerticalSlider.setValue(image.up)
self.view.downVerticalSlider.setValue(image.height - image.down)

self.render_preview()
self.view.imageLabel.show()
Expand All @@ -136,6 +137,10 @@ def render_preview(self):
QtUtil.preview_image(image.image_file, self.view.imageLabel, self.view.imageWidget)
self.set_image_up_shade(image)
self.set_image_down_shade(image)
self.view.upVerticalSlider.setRange(0, image.height)
self.view.downVerticalSlider.setRange(0, image.height)
self.view.upVerticalSlider.setValue(image.up)
self.view.downVerticalSlider.setValue(image.height - image.down)

def set_image_up_shade(self, image):
height = int(self.view.imageLabel.height() * (image.up * 1.0 / image.height))
Expand Down Expand Up @@ -273,6 +278,7 @@ def on_auto_detect(self):
if reply == QMessageBox.Yes:
self.view.setEnabled(False)
self.do_auto_detect(items, skip_first)
QApplication.processEvents()
self.view.setEnabled(True)

def do_auto_detect(self, items, skip_first=False):
Expand All @@ -282,3 +288,5 @@ def do_auto_detect(self, items, skip_first=False):
img.up, img.down = self.text_detector.detect_subtitle_range(img.image_file)
# items[i].setData(0, str(img))
items[i].refresh_ui()
self.render_preview()
self.view.statusBar().showMessage("Please preview final image.")
15 changes: 14 additions & 1 deletion src/pluto/ui/stitcher/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,32 @@ class ImageStitchingWindow(View):
def __init__(self):
super(ImageStitchingWindow, self).__init__(ui_file="image_stitching_window.ui")
self.imageListWidget.setIconSize(QSize(96, 96))
self.imageListWidget.resize(self.width() * 0.67, self.imageListWidget.height())
self.imageListWidget.resize(self.width() * 0.36, self.imageListWidget.height())
self.upImageLabel.setGeometry(0, 0, 0, 0)
self.upImageLabel.setStyleSheet("QLabel { background-color : rgba(0,0,0,.8); opacity:0.3;}")
self.upImageLabel.setText("")
self.downImageLabel.setGeometry(0, 0, 0, 0)
self.downImageLabel.setStyleSheet("QLabel { background-color : rgba(0,0,0,.8); opacity:0.3;}")
self.downImageLabel.setText("")
self.zoomInButton.hide()
self.zoomOutButton.hide()
self.__init_context_menu()

def __init_context_menu(self):
self.contextMenu = QMenu()
self.addAction = QAction("Add images", self)
self.removeSelectedAction = QAction("Delete selected", self)
self.autoDetectSelectedAction = QAction("Magic", 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.addAction)
self.contextMenu.addAction(self.removeSelectedAction)
self.contextMenu.addSeparator()
self.contextMenu.addAction(self.autoDetectSelectedAction)
self.contextMenu.addSeparator()
self.contextMenu.addAction(self.previewSelectedAction)
self.contextMenu.addAction(self.previewAllAction)
self.contextMenu.addAction(self.saveSelectedAction)
Expand Down

0 comments on commit 22f2336

Please sign in to comment.