MCPcopy Create free account
hub / github.com/WarmUpTill/SceneSwitcher / AddColorInternal

Method AddColorInternal

plugins/scripting/utils/properties-view.cpp:910–962  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

908}
909
910void OBSPropertiesView::AddColorInternal(obs_property_t *prop,
911 QFormLayout *layout, QLabel *&label,
912 bool supportAlpha)
913{
914 QPushButton *button = new QPushButton;
915 QLabel *colorLabel = new QLabel;
916 const char *name = obs_property_name(prop);
917 long long val = obs_data_get_int(settings, name);
918 QColor color = color_from_int(val);
919 QColor::NameFormat format;
920
921 if (!obs_property_enabled(prop)) {
922 button->setEnabled(false);
923 colorLabel->setEnabled(false);
924 }
925
926 button->setProperty("themeID", "settingsButtons");
927 button->setText(QTStr("Basic.PropertiesWindow.SelectColor"));
928 button->setToolTip(QT_UTF8(obs_property_long_description(prop)));
929
930 if (supportAlpha) {
931 format = QColor::HexArgb;
932 } else {
933 format = QColor::HexRgb;
934 color.setAlpha(255);
935 }
936
937 QPalette palette = QPalette(color);
938 colorLabel->setFrameStyle(QFrame::Sunken | QFrame::Panel);
939 colorLabel->setText(color.name(format));
940 colorLabel->setPalette(palette);
941 colorLabel->setStyleSheet(
942 QString("background-color :%1; color: %2;")
943 .arg(palette.color(QPalette::Window).name(format))
944 .arg(palette.color(QPalette::WindowText).name(format)));
945 colorLabel->setAutoFillBackground(true);
946 colorLabel->setAlignment(Qt::AlignCenter);
947 colorLabel->setToolTip(QT_UTF8(obs_property_long_description(prop)));
948
949 QHBoxLayout *subLayout = new QHBoxLayout;
950 subLayout->setContentsMargins(0, 0, 0, 0);
951
952 subLayout->addWidget(colorLabel);
953 subLayout->addWidget(button);
954
955 WidgetInfo *info = new WidgetInfo(this, prop, colorLabel);
956 connect(button, &QPushButton::clicked, info,
957 &WidgetInfo::ControlChanged);
958 children.emplace_back(info);
959
960 label = new QLabel(QT_UTF8(obs_property_description(prop)));
961 layout->addRow(label, subLayout);
962}
963
964void OBSPropertiesView::AddColor(obs_property_t *prop, QFormLayout *layout,
965 QLabel *&label)

Callers

nothing calls this directly

Calls 5

setTextMethod · 0.80
addRowMethod · 0.80
color_from_intFunction · 0.70
setToolTipMethod · 0.45
nameMethod · 0.45

Tested by

no test coverage detected