Skip to content

Commit 1bb31cc

Browse files
committed
qtvcp -versa/basic probe: add scroll buttons to help dialog
1 parent 46d7391 commit 1bb31cc

File tree

2 files changed

+64
-12
lines changed

2 files changed

+64
-12
lines changed

lib/python/qtvcp/widgets/basic_probe.py

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import json
2121
from PyQt5.QtCore import QProcess, QRegExp, QFile, Qt
2222
from PyQt5 import QtGui, QtWidgets, uic, QtCore
23-
from PyQt5.QtWidgets import QDialogButtonBox
23+
from PyQt5.QtWidgets import QDialogButtonBox, QAbstractSlider
2424
from qtvcp.widgets.widget_baseclass import _HalWidgetBase
2525
from qtvcp.core import Action, Status, Info, Path
2626
from qtvcp.widgets.dialogMixin import GeometryMixin
@@ -353,11 +353,6 @@ def buildWidget(self):
353353
l = QtWidgets.QVBoxLayout()
354354
t = QtWidgets.QTextEdit('Basic Probe Help')
355355
t.setReadOnly(True)
356-
try:
357-
self.next(t)
358-
except Exception as e:
359-
t.setText('Basic Probe Help file Unavailable:\n\n{}'.format(e))
360-
361356
l.addWidget(t)
362357

363358
buttons = QDialogButtonBox()
@@ -377,7 +372,19 @@ def buildWidget(self):
377372
previousbutton.setIcon(QtGui.QIcon(':/qt-project.org/styles/commonstyle/images/left-32.png'))
378373
previousbutton.clicked.connect(lambda : self.next(t,False))
379374

375+
self.pageStepUpbutton = QtWidgets.QPushButton()
376+
self.pageStepUpbutton.setIconSize(QtCore.QSize(38, 38))
377+
self.pageStepUpbutton.setIcon(QtGui.QIcon(':/qt-project.org/styles/commonstyle/images/up-32.png'))
378+
self.pageStepUpbutton.clicked.connect(lambda : self.pageStep(t,False))
379+
380+
self.pageStepDwnbutton = QtWidgets.QPushButton()
381+
self.pageStepDwnbutton.setIconSize(QtCore.QSize(38, 38))
382+
self.pageStepDwnbutton.setIcon(QtGui.QIcon(':/qt-project.org/styles/commonstyle/images/down-32.png'))
383+
self.pageStepDwnbutton.clicked.connect(lambda : self.pageStep(t,True))
384+
380385
bBox = QDialogButtonBox(buttons)
386+
bBox.addButton(self.pageStepUpbutton, QDialogButtonBox.ActionRole)
387+
bBox.addButton(self.pageStepDwnbutton, QDialogButtonBox.ActionRole)
381388
bBox.addButton(previousbutton, QDialogButtonBox.ActionRole)
382389
bBox.addButton(nextbutton, QDialogButtonBox.ActionRole)
383390
bBox.addButton(closebutton, QDialogButtonBox.DestructiveRole)
@@ -386,6 +393,11 @@ def buildWidget(self):
386393
l.addWidget(bBox)
387394
self.setLayout(l)
388395

396+
try:
397+
self.next(t)
398+
except Exception as e:
399+
t.setText('Basic Probe Help file Unavailable:\n\n{}'.format(e))
400+
389401
def next(self,t,direction=None):
390402
if direction is None:
391403
self.currentHelpPage = 0
@@ -405,6 +417,14 @@ def next(self,t,direction=None):
405417
html = str(html, encoding='utf8')
406418
html = html.replace("../images/widgets/","{}/widgets/".format(INFO.IMAGE_PATH))
407419
t.setHtml(html)
420+
if t.verticalScrollBar().isVisible():
421+
t.verticalScrollBar().setPageStep(100)
422+
self.pageStepDwnbutton.show()
423+
self.pageStepUpbutton.show()
424+
else:
425+
self.pageStepDwnbutton.hide()
426+
self.pageStepUpbutton.hide()
427+
408428
except Exception as e:
409429
t.setHtml('''
410430
<h1 style=" margin-top:18px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:xx-large; font-weight:600;">Basic Probe Help not available</span> </h1>
@@ -414,6 +434,12 @@ def next(self,t,direction=None):
414434
return
415435
self.show()
416436

437+
def pageStep(self, t, state):
438+
if state:
439+
t.verticalScrollBar().triggerAction (QAbstractSlider.SliderPageStepAdd)
440+
else:
441+
t.verticalScrollBar().triggerAction (QAbstractSlider.SliderPageStepSub)
442+
417443
# accept button applies presets and if line number given starts linuxcnc
418444
def close(self):
419445
self.record_geometry()

lib/python/qtvcp/widgets/versa_probe.py

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
from PyQt5 import QtGui, QtCore, QtWidgets, uic
2424
from PyQt5.QtCore import QProcess, QEvent, Qt
25-
from PyQt5.QtWidgets import QDialogButtonBox
25+
from PyQt5.QtWidgets import QDialogButtonBox, QAbstractSlider
2626

2727
from qtvcp.widgets.widget_baseclass import _HalWidgetBase
2828
from qtvcp.core import Status, Action, Info, Path
@@ -491,11 +491,6 @@ def buildWidget(self):
491491
l = QtWidgets.QVBoxLayout()
492492
t = QtWidgets.QTextEdit('Versa Probe Help')
493493
t.setReadOnly(True)
494-
try:
495-
self.next(t)
496-
except Exception as e:
497-
t.setText('Versa Probe Help file Unavailable:\n\n{}'.format(e))
498-
499494
l.addWidget(t)
500495

501496
buttons = QDialogButtonBox()
@@ -515,7 +510,19 @@ def buildWidget(self):
515510
previousbutton.setIcon(QtGui.QIcon(':/qt-project.org/styles/commonstyle/images/left-32.png'))
516511
previousbutton.clicked.connect(lambda : self.next(t,False))
517512

513+
self.pageStepUpbutton = QtWidgets.QPushButton()
514+
self.pageStepUpbutton.setIconSize(QtCore.QSize(38, 38))
515+
self.pageStepUpbutton.setIcon(QtGui.QIcon(':/qt-project.org/styles/commonstyle/images/up-32.png'))
516+
self.pageStepUpbutton.clicked.connect(lambda : self.pageStep(t,False))
517+
518+
self.pageStepDwnbutton = QtWidgets.QPushButton()
519+
self.pageStepDwnbutton.setIconSize(QtCore.QSize(38, 38))
520+
self.pageStepDwnbutton.setIcon(QtGui.QIcon(':/qt-project.org/styles/commonstyle/images/down-32.png'))
521+
self.pageStepDwnbutton.clicked.connect(lambda : self.pageStep(t,True))
522+
518523
bBox = QDialogButtonBox(buttons)
524+
bBox.addButton(self.pageStepUpbutton, QDialogButtonBox.ActionRole)
525+
bBox.addButton(self.pageStepDwnbutton, QDialogButtonBox.ActionRole)
519526
bBox.addButton(previousbutton, QDialogButtonBox.ActionRole)
520527
bBox.addButton(nextbutton, QDialogButtonBox.ActionRole)
521528
bBox.addButton(closebutton, QDialogButtonBox.DestructiveRole)
@@ -524,6 +531,11 @@ def buildWidget(self):
524531
l.addWidget(bBox)
525532
self.setLayout(l)
526533

534+
try:
535+
self.next(t)
536+
except Exception as e:
537+
t.setText('Versa Probe Help file Unavailable:\n\n{}'.format(e))
538+
527539
def next(self,t,direction=None):
528540
if direction is None:
529541
self.currentHelpPage = 0
@@ -543,12 +555,26 @@ def next(self,t,direction=None):
543555
html = str(html, encoding='utf8')
544556
html = html.replace("../images/probe_icons/","{}/probe_icons/".format(INFO.IMAGE_PATH))
545557
t.setHtml(html)
558+
if t.verticalScrollBar().isVisible():
559+
t.verticalScrollBar().setPageStep(20)
560+
self.pageStepDwnbutton.show()
561+
self.pageStepUpbutton.show()
562+
else:
563+
self.pageStepDwnbutton.hide()
564+
self.pageStepUpbutton.hide()
565+
546566
except Exception as e:
547567
t.setText('Versa Probe Help file Unavailable:\n\n{}'.format(e))
548568
if direction is None:
549569
return
550570
self.show()
551571

572+
def pageStep(self, t, state):
573+
if state:
574+
t.verticalScrollBar().triggerAction (QAbstractSlider.SliderPageStepAdd)
575+
else:
576+
t.verticalScrollBar().triggerAction (QAbstractSlider.SliderPageStepSub)
577+
552578
# accept button applies presets and if line number given starts linuxcnc
553579
def close(self):
554580
self.record_geometry()

0 commit comments

Comments
 (0)