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.Docks.CustomBrowserDocks="Custom Browser Docks..."
Basic.MainMenu.View.Toolbars.Listboxes="&Listboxes" Basic.MainMenu.View.Toolbars.Listboxes="&Listboxes"
Basic.MainMenu.View.SceneTransitions="S&cene Transitions" Basic.MainMenu.View.SceneTransitions="S&cene Transitions"
Basic.MainMenu.View.SourceIcons="Source &Icons"
Basic.MainMenu.View.StatusBar="&Status Bar" Basic.MainMenu.View.StatusBar="&Status Bar"
Basic.MainMenu.View.Fullscreen.Interface="Fullscreen Interface" Basic.MainMenu.View.Fullscreen.Interface="Fullscreen Interface"

View File

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

View File

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

View File

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

View File

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

View File

@ -1647,6 +1647,10 @@ void OBSBasic::OBSInit()
SET_VISIBILITY("ShowStatusBar", toggleStatusBar); SET_VISIBILITY("ShowStatusBar", toggleStatusBar);
#undef SET_VISIBILITY #undef SET_VISIBILITY
bool sourceIconsVisible = config_get_bool(
GetGlobalConfig(), "BasicWindow", "ShowSourceIcons");
ui->toggleSourceIcons->setChecked(sourceIconsVisible);
{ {
ProfileScope("OBSBasic::Load"); ProfileScope("OBSBasic::Load");
disableSaving--; disableSaving--;
@ -6801,6 +6805,14 @@ void OBSBasic::on_toggleStatusBar_toggled(bool visible)
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() void OBSBasic::on_actionLockPreview_triggered()
{ {
ui->preview->ToggleLocked(); ui->preview->ToggleLocked();

View File

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