UI: Add function for adding extra docks to main window
This commit is contained in:
@@ -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:"
|
||||
|
@@ -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());
|
||||
|
@@ -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:
|
||||
|
Reference in New Issue
Block a user