summaryrefslogtreecommitdiffstats
path: root/tests/manual/qtabbar/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/manual/qtabbar/main.cpp')
-rw-r--r--tests/manual/qtabbar/main.cpp74
1 files changed, 67 insertions, 7 deletions
diff --git a/tests/manual/qtabbar/main.cpp b/tests/manual/qtabbar/main.cpp
index 5a1a558c10..466a7e20fc 100644
--- a/tests/manual/qtabbar/main.cpp
+++ b/tests/manual/qtabbar/main.cpp
@@ -57,19 +57,25 @@
#include <QDesktopWidget>
#include <QTabWidget>
#include <QProxyStyle>
+#include <qdebug.h>
+#include "tabbarform.h"
-class MyProxyStyle : public QProxyStyle
+class TabBarProxyStyle : public QProxyStyle
{
public:
+ TabBarProxyStyle() : QProxyStyle(), alignment(Qt::AlignLeft)
+ { }
+
int styleHint(StyleHint hint, const QStyleOption *option = 0,
const QWidget *widget = 0, QStyleHintReturn *returnData = 0) const
{
if (hint == QStyle::SH_TabBar_Alignment)
- return Qt::AlignLeft;
-// return Qt::AlignRight;
-// return Qt::AlignCenter;
+ return alignment;
+
return QProxyStyle::styleHint(hint, option, widget, returnData);
}
+
+ Qt::Alignment alignment;
};
const int TabCount = 5;
@@ -77,7 +83,8 @@ const int TabCount = 5;
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
- app.setStyle(new MyProxyStyle);
+ auto *proxyStyle = new TabBarProxyStyle;
+ app.setStyle(proxyStyle);
QWidget widget;
QStackedWidget stackedWidget;
@@ -161,8 +168,61 @@ int main(int argc, char *argv[])
break;
}
- layout->setMargin(0);
- widget.resize(QApplication::desktop()->screenGeometry(&widget).size() * 0.5);
+ TabBarForm form;
+ layout->addWidget(&form);
+ layout->setAlignment(&form, Qt::AlignHCenter);
+
+ form.ui->documentModeButton->setChecked(tabBar.documentMode());
+ QObject::connect(form.ui->documentModeButton, &QCheckBox::toggled, [&] {
+ tabBar.setDocumentMode(form.ui->documentModeButton->isChecked());
+ // QMacStyle (and maybe other styles) requires a re-polish to get the right font
+ QApplication::sendEvent(&tabBar, new QEvent(QEvent::ThemeChange));
+ });
+
+ form.ui->movableTabsButton->setChecked(tabBar.isMovable());
+ QObject::connect(form.ui->movableTabsButton, &QCheckBox::toggled, [&] {
+ tabBar.setMovable(form.ui->movableTabsButton->isChecked());
+ tabBar.update();
+ });
+
+ form.ui->closableTabsButton->setChecked(tabBar.tabsClosable());
+ QObject::connect(form.ui->closableTabsButton, &QCheckBox::toggled, [&] {
+ tabBar.setTabsClosable(form.ui->closableTabsButton->isChecked());
+ tabBar.update();
+ });
+
+ form.ui->expandingTabsButton->setChecked(tabBar.expanding());
+ QObject::connect(form.ui->expandingTabsButton, &QCheckBox::toggled, [&] {
+ tabBar.setExpanding(form.ui->expandingTabsButton->isChecked());
+ tabBar.update();
+ });
+
+ form.ui->displayIconButton->setChecked(!tabBar.tabIcon(0).isNull());
+ QObject::connect(form.ui->displayIconButton, &QCheckBox::toggled, [&] {
+ const auto icon = form.ui->displayIconButton->isChecked() ?
+ tabBar.style()->standardIcon(QStyle::SP_ComputerIcon) : QIcon();
+ for (int i = 0; i < tabBar.count(); i++)
+ tabBar.setTabIcon(i, icon);
+ });
+
+ QObject::connect(form.ui->shapeComboBox, QOverload<int>::of(&QComboBox::currentIndexChanged), [&](int index) {
+ Q_UNUSED(index);
+ // TODO
+ });
+
+ if (proxyStyle->alignment == Qt::AlignLeft)
+ form.ui->leftAlignedButton->setChecked(true);
+ else if (proxyStyle->alignment == Qt::AlignRight)
+ form.ui->rightAlignedButton->setChecked(true);
+ else
+ form.ui->centeredButton->setChecked(true);
+ QObject::connect(form.ui->textAlignmentGroup, QOverload<QAbstractButton *>::of(&QButtonGroup::buttonClicked), [&](QAbstractButton *b) {
+ proxyStyle->alignment = b == form.ui->leftAlignedButton ? Qt::AlignLeft :
+ b == form.ui->rightAlignedButton ? Qt::AlignRight : Qt::AlignCenter;
+ QApplication::sendEvent(&tabBar, new QEvent(QEvent::StyleChange));
+ });
+
+ layout->setMargin(12);
widget.show();
return app.exec();