forked from qt-creator/qt-creator
QmlDesigner: Remove Switchsplittabwidget
Removed the unused class Switchsplittabwidget from the codebase. Change-Id: Idb0071d4e6bb54b6a08e6026f8768f9239a5c342 Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
@@ -29,7 +29,6 @@ add_qtc_plugin(QmlDesigner
|
|||||||
qmldesignerplugin.cpp qmldesignerplugin.h
|
qmldesignerplugin.cpp qmldesignerplugin.h
|
||||||
settingspage.cpp settingspage.h settingspage.ui
|
settingspage.cpp settingspage.h settingspage.ui
|
||||||
shortcutmanager.cpp shortcutmanager.h
|
shortcutmanager.cpp shortcutmanager.h
|
||||||
switchsplittabwidget.cpp switchsplittabwidget.h
|
|
||||||
designermcumanager.cpp designermcumanager.h
|
designermcumanager.cpp designermcumanager.h
|
||||||
EXPLICIT_MOC
|
EXPLICIT_MOC
|
||||||
components/propertyeditor/propertyeditorvalue.h
|
components/propertyeditor/propertyeditorvalue.h
|
||||||
|
@@ -24,7 +24,6 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include "designmodewidget.h"
|
#include "designmodewidget.h"
|
||||||
#include "switchsplittabwidget.h"
|
|
||||||
|
|
||||||
#include <designeractionmanager.h>
|
#include <designeractionmanager.h>
|
||||||
|
|
||||||
|
@@ -50,7 +50,6 @@ namespace QmlDesigner {
|
|||||||
class ItemLibraryWidget;
|
class ItemLibraryWidget;
|
||||||
class CrumbleBar;
|
class CrumbleBar;
|
||||||
class DocumentWarningWidget;
|
class DocumentWarningWidget;
|
||||||
class SwitchSplitTabWidget;
|
|
||||||
|
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
@@ -103,8 +102,6 @@ private: // functions
|
|||||||
void aboutToShowWorkspaces();
|
void aboutToShowWorkspaces();
|
||||||
|
|
||||||
private: // variables
|
private: // variables
|
||||||
SwitchSplitTabWidget* m_centralTabWidget = nullptr;
|
|
||||||
|
|
||||||
QPointer<QWidget> m_bottomSideBar;
|
QPointer<QWidget> m_bottomSideBar;
|
||||||
Core::EditorToolBar *m_toolBar;
|
Core::EditorToolBar *m_toolBar;
|
||||||
CrumbleBar *m_crumbleBar;
|
CrumbleBar *m_crumbleBar;
|
||||||
|
@@ -2,7 +2,6 @@ HEADERS += $$PWD/qmldesignerconstants.h \
|
|||||||
$$PWD/shortcutmanager.h \
|
$$PWD/shortcutmanager.h \
|
||||||
$$PWD/qmldesignerplugin.h \
|
$$PWD/qmldesignerplugin.h \
|
||||||
$$PWD/designmodewidget.h \
|
$$PWD/designmodewidget.h \
|
||||||
$$PWD/switchsplittabwidget.h \
|
|
||||||
$$PWD/designersettings.h \
|
$$PWD/designersettings.h \
|
||||||
$$PWD/generateresource.h \
|
$$PWD/generateresource.h \
|
||||||
$$PWD/settingspage.h \
|
$$PWD/settingspage.h \
|
||||||
@@ -16,7 +15,6 @@ HEADERS += $$PWD/qmldesignerconstants.h \
|
|||||||
SOURCES += $$PWD/qmldesignerplugin.cpp \
|
SOURCES += $$PWD/qmldesignerplugin.cpp \
|
||||||
$$PWD/shortcutmanager.cpp \
|
$$PWD/shortcutmanager.cpp \
|
||||||
$$PWD/designmodewidget.cpp \
|
$$PWD/designmodewidget.cpp \
|
||||||
$$PWD/switchsplittabwidget.cpp \
|
|
||||||
$$PWD/designersettings.cpp \
|
$$PWD/designersettings.cpp \
|
||||||
$$PWD/generateresource.cpp \
|
$$PWD/generateresource.cpp \
|
||||||
$$PWD/settingspage.cpp \
|
$$PWD/settingspage.cpp \
|
||||||
|
@@ -933,8 +933,6 @@ Project {
|
|||||||
"designmodecontext.h",
|
"designmodecontext.h",
|
||||||
"designmodewidget.cpp",
|
"designmodewidget.cpp",
|
||||||
"designmodewidget.h",
|
"designmodewidget.h",
|
||||||
"switchsplittabwidget.cpp",
|
|
||||||
"switchsplittabwidget.h",
|
|
||||||
"documentmanager.cpp",
|
"documentmanager.cpp",
|
||||||
"documentmanager.h",
|
"documentmanager.h",
|
||||||
"documentwarningwidget.cpp",
|
"documentwarningwidget.cpp",
|
||||||
|
@@ -1,212 +0,0 @@
|
|||||||
/****************************************************************************
|
|
||||||
**
|
|
||||||
** Copyright (C) 2016 The Qt Company Ltd.
|
|
||||||
** Contact: https://www.qt.io/licensing/
|
|
||||||
**
|
|
||||||
** This file is part of Qt Creator.
|
|
||||||
**
|
|
||||||
** 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
|
|
||||||
** 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.
|
|
||||||
**
|
|
||||||
** 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.
|
|
||||||
**
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#include "switchsplittabwidget.h"
|
|
||||||
#include <theme.h>
|
|
||||||
|
|
||||||
#include <utils/utilsicons.h>
|
|
||||||
#include <utils/fileutils.h>
|
|
||||||
|
|
||||||
#include <QVector>
|
|
||||||
#include <QBoxLayout>
|
|
||||||
#include <QTabBar>
|
|
||||||
#include <QToolButton>
|
|
||||||
#include <QSplitter>
|
|
||||||
#include <QLayoutItem>
|
|
||||||
#include <QEvent>
|
|
||||||
|
|
||||||
namespace QmlDesigner {
|
|
||||||
SwitchSplitTabWidget::SwitchSplitTabWidget(QWidget *parent)
|
|
||||||
: QWidget(parent)
|
|
||||||
, m_splitter(new QSplitter)
|
|
||||||
, m_tabBar(new QTabBar)
|
|
||||||
, m_tabBarBackground(new QWidget)
|
|
||||||
{
|
|
||||||
// setting object names for css
|
|
||||||
setObjectName("backgroundWidget");
|
|
||||||
m_splitter->setObjectName("centralTabWidget");
|
|
||||||
m_splitter->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
|
||||||
m_splitter->setHandleWidth(0);
|
|
||||||
|
|
||||||
QString sheet = QString::fromUtf8(Utils::FileReader::fetchQrc(":/qmldesigner/centerwidget.css"));
|
|
||||||
m_tabBarBackground->setStyleSheet(Theme::replaceCssColors(sheet));
|
|
||||||
|
|
||||||
m_tabBar->setObjectName("centralTabBar");
|
|
||||||
m_tabBar->setShape(QTabBar::RoundedEast);
|
|
||||||
m_tabBar->setDocumentMode(false);
|
|
||||||
// add a faketab to have the possibility to unselect all tabs
|
|
||||||
m_tabBar->addTab(QString());
|
|
||||||
selectFakeTab();
|
|
||||||
|
|
||||||
m_tabBarBackground->setObjectName("tabBarBackground");
|
|
||||||
|
|
||||||
connect(m_tabBar, &QTabBar::tabBarClicked, [this] (int index) {
|
|
||||||
if (index != -1)
|
|
||||||
updateSplitterSizes(index - fakeTab);
|
|
||||||
});
|
|
||||||
|
|
||||||
setLayout(new QHBoxLayout);
|
|
||||||
layout()->setContentsMargins(0, 0, 0, 0);
|
|
||||||
layout()->setSpacing(0);
|
|
||||||
layout()->addWidget(m_splitter);
|
|
||||||
|
|
||||||
m_tabBarBackground->setLayout(new QVBoxLayout);
|
|
||||||
m_tabBarBackground->layout()->setContentsMargins(0, 0, 0, 0);
|
|
||||||
m_tabBarBackground->layout()->addItem(new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding));
|
|
||||||
m_tabBarBackground->layout()->addWidget(m_tabBar);
|
|
||||||
|
|
||||||
auto horizontalButton = new QToolButton;
|
|
||||||
horizontalButton->setObjectName("centralTabBar");
|
|
||||||
horizontalButton->setIcon(Utils::Icon({{QLatin1String(":/qmldesigner/images/spliteditorvertically.png"),
|
|
||||||
Utils::Theme::IconsBaseColor}}).icon());
|
|
||||||
horizontalButton->setIconSize(QSize(8, 16));
|
|
||||||
connect(horizontalButton, &QToolButton::clicked, [this] () {
|
|
||||||
m_splitter->setOrientation(Qt::Vertical);
|
|
||||||
updateSplitterSizes();
|
|
||||||
selectFakeTab();
|
|
||||||
});
|
|
||||||
auto verticalButton = new QToolButton;
|
|
||||||
verticalButton->setObjectName("centralTabBar");
|
|
||||||
verticalButton->setIcon(Utils::Icon({{QLatin1String(":/qmldesigner/images/spliteditorhorizontally.png"),
|
|
||||||
Utils::Theme::IconsBaseColor}}).icon());
|
|
||||||
verticalButton->setIconSize(QSize(8, 16));
|
|
||||||
connect(verticalButton, &QToolButton::clicked, [this] () {
|
|
||||||
m_splitter->setOrientation(Qt::Horizontal);
|
|
||||||
updateSplitterSizes();
|
|
||||||
selectFakeTab();
|
|
||||||
});
|
|
||||||
|
|
||||||
m_tabBarBackground->layout()->addWidget(horizontalButton);
|
|
||||||
m_tabBarBackground->layout()->addWidget(verticalButton);
|
|
||||||
layout()->addWidget(m_tabBarBackground);
|
|
||||||
updateSplitButtons();
|
|
||||||
}
|
|
||||||
|
|
||||||
int SwitchSplitTabWidget::count() const
|
|
||||||
{
|
|
||||||
return m_splitter->count();
|
|
||||||
}
|
|
||||||
|
|
||||||
QWidget *SwitchSplitTabWidget::currentWidget() const
|
|
||||||
{
|
|
||||||
QList<int> sizes = m_splitter->sizes();
|
|
||||||
for (int i = 0; i < count(); ++i) {
|
|
||||||
if (sizes.at(i) > 0 && m_splitter->widget(i)->hasFocus())
|
|
||||||
return m_splitter->widget(i);
|
|
||||||
}
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
void SwitchSplitTabWidget::updateSplitterSizes(int index)
|
|
||||||
{
|
|
||||||
QVector<int> splitterSizes(m_splitter->count());
|
|
||||||
int splitterFullSize = 0;
|
|
||||||
bool isHorizontal = m_splitter->orientation() == Qt::Horizontal;
|
|
||||||
for (int i = 0; i < m_splitter->count(); ++i) {
|
|
||||||
auto widget = m_splitter->widget(i);
|
|
||||||
splitterFullSize += isHorizontal ? widget->width() : widget->height();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (index > -1) {
|
|
||||||
// collapse all but the one at index
|
|
||||||
splitterSizes.fill(0);
|
|
||||||
splitterSizes.replace(index, splitterFullSize);
|
|
||||||
} else {
|
|
||||||
// distribute full size among enabled tabs
|
|
||||||
int divisor = splitterSizes.count();
|
|
||||||
for (int i = 0; i < m_splitter->count(); ++i) {
|
|
||||||
if (!m_tabBar->isTabEnabled(i + fakeTab))
|
|
||||||
--divisor;
|
|
||||||
}
|
|
||||||
|
|
||||||
int splitSize = splitterFullSize / divisor;
|
|
||||||
for (int i = 0; i < m_splitter->count(); ++i)
|
|
||||||
splitterSizes.replace(i, m_tabBar->isTabEnabled(i + fakeTab) ? splitSize : 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
m_splitter->setSizes(splitterSizes.toList());
|
|
||||||
}
|
|
||||||
|
|
||||||
int SwitchSplitTabWidget::addTab(QWidget *w, const QString &label)
|
|
||||||
{
|
|
||||||
m_splitter->addWidget(w);
|
|
||||||
const int newIndex = m_tabBar->addTab(label);
|
|
||||||
if (mode() == TabMode) {
|
|
||||||
m_tabBar->setCurrentIndex(newIndex);
|
|
||||||
updateSplitterSizes(newIndex - fakeTab);
|
|
||||||
}
|
|
||||||
if (mode() == SplitMode)
|
|
||||||
updateSplitterSizes();
|
|
||||||
updateSplitButtons();
|
|
||||||
return newIndex;
|
|
||||||
}
|
|
||||||
|
|
||||||
QWidget *SwitchSplitTabWidget::takeTabWidget(const int index)
|
|
||||||
{
|
|
||||||
if (index == -1 || index > count() - 1)
|
|
||||||
return nullptr;
|
|
||||||
QWidget *widget = m_splitter->widget(index);
|
|
||||||
widget->setParent(nullptr);
|
|
||||||
m_tabBar->removeTab(index + fakeTab);
|
|
||||||
// TODO: set which mode and tab is the current one
|
|
||||||
updateSplitButtons();
|
|
||||||
return widget;
|
|
||||||
}
|
|
||||||
|
|
||||||
void SwitchSplitTabWidget::switchTo(QWidget *widget)
|
|
||||||
{
|
|
||||||
if (widget == nullptr || currentWidget() == widget)
|
|
||||||
return;
|
|
||||||
const int widgetIndex = m_splitter->indexOf(widget);
|
|
||||||
Q_ASSERT(widgetIndex != -1);
|
|
||||||
if (mode() == TabMode) {
|
|
||||||
updateSplitterSizes(widgetIndex);
|
|
||||||
m_tabBar->setCurrentIndex(widgetIndex + fakeTab);
|
|
||||||
}
|
|
||||||
|
|
||||||
widget->setFocus();
|
|
||||||
}
|
|
||||||
|
|
||||||
void SwitchSplitTabWidget::updateSplitButtons()
|
|
||||||
{
|
|
||||||
const bool isTabBarNecessary = count() > 1;
|
|
||||||
m_tabBarBackground->setVisible(isTabBarNecessary);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SwitchSplitTabWidget::selectFakeTab()
|
|
||||||
{
|
|
||||||
m_tabBar->setCurrentIndex(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
SwitchSplitTabWidget::Mode SwitchSplitTabWidget::mode() const
|
|
||||||
{
|
|
||||||
const bool isTabBarNecessary = count() > 1;
|
|
||||||
const int fakeTabPosition = 0;
|
|
||||||
const int hasSelectedTab = m_tabBar->currentIndex() > fakeTabPosition;
|
|
||||||
// Note: When splitting the view by dragging from the side of the view, SplitMode is not detected
|
|
||||||
return (isTabBarNecessary && !hasSelectedTab) ? SplitMode : TabMode;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace QmlDesigner
|
|
@@ -1,63 +0,0 @@
|
|||||||
/****************************************************************************
|
|
||||||
**
|
|
||||||
** Copyright (C) 2016 The Qt Company Ltd.
|
|
||||||
** Contact: https://www.qt.io/licensing/
|
|
||||||
**
|
|
||||||
** This file is part of Qt Creator.
|
|
||||||
**
|
|
||||||
** 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
|
|
||||||
** 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.
|
|
||||||
**
|
|
||||||
** 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.
|
|
||||||
**
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <QWidget>
|
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
|
||||||
class QTabBar;
|
|
||||||
class QSplitter;
|
|
||||||
class QPushButton;
|
|
||||||
QT_END_NAMESPACE
|
|
||||||
|
|
||||||
namespace QmlDesigner {
|
|
||||||
class SwitchSplitTabWidget : public QWidget
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
enum Mode { SplitMode, TabMode };
|
|
||||||
|
|
||||||
public:
|
|
||||||
explicit SwitchSplitTabWidget(QWidget *parent = nullptr);
|
|
||||||
int count() const;
|
|
||||||
QWidget *currentWidget() const;
|
|
||||||
|
|
||||||
int addTab(QWidget *widget, const QString &label);
|
|
||||||
QWidget *takeTabWidget(const int index);
|
|
||||||
void switchTo(QWidget *widget);
|
|
||||||
|
|
||||||
private:
|
|
||||||
void updateSplitterSizes(int index = -1);
|
|
||||||
void updateSplitButtons();
|
|
||||||
void selectFakeTab();
|
|
||||||
Mode mode() const;
|
|
||||||
|
|
||||||
QSplitter *m_splitter = nullptr;
|
|
||||||
QTabBar *m_tabBar = nullptr;
|
|
||||||
QWidget *m_tabBarBackground = nullptr;
|
|
||||||
const int fakeTab = 1;
|
|
||||||
};
|
|
||||||
} // namespace QmlDesigner
|
|
Reference in New Issue
Block a user