example: Show usage of segmented indicators

This commit is contained in:
Sergio Martins
2020-08-23 16:57:48 +01:00
parent 283d814dc6
commit 113e6453ea
4 changed files with 22 additions and 0 deletions

View File

@@ -75,6 +75,9 @@ int main(int argc, char **argv)
QCommandLineOption maximizeButton("b", QCoreApplication::translate("main", "DockWidgets have maximize/restore buttons instead of float/dock button"));
parser.addOption(maximizeButton);
QCommandLineOption segmentedIndicators("y", QCoreApplication::translate("main", "Use segmented indicators instead of classical"));
parser.addOption(segmentedIndicators);
parser.addPositionalArgument("savedlayout", QCoreApplication::translate("main", "loads the specified json file at startup"));
#ifdef KDDOCKWIDGETS_SUPPORTS_NESTED_MAINWINDOWS
@@ -101,6 +104,9 @@ int main(int argc, char **argv)
Config::self().setSeparatorThickness(10);
}
if (parser.isSet(segmentedIndicators))
KDDockWidgets::DefaultWidgetFactory::s_dropIndicatorType = KDDockWidgets::DropIndicatorType::Segmented;
MainWindowOptions options = MainWindowOption_None;
#if defined(DOCKS_DEVELOPER_MODE)
options = parser.isSet(centralFrame) ? MainWindowOption_HasCentralFrame

View File

@@ -37,6 +37,8 @@
using namespace KDDockWidgets;
DropIndicatorType DefaultWidgetFactory::s_dropIndicatorType = DropIndicatorType::Classic;
FrameworkWidgetFactory::~FrameworkWidgetFactory()
{
}
@@ -84,6 +86,13 @@ FloatingWindow *DefaultWidgetFactory::createFloatingWindow(Frame *frame, MainWin
DropIndicatorOverlayInterface *DefaultWidgetFactory::createDropIndicatorOverlay(DropArea *dropArea) const
{
switch (s_dropIndicatorType) {
case DropIndicatorType::Classic:
return new ClassicIndicators(dropArea);
case DropIndicatorType::Segmented:
return new SegmentedIndicators(dropArea);
}
return new ClassicIndicators(dropArea);
}

View File

@@ -142,6 +142,8 @@ public:
FloatingWindow *createFloatingWindow(Frame *frame, MainWindowBase *parent = nullptr) const override;
DropIndicatorOverlayInterface *createDropIndicatorOverlay(DropArea*) const override;
QWidgetOrQuick *createRubberBand(QWidgetOrQuick *parent) const override;
static DropIndicatorType s_dropIndicatorType;
private:
Q_DISABLE_COPY(DefaultWidgetFactory)
};

View File

@@ -73,6 +73,11 @@ namespace KDDockWidgets
SizePolicy, ///< Uses the item's sizeHint() and sizePolicy()
};
enum class DropIndicatorType {
Classic, ///< The default
Segmented
};
///@internal
inline QString locationStr(Location loc)
{