Skip to content
Snippets Groups Projects

Resolve "Change properties of operations in GUI"

Merged Felix Goding requested to merge 81-change-properties-of-operations-in-gui into develop
4 files
+ 267
586
Compare changes
  • Side-by-side
  • Inline
Files
4
+ 26
7
@@ -5,8 +5,10 @@ This class creates a dragbutton which can be clicked, dragged and dropped.
@@ -5,8 +5,10 @@ This class creates a dragbutton which can be clicked, dragged and dropped.
import os.path
import os.path
from PyQt5.QtWidgets import QPushButton
from properties_window import PropertiesWindow
from PyQt5.QtCore import Qt, QSize
 
from PyQt5.QtWidgets import QPushButton, QMenu, QAction
 
from PyQt5.QtCore import Qt, QSize, pyqtSignal
from PyQt5.QtGui import QIcon
from PyQt5.QtGui import QIcon
from utils import decorate_class, handle_error
from utils import decorate_class, handle_error
@@ -14,8 +16,11 @@ from utils import decorate_class, handle_error
@@ -14,8 +16,11 @@ from utils import decorate_class, handle_error
@decorate_class(handle_error)
@decorate_class(handle_error)
class DragButton(QPushButton):
class DragButton(QPushButton):
def __init__(self, name, operation, operation_path_name, window, parent = None):
connectionRequested = pyqtSignal(QPushButton)
 
moved = pyqtSignal()
 
def __init__(self, name, operation, operation_path_name, is_show_name, window, parent = None):
self.name = name
self.name = name
 
self.is_show_name = is_show_name
self._window = window
self._window = window
self.operation = operation
self.operation = operation
self.operation_path_name = operation_path_name
self.operation_path_name = operation_path_name
@@ -23,6 +28,20 @@ class DragButton(QPushButton):
@@ -23,6 +28,20 @@ class DragButton(QPushButton):
self.pressed = False
self.pressed = False
super(DragButton, self).__init__(self._window)
super(DragButton, self).__init__(self._window)
 
def contextMenuEvent(self, event):
 
menu = QMenu()
 
properties = QAction("Properties")
 
menu.addAction(properties)
 
properties.triggered.connect(self.show_properties_window)
 
menu.exec_(self.cursor().pos())
 
 
def show_properties_window(self):
 
self.properties_window = PropertiesWindow(self, self.__window)
 
self.properties_window.show()
 
 
def add_label(self, label):
 
self.label = label
 
def mousePressEvent(self, event):
def mousePressEvent(self, event):
self._mouse_press_pos = None
self._mouse_press_pos = None
self._mouse_move_pos = None
self._mouse_move_pos = None
@@ -38,20 +57,20 @@ class DragButton(QPushButton):
@@ -38,20 +57,20 @@ class DragButton(QPushButton):
if self.clicked == 1:
if self.clicked == 1:
self.pressed = True
self.pressed = True
self.setStyleSheet("background-color: grey; border-style: solid;\
self.setStyleSheet("background-color: grey; border-style: solid;\
border-color: black; border-width: 2px; border-radius: 10px")
border-color: black; border-width: 2px")
path_to_image = os.path.join('operation_icons', self.operation_path_name + '_grey.png')
path_to_image = os.path.join('operation_icons', self.operation_path_name + '_grey.png')
self.setIcon(QIcon(path_to_image))
self.setIcon(QIcon(path_to_image))
self.setIconSize(QSize(50, 50))
self.setIconSize(QSize(55, 55))
self._window.pressed_button.append(self)
self._window.pressed_button.append(self)
elif self.clicked == 2:
elif self.clicked == 2:
self.clicked = 0
self.clicked = 0
self.pressed = False
self.pressed = False
self.setStyleSheet("background-color: white; border-style: solid;\
self.setStyleSheet("background-color: white; border-style: solid;\
border-color: black; border-width: 2px; border-radius: 10px")
border-color: black; border-width: 2px")
path_to_image = os.path.join('operation_icons', self.operation_path_name + '.png')
path_to_image = os.path.join('operation_icons', self.operation_path_name + '.png')
self.setIcon(QIcon(path_to_image))
self.setIcon(QIcon(path_to_image))
self.setIconSize(QSize(50, 50))
self.setIconSize(QSize(55, 55))
self._window.pressed_button.remove(self)
self._window.pressed_button.remove(self)
super(DragButton, self).mousePressEvent(event)
super(DragButton, self).mousePressEvent(event)
Loading