From 16acde949fbf03d065e736eef827d12b58e4c57b Mon Sep 17 00:00:00 2001 From: Xuan Nguyen Date: Fri, 2 Jul 2021 10:19:45 +0700 Subject: [PATCH] Add TabWidet --- components/components.pro | 10 +- components/link_components.pri | 6 +- components/plugin/qtmaterialplugins.cpp | 3 +- .../qtmaterialtabwidgetcontainerextension.cpp | 44 ++ .../qtmaterialtabwidgetcontainerextension.h | 32 + .../qtmaterialtabwidgetextensionfactory.cpp | 20 + .../qtmaterialtabwidgetextensionfactory.h | 21 + .../plugin/qtmaterialtabwidgetplugin.cpp | 145 ++++ components/plugin/qtmaterialtabwidgetplugin.h | 33 + components/qtmaterialslider.cpp | 2 +- components/qtmaterialslider.h | 2 +- components/qtmaterialslider_internal.cpp | 6 +- components/qtmaterialtabs.cpp | 57 ++ components/qtmaterialtabs.h | 6 +- components/qtmaterialtabs_internal.cpp | 4 +- components/qtmaterialtabwidget.cpp | 98 +++ components/qtmaterialtabwidget.h | 48 ++ examples/examples.pro | 4 +- examples/plugindemoform.cpp | 6 + examples/plugindemoform.h | 1 + examples/plugindemoform.ui | 620 ++++++++++-------- 21 files changed, 885 insertions(+), 283 deletions(-) create mode 100644 components/plugin/qtmaterialtabwidgetcontainerextension.cpp create mode 100644 components/plugin/qtmaterialtabwidgetcontainerextension.h create mode 100644 components/plugin/qtmaterialtabwidgetextensionfactory.cpp create mode 100644 components/plugin/qtmaterialtabwidgetextensionfactory.h create mode 100644 components/plugin/qtmaterialtabwidgetplugin.cpp create mode 100644 components/plugin/qtmaterialtabwidgetplugin.h create mode 100644 components/qtmaterialtabwidget.cpp create mode 100644 components/qtmaterialtabwidget.h diff --git a/components/components.pro b/components/components.pro index 6937368..280adce 100644 --- a/components/components.pro +++ b/components/components.pro @@ -5,10 +5,16 @@ TEMPLATE = lib include(link_components.pri) SOURCES += \ - plugin/qtmaterialplugins.cpp + plugin/qtmaterialplugins.cpp \ + plugin/qtmaterialtabwidgetcontainerextension.cpp \ + plugin/qtmaterialtabwidgetextensionfactory.cpp \ + plugin/qtmaterialtabwidgetplugin.cpp HEADERS += \ plugin/plugintemplate.h \ - plugin/qtmaterialplugins.h + plugin/qtmaterialplugins.h \ + plugin/qtmaterialtabwidgetcontainerextension.h \ + plugin/qtmaterialtabwidgetextensionfactory.h \ + plugin/qtmaterialtabwidgetplugin.h TARGET = $$qtLibraryTarget(qt-material-widget) target.path = $$[QT_INSTALL_PLUGINS]/designer diff --git a/components/link_components.pri b/components/link_components.pri index a8dd692..561f257 100644 --- a/components/link_components.pri +++ b/components/link_components.pri @@ -50,7 +50,8 @@ SOURCES += \ $$COMP_PATH/qtmaterialmenu.cpp \ $$COMP_PATH/qtmaterialmenu_internal.cpp \ $$COMP_PATH/qtmateriallist.cpp \ - $$COMP_PATH/qtmateriallistitem.cpp + $$COMP_PATH/qtmateriallistitem.cpp \ + $$PWD/qtmaterialtabwidget.cpp HEADERS += \ $$COMP_PATH/qtmaterialavatar_p.h \ $$COMP_PATH/qtmaterialavatar.h \ @@ -129,7 +130,8 @@ HEADERS += \ $$COMP_PATH/qtmateriallist_p.h \ $$COMP_PATH/qtmateriallistitem.h \ $$COMP_PATH/qtmateriallistitem_p.h \ - $$PWD/lib/qtmaterialconst.h + $$PWD/lib/qtmaterialconst.h \ + $$PWD/qtmaterialtabwidget.h RESOURCES += \ $$COMP_PATH/material_res.qrc diff --git a/components/plugin/qtmaterialplugins.cpp b/components/plugin/qtmaterialplugins.cpp index b010611..a17cc90 100644 --- a/components/plugin/qtmaterialplugins.cpp +++ b/components/plugin/qtmaterialplugins.cpp @@ -1,5 +1,5 @@ #include "qtmaterialplugins.h" - +#include "qtmaterialtabwidgetplugin.h" QtMaterialPlugins::QtMaterialPlugins(QObject *parent) : QObject(parent) { m_plugins << new MaterialAppBarPlugin(this) @@ -27,6 +27,7 @@ QtMaterialPlugins::QtMaterialPlugins(QObject *parent) : QObject(parent) << new MaterialTabsPlugin(this) << new MaterialTextFieldPlugin(this) << new MaterialTogglePlugin(this) + << new QtMaterialTabWidgetPlugin(this) ; } diff --git a/components/plugin/qtmaterialtabwidgetcontainerextension.cpp b/components/plugin/qtmaterialtabwidgetcontainerextension.cpp new file mode 100644 index 0000000..2b067c3 --- /dev/null +++ b/components/plugin/qtmaterialtabwidgetcontainerextension.cpp @@ -0,0 +1,44 @@ +#include "qtmaterialtabwidgetcontainerextension.h" +#include "qtmaterialtabwidget.h" + +QtMaterialTabWidgetContainerExtension::QtMaterialTabWidgetContainerExtension(QtMaterialTabWidget *widget, + QObject *parent) + : QObject(parent) + , myWidget(widget) +{ +} + +void QtMaterialTabWidgetContainerExtension::addWidget(QWidget *widget) +{ + myWidget->addPage(widget); +} + +int QtMaterialTabWidgetContainerExtension::count() const +{ + return myWidget->count(); +} + +int QtMaterialTabWidgetContainerExtension::currentIndex() const +{ + return myWidget->currentIndex(); +} + +void QtMaterialTabWidgetContainerExtension::insertWidget(int index, QWidget *widget) +{ + myWidget->insertPage(index, widget); +} + +void QtMaterialTabWidgetContainerExtension::remove(int index) +{ + myWidget->removePage(index); +} + +void QtMaterialTabWidgetContainerExtension::setCurrentIndex(int index) +{ + myWidget->setCurrentIndex(index); +} + +QWidget* QtMaterialTabWidgetContainerExtension::widget(int index) const +{ + return myWidget->widget(index); +} diff --git a/components/plugin/qtmaterialtabwidgetcontainerextension.h b/components/plugin/qtmaterialtabwidgetcontainerextension.h new file mode 100644 index 0000000..eed4f5e --- /dev/null +++ b/components/plugin/qtmaterialtabwidgetcontainerextension.h @@ -0,0 +1,32 @@ +#ifndef QTMATERIALTABWIDGETCONTAINEREXTENSION_H +#define QTMATERIALTABWIDGETCONTAINEREXTENSION_H + +#include + +QT_BEGIN_NAMESPACE +class QExtensionManager; +QT_END_NAMESPACE +class QtMaterialTabWidget; + +class QtMaterialTabWidgetContainerExtension: public QObject, + public QDesignerContainerExtension +{ +Q_OBJECT +Q_INTERFACES(QDesignerContainerExtension) + +public: +explicit QtMaterialTabWidgetContainerExtension(QtMaterialTabWidget *widget, QObject *parent); + +void addWidget(QWidget *widget) override; +int count() const override; +int currentIndex() const override; +void insertWidget(int index, QWidget *widget) override; +void remove(int index) override; +void setCurrentIndex(int index) override; +QWidget *widget(int index) const override; + +private: +QtMaterialTabWidget *myWidget; +}; + +#endif // QTMATERIALTABWIDGETCONTAINEREXTENSION_H diff --git a/components/plugin/qtmaterialtabwidgetextensionfactory.cpp b/components/plugin/qtmaterialtabwidgetextensionfactory.cpp new file mode 100644 index 0000000..fa12de0 --- /dev/null +++ b/components/plugin/qtmaterialtabwidgetextensionfactory.cpp @@ -0,0 +1,20 @@ +#include "qtmaterialtabwidgetextensionfactory.h" +#include "qtmaterialtabwidgetcontainerextension.h" +#include "qtmaterialtabwidget.h" + +QtMaterialTabWidgetExtensionFactory::QtMaterialTabWidgetExtensionFactory(QExtensionManager *parent) + : QExtensionFactory(parent) +{} +//! [0] + +//! [1] +QObject *QtMaterialTabWidgetExtensionFactory::createExtension(QObject *object, + const QString &iid, + QObject *parent) const +{ + QtMaterialTabWidget *widget = qobject_cast(object); + + if (widget && (iid == Q_TYPEID(QDesignerContainerExtension))) + return new QtMaterialTabWidgetContainerExtension(widget, parent); + return nullptr; +} diff --git a/components/plugin/qtmaterialtabwidgetextensionfactory.h b/components/plugin/qtmaterialtabwidgetextensionfactory.h new file mode 100644 index 0000000..00b71e8 --- /dev/null +++ b/components/plugin/qtmaterialtabwidgetextensionfactory.h @@ -0,0 +1,21 @@ +#ifndef QTMATERIALTABWIDGETEXTENSIONFACTORY_H +#define QTMATERIALTABWIDGETEXTENSIONFACTORY_H + +#include + +QT_BEGIN_NAMESPACE +class QExtensionManager; +QT_END_NAMESPACE + +class QtMaterialTabWidgetExtensionFactory: public QExtensionFactory +{ + Q_OBJECT + +public: + explicit QtMaterialTabWidgetExtensionFactory(QExtensionManager *parent = nullptr); + +protected: + QObject *createExtension(QObject *object, const QString &iid, QObject *parent) const override; +}; + +#endif // QTMATERIALTABWIDGETEXTENSIONFACTORY_H diff --git a/components/plugin/qtmaterialtabwidgetplugin.cpp b/components/plugin/qtmaterialtabwidgetplugin.cpp new file mode 100644 index 0000000..b6faa96 --- /dev/null +++ b/components/plugin/qtmaterialtabwidgetplugin.cpp @@ -0,0 +1,145 @@ +#include +#include +#include +#include +#include +#include + +#include "qtmaterialtabwidgetplugin.h" +#include "qtmaterialtabwidget.h" +#include "qtmaterialtabwidgetextensionfactory.h" + +QtMaterialTabWidgetPlugin::QtMaterialTabWidgetPlugin(QObject *parent) + : QObject(parent) +{ +} + +QString QtMaterialTabWidgetPlugin::name() const +{ + return QLatin1String("QtMaterialTabWidget"); +} + +QString QtMaterialTabWidgetPlugin::group() const +{ + return QLatin1String("Qt Material Widgets"); +} + +QString QtMaterialTabWidgetPlugin::toolTip() const +{ + return QString(); +} + +QString QtMaterialTabWidgetPlugin::whatsThis() const +{ + return QString(); +} + +QString QtMaterialTabWidgetPlugin::includeFile() const +{ + return QLatin1String("qtmaterialtabwidget.h"); +} + +QIcon QtMaterialTabWidgetPlugin::icon() const +{ + return QIcon(); +} + +//! [0] //! [1] +bool QtMaterialTabWidgetPlugin::isContainer() const +{ + return true; +} + +//! [1] //! [2] +QWidget *QtMaterialTabWidgetPlugin::createWidget(QWidget *parent) +{ + QtMaterialTabWidget *widget = new QtMaterialTabWidget(parent); + connect(widget, &QtMaterialTabWidget::currentIndexChanged, + this, &QtMaterialTabWidgetPlugin::currentIndexChanged); + connect(widget, &QtMaterialTabWidget::pageTitleChanged, + this, &QtMaterialTabWidgetPlugin::pageTitleChanged); + return widget; +} + +//! [2] //! [3] +bool QtMaterialTabWidgetPlugin::isInitialized() const +{ + return initialized; +} +//! [3] + +//! [4] +void QtMaterialTabWidgetPlugin::initialize(QDesignerFormEditorInterface *formEditor) +{ + if (initialized) + return; +//! [4] + +//! [5] + QExtensionManager *manager = formEditor->extensionManager(); +//! [5] //! [6] + QExtensionFactory *factory = new QtMaterialTabWidgetExtensionFactory(manager); + + Q_ASSERT(manager != 0); + manager->registerExtensions(factory, Q_TYPEID(QDesignerContainerExtension)); + + initialized = true; +} +//! [6] + +//! [7] +QString QtMaterialTabWidgetPlugin::domXml() const +{ + return QLatin1String("\ +\ + \ + \ + \ + \ + \ + QtMaterialTabWidget\ + QWidget\ + addPage\ + \ + \ +"); +} +//! [7] + +//! [8] +void QtMaterialTabWidgetPlugin::currentIndexChanged(int index) +{ + Q_UNUSED(index); + QtMaterialTabWidget *widget = qobject_cast(sender()); +//! [8] //! [9] + if (widget) { + QDesignerFormWindowInterface *form = QDesignerFormWindowInterface::findFormWindow(widget); + if (form) + form->emitSelectionChanged(); + } +} +//! [9] + +//! [10] +void QtMaterialTabWidgetPlugin::pageTitleChanged(const QString &title) +{ + Q_UNUSED(title); + QtMaterialTabWidget *widget = qobject_cast(sender()); +//! [10] //! [11] + if (widget) { + QWidget *page = widget->widget(widget->currentIndex()); + QDesignerFormWindowInterface *form; + form = QDesignerFormWindowInterface::findFormWindow(widget); +//! [11] + if (form) { +//! [12] + QDesignerFormEditorInterface *editor = form->core(); + QExtensionManager *manager = editor->extensionManager(); +//! [12] //! [13] + QDesignerPropertySheetExtension *sheet; + sheet = qt_extension(manager, page); + const int propertyIndex = sheet->indexOf(QLatin1String("windowTitle")); + sheet->setChanged(propertyIndex, true); + } + } +} diff --git a/components/plugin/qtmaterialtabwidgetplugin.h b/components/plugin/qtmaterialtabwidgetplugin.h new file mode 100644 index 0000000..f07d7f6 --- /dev/null +++ b/components/plugin/qtmaterialtabwidgetplugin.h @@ -0,0 +1,33 @@ +#ifndef QTMATERIALTABWIDGETPLUGIN_H +#define QTMATERIALTABWIDGETPLUGIN_H + +#include +#include + +class QtMaterialTabWidgetPlugin: public QObject, public QDesignerCustomWidgetInterface +{ + Q_OBJECT +public: + explicit QtMaterialTabWidgetPlugin(QObject *parent = nullptr); + + QString name() const override; + QString group() const override; + QString toolTip() const override; + QString whatsThis() const override; + QString includeFile() const override; + QIcon icon() const override; + bool isContainer() const override; + QWidget *createWidget(QWidget *parent) override; + bool isInitialized() const override; + void initialize(QDesignerFormEditorInterface *formEditor) override; + QString domXml() const override; + +private slots: + void currentIndexChanged(int index); + void pageTitleChanged(const QString &title); + +private: + bool initialized = false; +}; + +#endif // QTMATERIALTABWIDGETPLUGIN_H diff --git a/components/qtmaterialslider.cpp b/components/qtmaterialslider.cpp index a0d17dc..1ef2e94 100644 --- a/components/qtmaterialslider.cpp +++ b/components/qtmaterialslider.cpp @@ -29,7 +29,7 @@ void QtMaterialSliderPrivate::init() stateMachine = new QtMaterialSliderStateMachine(q, thumb, track); stepTo = 0; oldValue = q->value(); - trackWidth = 2; + trackWidth = 4; hoverTrack = false; hoverThumb = false; hover = false; diff --git a/components/qtmaterialslider.h b/components/qtmaterialslider.h index 6b68597..8c73b19 100644 --- a/components/qtmaterialslider.h +++ b/components/qtmaterialslider.h @@ -5,7 +5,7 @@ #include #include -#define QT_MATERIAL_SLIDER_MARGIN 30 +#define QT_MATERIAL_SLIDER_MARGIN 10 class QtMaterialSliderPrivate; diff --git a/components/qtmaterialslider_internal.cpp b/components/qtmaterialslider_internal.cpp index fd2d50b..22dd0eb 100644 --- a/components/qtmaterialslider_internal.cpp +++ b/components/qtmaterialslider_internal.cpp @@ -45,9 +45,9 @@ QtMaterialSliderStateMachine::QtMaterialSliderStateMachine( m_pulseOutState->assignProperty(thumb, "haloSize", 35); m_pulseInState->assignProperty(thumb, "haloSize", 28); - m_inactiveState->assignProperty(thumb, "diameter", 11); - m_focusState->assignProperty(thumb, "diameter", 11); - m_slidingState->assignProperty(thumb, "diameter", 17); + m_inactiveState->assignProperty(thumb, "diameter", 15); + m_focusState->assignProperty(thumb, "diameter", 15); + m_slidingState->assignProperty(thumb, "diameter", 20); QAbstractTransition *transition; QtMaterialStateTransition *customTransition; diff --git a/components/qtmaterialtabs.cpp b/components/qtmaterialtabs.cpp index aa1f3a9..5bc97a5 100644 --- a/components/qtmaterialtabs.cpp +++ b/components/qtmaterialtabs.cpp @@ -180,6 +180,42 @@ void QtMaterialTabs::setCurrentTab(int index) emit currentChanged(index); } +void QtMaterialTabs::setTabText(int index, const QString &text) +{ + Q_D(QtMaterialTabs); + + if (index > -1) { + QtMaterialTab *tab = static_cast(d->tabLayout->itemAt(index)->widget()); + if (tab) { + tab->setText(text); + } + } +} + +void QtMaterialTabs::insertTab(int index, const QString &text, const QIcon &icon) +{ + Q_D(QtMaterialTabs); + + QtMaterialTab *tab = new QtMaterialTab(this); + tab->setText(text); + tab->setHaloVisible(isHaloVisible()); + tab->setRippleStyle(rippleStyle()); + + if (!icon.isNull()) { + tab->setIcon(icon); + tab->setIconSize(QSize(22, 22)); + } + + d->tabLayout->insertWidget(index, tab); + + if (-1 == d->tab) { + d->tab = 0; + d->inkBar->refreshGeometry(); + d->inkBar->raise(); + tab->setActive(true); + }; +} + void QtMaterialTabs::addTab(const QString &text, const QIcon &icon) { Q_D(QtMaterialTabs); @@ -204,6 +240,27 @@ void QtMaterialTabs::addTab(const QString &text, const QIcon &icon) } } +void QtMaterialTabs::removeTab(int index) +{ + Q_D(QtMaterialTabs); + + if (index > -1) { + QtMaterialTab *tab = static_cast(d->tabLayout->itemAt(index)->widget()); + if (tab) { + d->tabLayout->removeWidget(tab); + delete tab; + } + + setCurrentTab(index - 1); + } +} + +int QtMaterialTabs::count() const +{ + Q_D(const QtMaterialTabs); + return d->tabLayout->count(); +} + int QtMaterialTabs::currentIndex() const { Q_D(const QtMaterialTabs); diff --git a/components/qtmaterialtabs.h b/components/qtmaterialtabs.h index 1d822f4..e1b1c35 100644 --- a/components/qtmaterialtabs.h +++ b/components/qtmaterialtabs.h @@ -35,14 +35,18 @@ public: void setTextColor(const QColor &color); QColor textColor() const; + void insertTab(int index, const QString &text, const QIcon &icon = QIcon()); void addTab(const QString &text, const QIcon &icon = QIcon()); + void removeTab(int index); + int count() const; void setCurrentTab(QtMaterialTab *tab); void setCurrentTab(int index); + void setTabText(int index, const QString &text); int currentIndex() const; -signals: +Q_SIGNALS: void currentChanged(int); protected: diff --git a/components/qtmaterialtabs_internal.cpp b/components/qtmaterialtabs_internal.cpp index 7041ba9..34b3cbc 100644 --- a/components/qtmaterialtabs_internal.cpp +++ b/components/qtmaterialtabs_internal.cpp @@ -45,11 +45,11 @@ void QtMaterialTabsInkBar::refreshGeometry() const qreal s = 1-m_tween; if (QAbstractAnimation::Running != m_animation->state()) { - m_geometry = QRect(r.left(), r.bottom()-1, r.width(), 2); + m_geometry = QRect(r.left(), r.bottom()-1, r.width(), 4); } else { const qreal left = m_previousGeometry.left()*s + r.left()*m_tween; const qreal width = m_previousGeometry.width()*s + r.width()*m_tween; - m_geometry = QRect(left, r.bottom()-1, width, 2); + m_geometry = QRect(left, r.bottom()-1, width, 4); } m_tabs->update(); } diff --git a/components/qtmaterialtabwidget.cpp b/components/qtmaterialtabwidget.cpp new file mode 100644 index 0000000..3ef83d3 --- /dev/null +++ b/components/qtmaterialtabwidget.cpp @@ -0,0 +1,98 @@ +#include "qtmaterialtabwidget.h" +#include +#include +#include + +QtMaterialTabWidget::QtMaterialTabWidget(QWidget *parent) + : QWidget(parent) + , tabBar(new QtMaterialTabs) + , stackWidget(new QStackedWidget) +{ + tabBar->setObjectName(QStringLiteral("__qt__passive_tabBar")); + + connect(tabBar, QOverload::of(&QtMaterialTabs::currentChanged), + this, &QtMaterialTabWidget::setCurrentIndex); + + QVBoxLayout *layout = new QVBoxLayout(this); + layout->addWidget(tabBar); + layout->addWidget(stackWidget); +} + +QSize QtMaterialTabWidget::sizeHint() const +{ + return QSize(300, 200); +} + +void QtMaterialTabWidget::addPage(QWidget *page) +{ + insertPage(count(), page); +} + +void QtMaterialTabWidget::removePage(int index) +{ + QWidget *widget = stackWidget->widget(index); + stackWidget->removeWidget(widget); + + tabBar->removeTab(index); +} + +int QtMaterialTabWidget::count() const +{ + return stackWidget->count(); +} + +int QtMaterialTabWidget::currentIndex() const +{ + return stackWidget->currentIndex(); +} + +void QtMaterialTabWidget::insertPage(int index, QWidget *page) +{ + page->setParent(stackWidget); + + stackWidget->insertWidget(index, page); + + QString title = page->windowTitle(); + if (title.isEmpty()) { + title = tr("Tab %1").arg(tabBar->count() + 1); + page->setWindowTitle(title); + } + connect(page, &QWidget::windowTitleChanged, + this, &QtMaterialTabWidget::pageWindowTitleChanged); + tabBar->insertTab(index, title); +} + +void QtMaterialTabWidget::setCurrentIndex(int index) +{ + if (index != currentIndex()) { + stackWidget->setCurrentIndex(index); + tabBar->setCurrentTab(index); + emit currentIndexChanged(index); + } +} + +void QtMaterialTabWidget::pageWindowTitleChanged() +{ + QWidget *page = qobject_cast(sender()); + const int index = stackWidget->indexOf(page); + tabBar->setTabText(index, page->windowTitle()); +} + +QWidget* QtMaterialTabWidget::widget(int index) +{ + return stackWidget->widget(index); +} + +QString QtMaterialTabWidget::pageTitle() const +{ + if (const QWidget *currentWidget = stackWidget->currentWidget()) + return currentWidget->windowTitle(); + return QString(); +} + +void QtMaterialTabWidget::setPageTitle(QString const &newTitle) +{ + if (QWidget *currentWidget = stackWidget->currentWidget()) + currentWidget->setWindowTitle(newTitle); + emit pageTitleChanged(newTitle); +} diff --git a/components/qtmaterialtabwidget.h b/components/qtmaterialtabwidget.h new file mode 100644 index 0000000..d100f24 --- /dev/null +++ b/components/qtmaterialtabwidget.h @@ -0,0 +1,48 @@ +#ifndef QTMATERIALTABWIDGET_H +#define QTMATERIALTABWIDGET_H + +#include +#include + +QT_BEGIN_NAMESPACE +class QStackedWidget; +QT_END_NAMESPACE +class QtMaterialTabs; + +class QDESIGNER_WIDGET_EXPORT QtMaterialTabWidget : public QWidget +{ + Q_OBJECT + Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex) + Q_PROPERTY(QString pageTitle READ pageTitle WRITE setPageTitle STORED false) + +public: + explicit QtMaterialTabWidget(QWidget *parent = nullptr); + + QSize sizeHint() const override; + + + int count() const; + int currentIndex() const; + QWidget *widget(int index); + QString pageTitle() const; + +public slots: + void addPage(QWidget *page); + void insertPage(int index, QWidget *page); + void removePage(int index); + void setPageTitle(QString const &newTitle); + void setCurrentIndex(int index); + +private slots: + void pageWindowTitleChanged(); + +signals: + void currentIndexChanged(int index); + void pageTitleChanged(const QString &title); + +private: + QtMaterialTabs *tabBar; + QStackedWidget *stackWidget; +}; + +#endif // QTMATERIALTABWIDGET_H diff --git a/examples/examples.pro b/examples/examples.pro index db4f350..ceff3fc 100644 --- a/examples/examples.pro +++ b/examples/examples.pro @@ -67,11 +67,11 @@ FORMS += \ radiobuttonsettingsform.ui \ togglesettingsform.ui \ textfieldsettingsform.ui \ - tabssettingsform.ui \ dialogsettingsform.ui \ drawersettingsform.ui \ scrollbarsettingsform.ui \ - appbarsettingsform.ui + appbarsettingsform.ui \ + tabssettingsform.ui RESOURCES += \ ../components/material_res.qrc \ diff --git a/examples/plugindemoform.cpp b/examples/plugindemoform.cpp index e00e020..c477943 100644 --- a/examples/plugindemoform.cpp +++ b/examples/plugindemoform.cpp @@ -32,6 +32,8 @@ PluginDemoForm::PluginDemoForm(QWidget *parent) : dialogLayout->addWidget(dialogWidget); connect(closeButton, SIGNAL(pressed()), m_dialog, SLOT(hideDialog())); + + } PluginDemoForm::~PluginDemoForm() @@ -43,3 +45,7 @@ void PluginDemoForm::on_qtmaterialflatbutton_3_clicked() { m_dialog->showDialog(); } + +void PluginDemoForm::tabIndexChanged(int index) +{ +} diff --git a/examples/plugindemoform.h b/examples/plugindemoform.h index bf169df..bd673ea 100644 --- a/examples/plugindemoform.h +++ b/examples/plugindemoform.h @@ -19,6 +19,7 @@ public: private slots: void on_qtmaterialflatbutton_3_clicked(); + void tabIndexChanged(int index); private: Ui::PluginDemoForm *ui; diff --git a/examples/plugindemoform.ui b/examples/plugindemoform.ui index 5267796..b69e0e1 100644 --- a/examples/plugindemoform.ui +++ b/examples/plugindemoform.ui @@ -7,81 +7,44 @@ 0 0 907 - 849 + 908 Form - - - - - 0 - 0 - - - - - Roboto - - - - CheckBox - - + + - - + + - 200 + 150 16777215 - CheckBox + FlatButton - - - - - - - 0 - 0 - + + + :/icons/icons/maps/svg/production/ic_local_see_24px.svg:/icons/icons/maps/svg/production/ic_local_see_24px.svg - - - Roboto - - - - FloatActionButton - - - - - - + - 200 - 16777215 + 20 + 20 - - - HELLO - WORLD - MATERIAL - + + MaterialConst::TintedOverlay - - + + 0 @@ -94,11 +57,11 @@ - IconButton + RaiseButton - + @@ -109,71 +72,32 @@ - - + + + + + 0 + 0 + + + + + Roboto + + + + CirculaProgress + + + + + 200 16777215 - - RadioButton 1 - - - - - - - - 0 - 0 - - - - - Roboto - - - - Slider - - - - - - - - 0 - 0 - - - - - Roboto - - - - Progress - - - - - - - - 0 - 0 - - - - - Roboto - - - - Avatar & Badge - @@ -218,57 +142,34 @@ - - + + 200 16777215 - - - - - - - 200 - 16777215 - - - - Input Text - - - - - - - - 150 - 16777215 - - - FlatButton - - - - :/icons/icons/maps/svg/production/ic_local_see_24px.svg:/icons/icons/maps/svg/production/ic_local_see_24px.svg - - - - 20 - 20 - - - - MaterialConst::TintedOverlay + CheckBox - - + + + + + 60 + 60 + + + + 40.000000000000000 + + + + + 0 @@ -281,11 +182,61 @@ - RaiseButton + FloatActionButton - + + + + + 0 + 0 + + + + + Roboto + + + + AutoComplete + + + + + + + + :/icons/icons/content/svg/production/ic_mail_24px.svg:/icons/icons/content/svg/production/ic_mail_24px.svg + + + + 40 + 40 + + + + + + + + + 0 + 0 + + + + + Roboto + + + + Dialog + + + + @@ -303,10 +254,42 @@ - - + + + + + 200 + 16777215 + + + + + HELLO + WORLD + MATERIAL + + + - + + + + + 0 + 0 + + + + + Roboto + + + + RadioButton + + + + @@ -324,6 +307,31 @@ + + + + + 0 + 0 + + + + + Roboto + + + + CheckBox + + + + + + + Qt::Vertical + + + @@ -362,40 +370,43 @@ - - - - - 200 - 16777215 - + + + + + 0 + 0 + - - 50 + + + Roboto + + + + Progress - - - - - 60 - 60 - + + + + + 0 + 0 + - - 40.000000000000000 + + + Roboto + + + + Avatar & Badge - - - - Qt::Vertical - - - - + @@ -411,22 +422,34 @@ - - - - - :/icons/icons/content/svg/production/ic_mail_24px.svg:/icons/icons/content/svg/production/ic_mail_24px.svg - - + + + - 40 - 40 + 200 + 16777215 + + RadioButton 2 + - - + + + + + 200 + 16777215 + + + + 50 + + + + + 0 @@ -439,12 +462,12 @@ - Dialog + IconButton - - + + 0 @@ -457,11 +480,55 @@ - CirculaProgress + Slider - + + + + + 0 + 0 + + + + + Roboto + + + + Toggle + + + + + + + + 200 + 16777215 + + + + RadioButton 1 + + + + + + + + 200 + 16777215 + + + + Input Text + + + + @@ -493,71 +560,80 @@ - - - - - 0 - 0 - - - - - Roboto - - - - RadioButton - - - - - - - - 0 - 0 - - - - - Roboto - - - - Toggle - - - - - - - - 0 - 0 - - - - - Roboto - - - - AutoComplete - - - - - - - - 200 - 16777215 - - - - RadioButton 2 - + + + + + + + 130 + 0 + 78 + 78 + + + + + + + 30 + 10 + 86 + 61 + + + + + 0 + 0 + + + + + Roboto + + + + Tab 1 content + + + + + + + + 40 + 20 + 86 + 41 + + + + + 0 + 0 + + + + + Roboto + + + + Tab 2 content + + + + + + 210 + 30 + 112 + 24 + + + + @@ -647,9 +723,17 @@
qtmaterialtoggle.h
1 + + QtMaterialTabWidget + QWidget +
qtmaterialtabwidget.h
+ addPage + 1 +
+