File indexing completed on 2024-04-28 03:59:17

0001 /*
0002     This file is part of the KDE libraries
0003     SPDX-FileCopyrightText: 2015 David Edmundson <davidedmundson@kde.org>
0004     Based on test program by Dominik Haumann <dhaumann@kde.org>
0005 
0006     SPDX-License-Identifier: LGPL-2.1-or-later
0007 */
0008 #include <QApplication>
0009 #include <QCheckBox>
0010 #include <QLabel>
0011 #include <QLineEdit>
0012 #include <QVBoxLayout>
0013 #include <QWidget>
0014 
0015 #include "kdatepicker.h"
0016 #include <kcollapsiblegroupbox.h>
0017 
0018 int main(int argc, char *argv[])
0019 {
0020     QApplication app(argc, argv);
0021 
0022     QWidget mainWindow;
0023 
0024     QVBoxLayout mainWindowLayout(&mainWindow);
0025 
0026     // add a layout with many items to make sure it doesn't shuffle them weirdly when animating
0027     {
0028         auto groupBox = new KCollapsibleGroupBox;
0029         groupBox->setTitle(QStringLiteral("&Advanced Options"));
0030 
0031         auto *innerLayout = new QVBoxLayout(groupBox);
0032         for (int i = 0; i < 6; i++) {
0033             auto checkBox = new QCheckBox(QStringLiteral("Some text"));
0034             innerLayout->addWidget(checkBox);
0035         }
0036         auto checkBox = new QCheckBox(QStringLiteral("Some really long text that goes on and on and on for ever and ever"));
0037         innerLayout->addWidget(checkBox);
0038 
0039         auto label = new QLabel(groupBox);
0040         label->setText(QStringLiteral("Some input field:"));
0041         // Word-wrapping in labels triggers a bug in the layout positioning.
0042         label->setWordWrap(true);
0043         innerLayout->addWidget(label);
0044 
0045         auto lineEdit = new QLineEdit(groupBox);
0046         innerLayout->addWidget(lineEdit);
0047 
0048         auto hiddenCheckBox = new QCheckBox(QStringLiteral("This will be always hidden"));
0049         innerLayout->addWidget(hiddenCheckBox);
0050         hiddenCheckBox->hide();
0051 
0052         mainWindowLayout.addWidget(groupBox);
0053     }
0054 
0055     // another item which should expand to fill width
0056     {
0057         auto groupBox = new KCollapsibleGroupBox;
0058         groupBox->setTitle(QStringLiteral("Pick a &date"));
0059 
0060         auto innerLayout = new QVBoxLayout(groupBox);
0061         auto datePicker = new KDatePicker();
0062         innerLayout->addWidget(datePicker);
0063         mainWindowLayout.addWidget(groupBox);
0064     }
0065 
0066     mainWindowLayout.addStretch();
0067 
0068     mainWindow.resize(400, 300);
0069     mainWindow.show();
0070 
0071     return app.exec();
0072 }
0073 
0074 // kate: replace-tabs on;