From 35e61ce52a043aa076e556adf6ad0570f69f2004 Mon Sep 17 00:00:00 2001 From: Peter Hartmann Date: Tue, 5 Jul 2022 15:45:06 +0200 Subject: [PATCH] gallery: Add tab for dialogs --- examples/gallery/dialog/DialogPage.cpp | 82 ++++++++++++++++++++++++++ examples/gallery/dialog/DialogPage.h | 17 ++++++ examples/gallery/gallery.pro | 6 ++ examples/gallery/main.cpp | 2 + 4 files changed, 107 insertions(+) create mode 100644 examples/gallery/dialog/DialogPage.cpp create mode 100644 examples/gallery/dialog/DialogPage.h diff --git a/examples/gallery/dialog/DialogPage.cpp b/examples/gallery/dialog/DialogPage.cpp new file mode 100644 index 00000000..8bd36eb5 --- /dev/null +++ b/examples/gallery/dialog/DialogPage.cpp @@ -0,0 +1,82 @@ +/****************************************************************************** + * QSkinny - Copyright (C) 2016 Uwe Rathmann + * This file may be used under the terms of the 3-clause BSD License + *****************************************************************************/ + +#include "DialogPage.h" + +#include +#include +#include +#include + +namespace +{ + class Box : public QskGridBox + { + public: + Box( QQuickItem* parent ) + : QskGridBox( parent ) + { + auto* messageButton = new QskPushButton( "message", this ); + + connect( messageButton, &QskPushButton::clicked, this, []() + { + qskDialog->message( "message", "text", QskStandardSymbol::Ok ); + } ); + + auto* informationButton = new QskPushButton( "information", this ); + + connect( informationButton, &QskPushButton::clicked, this, []() + { + qskDialog->information( "information", "text" ); + } ); + + auto* warningButton = new QskPushButton( "warning", this ); + + connect( warningButton, &QskPushButton::clicked, this, []() + { + qskDialog->warning( "warning", "text" ); + } ); + + auto* criticalButton = new QskPushButton( "critical", this ); + + connect( criticalButton, &QskPushButton::clicked, this, []() + { + qskDialog->critical( "critical", "text" ); + } ); + + auto* questionButton = new QskPushButton( "question", this ); + + connect( questionButton, &QskPushButton::clicked, this, []() + { + qskDialog->question( "question", "text" ); + } ); + + auto* selectButton = new QskPushButton( "select", this ); + + connect( selectButton, &QskPushButton::clicked, this, []() + { + qskDialog->select( "select", "text", { "yes", "no", "maybe" } ); + } ); + + addItem( messageButton, 0, 0 ); + addItem( informationButton, 0, 1 ); + addItem( warningButton, 0, 2 ); + addItem( criticalButton, 1, 0 ); + addItem( questionButton, 1, 1 ); + addItem( selectButton, 1, 2 ); + } + }; +} + +DialogPage::DialogPage( QQuickItem* parent ) + : Page( Qt::Horizontal, parent ) +{ + populate(); +} + +void DialogPage::populate() +{ + new Box( this ); +} diff --git a/examples/gallery/dialog/DialogPage.h b/examples/gallery/dialog/DialogPage.h new file mode 100644 index 00000000..f41a2a37 --- /dev/null +++ b/examples/gallery/dialog/DialogPage.h @@ -0,0 +1,17 @@ +/****************************************************************************** + * QSkinny - Copyright (C) 2016 Uwe Rathmann + * This file may be used under the terms of the 3-clause BSD License + *****************************************************************************/ + +#pragma once + +#include "Page.h" + +class DialogPage : public Page +{ + public: + DialogPage( QQuickItem* = nullptr ); + + private: + void populate(); +}; diff --git a/examples/gallery/gallery.pro b/examples/gallery/gallery.pro index 0435c5ea..d282c339 100644 --- a/examples/gallery/gallery.pro +++ b/examples/gallery/gallery.pro @@ -36,6 +36,12 @@ HEADERS += \ SOURCES += \ selector/SelectorPage.cpp \ +HEADERS += \ + dialog/DialogPage.h + +SOURCES += \ + dialog/DialogPage.cpp \ + HEADERS += \ Page.h diff --git a/examples/gallery/main.cpp b/examples/gallery/main.cpp index 0d4bf2a5..b2bec795 100644 --- a/examples/gallery/main.cpp +++ b/examples/gallery/main.cpp @@ -9,6 +9,7 @@ #include "button/ButtonPage.h" #include "textinput/TextInputPage.h" #include "selector/SelectorPage.h" +#include "dialog/DialogPage.h" #include #include @@ -138,6 +139,7 @@ namespace tabView->addTab( "Progress\nBars", new ProgressBarPage() ); tabView->addTab( "Text\nInputs", new TextInputPage() ); tabView->addTab( "Selectors", new SelectorPage() ); + tabView->addTab( "Dialogs", new DialogPage() ); connect( header, &Header::enabledToggled, tabView, &TabView::setTabsEnabled );