forked from qt-creator/qt-creator
Core: compress shortcut settings widget updates
reduces the number of calls to ShortcutSettingsWidget::initialize while the shortcut settings widget is open and actions get registered. For example when searching the preferences dialog the shortcut settings widget is alive and some setting page widgets create a text editor, which again registers some actions. Change-Id: Ieb3c3d1c7ce317c3407a9c97514f6cc4a4ce76c4 Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -30,6 +30,7 @@
|
||||
#include <QLineEdit>
|
||||
#include <QPointer>
|
||||
#include <QPushButton>
|
||||
#include <QTimer>
|
||||
#include <QTreeWidgetItem>
|
||||
|
||||
#include <array>
|
||||
@@ -420,6 +421,7 @@ private:
|
||||
QGridLayout *m_shortcutLayout;
|
||||
std::vector<std::unique_ptr<ShortcutInput>> m_shortcutInputs;
|
||||
QPointer<QPushButton> m_addButton = nullptr;
|
||||
QTimer m_updateTimer;
|
||||
};
|
||||
|
||||
ShortcutSettingsWidget::ShortcutSettingsWidget()
|
||||
@@ -428,7 +430,12 @@ ShortcutSettingsWidget::ShortcutSettingsWidget()
|
||||
setTargetHeader(Tr::tr("Shortcut"));
|
||||
setResetVisible(true);
|
||||
|
||||
m_updateTimer.setSingleShot(true);
|
||||
m_updateTimer.setInterval(100);
|
||||
|
||||
connect(ActionManager::instance(), &ActionManager::commandListChanged,
|
||||
&m_updateTimer, qOverload<>(&QTimer::start));
|
||||
connect(&m_updateTimer, &QTimer::timeout,
|
||||
this, &ShortcutSettingsWidget::initialize);
|
||||
connect(this, &ShortcutSettingsWidget::currentCommandChanged,
|
||||
this, &ShortcutSettingsWidget::handleCurrentCommandChanged);
|
||||
|
Reference in New Issue
Block a user