File indexing completed on 2024-05-12 05:46:53
0001 /* This file is part of the KDE libraries 0002 * 0003 * Copyright 2015 David Edmundson <davidedmundson@kde.org> 0004 * 0005 * Based on test program by Dominik Haumann <dhaumann@kde.org> 0006 * 0007 * This library is free software; you can redistribute it and/or 0008 * modify it under the terms of the GNU Lesser General Public 0009 * License as published by the Free Software Foundation; either 0010 * version 2.1 of the License, or (at your option) any later version. 0011 * 0012 * This library is distributed in the hope that it will be useful, 0013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0015 * Lesser General Public License for more details. 0016 * 0017 * You should have received a copy of the GNU General Public License 0018 * along with this program. If not, see <http://www.gnu.org/licenses/>. 0019 */ 0020 #include <QApplication> 0021 #include <QLineEdit> 0022 #include <QWidget> 0023 #include <QVBoxLayout> 0024 #include <QCheckBox> 0025 #include <QLabel> 0026 0027 #include <kcollapsiblegroupbox.h> 0028 #include "kdatepicker.h" 0029 0030 0031 int main(int argc, char *argv[]) 0032 { 0033 QApplication app(argc, argv); 0034 app.setAttribute(Qt::AA_UseHighDpiPixmaps, true); 0035 0036 QWidget mainWindow; 0037 0038 QVBoxLayout mainWindowLayout(&mainWindow); 0039 0040 //add a layout with many items to make sure it doesn't shuffle them weirdly when animating 0041 { 0042 auto groupBox = new KCollapsibleGroupBox; 0043 groupBox->setTitle(QStringLiteral("&Advanced Options")); 0044 0045 auto innerLayout = new QVBoxLayout; 0046 for (int i =0; i<6;i++) { 0047 auto checkBox = new QCheckBox(QStringLiteral("Some text")); 0048 innerLayout->addWidget(checkBox); 0049 } 0050 auto checkBox = new QCheckBox(QStringLiteral("Some really long text that goes on and on and on for ever and ever")); 0051 innerLayout->addWidget(checkBox); 0052 0053 auto label = new QLabel(groupBox); 0054 label->setText(QStringLiteral("Some input field:")); 0055 // Word-wrapping in labels triggers a bug in the layout positioning. 0056 label->setWordWrap(true); 0057 innerLayout->addWidget(label); 0058 0059 auto lineEdit = new QLineEdit(groupBox); 0060 innerLayout->addWidget(lineEdit); 0061 0062 auto hiddenCheckBox = new QCheckBox(QStringLiteral("This will be always hidden")); 0063 innerLayout->addWidget(hiddenCheckBox); 0064 hiddenCheckBox->hide(); 0065 0066 groupBox->setLayout(innerLayout); 0067 mainWindowLayout.addWidget(groupBox); 0068 } 0069 0070 //another item which should expand to fill width 0071 { 0072 auto groupBox = new KCollapsibleGroupBox; 0073 groupBox->setTitle(QStringLiteral("Pick a &date")); 0074 0075 auto innerLayout = new QVBoxLayout; 0076 auto datePicker = new KDatePicker(); 0077 innerLayout->addWidget(datePicker); 0078 groupBox->setLayout(innerLayout); 0079 mainWindowLayout.addWidget(groupBox); 0080 } 0081 0082 mainWindowLayout.addStretch(); 0083 mainWindow.setLayout(&mainWindowLayout); 0084 0085 mainWindow.resize(400, 300); 0086 mainWindow.show(); 0087 0088 return app.exec(); 0089 } 0090 0091 // kate: replace-tabs on;