KProperty

KPropertyGenericSelectionEditor.cpp
1/* This file is part of the KDE project
2 Copyright (C) 2016 Jarosław Staniek <staniek@kde.org>
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18*/
19
20#include "KPropertyGenericSelectionEditor.h"
21
22#include <QHBoxLayout>
23#include <QPushButton>
24
25class Q_DECL_HIDDEN KPropertyGenericSelectionEditor::Private
26{
27public:
28 Private() {
29 }
30 QHBoxLayout *lyr;
31 QPushButton *btn;
32};
33
34KPropertyGenericSelectionEditor::KPropertyGenericSelectionEditor(QWidget *parent)
35 : QWidget(parent), d(new Private)
36{
37 setAutoFillBackground(true);
38 d->lyr = new QHBoxLayout(this);
39 d->lyr->setContentsMargins(0, 0, 0, 0);
40 d->lyr->setSpacing(2);
41 d->btn = new QPushButton(tr("...", "... button"));
42 d->btn->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred);
43 d->btn->setFixedWidth(d->btn->fontMetrics().width(d->btn->text() + QLatin1String(" ")));
44 d->btn->setFocusPolicy(Qt::NoFocus);
46 d->lyr->addWidget(d->btn);
47}
48
49KPropertyGenericSelectionEditor::~KPropertyGenericSelectionEditor()
50{
51}
52
53void KPropertyGenericSelectionEditor::setMainWidget(QWidget *widget)
54{
55 if (d->lyr->count() > 1) {
56 delete d->lyr->takeAt(0)->widget();
57 }
58 if (widget) {
59 d->lyr->insertWidget(0, widget);
61 setFocusProxy(widget);
62 }
63}
64
66{
67 d->btn->setVisible(set);
68}
69
A base class for use by editors that have widget on the left and "..." select button on the right.
virtual void selectButtonClicked()
Reimplement to react on clicking the "..." select button.
void setSelectionButtonVisible(bool set)
Sets the visibility of the "..." select button.
void clicked(bool checked)
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)
void setFocusProxy(QWidget *w)
void setSizePolicy(QSizePolicy)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:04:09 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.