Add option to disable filtering by typing in FilterComboBox

This commit is contained in:
WarmUpTill 2023-08-12 11:26:22 +02:00 committed by WarmUpTill
parent 68c6492c3f
commit a0b4df574b
7 changed files with 68 additions and 2 deletions

View File

@ -30,6 +30,7 @@ AdvSceneSwitcher.generalTab.generalBehavior.verboseLogging="Enable verbose loggi
AdvSceneSwitcher.generalTab.generalBehavior.saveWindowGeo="Save window position and size"
AdvSceneSwitcher.generalTab.generalBehavior.showTrayNotifications="Show system tray notifications"
AdvSceneSwitcher.generalTab.generalBehavior.disableUIHints="Disable UI hints"
AdvSceneSwitcher.generalTab.generalBehavior.comboBoxFilterDisable="Disable filtering by typing in drop down menus"
AdvSceneSwitcher.generalTab.generalBehavior.warnPluginLoadFailure="Display warning if plugins cannot be loaded"
AdvSceneSwitcher.generalTab.generalBehavior.warnPluginLoadFailureMessage="<html><body>Loading of the following plugin libraries was unsuccessful, which could result in some Advanced Scene Switcher functions not being available:%1Check the OBS logs for details.<br>This message can be disabled on the General tab.</body></html>"
AdvSceneSwitcher.generalTab.generalBehavior.hideLegacyTabs="Hide tabs which can be represented via macros"

View File

@ -67,8 +67,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>957</width>
<height>905</height>
<width>962</width>
<height>1033</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_19">
@ -256,6 +256,30 @@
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_11">
<item>
<widget class="QCheckBox" name="disableComboBoxFilter">
<property name="text">
<string>AdvSceneSwitcher.generalTab.generalBehavior.comboBoxFilterDisable</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_13">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_26">
<item>

View File

@ -63,6 +63,7 @@ public slots:
void on_saveWindowGeo_stateChanged(int state);
void on_showTrayNotifications_stateChanged(int state);
void on_uiHintsDisable_stateChanged(int state);
void on_disableComboBoxFilter_stateChanged(int state);
void on_warnPluginLoadFailure_stateChanged(int state);
void on_hideLegacyTabs_stateChanged(int state);
void on_priorityUp_clicked();

View File

@ -2,6 +2,7 @@
#include "switcher-data.hpp"
#include "status-control.hpp"
#include "file-selection.hpp"
#include "filter-combo-box.hpp"
#include "utility.hpp"
#include "version.h"
@ -175,6 +176,16 @@ void AdvSceneSwitcher::on_uiHintsDisable_stateChanged(int state)
switcher->disableHints = state;
}
void AdvSceneSwitcher::on_disableComboBoxFilter_stateChanged(int state)
{
if (loading) {
return;
}
switcher->disableFilterComboboxFilter = state;
FilterComboBox::SetFilterBehaviourEnabled(!state);
}
void AdvSceneSwitcher::on_warnPluginLoadFailure_stateChanged(int state)
{
if (loading) {
@ -575,6 +586,8 @@ void SwitcherData::SaveGeneralSettings(obs_data_t *obj)
obs_data_set_bool(obj, "showSystemTrayNotifications",
showSystemTrayNotifications);
obs_data_set_bool(obj, "disableHints", disableHints);
obs_data_set_bool(obj, "disableFilterComboboxFilter",
disableFilterComboboxFilter);
obs_data_set_bool(obj, "warnPluginLoadFailure", warnPluginLoadFailure);
obs_data_set_bool(obj, "hideLegacyTabs", hideLegacyTabs);
@ -623,6 +636,8 @@ void SwitcherData::LoadGeneralSettings(obs_data_t *obj)
showSystemTrayNotifications =
obs_data_get_bool(obj, "showSystemTrayNotifications");
disableHints = obs_data_get_bool(obj, "disableHints");
disableFilterComboboxFilter =
obs_data_get_bool(obj, "disableFilterComboboxFilter");
obs_data_set_default_bool(obj, "warnPluginLoadFailure", true);
warnPluginLoadFailure = obs_data_get_bool(obj, "warnPluginLoadFailure");
obs_data_set_default_bool(obj, "hideLegacyTabs", true);
@ -997,6 +1012,10 @@ void AdvSceneSwitcher::SetupGeneralTab()
ui->showTrayNotifications->setChecked(
switcher->showSystemTrayNotifications);
ui->uiHintsDisable->setChecked(switcher->disableHints);
ui->disableComboBoxFilter->setChecked(
switcher->disableFilterComboboxFilter);
FilterComboBox::SetFilterBehaviourEnabled(
!switcher->disableFilterComboboxFilter);
ui->warnPluginLoadFailure->setChecked(switcher->warnPluginLoadFailure);
ui->hideLegacyTabs->setChecked(switcher->hideLegacyTabs);

View File

@ -204,6 +204,7 @@ public:
QStringList loadFailureLibs;
bool warnPluginLoadFailure = true;
bool disableHints = false;
bool disableFilterComboboxFilter = false;
bool hideLegacyTabs = true;
std::vector<int> tabOrder = std::vector<int>(tab_count);
bool saveWindowGeo = false;

View File

@ -7,9 +7,22 @@
namespace advss {
bool FilterComboBox::_filteringEnabled = false;
FilterComboBox::FilterComboBox(QWidget *parent, const QString &placehodler)
: QComboBox(parent)
{
// If the filtering behaviour of the FilterComboBox is disabled it is
// just a regular QComboBox with the option to set a placeholder so exit
// the constructor early.
if (!_filteringEnabled) {
if (!placehodler.isEmpty()) {
setPlaceholderText(placehodler);
}
return;
}
// Allow edit for completer but don't add new entries on pressing enter
setEditable(true);
setInsertPolicy(InsertPolicy::NoInsert);
@ -31,6 +44,11 @@ FilterComboBox::FilterComboBox(QWidget *parent, const QString &placehodler)
&FilterComboBox::TextChagned);
}
void FilterComboBox::SetFilterBehaviourEnabled(bool value)
{
FilterComboBox::_filteringEnabled = value;
}
void FilterComboBox::focusOutEvent(QFocusEvent *event)
{
// Reset on invalid selection

View File

@ -10,6 +10,7 @@ class FilterComboBox : public QComboBox {
public:
FilterComboBox(QWidget *parent = nullptr,
const QString &placehodler = "");
static void SetFilterBehaviourEnabled(bool);
protected:
void focusOutEvent(QFocusEvent *event) override;
@ -20,6 +21,7 @@ private slots:
private:
int _lastCompleterHighlightRow = -1;
static bool _filteringEnabled;
};
} // namespace advss