- added a new GUI element, an InputDialog made out of FCSliderWithSpinner named FCInputDialogSlider

- replaced the InputDialog in the Opacity pop menu for the objects in the Project Tab with a FCInputDialogSlider
This commit is contained in:
Marius Stanciu 2020-10-24 01:22:43 +03:00 committed by Marius
parent f771838c81
commit 5c845fcfb2
3 changed files with 70 additions and 4 deletions

View File

@ -7,6 +7,11 @@ CHANGELOG for FlatCAM beta
=================================================
24.10.2020
- added a new GUI element, an InputDialog made out of FCSliderWithSpinner named FCInputDialogSlider
- replaced the InputDialog in the Opacity pop menu for the objects in the Project Tab with a FCInputDialogSlider
23.10.2020
- updated Copper Thieving Tool to work with the updated program

View File

@ -1687,6 +1687,64 @@ class FCInputDialog(QtWidgets.QInputDialog):
pass
class FCInputDialogSlider(QtWidgets.QDialog):
def __init__(self, parent=None, title=None, text=None, min=None, max=None, step=1, init_val=None):
super().__init__(parent)
self.val = 0.0
self.init_value = init_val if init_val else 0.0
self.setWindowTitle(title) if title else self.setWindowTitle('title')
self.text = text if text else 'text'
self.min = min if min else 0
self.max = max if max else 255
self.step = step if step else 1
self.lbl = FCLabel(self.text)
self.wdg = FCSliderWithSpinner(min=self.min, max=self.max, step=self.step)
self.wdg.set_value(self.init_value)
QBtn = QtWidgets.QDialogButtonBox.Ok | QtWidgets.QDialogButtonBox.Cancel
self.buttonBox = QtWidgets.QDialogButtonBox(QBtn)
self.buttonBox.accepted.connect(self.accept)
self.buttonBox.rejected.connect(self.reject)
self.layout = QtWidgets.QVBoxLayout()
self.layout.addWidget(self.lbl)
self.layout.addWidget(self.wdg)
self.layout.addWidget(self.buttonBox)
self.setLayout(self.layout)
def set_title(self, txt):
self.setWindowTitle(txt)
def set_text(self, txt):
self.lbl.set_value(txt)
def set_min(self, val):
self.wdg.spinner.setMinimum(val)
def set_max(self, val):
self.wdg.spinner.setMaximum(val)
def set_range(self, min, max):
self.wdg.spinner.set_range(min, max)
def set_step(self, val):
self.wdg.spinner.set_step(val)
def get_results(self):
if self.exec_() == QtWidgets.QDialog.Accepted:
return self.wdg.get_value(), True
else:
return None, False
class FCButton(QtWidgets.QPushButton):
def __init__(self, text=None, checkable=None, click_callback=None, parent=None):
super(FCButton, self).__init__(text, parent)

View File

@ -73,7 +73,7 @@ from camlib import to_dict, dict2obj, ET, ParseError, Geometry, CNCjob
from appGUI.PlotCanvas import *
from appGUI.PlotCanvasLegacy import *
from appGUI.MainGUI import *
from appGUI.GUIElements import FCFileSaveDialog, message_dialog, FlatCAMSystemTray
from appGUI.GUIElements import FCFileSaveDialog, message_dialog, FlatCAMSystemTray, FCInputDialogSlider
# FlatCAM Pre-processors
from appPreProcessor import load_preprocessors
@ -10198,11 +10198,14 @@ class App(QtCore.QObject):
return
if act_name == _("Opacity"):
alpha_level, ok_button = QtWidgets.QInputDialog.getInt(
self.ui, _("Set alpha level ..."), '%s:' % _("Value"), min=0, max=255, step=1, value=191)
# alpha_level, ok_button = QtWidgets.QInputDialog.getInt(
# self.ui, _("Set alpha level ..."), '%s:' % _("Value"), min=0, max=255, step=1, value=191)
alpha_dialog = FCInputDialogSlider(
self.ui, _("Set alpha level ..."), '%s:' % _("Value"), min=0, max=255, step=1, init_val=191)
alpha_level, ok_button = alpha_dialog.get_results()
if ok_button:
alpha_str = str(hex(alpha_level)[2:]) if alpha_level != 0 else '00'
for sel_obj in sel_obj_list:
sel_obj.fill_color = sel_obj.fill_color[:-2] + alpha_str