Skip to content

Commit 407944a

Browse files
Warchamp7RytoEX
authored andcommitted
frontend: Rearrange default dock positions
1 parent 6a64053 commit 407944a

File tree

5 files changed

+47
-35
lines changed

5 files changed

+47
-35
lines changed

frontend/OBSApp.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ void OBSApp::InitUserConfigDefaults()
362362
config_set_default_bool(userConfig, "BasicWindow", "ShowContextToolbars", true);
363363
config_set_default_bool(userConfig, "BasicWindow", "StudioModeLabels", true);
364364

365-
config_set_default_bool(userConfig, "BasicWindow", "VerticalVolControl", false);
365+
config_set_default_bool(userConfig, "BasicWindow", "VerticalVolControl", true);
366366

367367
config_set_default_bool(userConfig, "BasicWindow", "MultiviewMouseSwitch", true);
368368

frontend/forms/OBSBasic.ui

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
<rect>
88
<x>0</x>
99
<y>0</y>
10-
<width>1086</width>
11-
<height>729</height>
10+
<width>1280</width>
11+
<height>960</height>
1212
</rect>
1313
</property>
1414
<property name="sizePolicy">
@@ -703,7 +703,7 @@
703703
<rect>
704704
<x>0</x>
705705
<y>0</y>
706-
<width>1086</width>
706+
<width>1280</width>
707707
<height>22</height>
708708
</rect>
709709
</property>
@@ -1289,7 +1289,7 @@
12891289
<rect>
12901290
<x>0</x>
12911291
<y>0</y>
1292-
<width>322</width>
1292+
<width>380</width>
12931293
<height>16</height>
12941294
</rect>
12951295
</property>
@@ -2213,7 +2213,7 @@
22132213
<bool>true</bool>
22142214
</property>
22152215
<property name="checked">
2216-
<bool>false</bool>
2216+
<bool>true</bool>
22172217
</property>
22182218
<property name="text">
22192219
<string>Basic.MainMenu.Docks.SideDocks</string>

frontend/widgets/OBSBasic.cpp

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,6 @@ OBSBasic::OBSBasic(QWidget *parent) : OBSMainWindow(parent), undo_s(ui), ui(new
285285
controlsDock->setWindowTitle(QTStr("Basic.Main.Controls"));
286286
/* Parenting is done there so controls will be deleted alongside controlsDock */
287287
controlsDock->setWidget(controls);
288-
addDockWidget(Qt::BottomDockWidgetArea, controlsDock);
289288

290289
connect(controls, &OBSBasicControls::StreamButtonClicked, this, &OBSBasic::StreamActionTriggered);
291290

@@ -342,6 +341,17 @@ OBSBasic::OBSBasic(QWidget *parent) : OBSMainWindow(parent), undo_s(ui), ui(new
342341
connect(ui->transitionDuration, &QSpinBox::valueChanged, this,
343342
[this](int value) { SetTransitionDuration(value); });
344343

344+
/* Main window default layout */
345+
setDockCornersVertical(true);
346+
347+
/* Scenes and Sources dock on left
348+
* This specific arrangement can't be set up in Qt Designer */
349+
addDockWidget(Qt::LeftDockWidgetArea, ui->scenesDock);
350+
splitDockWidget(ui->scenesDock, ui->sourcesDock, Qt::Vertical);
351+
int sideDockWidth = std::min(width() * 30 / 100, 320);
352+
resizeDocks({ui->scenesDock, ui->sourcesDock}, {sideDockWidth, sideDockWidth}, Qt::Horizontal);
353+
addDockWidget(Qt::BottomDockWidgetArea, controlsDock);
354+
345355
startingDockLayout = saveState();
346356

347357
statsDock = new OBSDock();
@@ -1232,10 +1242,8 @@ void OBSBasic::OBSInit()
12321242
ui->lockDocks->blockSignals(false);
12331243

12341244
bool sideDocks = config_get_bool(App()->GetUserConfig(), "BasicWindow", "SideDocks");
1235-
on_sideDocks_toggled(sideDocks);
1236-
ui->sideDocks->blockSignals(true);
12371245
ui->sideDocks->setChecked(sideDocks);
1238-
ui->sideDocks->blockSignals(false);
1246+
setDockCornersVertical(sideDocks);
12391247

12401248
SystemTray(true);
12411249

frontend/widgets/OBSBasic.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,7 @@ public slots:
456456
void RemoveDockWidget(const QString &name);
457457
bool IsDockObjectNameUsed(const QString &name);
458458
void AddCustomDockWidget(QDockWidget *dock);
459+
void setDockCornersVertical(bool vertical);
459460

460461
private slots:
461462
void on_resetDocks_triggered(bool force = false);

frontend/widgets/OBSBasic_Docks.cpp

Lines changed: 28 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -74,21 +74,12 @@ void OBSBasic::on_resetDocks_triggered(bool force)
7474
#undef RESET_DOCKLIST
7575

7676
restoreState(startingDockLayout);
77+
ui->sideDocks->setChecked(true);
7778

7879
int cx = width();
79-
int cy = height();
80+
int bottomDocksHeight = height();
8081

81-
int cx22_5 = cx * 225 / 1000;
82-
int cx5 = cx * 5 / 100;
83-
int cx21 = cx * 21 / 100;
84-
85-
cy = cy * 225 / 1000;
86-
87-
int mixerSize = cx - (cx22_5 * 2 + cx5 + cx21);
88-
89-
QList<QDockWidget *> docks{ui->scenesDock, ui->sourcesDock, ui->mixerDock, ui->transitionsDock, controlsDock};
90-
91-
QList<int> sizes{cx22_5, cx22_5, mixerSize, cx5, cx21};
82+
bottomDocksHeight = bottomDocksHeight * 225 / 1000;
9283

9384
ui->scenesDock->setVisible(true);
9485
ui->sourcesDock->setVisible(true);
@@ -98,8 +89,13 @@ void OBSBasic::on_resetDocks_triggered(bool force)
9889
statsDock->setVisible(false);
9990
statsDock->setFloating(true);
10091

101-
resizeDocks(docks, {cy, cy, cy, cy, cy}, Qt::Vertical);
102-
resizeDocks(docks, sizes, Qt::Horizontal);
92+
QList<QDockWidget *> bottomDocks{ui->mixerDock, ui->transitionsDock, controlsDock};
93+
94+
resizeDocks(bottomDocks, {bottomDocksHeight, bottomDocksHeight, bottomDocksHeight}, Qt::Vertical);
95+
resizeDocks(bottomDocks, {cx * 45 / 100, cx * 14 / 100, cx * 16 / 100}, Qt::Horizontal);
96+
97+
int sideDockWidth = std::min(width() * 30 / 100, 280);
98+
resizeDocks({ui->scenesDock, ui->sourcesDock}, {sideDockWidth, sideDockWidth}, Qt::Horizontal);
10399

104100
activateWindow();
105101
}
@@ -135,17 +131,9 @@ void OBSBasic::on_lockDocks_toggled(bool lock)
135131

136132
void OBSBasic::on_sideDocks_toggled(bool side)
137133
{
138-
if (side) {
139-
setCorner(Qt::TopLeftCorner, Qt::LeftDockWidgetArea);
140-
setCorner(Qt::TopRightCorner, Qt::RightDockWidgetArea);
141-
setCorner(Qt::BottomLeftCorner, Qt::LeftDockWidgetArea);
142-
setCorner(Qt::BottomRightCorner, Qt::RightDockWidgetArea);
143-
} else {
144-
setCorner(Qt::TopLeftCorner, Qt::TopDockWidgetArea);
145-
setCorner(Qt::TopRightCorner, Qt::TopDockWidgetArea);
146-
setCorner(Qt::BottomLeftCorner, Qt::BottomDockWidgetArea);
147-
setCorner(Qt::BottomRightCorner, Qt::BottomDockWidgetArea);
148-
}
134+
config_set_bool(App()->GetUserConfig(), "BasicWindow", "SideDocks", side);
135+
136+
setDockCornersVertical(side);
149137
}
150138

151139
void OBSBasic::AddDockWidget(QDockWidget *dock, Qt::DockWidgetArea area, bool extraBrowser)
@@ -232,6 +220,21 @@ void OBSBasic::AddCustomDockWidget(QDockWidget *dock)
232220
extraCustomDocks.push_back(dock);
233221
}
234222

223+
void OBSBasic::setDockCornersVertical(bool vertical)
224+
{
225+
if (vertical) {
226+
setCorner(Qt::TopLeftCorner, Qt::LeftDockWidgetArea);
227+
setCorner(Qt::TopRightCorner, Qt::RightDockWidgetArea);
228+
setCorner(Qt::BottomLeftCorner, Qt::LeftDockWidgetArea);
229+
setCorner(Qt::BottomRightCorner, Qt::RightDockWidgetArea);
230+
} else {
231+
setCorner(Qt::TopLeftCorner, Qt::TopDockWidgetArea);
232+
setCorner(Qt::TopRightCorner, Qt::TopDockWidgetArea);
233+
setCorner(Qt::BottomLeftCorner, Qt::BottomDockWidgetArea);
234+
setCorner(Qt::BottomRightCorner, Qt::BottomDockWidgetArea);
235+
}
236+
}
237+
235238
void OBSBasic::RepairCustomExtraDockName()
236239
{
237240
QDockWidget *dock = reinterpret_cast<QDockWidget *>(sender());

0 commit comments

Comments
 (0)