mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-03-21 17:34:57 -05:00
Add WindowSelectionWidget
Refreshes list of windows when widget becomes visible to support widget caching
This commit is contained in:
parent
c43439ee64
commit
c281c6db83
|
|
@ -181,7 +181,9 @@ target_sources(
|
|||
utils/websocket-helpers.cpp
|
||||
utils/websocket-helpers.hpp
|
||||
utils/websocket-tab.cpp
|
||||
utils/websocket-tab.hpp)
|
||||
utils/websocket-tab.hpp
|
||||
utils/window-selection.cpp
|
||||
utils/window-selection.hpp)
|
||||
|
||||
if(OS_WINDOWS)
|
||||
target_sources(${PROJECT_NAME} PRIVATE utils/windows/windows.cpp)
|
||||
|
|
|
|||
|
|
@ -163,16 +163,12 @@ MacroActionWindowEdit::MacroActionWindowEdit(
|
|||
QWidget *parent, std::shared_ptr<MacroActionWindow> entryData)
|
||||
: QWidget(parent),
|
||||
_actions(new QComboBox()),
|
||||
_windows(new QComboBox()),
|
||||
_windows(new WindowSelectionWidget(this)),
|
||||
_regex(new RegexConfigWidget(this)),
|
||||
_infoLayout(new QHBoxLayout())
|
||||
{
|
||||
populateActionSelection(_actions);
|
||||
|
||||
_windows->setEditable(true);
|
||||
_windows->setMaxVisibleItems(20);
|
||||
PopulateWindowSelection(_windows);
|
||||
|
||||
auto focusLimitation = new QLabel(obs_module_text(
|
||||
"AdvSceneSwitcher.action.window.type.setFocusWindow.limitation"));
|
||||
_infoLayout->addWidget(focusLimitation);
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
#include "macro-action-edit.hpp"
|
||||
#include "regex-config.hpp"
|
||||
#include "variable-string.hpp"
|
||||
#include "window-selection.hpp"
|
||||
|
||||
namespace advss {
|
||||
|
||||
|
|
@ -62,7 +63,7 @@ private:
|
|||
void SetWidgetVisibility();
|
||||
|
||||
QComboBox *_actions;
|
||||
QComboBox *_windows;
|
||||
WindowSelectionWidget *_windows;
|
||||
RegexConfigWidget *_regex;
|
||||
QHBoxLayout *_infoLayout;
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
#include "layout-helpers.hpp"
|
||||
#include "plugin-state-helpers.hpp"
|
||||
#include "platform-funcs.hpp"
|
||||
#include "selection-helpers.hpp"
|
||||
|
||||
#include <regex>
|
||||
|
||||
|
|
@ -193,7 +192,7 @@ void MacroConditionWindow::SetupTempVars()
|
|||
MacroConditionWindowEdit::MacroConditionWindowEdit(
|
||||
QWidget *parent, std::shared_ptr<MacroConditionWindow> entryData)
|
||||
: QWidget(parent),
|
||||
_windowSelection(new QComboBox()),
|
||||
_windowSelection(new WindowSelectionWidget(this)),
|
||||
_windowRegex(new RegexConfigWidget(this)),
|
||||
_checkTitle(new QCheckBox()),
|
||||
_fullscreen(new QCheckBox()),
|
||||
|
|
@ -206,9 +205,6 @@ MacroConditionWindowEdit::MacroConditionWindowEdit(
|
|||
_focusWindow(new QLabel()),
|
||||
_currentFocusLayout(new QHBoxLayout())
|
||||
{
|
||||
_windowSelection->setEditable(true);
|
||||
_windowSelection->setMaxVisibleItems(20);
|
||||
|
||||
_checkText->setToolTip(obs_module_text(
|
||||
"AdvSceneSwitcher.condition.window.entry.text.note"));
|
||||
_text->setToolTip(obs_module_text(
|
||||
|
|
@ -240,8 +236,6 @@ MacroConditionWindowEdit::MacroConditionWindowEdit(
|
|||
QWidget::connect(&_timer, SIGNAL(timeout()), this,
|
||||
SLOT(UpdateFocusWindow()));
|
||||
|
||||
PopulateWindowSelection(_windowSelection);
|
||||
|
||||
const std::unordered_map<std::string, QWidget *> widgetPlaceholders = {
|
||||
{"{{windows}}", _windowSelection},
|
||||
{"{{windowRegex}}", _windowRegex},
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
#include "macro-condition-edit.hpp"
|
||||
#include "variable-text-edit.hpp"
|
||||
#include "regex-config.hpp"
|
||||
#include "window-selection.hpp"
|
||||
|
||||
#include <QComboBox>
|
||||
#include <QCheckBox>
|
||||
|
|
@ -77,7 +78,7 @@ signals:
|
|||
void HeaderInfoChanged(const QString &);
|
||||
|
||||
protected:
|
||||
QComboBox *_windowSelection;
|
||||
WindowSelectionWidget *_windowSelection;
|
||||
RegexConfigWidget *_windowRegex;
|
||||
QCheckBox *_checkTitle;
|
||||
QCheckBox *_fullscreen;
|
||||
|
|
|
|||
25
plugins/base/utils/window-selection.cpp
Normal file
25
plugins/base/utils/window-selection.cpp
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
#include "window-selection.hpp"
|
||||
#include "selection-helpers.hpp"
|
||||
|
||||
namespace advss {
|
||||
|
||||
WindowSelectionWidget::WindowSelectionWidget(QWidget *parent)
|
||||
: FilterComboBox(parent)
|
||||
{
|
||||
setEditable(true);
|
||||
SetAllowUnmatchedSelection(true);
|
||||
setMaxVisibleItems(20);
|
||||
PopulateWindowSelection(this);
|
||||
}
|
||||
|
||||
void WindowSelectionWidget::showEvent(QShowEvent *event)
|
||||
{
|
||||
FilterComboBox::showEvent(event);
|
||||
const QSignalBlocker b(this);
|
||||
const auto text = currentText();
|
||||
clear();
|
||||
PopulateWindowSelection(this);
|
||||
setCurrentText(text);
|
||||
}
|
||||
|
||||
} // namespace advss
|
||||
16
plugins/base/utils/window-selection.hpp
Normal file
16
plugins/base/utils/window-selection.hpp
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
#pragma once
|
||||
#include "filter-combo-box.hpp"
|
||||
|
||||
namespace advss {
|
||||
|
||||
class WindowSelectionWidget : public FilterComboBox {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
WindowSelectionWidget(QWidget *parent);
|
||||
|
||||
protected:
|
||||
void showEvent(QShowEvent *event) override;
|
||||
};
|
||||
|
||||
} // namespace advss
|
||||
Loading…
Reference in New Issue
Block a user