Move Frame::Options enum to KDDockWidgets.h
So we can forward declare Frame and not include private headers in FrameworkWidgetFactory.h
This commit is contained in:
@@ -38,6 +38,6 @@ DropAreaWithCentralFrame::~DropAreaWithCentralFrame()
|
||||
|
||||
Frame* DropAreaWithCentralFrame::createCentralFrame(MainWindowOptions options)
|
||||
{
|
||||
return (options & MainWindowOption_HasCentralFrame) ? Config::self().frameworkWidgetFactory()->createFrame(nullptr, Frame::Option_IsCentralFrame | Frame::Option_AlwaysShowsTabs)
|
||||
return (options & MainWindowOption_HasCentralFrame) ? Config::self().frameworkWidgetFactory()->createFrame(nullptr, FrameOptions() | FrameOption_IsCentralFrame | FrameOption_AlwaysShowsTabs)
|
||||
: nullptr;
|
||||
}
|
||||
|
||||
@@ -47,16 +47,16 @@ static int s_dbg_numFrames = 0;
|
||||
using namespace KDDockWidgets;
|
||||
|
||||
namespace KDDockWidgets {
|
||||
static Frame::Options actualOptions(Frame::Options options)
|
||||
static FrameOptions actualOptions(FrameOptions options)
|
||||
{
|
||||
if (Config::self().flags() & Config::Flag_AlwaysShowTabs)
|
||||
options |= Frame::Option_AlwaysShowsTabs;
|
||||
options |= FrameOption_AlwaysShowsTabs;
|
||||
|
||||
return options;
|
||||
}
|
||||
}
|
||||
|
||||
Frame::Frame(QWidgetOrQuick *parent, Options options)
|
||||
Frame::Frame(QWidgetOrQuick *parent, FrameOptions options)
|
||||
: QWidgetAdapter(parent)
|
||||
, m_tabWidget(Config::self().frameworkWidgetFactory()->createTabWidget(this))
|
||||
, m_titleBar(Config::self().frameworkWidgetFactory()->createTitleBar(this))
|
||||
@@ -165,7 +165,7 @@ void Frame::onDockWidgetCountChanged()
|
||||
updateTitleBarVisibility();
|
||||
|
||||
// We don't really keep track of the state, so emit even if the visibility didn't change. No biggie.
|
||||
if (!(m_options & Option_AlwaysShowsTabs))
|
||||
if (!(m_options & FrameOption_AlwaysShowsTabs))
|
||||
Q_EMIT hasTabsVisibleChanged();
|
||||
}
|
||||
|
||||
@@ -466,7 +466,7 @@ bool Frame::event(QEvent *e)
|
||||
|
||||
Frame *Frame::deserialize(const LayoutSaver::Frame &f)
|
||||
{
|
||||
auto frame = Config::self().frameworkWidgetFactory()->createFrame(/*parent=*/nullptr, Frame::Options(f.options));
|
||||
auto frame = Config::self().frameworkWidgetFactory()->createFrame(/*parent=*/nullptr, FrameOptions(f.options));
|
||||
frame->setObjectName(f.objectName);
|
||||
|
||||
for (const auto &savedDock : qAsConst(f.dockWidgets)) {
|
||||
|
||||
@@ -63,15 +63,8 @@ class DOCKS_EXPORT Frame : public QWidgetAdapter
|
||||
Q_PROPERTY(KDDockWidgets::TitleBar* titleBar READ titleBar CONSTANT)
|
||||
public:
|
||||
typedef QList<Frame *> List;
|
||||
typedef int Options;
|
||||
enum Option {
|
||||
Option_None = 0,
|
||||
Option_AlwaysShowsTabs = 1,
|
||||
Option_IsCentralFrame = 2
|
||||
};
|
||||
Q_ENUM(Option)
|
||||
|
||||
explicit Frame(QWidgetOrQuick *parent = nullptr, Options = Option_None);
|
||||
explicit Frame(QWidgetOrQuick *parent = nullptr, FrameOptions = FrameOption_None);
|
||||
~Frame() override;
|
||||
|
||||
static Frame *deserialize(const LayoutSaver::Frame &);
|
||||
@@ -130,7 +123,7 @@ public:
|
||||
*
|
||||
* @return whether this widget is the central frame in a main window
|
||||
*/
|
||||
bool isCentralFrame() const { return m_options & Option_IsCentralFrame; }
|
||||
bool isCentralFrame() const { return m_options & FrameOption_IsCentralFrame; }
|
||||
|
||||
/**
|
||||
* @brief whether the tab widget will always show tabs, even if there's only 1 dock widget
|
||||
@@ -141,7 +134,7 @@ public:
|
||||
*
|
||||
* @return whether the tab widget will always show tabs, even if there's only 1 dock widget
|
||||
*/
|
||||
bool alwaysShowsTabs() const { return m_options & Option_AlwaysShowsTabs; }
|
||||
bool alwaysShowsTabs() const { return m_options & FrameOption_AlwaysShowsTabs; }
|
||||
|
||||
|
||||
/// @brief returns the number of dock widgets inside the frame
|
||||
@@ -169,7 +162,7 @@ public:
|
||||
|
||||
DockWidgetBase *currentDockWidget() const;
|
||||
|
||||
Options options() const { return m_options; }
|
||||
FrameOptions options() const { return m_options; }
|
||||
bool anyNonClosable() const;
|
||||
|
||||
|
||||
@@ -226,7 +219,7 @@ private:
|
||||
TabWidget *const m_tabWidget;
|
||||
TitleBar *const m_titleBar;
|
||||
DropArea *m_dropArea = nullptr;
|
||||
const Options m_options;
|
||||
const FrameOptions m_options;
|
||||
QPointer<Item> m_layoutItem;
|
||||
bool m_beingDeleted = false;
|
||||
};
|
||||
|
||||
@@ -51,7 +51,7 @@ FrameworkWidgetFactory::~FrameworkWidgetFactory()
|
||||
}
|
||||
|
||||
#ifdef KDDOCKWIDGETS_QTWIDGETS
|
||||
Frame *DefaultWidgetFactory::createFrame(QWidgetOrQuick *parent, Frame::Options options) const
|
||||
Frame *DefaultWidgetFactory::createFrame(QWidgetOrQuick *parent, FrameOptions options) const
|
||||
{
|
||||
return new FrameWidget(parent, options);
|
||||
}
|
||||
|
||||
@@ -22,8 +22,8 @@
|
||||
#define KDDOCKWIDGETS_FRAMEWORKWIDGETFACTORY_H
|
||||
|
||||
#include "docks_export.h"
|
||||
#include "KDDockWidgets.h"
|
||||
#include "QWidgetAdapter.h"
|
||||
#include "Frame_p.h"
|
||||
|
||||
/**
|
||||
* @file
|
||||
@@ -73,7 +73,7 @@ public:
|
||||
/// DockWidgets.
|
||||
///@param parent just forward to Frame's constructor
|
||||
///@param options just forward to Frame's constructor
|
||||
virtual Frame* createFrame(QWidgetOrQuick *parent = nullptr, Frame::Options = Frame::Option_None) const = 0;
|
||||
virtual Frame* createFrame(QWidgetOrQuick *parent = nullptr, FrameOptions = FrameOption_None) const = 0;
|
||||
|
||||
///@brief Called internally by the framework to create a TitleBar
|
||||
/// Override to provide your own TitleBar sub-class. If overridden then
|
||||
@@ -129,7 +129,7 @@ public:
|
||||
class DOCKS_EXPORT DefaultWidgetFactory : public FrameworkWidgetFactory
|
||||
{
|
||||
public:
|
||||
Frame *createFrame(QWidgetOrQuick *parent, Frame::Options) const override;
|
||||
Frame *createFrame(QWidgetOrQuick *parent, FrameOptions) const override;
|
||||
TitleBar *createTitleBar(Frame *) const override;
|
||||
TitleBar *createTitleBar(FloatingWindow *) const override;
|
||||
TabBar *createTabBar(TabWidget *parent) const override;
|
||||
|
||||
@@ -51,6 +51,14 @@ namespace KDDockWidgets
|
||||
AddingOption_StartHidden ///< Don't show the dock widget when adding it
|
||||
};
|
||||
|
||||
///@internal
|
||||
enum FrameOption {
|
||||
FrameOption_None = 0,
|
||||
FrameOption_AlwaysShowsTabs = 1,
|
||||
FrameOption_IsCentralFrame = 2
|
||||
};
|
||||
Q_DECLARE_FLAGS(FrameOptions, FrameOption)
|
||||
|
||||
///@internal
|
||||
inline Location oppositeLocation(Location loc)
|
||||
{
|
||||
|
||||
@@ -56,7 +56,7 @@ public:
|
||||
|
||||
VBoxLayout::~VBoxLayout() = default;
|
||||
|
||||
FrameWidget::FrameWidget(QWidget *parent, Options options)
|
||||
FrameWidget::FrameWidget(QWidget *parent, FrameOptions options)
|
||||
: Frame(parent, options)
|
||||
{
|
||||
auto vlayout = new VBoxLayout(this);
|
||||
|
||||
@@ -35,7 +35,7 @@ class DOCKS_EXPORT FrameWidget : public Frame
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit FrameWidget(QWidget *parent = nullptr, Options = Option_None);
|
||||
explicit FrameWidget(QWidget *parent = nullptr, FrameOptions = FrameOption_None);
|
||||
QTabBar *tabBar() const;
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *) override;
|
||||
|
||||
@@ -1433,7 +1433,7 @@ void TestDocks::tst_restoreCentralFrame()
|
||||
QCOMPARE(layout->count(), 1);
|
||||
Item *item = m->dropArea()->centralFrame();
|
||||
QVERIFY(item);
|
||||
QCOMPARE(item->frame()->options(), Frame::Option_IsCentralFrame | Frame::Option_AlwaysShowsTabs);
|
||||
QCOMPARE(item->frame()->options(), FrameOption_IsCentralFrame | FrameOption_AlwaysShowsTabs);
|
||||
QVERIFY(!item->frame()->titleBar()->isVisible());
|
||||
|
||||
LayoutSaver saver;
|
||||
@@ -1443,7 +1443,7 @@ void TestDocks::tst_restoreCentralFrame()
|
||||
QCOMPARE(layout->count(), 1);
|
||||
item = m->dropArea()->centralFrame();
|
||||
QVERIFY(item);
|
||||
QCOMPARE(item->frame()->options(), Frame::Option_IsCentralFrame | Frame::Option_AlwaysShowsTabs);
|
||||
QCOMPARE(item->frame()->options(), FrameOption_IsCentralFrame | FrameOption_AlwaysShowsTabs);
|
||||
QVERIFY(!item->frame()->titleBar()->isVisible());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user