Qt4 compatibility.

This commit is contained in:
Matthias Koefferlein 2021-02-21 21:55:36 +01:00
parent effa8027cc
commit fea33b284e
4 changed files with 39 additions and 2 deletions

View File

@ -1890,7 +1890,7 @@ MacroEditorDialog::set_editor_focus ()
return;
}
QSignalBlocker signal_blocker (searchEditBox);
lay::SignalBlocker signal_blocker (searchEditBox);
page->set_editor_focus ();
}

View File

@ -43,7 +43,6 @@
#include <QResource>
#include <QBuffer>
#include <QTimer>
#include <QWindow>
#include <QListWidget>
#include <QApplication>

View File

@ -189,5 +189,21 @@ indicate_error (QWidget *le, bool f)
le->setPalette (pl);
}
#if QT_VERSION < 0x050000
SignalBlocker::SignalBlocker (QWidget *w)
: mp_widget (w)
{
m_state = mp_widget->blockSignals (true);
}
SignalBlocker::~SignalBlocker ()
{
mp_widget->blockSignals (m_state);
}
#endif
}

View File

@ -31,6 +31,7 @@
class QLabel;
class QWidget;
class QObject;
class QSignalBlocker;
namespace tl
{
@ -81,6 +82,27 @@ LAYBASIC_PUBLIC void indicate_error (QWidget *le, const tl::Exception *ex);
*/
LAYBASIC_PUBLIC void indicate_error (QWidget *le, bool error);
#if QT_VERSION < 0x050000
// Provide missing QSignalBlocker for Qt4
class SignalBlocker
{
public:
SignalBlocker (QWidget *w);
~SignalBlocker ();
private:
QWidget *mp_widget;
bool m_state;
};
#else
typedef QSignalBlocker SignalBlocker;
#endif
} // namespace lay
#endif