QmlDesigner: Hide ADS for lite designer

* Adapt top toolbar by removing lock button and workspace combo box both
  in toolbar and flyout
* Add lite mode bool to dockamanager in order to lock workspace by
  default and skip config parameter
* Add new flag to ADS to block context menu on DockWidgetTab
* Hide workspace menu in view menu
* Deactivate middle mouse button and close button on DockWidgetTab

Task-number: QDS-13169
Change-Id: I3158c9d7eaef1a58520dc466e85a859e074d1c9e
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
Henning Gruendl
2024-07-10 10:58:16 +02:00
committed by Henning Gründl
parent ea5a5b7f1c
commit 7b0b0deb84
7 changed files with 91 additions and 62 deletions

View File

@@ -282,7 +282,7 @@ Rectangle {
ToolbarButton {
id: enterComponent
anchors.verticalCenter: parent.verticalCenter
anchors.right: lockWorkspace.left
anchors.right: backend.isLiteModeEnabled ? shareButton.left : lockWorkspace.left
anchors.rightMargin: 10
enabled: goIntoComponentBackend.available
tooltip: goIntoComponentBackend.tooltip
@@ -305,7 +305,7 @@ Rectangle {
tooltip: qsTr("Sets the visible <b>Views</b> to immovable across the Workspaces.")
buttonIcon: backend.lockWorkspace ? StudioTheme.Constants.lockOn
: StudioTheme.Constants.lockOff
visible: !root.flyoutEnabled
visible: !root.flyoutEnabled && !backend.isLiteModeEnabled
checkable: true
checked: backend.lockWorkspace
checkedInverted: true
@@ -318,9 +318,9 @@ Rectangle {
style: StudioTheme.Values.toolbarStyle
width: 210
anchors.verticalCenter: parent.verticalCenter
anchors.right: annotations.left
anchors.right: shareButton.left
anchors.rightMargin: 10
visible: !root.flyoutEnabled
visible: !root.flyoutEnabled && !backend.isLiteModeEnabled
model: WorkspaceModel { id: workspaceModel }
textRole: "displayName"
valueRole: "fileName"
@@ -333,20 +333,6 @@ Rectangle {
onCountChanged: workspaces.currentIndex = workspaces.indexOfValue(backend.currentWorkspace)
}
ToolbarButton {
id: annotations
visible: false
enabled: backend.isInDesignMode
anchors.verticalCenter: parent.verticalCenter
anchors.right: shareButton.left
anchors.rightMargin: 10
width: 0
tooltip: qsTr("Edit Annotations")
buttonIcon: StudioTheme.Constants.annotations_large
onClicked: backend.editGlobalAnnoation()
}
ToolbarButton {
id: shareButton
style: StudioTheme.Values.primaryToolbarStyle
@@ -394,7 +380,8 @@ Rectangle {
readonly property int padding: 6
width: row.width + window.padding * 2
height: row.height + workspacesFlyout.height + 3 * window.padding
height: row.height + (backend.isLiteModeEnabled ? 0 : workspacesFlyout.height)
+ (backend.isLiteModeEnabled ? 2 : 3) * window.padding
+ (workspacesFlyout.popup.opened ? workspacesFlyout.popup.height : 0)
visible: false
flags: Qt.FramelessWindowHint | Qt.Dialog | Qt.NoDropShadowWindowHint
@@ -470,6 +457,7 @@ Rectangle {
: StudioTheme.Constants.lockOff
checkable: true
checked: backend.lockWorkspace
visible: !backend.isLiteModeEnabled
onClicked: backend.setLockWorkspace(lockWorkspaceFlyout.checked)
}
@@ -498,6 +486,7 @@ Rectangle {
textRole: "displayName"
valueRole: "fileName"
currentIndex: workspacesFlyout.indexOfValue(backend.currentWorkspace)
visible: !backend.isLiteModeEnabled
onCompressedActivated: backend.setCurrentWorkspace(workspacesFlyout.currentValue)
onCountChanged: workspacesFlyout.currentIndex = workspacesFlyout.indexOfValue(backend.currentWorkspace)

View File

@@ -102,6 +102,9 @@ public:
bool m_wasShown = false;
bool m_workspaceOrderDirty = false;
bool m_mcusProject = false;
bool m_liteModeEnabled = false;
/**
* Private data constructor
*/
@@ -498,6 +501,9 @@ void DockManager::initialize()
openWorkspace(workspace);
if (d->m_liteModeEnabled)
lockWorkspace(true);
else
lockWorkspace(d->m_settings->value(Constants::LOCK_WORKSPACE_SETTINGS_KEY, false).toBool());
}
@@ -1749,11 +1755,21 @@ void DockManager::saveLockWorkspace()
}
void DockManager::setMcusProject(bool value) {
m_mcusProject = value;
d->m_mcusProject = value;
}
bool DockManager::mcusProject() const {
return m_mcusProject;
return d->m_mcusProject;
}
void DockManager::setLiteMode(bool value)
{
d->m_liteModeEnabled = value;
}
bool DockManager::isLiteModeEnabled() const
{
return d->m_liteModeEnabled;
}
} // namespace ADS

View File

@@ -144,6 +144,8 @@ public:
EqualSplitOnInsertion
= 0x400000, ///!< if enabled, the space is equally distributed to all widgets in a splitter
HideContextMenuDockWidgetTab = 0x800000,
MiddleMouseButtonClosesTab
= 0x2000000, //! If the flag is set, the user can use the mouse middle button to close the tab under the mouse
@@ -182,15 +184,15 @@ public:
AutoHideButtonCheckable
= 0x08, //!< If the flag is set, the auto hide button will be checked and unchecked depending on the auto hide state. Mainly for styling purposes.
AutoHideSideBarsIconOnly
= 0x10, ///< show only icons in auto hide side tab - if a tab has no icon, then the text will be shown
= 0x10, //!< show only icons in auto hide side tab - if a tab has no icon, then the text will be shown
AutoHideShowOnMouseOver
= 0x20, ///< show the auto hide window on mouse over tab and hide it if mouse leaves auto hide container
= 0x20, //!< show the auto hide window on mouse over tab and hide it if mouse leaves auto hide container
AutoHideCloseButtonCollapsesDock
= 0x40, ///< Close button of an auto hide container collapses the dock instead of hiding it completely
= 0x40, //!< Close button of an auto hide container collapses the dock instead of hiding it completely
AutoHideHasCloseButton
= 0x80, //< If the flag is set an auto hide title bar has a close button
= 0x80, //!< If the flag is set an auto hide title bar has a close button
AutoHideHasMinimizeButton
= 0x100, ///< if this flag is set, the auto hide title bar has a minimize button to collapse the dock widget
= 0x100, //!< if this flag is set, the auto hide title bar has a minimize button to collapse the dock widget
DefaultAutoHideConfig = AutoHideFeatureEnabled | DockAreaHasAutoHideButton
| AutoHideCloseButtonCollapsesDock | AutoHideHasCloseButton
@@ -774,6 +776,9 @@ public:
void setMcusProject(bool value);
bool mcusProject() const;
void setLiteMode(bool value);
bool isLiteModeEnabled() const;
signals:
void aboutToUnloadWorkspace(QString fileName);
void aboutToLoadWorkspace(QString fileName);
@@ -795,8 +800,6 @@ private:
void saveStartupWorkspace();
void saveLockWorkspace();
bool m_mcusProject = false;
}; // class DockManager
} // namespace ADS

View File

@@ -461,6 +461,9 @@ void DockWidgetTab::mouseMoveEvent(QMouseEvent *event)
void DockWidgetTab::contextMenuEvent(QContextMenuEvent *event)
{
if (DockManager::testConfigFlag(DockManager::HideContextMenuDockWidgetTab))
return;
event->accept();
if (d->isDraggingState(DraggingFloatingWidget))
return;

View File

@@ -763,6 +763,11 @@ bool ToolBarBackend::isDocumentDirty() const
&& Core::EditorManager::currentDocument()->isModified();
}
bool ToolBarBackend::isLiteModeEnabled() const
{
return QmlDesignerBasePlugin::isLiteModeEnabled();
}
void ToolBarBackend::launchGlobalAnnotations()
{
QmlDesignerPlugin::emitUsageStatistics(Constants::EVENT_TOOLBAR_EDIT_GLOBAL_ANNOTATION);

View File

@@ -99,6 +99,8 @@ class ToolBarBackend : public QObject
Q_PROPERTY(bool isSharingEnabled READ isSharingEnabled NOTIFY isSharingEnabledChanged)
Q_PROPERTY(bool isDocumentDirty READ isDocumentDirty NOTIFY isDocumentDirtyChanged)
Q_PROPERTY(bool isLiteModeEnabled READ isLiteModeEnabled CONSTANT)
public:
ToolBarBackend(QObject *parent = nullptr);
static void registerDeclarativeType();
@@ -150,6 +152,8 @@ public:
bool isDocumentDirty() const;
bool isLiteModeEnabled() const;
static void launchGlobalAnnotations();
signals:

View File

@@ -205,14 +205,20 @@ void DesignModeWidget::setup()
ADS::DockManager::setConfigFlag(ADS::DockManager::OpaqueSplitterResize, true);
ADS::DockManager::setConfigFlag(ADS::DockManager::AllTabsHaveCloseButton, false);
ADS::DockManager::setConfigFlag(ADS::DockManager::RetainTabSizeWhenCloseButtonHidden, true);
//ADS::DockManager::setAutoHideConfigFlags(ADS::DockManager::DefaultAutoHideConfig);
if (QmlDesignerBasePlugin::isLiteModeEnabled()) {
ADS::DockManager::setConfigFlag(ADS::DockManager::ActiveTabHasCloseButton, false);
ADS::DockManager::setConfigFlag(ADS::DockManager::MiddleMouseButtonClosesTab, false);
ADS::DockManager::setConfigFlag(ADS::DockManager::HideContextMenuDockWidgetTab, true);
}
auto designerSettings = DesignerSettings(settings);
if (designerSettings.value(DesignerSettingsKey::ENABLE_DOCKWIDGET_CONTENT_MIN_SIZE).toBool())
m_minimumSizeHintMode = ADS::DockWidget::MinimumSizeHintFromContentMinimumSize;
m_dockManager = new ADS::DockManager(this);
m_dockManager->setLiteMode(QmlDesignerBasePlugin::isLiteModeEnabled());
m_dockManager->setSettings(settings);
m_dockManager->setWorkspacePresetsPath(
Core::ICore::resourcePath("qmldesigner/workspacePresets/").toString());
@@ -277,35 +283,6 @@ void DesignModeWidget::setup()
ADS::DockManager::iconProvider().registerCustomIcon(ADS::FloatingWidgetNormalIcon,
floatingWidgetNormalIcon);
// Setup Actions and Menus
Core::ActionContainer *mview = Core::ActionManager::actionContainer(Core::Constants::M_VIEW);
// View > Views
Core::ActionContainer *mviews = Core::ActionManager::createMenu(Core::Constants::M_VIEW_VIEWS);
connect(mviews->menu(), &QMenu::aboutToShow, this, &DesignModeWidget::aboutToShowViews);
mviews->menu()->addSeparator();
// View > Workspaces
Core::ActionContainer *mworkspaces = Core::ActionManager::createMenu(QmlDesigner::Constants::M_VIEW_WORKSPACES);
mview->addMenu(mworkspaces, Core::Constants::G_VIEW_VIEWS);
mworkspaces->menu()->setTitle(tr("&Workspaces"));
mworkspaces->setOnAllDisabledBehavior(Core::ActionContainer::Show);
// Connect opening of the 'workspaces' menu with creation of the workspaces menu
connect(mworkspaces->menu(), &QMenu::aboutToShow, this, &DesignModeWidget::aboutToShowWorkspaces);
// Initially disable menus
mworkspaces->menu()->setEnabled(false);
// Enable/disable menus when mode is different to MODE_DESIGN
connect(Core::ModeManager::instance(),
&Core::ModeManager::currentModeChanged,
this,
[mworkspaces](Utils::Id mode, Utils::Id) {
if (mode == Core::Constants::MODE_DESIGN) {
mworkspaces->menu()->setEnabled(true);
} else {
mworkspaces->menu()->setEnabled(false);
}
});
// Create a DockWidget for each QWidget and add them to the DockManager
const Core::Context designContext(Core::Constants::C_DESIGN_MODE);
static const Utils::Id actionToggle("QmlDesigner.Toggle");
@@ -403,8 +380,40 @@ void DesignModeWidget::setup()
return first->description() < second->description();
});
if (!QmlDesignerBasePlugin::isLiteModeEnabled()) {
// Setup Actions and Menus
Core::ActionContainer *mview = Core::ActionManager::actionContainer(Core::Constants::M_VIEW);
// View > Views
Core::ActionContainer *mviews = Core::ActionManager::createMenu(Core::Constants::M_VIEW_VIEWS);
connect(mviews->menu(), &QMenu::aboutToShow, this, &DesignModeWidget::aboutToShowViews);
mviews->menu()->addSeparator();
// View > Workspaces
Core::ActionContainer *mworkspaces = Core::ActionManager::createMenu(
QmlDesigner::Constants::M_VIEW_WORKSPACES);
mview->addMenu(mworkspaces, Core::Constants::G_VIEW_VIEWS);
mworkspaces->menu()->setTitle(tr("&Workspaces"));
mworkspaces->setOnAllDisabledBehavior(Core::ActionContainer::Show);
// Connect opening of the 'workspaces' menu with creation of the workspaces menu
connect(mworkspaces->menu(), &QMenu::aboutToShow, this, &DesignModeWidget::aboutToShowWorkspaces);
// Initially disable menus
mworkspaces->menu()->setEnabled(false);
// Enable/disable menus when mode is different to MODE_DESIGN
connect(Core::ModeManager::instance(),
&Core::ModeManager::currentModeChanged,
this,
[mworkspaces](Utils::Id mode, Utils::Id) {
if (mode == Core::Constants::MODE_DESIGN) {
mworkspaces->menu()->setEnabled(true);
} else {
mworkspaces->menu()->setEnabled(false);
}
});
for (Core::Command *command : viewCommands)
mviews->addAction(command);
}
// Create toolbars
if (!ToolBar::isVisible()) {