Explorar o código

UI: Show source icon in context bar

This shows the source icon next to the source label in the
context bar.
Clayton Groeneveld %!s(int64=4) %!d(string=hai) anos
pai
achega
a3f3b9d03c
Modificáronse 2 ficheiros con 39 adicións e 0 borrados
  1. 25 0
      UI/forms/OBSBasic.ui
  2. 14 0
      UI/window-basic-main.cpp

+ 25 - 0
UI/forms/OBSBasic.ui

@@ -258,6 +258,31 @@
           <property name="bottomMargin">
            <number>0</number>
           </property>
+          <item>
+           <widget class="QLabel" name="contextSourceIcon">
+            <property name="sizePolicy">
+             <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+              <horstretch>0</horstretch>
+              <verstretch>0</verstretch>
+             </sizepolicy>
+            </property>
+            <property name="minimumSize">
+             <size>
+              <width>22</width>
+              <height>22</height>
+             </size>
+            </property>
+            <property name="maximumSize">
+             <size>
+              <width>22</width>
+              <height>22</height>
+             </size>
+            </property>
+            <property name="text">
+             <string/>
+            </property>
+           </widget>
+          </item>
           <item>
            <widget class="QLabel" name="contextSourceLabel">
             <property name="sizePolicy">

+ 14 - 0
UI/window-basic-main.cpp

@@ -3123,6 +3123,19 @@ void OBSBasic::UpdateContextBar(bool force)
 			ui->emptySpace->layout()->addWidget(c);
 		}
 
+		QIcon icon;
+
+		if (strcmp(id, "scene") == 0)
+			icon = GetSceneIcon();
+		else if (strcmp(id, "group") == 0)
+			icon = GetGroupIcon();
+		else
+			icon = GetSourceIcon(id);
+
+		QPixmap pixmap = icon.pixmap(QSize(16, 16));
+		ui->contextSourceIcon->setPixmap(pixmap);
+		ui->contextSourceIcon->show();
+
 		const char *name = obs_source_get_name(source);
 		ui->contextSourceLabel->setText(name);
 
@@ -3130,6 +3143,7 @@ void OBSBasic::UpdateContextBar(bool force)
 		ui->sourcePropertiesButton->setEnabled(
 			obs_source_configurable(source));
 	} else {
+		ui->contextSourceIcon->hide();
 		ui->contextSourceLabel->setText(
 			QTStr("ContextBar.NoSelectedSource"));