Since we're moving logic to tab bar instead of tab widget. Otherwise calling count() on the tab bar while QTabWidget::tabInserted is running can give the wrong value. So settle with a single class.
69 lines
1.7 KiB
C++
69 lines
1.7 KiB
C++
/*
|
|
This file is part of KDDockWidgets.
|
|
|
|
SPDX-FileCopyrightText: 2019-2022 Klarälvdalens Datakonsult AB, a KDAB Group company
|
|
<info@kdab.com> Author: Sérgio Martins <sergio.martins@kdab.com>
|
|
|
|
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
|
|
|
|
Contact KDAB at <info@kdab.com> for commercial licensing options.
|
|
*/
|
|
|
|
|
|
#pragma once
|
|
|
|
#include "View_qtwidgets.h"
|
|
#include "views/StackViewInterface.h"
|
|
|
|
#include <QTabWidget>
|
|
|
|
#include "kdbindings/signal.h"
|
|
|
|
QT_BEGIN_NAMESPACE
|
|
class QAbstractButton;
|
|
class QHBoxLayout;
|
|
QT_END_NAMESPACE
|
|
|
|
namespace KDDockWidgets {
|
|
namespace Views {
|
|
|
|
class DOCKS_EXPORT Stack_qtwidgets : public View_qtwidgets<QTabWidget>, public StackViewInterface
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
explicit Stack_qtwidgets(Controllers::Stack *controller, QWidget *parent = nullptr);
|
|
~Stack_qtwidgets();
|
|
|
|
/// @brief Returns the QTabBar associated with this QTabWidget
|
|
QTabBar *tabBar() const;
|
|
|
|
bool isPositionDraggable(QPoint p) const override;
|
|
void init() override;
|
|
void setDocumentMode(bool) override;
|
|
|
|
/// @brief Returns the controller
|
|
Controllers::Stack *stack() const;
|
|
|
|
public: // TODOm3: make protected
|
|
void mouseDoubleClickEvent(QMouseEvent *) override;
|
|
void mousePressEvent(QMouseEvent *) override;
|
|
|
|
/// @brief Shows the context menu. Override to implement your own context menu.
|
|
/// By default it's used to honour Config::Flag_AllowSwitchingTabsViaMenu
|
|
virtual void showContextMenu(QPoint pos);
|
|
|
|
private:
|
|
void updateMargins();
|
|
void setupTabBarButtons();
|
|
|
|
QHBoxLayout *m_cornerWidgetLayout = nullptr;
|
|
QAbstractButton *m_floatButton = nullptr;
|
|
QAbstractButton *m_closeButton = nullptr;
|
|
KDBindings::ScopedConnection m_tabBarAutoHideChanged;
|
|
|
|
Q_DISABLE_COPY(Stack_qtwidgets)
|
|
};
|
|
|
|
}
|
|
}
|