UI: Add function for adding extra docks to main window

This commit is contained in:
jp9000
2019-02-06 13:57:59 -08:00
parent 412520c5d0
commit dcf48e8ffc
3 changed files with 69 additions and 0 deletions

View File

@@ -172,6 +172,9 @@ Basic.Stats.DroppedFrames="Dropped Frames (Network)"
Basic.Stats.MegabytesSent="Total Data Output"
Basic.Stats.Bitrate="Bitrate"
ResetUIWarning.Title="Are you sure you want to reset the UI?"
ResetUIWarning.Text="Resetting the UI will hide additional docks. You will need to unhide these docks from the view menu if you want them to be visible.\n\nAre you sure you want to reset the UI?"
# updater
Updater.Title="New update available"
Updater.Text="There is a new update available:"

View File

@@ -6219,6 +6219,36 @@ int OBSBasic::GetProfilePath(char *path, size_t size, const char *file) const
void OBSBasic::on_resetUI_triggered()
{
/* prune deleted extra docks */
for (int i = extraDocks.size() - 1; i >= 0 ; i--) {
if (!extraDocks[i]) {
extraDocks.removeAt(i);
}
}
if (extraDocks.size()) {
QMessageBox::StandardButton button = QMessageBox::question(
this,
QTStr("ResetUIWarning.Title"),
QTStr("ResetUIWarning.Text"));
if (button == QMessageBox::No)
return;
}
/* undock/hide/center extra docks */
for (int i = extraDocks.size() - 1; i >= 0 ; i--) {
if (extraDocks[i]) {
extraDocks[i]->setVisible(true);
extraDocks[i]->setFloating(true);
extraDocks[i]->move(
frameGeometry().topLeft() +
rect().center() -
extraDocks[i]->rect().center());
extraDocks[i]->setVisible(false);
}
}
restoreState(startingDockLayout);
#if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0)
@@ -6273,6 +6303,14 @@ void OBSBasic::on_lockUI_toggled(bool lock)
ui->transitionsDock->setFeatures(features);
ui->controlsDock->setFeatures(features);
statsDock->setFeatures(features);
for (int i = extraDocks.size() - 1; i >= 0 ; i--) {
if (!extraDocks[i]) {
extraDocks.removeAt(i);
} else {
extraDocks[i]->setFeatures(features);
}
}
}
void OBSBasic::on_toggleListboxToolbars_toggled(bool visible)
@@ -6858,6 +6896,30 @@ void OBSBasic::ResizeOutputSizeOfSource()
on_actionFitToScreen_triggered();
}
QAction *OBSBasic::AddDockWidget(QDockWidget *dock)
{
QAction *action = ui->viewMenuDocks->addAction(dock->windowTitle());
action->setCheckable(true);
assignDockToggle(dock, action);
extraDocks.push_back(dock);
bool lock = ui->lockUI->isChecked();
QDockWidget::DockWidgetFeatures features = lock
? QDockWidget::NoDockWidgetFeatures
: QDockWidget::AllDockWidgetFeatures;
dock->setFeatures(features);
/* prune deleted docks */
for (int i = extraDocks.size() - 1; i >= 0 ; i--) {
if (!extraDocks[i]) {
extraDocks.removeAt(i);
}
}
return action;
}
OBSBasic *OBSBasic::Get()
{
return reinterpret_cast<OBSBasic*>(App()->GetMainWindow());

View File

@@ -140,6 +140,8 @@ private:
std::vector<OBSSignal> signalHandlers;
QList<QPointer<QDockWidget>> extraDocks;
bool loaded = false;
long disableSaving = 1;
bool projectChanged = false;
@@ -617,6 +619,8 @@ public:
void CreatePropertiesWindow(obs_source_t *source);
void CreateFiltersWindow(obs_source_t *source);
QAction *AddDockWidget(QDockWidget *dock);
static OBSBasic *Get();
protected: