UI: Add option to toggle source icons to View menu

This commit is contained in:
jp9000 2020-01-20 23:18:46 -08:00
parent 8c549a3223
commit 9f1c442d35
7 changed files with 61 additions and 16 deletions

View file

@ -591,6 +591,7 @@ Basic.MainMenu.View.Docks.LockUI="Lock UI"
Basic.MainMenu.View.Docks.CustomBrowserDocks="Custom Browser Docks..."
Basic.MainMenu.View.Toolbars.Listboxes="&Listboxes"
Basic.MainMenu.View.SceneTransitions="S&cene Transitions"
Basic.MainMenu.View.SourceIcons="Source &Icons"
Basic.MainMenu.View.StatusBar="&Status Bar"
Basic.MainMenu.View.Fullscreen.Interface="Fullscreen Interface"

View file

@ -188,7 +188,7 @@
<x>0</x>
<y>0</y>
<width>1079</width>
<height>22</height>
<height>21</height>
</rect>
</property>
<widget class="QMenu" name="menu_File">
@ -393,6 +393,7 @@
<addaction name="separator"/>
<addaction name="viewMenuDocks"/>
<addaction name="viewMenuToolbars"/>
<addaction name="toggleSourceIcons"/>
<addaction name="toggleStatusBar"/>
<addaction name="separator"/>
<addaction name="stats"/>
@ -728,7 +729,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>64</width>
<width>80</width>
<height>16</height>
</rect>
</property>
@ -1788,6 +1789,17 @@
<string>Basic.MainMenu.Help.About</string>
</property>
</action>
<action name="toggleSourceIcons">
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="text">
<string>Basic.MainMenu.View.SourceIcons</string>
</property>
</action>
</widget>
<customwidgets>
<customwidget>

View file

@ -424,6 +424,8 @@ bool OBSApp::InitGlobalConfigDefaults()
"ShowListboxToolbars", true);
config_set_default_bool(globalConfig, "BasicWindow", "ShowStatusBar",
true);
config_set_default_bool(globalConfig, "BasicWindow", "ShowSourceIcons",
true);
config_set_default_bool(globalConfig, "BasicWindow", "StudioModeLabels",
true);

View file

@ -59,21 +59,25 @@ SourceTreeItem::SourceTreeItem(SourceTree *tree_, OBSSceneItem sceneitem_)
OBSBasic *main = reinterpret_cast<OBSBasic *>(App()->GetMainWindow());
const char *id = obs_source_get_id(source);
QIcon icon;
if (strcmp(id, "scene") == 0)
icon = main->GetSceneIcon();
else if (strcmp(id, "group") == 0)
icon = main->GetGroupIcon();
else
icon = main->GetSourceIcon(id);
QLabel *iconLabel = nullptr;
if (tree->iconsVisible) {
QIcon icon;
QPixmap pixmap = icon.pixmap(QSize(16, 16));
if (strcmp(id, "scene") == 0)
icon = main->GetSceneIcon();
else if (strcmp(id, "group") == 0)
icon = main->GetGroupIcon();
else
icon = main->GetSourceIcon(id);
QLabel *iconLabel = new QLabel();
iconLabel->setPixmap(pixmap);
iconLabel->setFixedSize(16, 16);
iconLabel->setStyleSheet("background: none");
QPixmap pixmap = icon.pixmap(QSize(16, 16));
iconLabel = new QLabel();
iconLabel->setPixmap(pixmap);
iconLabel->setFixedSize(16, 16);
iconLabel->setStyleSheet("background: none");
}
vis = new VisibilityCheckBox();
vis->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum);
@ -100,8 +104,10 @@ SourceTreeItem::SourceTreeItem(SourceTree *tree_, OBSSceneItem sceneitem_)
boxLayout = new QHBoxLayout();
boxLayout->setContentsMargins(0, 0, 0, 0);
boxLayout->addWidget(iconLabel);
boxLayout->addSpacing(2);
if (iconLabel) {
boxLayout->addWidget(iconLabel);
boxLayout->addSpacing(2);
}
boxLayout->addWidget(label);
boxLayout->addWidget(vis);
boxLayout->addSpacing(1);
@ -972,6 +978,14 @@ void SourceTree::UpdateIcons()
stm->SceneChanged();
}
void SourceTree::SetIconsVisible(bool visible)
{
SourceTreeModel *stm = GetStm();
iconsVisible = visible;
stm->SceneChanged();
}
void SourceTree::ResetWidgets()
{
OBSScene scene = GetCurrentScene();

View file

@ -144,6 +144,8 @@ class SourceTree : public QListView {
QStaticText textNoSources;
QSvgRenderer iconNoSources;
bool iconsVisible = true;
void UpdateNoSourcesMessage();
void ResetWidgets();
@ -178,6 +180,7 @@ public:
bool GroupedItemsSelected() const;
void UpdateIcons();
void SetIconsVisible(bool visible);
public slots:
inline void ReorderItems() { GetStm()->ReorderItems(); }

View file

@ -1647,6 +1647,10 @@ void OBSBasic::OBSInit()
SET_VISIBILITY("ShowStatusBar", toggleStatusBar);
#undef SET_VISIBILITY
bool sourceIconsVisible = config_get_bool(
GetGlobalConfig(), "BasicWindow", "ShowSourceIcons");
ui->toggleSourceIcons->setChecked(sourceIconsVisible);
{
ProfileScope("OBSBasic::Load");
disableSaving--;
@ -6801,6 +6805,14 @@ void OBSBasic::on_toggleStatusBar_toggled(bool visible)
visible);
}
void OBSBasic::on_toggleSourceIcons_toggled(bool visible)
{
ui->sources->SetIconsVisible(visible);
config_set_bool(App()->GlobalConfig(), "BasicWindow", "ShowSourceIcons",
visible);
}
void OBSBasic::on_actionLockPreview_triggered()
{
ui->preview->ToggleLocked();

View file

@ -893,6 +893,7 @@ private slots:
void on_toggleListboxToolbars_toggled(bool visible);
void on_toggleStatusBar_toggled(bool visible);
void on_toggleSourceIcons_toggled(bool visible);
void on_transitions_currentIndexChanged(int index);
void on_transitionAdd_clicked();