2022-08-19 15:59:36 +02:00
|
|
|
// Copyright (C) 2016 The Qt Company Ltd.
|
2022-12-21 10:12:09 +01:00
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
2008-12-02 14:09:21 +01:00
|
|
|
|
2016-03-18 07:55:01 +01:00
|
|
|
#pragma once
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2023-09-14 12:15:19 +02:00
|
|
|
#include "minisplitter.h"
|
2020-06-26 13:59:38 +02:00
|
|
|
|
|
|
|
|
#include <utils/id.h>
|
2023-08-23 17:51:05 +02:00
|
|
|
#include <utils/store.h>
|
2009-07-16 15:00:29 +02:00
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QHash>
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
QT_BEGIN_NAMESPACE
|
|
|
|
|
class QSettings;
|
2010-09-16 12:26:28 +02:00
|
|
|
class QAbstractItemModel;
|
2008-12-02 12:01:29 +01:00
|
|
|
QT_END_NAMESPACE
|
|
|
|
|
|
2020-12-10 11:24:27 +01:00
|
|
|
namespace Utils {
|
|
|
|
|
class QtcSettings;
|
|
|
|
|
}
|
|
|
|
|
|
2009-10-05 11:06:05 +02:00
|
|
|
namespace Core {
|
2008-12-02 12:01:29 +01:00
|
|
|
class INavigationWidgetFactory;
|
2009-01-14 13:17:53 +01:00
|
|
|
class Command;
|
2008-12-02 12:01:29 +01:00
|
|
|
class NavigationWidget;
|
2010-09-16 12:26:28 +02:00
|
|
|
struct NavigationWidgetPrivate;
|
2014-02-11 21:55:42 +02:00
|
|
|
namespace Internal { class NavigationSubWidget; }
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2016-09-17 18:31:56 +03:00
|
|
|
enum class Side {
|
|
|
|
|
Left,
|
|
|
|
|
Right
|
|
|
|
|
};
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
class CORE_EXPORT NavigationWidgetPlaceHolder : public QWidget
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
2011-09-16 15:00:41 +02:00
|
|
|
friend class Core::NavigationWidget;
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
public:
|
2020-06-26 13:59:38 +02:00
|
|
|
explicit NavigationWidgetPlaceHolder(Utils::Id mode, Side side, QWidget *parent = nullptr);
|
2018-05-07 15:00:03 +02:00
|
|
|
~NavigationWidgetPlaceHolder() override;
|
2016-09-17 18:31:56 +03:00
|
|
|
static NavigationWidgetPlaceHolder *current(Side side);
|
|
|
|
|
static void setCurrent(Side side, NavigationWidgetPlaceHolder *navWidget);
|
Fix left sidebar width after switching modes
After switching to debug mode, hiding left sidebar, switching back to
edit, and showing left sidebar, the sidebar had very small width.
We may not calculate the splitter sizes for each placeholder
individually, because setting them on the splitter might distribute them
in a weird way when widgets are hidden. In the above example switching
back to edit mode while both sidebars are hidden triggered something
similar to the following updates:
Left side bar update:
- calculated: (300, 1000, 0)
- actual resulting: (0, 1000, 0)
Right side bar update:
- calculated: (0, 1000, 300)
- actual resulting: (100, 900, 0)
In the longer run it would probably be better handle the resizing in a
more centralized way, since now it sets the same sizes twice (once for
each side bar update).
Task-number: QTCREATORBUG-18009
Change-Id: Ife5d6f1caded55f444245f4c3c98ae05371363b8
Reviewed-by: Serhii Moroz <frost.asm@gmail.com>
Reviewed-by: André Hartmann <aha_1980@gmx.de>
Reviewed-by: David Schulz <david.schulz@qt.io>
2017-04-20 16:17:18 +02:00
|
|
|
void applyStoredSize();
|
2010-09-16 12:26:28 +02:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
private:
|
2020-06-26 13:59:38 +02:00
|
|
|
void currentModeAboutToChange(Utils::Id mode);
|
Fix left sidebar width after switching modes
After switching to debug mode, hiding left sidebar, switching back to
edit, and showing left sidebar, the sidebar had very small width.
We may not calculate the splitter sizes for each placeholder
individually, because setting them on the splitter might distribute them
in a weird way when widgets are hidden. In the above example switching
back to edit mode while both sidebars are hidden triggered something
similar to the following updates:
Left side bar update:
- calculated: (300, 1000, 0)
- actual resulting: (0, 1000, 0)
Right side bar update:
- calculated: (0, 1000, 300)
- actual resulting: (100, 900, 0)
In the longer run it would probably be better handle the resizing in a
more centralized way, since now it sets the same sizes twice (once for
each side bar update).
Task-number: QTCREATORBUG-18009
Change-Id: Ife5d6f1caded55f444245f4c3c98ae05371363b8
Reviewed-by: Serhii Moroz <frost.asm@gmail.com>
Reviewed-by: André Hartmann <aha_1980@gmx.de>
Reviewed-by: David Schulz <david.schulz@qt.io>
2017-04-20 16:17:18 +02:00
|
|
|
int storedWidth() const;
|
2014-11-16 10:52:41 +02:00
|
|
|
|
2020-06-26 13:59:38 +02:00
|
|
|
Utils::Id m_mode;
|
2016-09-17 18:31:56 +03:00
|
|
|
Side m_side;
|
|
|
|
|
static NavigationWidgetPlaceHolder *s_currentLeft;
|
|
|
|
|
static NavigationWidgetPlaceHolder *s_currentRight;
|
2008-12-02 12:01:29 +01:00
|
|
|
};
|
|
|
|
|
|
2010-08-13 10:10:43 +02:00
|
|
|
class CORE_EXPORT NavigationWidget : public MiniSplitter
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
2011-09-16 15:00:41 +02:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
public:
|
2010-07-15 12:24:03 +02:00
|
|
|
enum FactoryModelRoles {
|
|
|
|
|
FactoryObjectRole = Qt::UserRole,
|
2010-09-09 14:35:26 +02:00
|
|
|
FactoryIdRole,
|
2021-09-21 16:21:33 +02:00
|
|
|
FactoryActionIdRole,
|
2010-09-09 14:35:26 +02:00
|
|
|
FactoryPriorityRole
|
2010-07-15 12:24:03 +02:00
|
|
|
};
|
|
|
|
|
|
2016-09-17 18:31:56 +03:00
|
|
|
explicit NavigationWidget(QAction *toggleSideBarAction, Side side);
|
2018-05-07 15:00:03 +02:00
|
|
|
~NavigationWidget() override;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2013-11-13 13:34:47 +01:00
|
|
|
void setFactories(const QList<INavigationWidgetFactory*> &factories);
|
2010-07-15 12:24:03 +02:00
|
|
|
|
2023-08-23 17:51:05 +02:00
|
|
|
Utils::Key settingsGroup() const;
|
2020-12-10 11:24:27 +01:00
|
|
|
void saveSettings(Utils::QtcSettings *settings);
|
2023-09-05 09:20:31 +02:00
|
|
|
void restoreSettings(Utils::QtcSettings *settings);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2020-06-26 13:59:38 +02:00
|
|
|
QWidget *activateSubWidget(Utils::Id factoryId, int preferredPosition);
|
2010-08-11 14:59:04 +02:00
|
|
|
void closeSubWidgets();
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
bool isShown() const;
|
|
|
|
|
void setShown(bool b);
|
|
|
|
|
|
2020-06-26 13:59:38 +02:00
|
|
|
static QWidget *activateSubWidget(Utils::Id factoryId, Side fallbackSide);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
int storedWidth();
|
|
|
|
|
|
|
|
|
|
// Called from the place holders
|
Use sidebar buttons for hiding/showing dock areas
So far, if a mode includes navigation widget placeholders, these are
used for the sidebar toggle buttons, otherwise the buttons are disabled.
Now, if a mode does not include navigation widget placeholders, but the
mode has a FancyMainWindow attached, use the buttons to hide or show the
corresponding dock widget area (left or right).
Since QMainWindow does not really support "hiding a dock widget area",
the FancyMainWindow needs to track that state manually, by tracking the
dock widgets that were visible before "hiding the dock widget area".
Also, if a dock widget is dragged into a "hidden" area, or a widget is
made visible or "unfloated" into that area, show the other widgets in the
area again as well, "unhiding" the area.
Since the mode widgets that have a mainwindow somewhere usually wrap
that into a splitter for the output panes, and the Design mode is
actually a stack widget, IMode needs another method that returns the
appropriate FancyMainWindow if available.
The patch implements this for Widget Designer.
Change-Id: I03531f4d5130c846ff5d65831b1c9be210e1c561
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-11-24 09:26:31 +01:00
|
|
|
void placeHolderChanged();
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2020-06-26 13:59:38 +02:00
|
|
|
QHash<Utils::Id, Command *> commandMap() const;
|
2010-07-15 12:24:03 +02:00
|
|
|
QAbstractItemModel *factoryModel() const;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
protected:
|
2018-05-07 15:00:03 +02:00
|
|
|
void resizeEvent(QResizeEvent *) override;
|
2010-07-15 12:24:03 +02:00
|
|
|
|
2016-02-02 09:10:54 +02:00
|
|
|
private:
|
2022-07-20 12:05:49 +02:00
|
|
|
void closeSubWidget(Internal::NavigationSubWidget *subWidget);
|
Use sidebar buttons for hiding/showing dock areas
So far, if a mode includes navigation widget placeholders, these are
used for the sidebar toggle buttons, otherwise the buttons are disabled.
Now, if a mode does not include navigation widget placeholders, but the
mode has a FancyMainWindow attached, use the buttons to hide or show the
corresponding dock widget area (left or right).
Since QMainWindow does not really support "hiding a dock widget area",
the FancyMainWindow needs to track that state manually, by tracking the
dock widgets that were visible before "hiding the dock widget area".
Also, if a dock widget is dragged into a "hidden" area, or a widget is
made visible or "unfloated" into that area, show the other widgets in the
area again as well, "unhiding" the area.
Since the mode widgets that have a mainwindow somewhere usually wrap
that into a splitter for the output panes, and the Design mode is
actually a stack widget, IMode needs another method that returns the
appropriate FancyMainWindow if available.
The patch implements this for Widget Designer.
Change-Id: I03531f4d5130c846ff5d65831b1c9be210e1c561
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-11-24 09:26:31 +01:00
|
|
|
bool toggleActionVisible() const;
|
|
|
|
|
bool toggleActionEnabled() const;
|
|
|
|
|
bool toggleActionChecked() const;
|
|
|
|
|
void updateMode();
|
|
|
|
|
void updateToggleAction();
|
2023-10-25 09:18:49 +02:00
|
|
|
Internal::NavigationSubWidget *insertSubItem(int position,
|
|
|
|
|
int factoryIndex,
|
|
|
|
|
bool updateActivationsMap = true);
|
2020-06-26 13:59:38 +02:00
|
|
|
int factoryIndex(Utils::Id id);
|
2023-08-23 17:51:05 +02:00
|
|
|
Utils::Key settingsKey(const Utils::Key &key) const;
|
2010-07-15 12:24:03 +02:00
|
|
|
|
2011-09-16 15:00:41 +02:00
|
|
|
NavigationWidgetPrivate *d;
|
2008-12-02 12:01:29 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace Core
|