UI: Add SetComboItemEnabled
Replaces SetComboItemDisabled in context-bar-controls.cpp with a global function in qt-wrappers called SetComboItemEnabled, which allows both enabling and disabling items in a combo box.
This commit is contained in:
parent
a164a75ed6
commit
97491ee91a
@ -96,14 +96,6 @@ static int FillPropertyCombo(QComboBox *c, obs_property_t *p,
|
||||
return cur_idx;
|
||||
}
|
||||
|
||||
static void SetComboItemDisabled(QComboBox *c, int idx)
|
||||
{
|
||||
QStandardItemModel *model =
|
||||
dynamic_cast<QStandardItemModel *>(c->model());
|
||||
QStandardItem *item = model->item(idx);
|
||||
item->setFlags(Qt::NoItemFlags);
|
||||
}
|
||||
|
||||
void UpdateSourceComboToolbarProperties(QComboBox *combo, OBSSource source,
|
||||
obs_properties_t *props,
|
||||
const char *prop_name, bool is_int)
|
||||
@ -131,7 +123,7 @@ void UpdateSourceComboToolbarProperties(QComboBox *combo, OBSSource source,
|
||||
cur_idx = 0;
|
||||
}
|
||||
|
||||
SetComboItemDisabled(combo, cur_idx);
|
||||
SetComboItemEnabled(combo, cur_idx, false);
|
||||
}
|
||||
|
||||
combo->setCurrentIndex(cur_idx);
|
||||
@ -345,7 +337,7 @@ GameCaptureToolbar::GameCaptureToolbar(QWidget *parent, OBSSource source)
|
||||
ui->window->blockSignals(false);
|
||||
|
||||
if (cur_idx != -1 && obs_property_list_item_disabled(p, cur_idx)) {
|
||||
SetComboItemDisabled(ui->window, cur_idx);
|
||||
SetComboItemEnabled(ui->window, cur_idx, false);
|
||||
}
|
||||
|
||||
UpdateWindowVisibility();
|
||||
|
@ -22,10 +22,12 @@
|
||||
#include <util/threading.h>
|
||||
#include <QWidget>
|
||||
#include <QLayout>
|
||||
#include <QComboBox>
|
||||
#include <QMessageBox>
|
||||
#include <QDataStream>
|
||||
#include <QKeyEvent>
|
||||
#include <QFileDialog>
|
||||
#include <QStandardItemModel>
|
||||
|
||||
#if !defined(_WIN32) && !defined(__APPLE__)
|
||||
#include <QX11Info>
|
||||
@ -326,6 +328,15 @@ bool LineEditChanged(QEvent *event)
|
||||
return false;
|
||||
}
|
||||
|
||||
void SetComboItemEnabled(QComboBox *c, int idx, bool enabled)
|
||||
{
|
||||
QStandardItemModel *model =
|
||||
dynamic_cast<QStandardItemModel *>(c->model());
|
||||
QStandardItem *item = model->item(idx);
|
||||
item->setFlags(enabled ? Qt::ItemIsSelectable | Qt::ItemIsEnabled
|
||||
: Qt::NoItemFlags);
|
||||
}
|
||||
|
||||
void setThemeID(QWidget *widget, const QString &themeID)
|
||||
{
|
||||
if (widget->property("themeID").toString() != themeID) {
|
||||
|
@ -31,6 +31,7 @@
|
||||
#define QT_TO_UTF8(str) str.toUtf8().constData()
|
||||
|
||||
class QDataStream;
|
||||
class QComboBox;
|
||||
class QWidget;
|
||||
class QLayout;
|
||||
class QString;
|
||||
@ -106,6 +107,8 @@ static inline Qt::ConnectionType WaitConnection()
|
||||
bool LineEditCanceled(QEvent *event);
|
||||
bool LineEditChanged(QEvent *event);
|
||||
|
||||
void SetComboItemEnabled(QComboBox *c, int idx, bool enabled);
|
||||
|
||||
void setThemeID(QWidget *widget, const QString &themeID);
|
||||
|
||||
QString SelectDirectory(QWidget *parent, QString title, QString path);
|
||||
|
Loading…
x
Reference in New Issue
Block a user