JKQTPlotter: made resize-timer status accessible from outside via JKQTPlotter::isResizeTimerRunning()

made it's delay a global static variable that can be set and red with JKQTPlotter::setGlobalResizeDelay() and JKQTPlotter::getGlobalResizeDelay()
This commit is contained in:
jkriege2 2022-08-28 22:47:46 +02:00
parent c9d9172765
commit 2aa6c8e3b6
2 changed files with 37 additions and 1 deletions

View File

@ -32,8 +32,17 @@
#include "jkqtplotter.h" #include "jkqtplotter.h"
#define jkqtp_RESIZE_DELAY 100 int JKQTPlotter::jkqtp_RESIZE_DELAY = 100;
void JKQTPlotter::setGlobalResizeDelay(int delayMS)
{
jkqtp_RESIZE_DELAY=delayMS;
}
int JKQTPlotter::getGlobalResizeDelay()
{
return jkqtp_RESIZE_DELAY;
}
@ -42,6 +51,7 @@
/************************************************************************************************************************** /**************************************************************************************************************************
* JKQTPlotter * JKQTPlotter
**************************************************************************************************************************/ **************************************************************************************************************************/
JKQTPlotter::JKQTPlotter(bool datastore_internal, QWidget* parent, JKQTPDatastore* datast): JKQTPlotter::JKQTPlotter(bool datastore_internal, QWidget* parent, JKQTPDatastore* datast):
QWidget(parent, Qt::Widget), QWidget(parent, Qt::Widget),
currentMouseDragAction(), currentMouseDragAction(),
@ -1348,6 +1358,11 @@ QSize JKQTPlotter::sizeHint() const {
return QWidget::sizeHint(); return QWidget::sizeHint();
} }
bool JKQTPlotter::isResizeTimerRunning() const
{
return resizeTimer.isActive();
}
void JKQTPlotter::synchronizeToMaster(JKQTPlotter *master, JKQTBasePlotter::SynchronizationDirection synchronizeDirection, bool synchronizeAxisLength, bool synchronizeZoomingMasterToSlave, bool synchronizeZoomingSlaveToMaster) void JKQTPlotter::synchronizeToMaster(JKQTPlotter *master, JKQTBasePlotter::SynchronizationDirection synchronizeDirection, bool synchronizeAxisLength, bool synchronizeZoomingMasterToSlave, bool synchronizeZoomingSlaveToMaster)
{ {
if (masterPlotterX) disconnect(masterPlotterX->getPlotter(), SIGNAL(plotScalingRecalculated()), this, SLOT(masterPlotScalingRecalculated())); if (masterPlotterX) disconnect(masterPlotterX->getPlotter(), SIGNAL(plotScalingRecalculated()), this, SLOT(masterPlotScalingRecalculated()));

View File

@ -441,6 +441,15 @@ JKQTPLOTTER_LIB_EXPORT void initJKQTPlotterResources();
class JKQTPLOTTER_LIB_EXPORT JKQTPlotter: public QWidget { class JKQTPLOTTER_LIB_EXPORT JKQTPlotter: public QWidget {
Q_OBJECT Q_OBJECT
public: public:
/** \brief sets the global resize delay in milliseconds \a delayMS. After calling this function all plots will use the new delay
*
* \see jkqtp_RESIZE_DELAY, setGlobalResizeDelay(), getGlobalResizeDelay(), resizeTimer */
static void setGlobalResizeDelay(int delayMS);
/** \brief returns the currently set global resize delay in milliseconds \a delayMS.
*
* \see jkqtp_RESIZE_DELAY, setGlobalResizeDelay(), getGlobalResizeDelay(), resizeTimer */
static int getGlobalResizeDelay();
/** \brief class constructor /** \brief class constructor
* *
* If \a datastore_internal \c ==false, you can supply an external JKQTPDatastore with the parameter \a datast * If \a datastore_internal \c ==false, you can supply an external JKQTPDatastore with the parameter \a datast
@ -553,6 +562,10 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPlotter: public QWidget {
/** \brief returns the size of the widget */ /** \brief returns the size of the widget */
QSize sizeHint() const; QSize sizeHint() const;
/** \brief returns \c true, if the JKQTPlotter::resizeTimer is currently running and the widget is waiting for the resize-event to finish
*
* \see jkqtp_RESIZE_DELAY, setGlobalResizeDelay(), getGlobalResizeDelay(), resizeTimer */
bool isResizeTimerRunning() const;
@ -1693,9 +1706,17 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPlotter: public QWidget {
* \see delayedResizeEvent() * \see delayedResizeEvent()
* *
* \image html jkqtplotter_fastresizing.gif * \image html jkqtplotter_fastresizing.gif
*
* \see jkqtp_RESIZE_DELAY, setGlobalResizeDelay(), getGlobalResizeDelay(), resizeTimer
*/ */
QTimer resizeTimer; QTimer resizeTimer;
/** \brief delay for resizing in milliseconds
*
* \see jkqtp_RESIZE_DELAY, setGlobalResizeDelay(), getGlobalResizeDelay(), resizeTimer
*/
static int jkqtp_RESIZE_DELAY;
/** \brief destroys the internal contextMenu and optionally creates a new one /** \brief destroys the internal contextMenu and optionally creates a new one
* *
* \param createnew if \c ==true, contextMenu is reinitialized with a (shiny) new QMenu, * \param createnew if \c ==true, contextMenu is reinitialized with a (shiny) new QMenu,