Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Merge pull request #10484 from AdmiralCurtiss/general-pane-signalblocker
Qt/GeneralPane: Don't trigger config change events when populating GUI.
- Loading branch information
Showing
4 changed files
with
56 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| // Copyright 2022 Dolphin Emulator Project | ||
| // SPDX-License-Identifier: GPL-2.0-or-later | ||
|
|
||
| #pragma once | ||
|
|
||
| #include <QSignalBlocker> | ||
|
|
||
| // Helper class for populating a GUI element without triggering its data change signals. | ||
|
|
||
| template <typename T> | ||
| class SignalBlockerProxy | ||
| { | ||
| public: | ||
| explicit SignalBlockerProxy(T* object) : m_object(object), m_blocker(object) {} | ||
| SignalBlockerProxy(const SignalBlockerProxy& other) = delete; | ||
| SignalBlockerProxy(SignalBlockerProxy&& other) = default; | ||
| SignalBlockerProxy& operator=(const SignalBlockerProxy& other) = delete; | ||
| SignalBlockerProxy& operator=(SignalBlockerProxy&& other) = default; | ||
| ~SignalBlockerProxy() = default; | ||
|
|
||
| T* operator->() const { return m_object; } | ||
|
|
||
| private: | ||
| T* m_object; | ||
| QSignalBlocker m_blocker; | ||
| }; | ||
|
|
||
| template <typename T> | ||
| SignalBlockerProxy<T> SignalBlocking(T* object) | ||
| { | ||
| return SignalBlockerProxy<T>(object); | ||
| } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters