forked from qt-creator/qt-creator
ADS: Hide detached window if not in design mode
Task-number: QDS-1672 Change-Id: Ia20113cb9025c19194d87920cf060d2b9791e52a Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
committed by
Thomas Hartmann
parent
6de4e49646
commit
73aaa2a381
@@ -98,6 +98,7 @@ namespace ADS
|
||||
bool m_autorestoreLastWorkspace; // This option is set in the Workspace Manager!
|
||||
QSettings *m_settings = nullptr;
|
||||
QString m_workspacePresetsPath;
|
||||
bool m_modeChangeState;
|
||||
|
||||
/**
|
||||
* Private data constructor
|
||||
@@ -576,6 +577,9 @@ namespace ADS
|
||||
|
||||
bool DockManager::save()
|
||||
{
|
||||
if (isModeChangeState())
|
||||
return false;
|
||||
|
||||
emit aboutToSaveWorkspace();
|
||||
|
||||
bool result = write(activeWorkspace(), saveState(), parentWidget());
|
||||
@@ -836,6 +840,16 @@ namespace ADS
|
||||
return result;
|
||||
}
|
||||
|
||||
void DockManager::setModeChangeState(bool value)
|
||||
{
|
||||
d->m_modeChangeState = value;
|
||||
}
|
||||
|
||||
bool DockManager::isModeChangeState() const
|
||||
{
|
||||
return d->m_modeChangeState;
|
||||
}
|
||||
|
||||
bool DockManager::write(const QString &workspace, const QByteArray &data, QString *errorString) const
|
||||
{
|
||||
Utils::FilePath filename = workspaceNameToFileName(workspace);
|
||||
|
||||
@@ -473,6 +473,9 @@ public:
|
||||
|
||||
bool isWorkspacePreset(const QString &workspace) const;
|
||||
|
||||
void setModeChangeState(bool value);
|
||||
bool isModeChangeState() const;
|
||||
|
||||
signals:
|
||||
void aboutToUnloadWorkspace(QString workspaceName);
|
||||
void aboutToLoadWorkspace(QString workspaceName);
|
||||
|
||||
@@ -42,6 +42,7 @@
|
||||
#include <coreplugin/actionmanager/actionmanager.h>
|
||||
#include <coreplugin/actionmanager/actionmanager_p.h>
|
||||
#include <coreplugin/actionmanager/command.h>
|
||||
#include <coreplugin/modemanager.h>
|
||||
#include <qmldesigner/qmldesignerconstants.h>
|
||||
|
||||
#include <coreplugin/outputpane.h>
|
||||
@@ -381,6 +382,23 @@ void DesignModeWidget::setup()
|
||||
setupNavigatorHistory(currentDesignDocument()->textEditor());
|
||||
|
||||
m_dockManager->initialize();
|
||||
|
||||
connect(Core::ModeManager::instance(), &Core::ModeManager::currentModeChanged,
|
||||
this, [this](Core::Id mode, Core::Id oldMode) {
|
||||
if (mode == Core::Constants::MODE_DESIGN) {
|
||||
m_dockManager->reloadActiveWorkspace();
|
||||
m_dockManager->setModeChangeState(false);
|
||||
}
|
||||
|
||||
if (oldMode == Core::Constants::MODE_DESIGN
|
||||
&& mode != Core::Constants::MODE_DESIGN) {
|
||||
m_dockManager->save();
|
||||
m_dockManager->setModeChangeState(true);
|
||||
for (auto floatingWidget : m_dockManager->floatingWidgets())
|
||||
floatingWidget->hide();
|
||||
}
|
||||
});
|
||||
|
||||
viewManager().enableWidgets();
|
||||
readSettings();
|
||||
show();
|
||||
|
||||
Reference in New Issue
Block a user