Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,21 @@ PySide client for Jean-Paul Start

![](jeanpaulstartui.jpg)

### Installation

jeanpaulstartui uses Mottosso's [Qt5](https://github.com/mottosso/Qt5.py) to adapt itself to all Qt5 bindings.
If don't have any Qt5 binding installed in your environment, you must specify the binding you want to use:
```
# To install with PySide2 binding
pip install git+https://github.com/cube-creative/jeanpaulstartui.git[PySide2]

# To install with PyQt5 binding
pip install git+https://github.com/cube-creative/jeanpaulstartui.git[PyQt5]

# To install without PySide2 or PyQt5 (If a Qt5 binding is already provided by the environment you are installing to ex: maya)
pip install git+https://github.com/cube-creative/jeanpaulstartui.git
```

### Launching

Run the module `jeanpaulstartui` giving a path where to find batches, and the user tags description file
Expand Down
4 changes: 2 additions & 2 deletions jeanpaulstartui/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import getpass
import argparse
import pkg_resources
from PySide.QtGui import *
from Qt5 import QtWidgets
from jeanpaulstartui import ROOT
from jeanpaulstartui.launcher import Launcher

Expand Down Expand Up @@ -78,7 +78,7 @@ def process_args():
except pkg_resources.DistributionNotFound:
version = 'Not installed with pip'

app = QApplication(sys.argv)
app = QtWidgets.QApplication(sys.argv)
with open(ROOT + '/resources/stylesheet.css', 'r') as f_stylesheet:
stylesheet = str(f_stylesheet.read())
app.setStyleSheet(stylesheet)
Expand Down
23 changes: 11 additions & 12 deletions jeanpaulstartui/view/flow_layout.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from PySide.QtCore import *
from PySide.QtGui import *
from Qt5 import QtCore, QtWidgets


"""
Expand All @@ -8,10 +7,10 @@
"""


class FlowLayout(QLayout):
class FlowLayout(QtWidgets.QLayout):

def __init__(self, parent=None, margin=0, spacing=-1):
QLayout.__init__(self, parent)
super(FlowLayout, self).__init__(parent)
self.item_list = []

if parent is None:
Expand Down Expand Up @@ -41,13 +40,13 @@ def takeAt(self, index):
return None

def expandingDirections(self):
return Qt.Orientations(Qt.Orientation(0))
return QtCore.Qt.Orientations(QtCore.Qt.Orientation(0))

def hasHeightForWidth(self):
return True

def heightForWidth(self, width):
height = self.do_layout(QRect(0, 0, width, 0))
height = self.do_layout(QtCore.QRect(0, 0, width, 0))
return height

def setGeometry(self, rect):
Expand All @@ -63,7 +62,7 @@ def minimumSize(self):
# for item in self.item_list:
# size = size.expandedTo(item.minimumSize())
# size = size + QSize(2 * self.contentsMargins().top(), 2 * self.contentsMargins().top())
size = QSize(2 * self.contentsMargins().top(), 2 * self.contentsMargins().top())
size = QtCore.QSize(2 * self.contentsMargins().top(), 2 * self.contentsMargins().top())
return size

def do_layout(self, rect, test_only=True):
Expand All @@ -73,10 +72,10 @@ def do_layout(self, rect, test_only=True):

for item in self.item_list:
widget = item.widget()
space_x = self.spacing() + widget.style().layoutSpacing(QSizePolicy.PushButton,
QSizePolicy.PushButton, Qt.Horizontal)
space_y = self.spacing() + widget.style().layoutSpacing(QSizePolicy.PushButton,
QSizePolicy.PushButton, Qt.Vertical) + 1
space_x = self.spacing() + widget.style().layoutSpacing(QtWidgets.QSizePolicy.PushButton,
QtWidgets.QSizePolicy.PushButton, QtCore.Qt.Horizontal)
space_y = self.spacing() + widget.style().layoutSpacing(QtWidgets.QSizePolicy.PushButton,
QtWidgets.QSizePolicy.PushButton, QtCore.Qt.Vertical) + 1
next_x = x + item.sizeHint().width() + space_x
if next_x - space_x > rect.right() and line_height > 0:
x = rect.x()
Expand All @@ -85,7 +84,7 @@ def do_layout(self, rect, test_only=True):
line_height = 0

if not test_only:
item.setGeometry(QRect(QPoint(x, y), item.sizeHint()))
item.setGeometry(QtCore.QRect(QtCore.QPoint(x, y), item.sizeHint()))

x = next_x

Expand Down
89 changes: 46 additions & 43 deletions jeanpaulstartui/view/launcher_widget.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import os
import sys
import logging
from PySide.QtGui import *
from PySide.QtCore import *
from Qt5 import QtWidgets, QtCore, QtGui

from jeanpaulstartui import ROOT
from jeanpaulstartui.view.flow_layout import FlowLayout
Expand All @@ -14,59 +13,63 @@ def _clear_layout(layout):
layout.itemAt(i).widget().deleteLater()


class LauncherWidget(QWidget):
class LauncherWidget(QtWidgets.QWidget):

def __init__(self, parent=None):
QWidget.__init__(self, parent=parent)
super(LauncherWidget, self).__init__(parent=parent)

self.mouse_pressed = False
self.offset = QCursor()
self.window_icon = QIcon(ROOT + '/resources/ceci-n-est-pas-une-icone.png')
self.offset = QtGui.QCursor()
self.window_icon = QtGui.QIcon(ROOT + '/resources/ceci-n-est-pas-une-icone.png')

self.settings = QSettings('CubeCreative', 'JeanPaulStart')
self.restoreGeometry(self.settings.value('geometry', ''))
self.settings = QtCore.QSettings('CubeCreative', 'JeanPaulStart')

geometry = self.settings.value('geometry', '')
if not isinstance(geometry, QtCore.QByteArray):
geometry = QtCore.QByteArray(geometry.encode("utf-8"))
self.restoreGeometry(geometry)

self.setMouseTracking(True)
self.setObjectName('LauncherWidget')
self.setWindowTitle('Jean-Paul Start')
self.setWindowIcon(self.window_icon)
self.setMinimumSize(376, 144)
self.setWindowFlags(
Qt.CustomizeWindowHint |
Qt.Dialog |
Qt.WindowCloseButtonHint |
Qt.WindowMinimizeButtonHint |
Qt.WindowSystemMenuHint
QtCore.Qt.CustomizeWindowHint |
QtCore.Qt.Dialog |
QtCore.Qt.WindowCloseButtonHint |
QtCore.Qt.WindowMinimizeButtonHint |
QtCore.Qt.WindowSystemMenuHint
)

batches_widget = QWidget()
batches_widget = QtWidgets.QWidget()
self.batches_layout = FlowLayout(parent=batches_widget, spacing=0)
batches_widget.setLayout(self.batches_layout)
batches_widget.setContentsMargins(16, 16, 16, 16)
self.batches_layout.setSpacing(16)

self.scroll_area = QScrollArea()
self.scroll_area = QtWidgets.QScrollArea()
self.scroll_area.setWidget(batches_widget)
self.scroll_area.setWidgetResizable(True)

self.status_progress_bar = ProgressLabel()
self.status_progress_bar.setFixedHeight(15)
self.status_progress_bar.setObjectName("status")

self.main_layout = QVBoxLayout(self)
self.main_layout = QtWidgets.QVBoxLayout(self)
self.main_layout.addWidget(self.scroll_area)
self.main_layout.addWidget(self.status_progress_bar)
self.main_layout.setContentsMargins(8, 8, 8, 8)

self.controller = None

self.tray = QSystemTrayIcon()
self.tray = QtWidgets.QSystemTrayIcon()
self.tray.setIcon(self.window_icon)
self.tray.setToolTip('Jean-Paul Start')
self.tray.setVisible(True)
self.tray.activated.connect(self.showNormalReason)

menu = QMenu()
menu = QtWidgets.QMenu()
self.version_menu = menu.addAction('')
self.version_menu.setDisabled(True)
menu.addSeparator()
Expand All @@ -80,13 +83,13 @@ def __init__(self, parent=None):
self.tray.setContextMenu(menu)

def refresh(self):
QApplication.processEvents()
QtWidgets.QApplication.processEvents()

def set_hourglass(self, is_hourglass):
if is_hourglass:
QApplication.setOverrideCursor(Qt.WaitCursor)
QtWidgets.QApplication.setOverrideCursor(QtCore.Qt.WaitCursor)
else:
QApplication.restoreOverrideCursor()
QtWidgets.QApplication.restoreOverrideCursor()

def set_status_message(self, message):
self.status_progress_bar.setText(message)
Expand All @@ -100,26 +103,26 @@ def set_version(self, version):

def show(self):
self.tray.show()
return QWidget.show(self)
return super(LauncherWidget, self).show()

def showNormal(self):
self.activateWindow()
return QWidget.showNormal(self)
return super(LauncherWidget, self).showNormal()

def showNormalReason(self, reason):
if reason == QSystemTrayIcon.Trigger:
if reason == QtWidgets.QSystemTrayIcon.Trigger:
self.showNormal()

def keyPressEvent(self, event):
if event.key() == Qt.Key_F5:
self.reload_batches()
QWidget.keyPressEvent(self, event)
super(LauncherWidget, self).keyPressEvent(event)

def reload_batches(self):
self.showNormal()
QApplication.setOverrideCursor(Qt.BusyCursor)
QtWidgets.QApplication.setOverrideCursor(QtCore.Qt.BusyCursor)
self.controller.update()
QApplication.restoreOverrideCursor()
QtWidgets.QApplication.restoreOverrideCursor()

def populate_layout(self, batches):
_clear_layout(self.batches_layout)
Expand All @@ -128,37 +131,37 @@ def populate_layout(self, batches):
self.batches_layout.addWidget(batch_button)

def _make_batch_button(self, batch):
button = QPushButton(self)
button_icon = QLabel()
button = QtWidgets.QPushButton(self)
button_icon = QtWidgets.QLabel()

image_path = os.path.expandvars(batch.icon_path)
if os.path.isfile(image_path):
image = QImage(image_path)
image = QtGui.QImage(image_path)
else:
image = QImage(2, 2, QImage.Format_RGB16)
image = QtGui.QImage(2, 2, QtGui.QImage.Format_RGB16)
logging.warn("Impossible to find " + image_path)
button_icon.setPixmap(QPixmap.fromImage(image.scaled(
button_icon.setPixmap(QtGui.QPixmap.fromImage(image.scaled(
48,
48,
Qt.KeepAspectRatioByExpanding,
Qt.SmoothTransformation
QtCore.Qt.KeepAspectRatioByExpanding,
QtCore.Qt.SmoothTransformation
)))

button_icon.setAlignment(Qt.AlignCenter)
button_icon.setTextInteractionFlags(Qt.NoTextInteraction)
button_icon.setAlignment(QtCore.Qt.AlignCenter)
button_icon.setTextInteractionFlags(QtCore.Qt.NoTextInteraction)
button_icon.setMouseTracking(False)
button_icon.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
button_icon.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
button_icon.setContentsMargins(0, 8, 0, 0)

batch_name = batch.name
button_text = QLabel(batch_name)
button_text.setAlignment(Qt.AlignCenter | Qt.AlignBottom)
button_text = QtWidgets.QLabel(batch_name)
button_text.setAlignment(QtCore.Qt.AlignCenter | QtCore.Qt.AlignBottom)
button_text.setWordWrap(True)
button_text.setTextInteractionFlags(Qt.NoTextInteraction)
button_text.setTextInteractionFlags(QtCore.Qt.NoTextInteraction)
button_text.setMouseTracking(False)
button_text.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
button_text.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)

button_layout = QVBoxLayout()
button_layout = QtWidgets.QVBoxLayout()
button_layout.addWidget(button_icon)
button_layout.addWidget(button_text)
button_layout.setSpacing(0)
Expand All @@ -169,7 +172,7 @@ def _make_batch_button(self, batch):
button.setFixedSize(96, 96)
button.setObjectName(batch.name + '_button')
button.setLayout(button_layout)
button.setCursor(QCursor(Qt.PointingHandCursor))
button.setCursor(QtGui.QCursor(QtCore.Qt.PointingHandCursor))

button.batch = batch
button.clicked.connect(self._batch_clicked)
Expand Down
15 changes: 7 additions & 8 deletions jeanpaulstartui/view/progress_label.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
from PySide.QtGui import *
from PySide.QtCore import Qt
from Qt5 import QtCore, QtWidgets, QtGui


class ProgressLabel(QLabel):
class ProgressLabel(QtWidgets.QLabel):

def __init__(self, parent=None):
QLabel.__init__(self, parent=parent)
super(ProgressLabel, self).__init__(parent=parent)
self._progress = 0.0

def set_progress(self, value):
self._progress = value

def paintEvent(self, event):
painter = QPainter()
painter = QtGui.QPainter()
painter.begin(self)
painter.setPen(Qt.NoPen)
painter.setBrush(QColor(61, 174, 233))
painter.setPen(QtCore.Qt.NoPen)
painter.setBrush(QtGui.QColor(61, 174, 233))
painter.drawRect(event.rect().adjusted(0, 13, -self.width()*(1 - self._progress), 0))
painter.end()

QLabel.paintEvent(self, event)
super(ProgressLabel, self).paintEvent(event)
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
jeanpaulstart
PySide
jeanpaulstart @ git+https://github.com/Arubinu/jeanpaulstart.git@master
Qt5.py
8 changes: 6 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@

if path.isfile(_requirements_filepath):
with open(_requirements_filepath) as requirements_file:
_requirements = requirements_file.readlines()
_requirements = [r.strip() for r in requirements_file.readlines()]
else:
_requirements = list()

print(_requirements)

setup(
name=NAME,
Expand All @@ -38,5 +38,9 @@
author_email=AUTHOR_EMAIL,
packages=find_packages(exclude=['tests']),
install_requires=_requirements,
extras_require={
"PySide2": ["PySide2"],
"PyQt5": ["PyQt5"]
},
include_package_data=True
)