2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** Commercial License Usage
|
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
2016-01-15 14:57:40 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms
|
|
|
|
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
|
|
|
** information use the contact form at https://www.qt.io/contact-us.
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** GNU General Public License Usage
|
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU
|
|
|
|
|
** General Public License version 3 as published by the Free Software
|
|
|
|
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
|
|
|
** included in the packaging of this file. Please review the following
|
|
|
|
|
** information to ensure the GNU General Public License requirements will
|
|
|
|
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
2010-12-17 16:01:08 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
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
|
|
|
|
2009-07-16 15:00:29 +02:00
|
|
|
#include <coreplugin/minisplitter.h>
|
2011-11-09 12:07:41 +01:00
|
|
|
#include <coreplugin/id.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
|
|
|
|
|
|
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:
|
2018-05-07 17:34:42 +02:00
|
|
|
explicit NavigationWidgetPlaceHolder(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:
|
2016-03-25 20:00:19 +01:00
|
|
|
void currentModeAboutToChange(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
|
|
|
|
2016-03-25 20:00:19 +01:00
|
|
|
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,
|
|
|
|
|
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
|
|
|
|
2016-09-17 18:31:56 +03:00
|
|
|
QString settingsGroup() const;
|
2008-12-02 12:01:29 +01:00
|
|
|
void saveSettings(QSettings *settings);
|
2008-12-11 14:35:14 +01:00
|
|
|
void restoreSettings(QSettings *settings);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2016-09-17 18:31:56 +03:00
|
|
|
QWidget *activateSubWidget(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);
|
|
|
|
|
|
2016-09-17 18:31:56 +03:00
|
|
|
static NavigationWidget *instance(Side side);
|
|
|
|
|
static QWidget *activateSubWidget(Id factoryId, Side fallbackSide);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
int storedWidth();
|
|
|
|
|
|
|
|
|
|
// Called from the place holders
|
|
|
|
|
void placeHolderChanged(NavigationWidgetPlaceHolder *holder);
|
|
|
|
|
|
2014-11-16 10:52:41 +02:00
|
|
|
QHash<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:
|
2014-12-04 13:07:01 +01:00
|
|
|
void splitSubWidget(int factoryIndex);
|
2009-08-20 17:27:33 +02:00
|
|
|
void closeSubWidget();
|
2009-12-08 18:29:44 +01:00
|
|
|
void updateToggleText();
|
2016-09-17 18:31:56 +03:00
|
|
|
Internal::NavigationSubWidget *insertSubItem(int position, int factoryIndex);
|
2014-07-01 11:08:26 +02:00
|
|
|
int factoryIndex(Id id);
|
2016-09-17 18:31:56 +03:00
|
|
|
QString settingsKey(const QString &key) const;
|
|
|
|
|
void onSubWidgetFactoryIndexChanged(int factoryIndex);
|
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
|