Libkdepim

progressindicatorlabel.cpp
1/*
2 SPDX-FileCopyrightText: 2013-2024 Laurent Montel <montel@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#include "progressindicatorlabel.h"
8#include <KBusyIndicatorWidget>
9
10#include <QHBoxLayout>
11#include <QLabel>
12
13using namespace KPIM;
14class KPIM::ProgressIndicatorLabelPrivate
15{
16public:
17 ProgressIndicatorLabelPrivate(const QString &_label, ProgressIndicatorLabel *qq)
18 : labelStr(_label)
19 , q(qq)
20 {
21 auto lay = new QHBoxLayout(q);
22 lay->setContentsMargins(0, 0, 0, 0);
23 indicator = new KBusyIndicatorWidget(q);
24 lay->addWidget(indicator);
25 label = new QLabel(q);
26 lay->addWidget(label);
27 }
28
29 ~ProgressIndicatorLabelPrivate() = default;
30
31 void setActiveLabel(const QString &str)
32 {
33 if (!indicator->isHidden()) {
34 label->setText(str);
35 }
36 }
37
38 void start()
39 {
40 indicator->show();
41 label->setText(labelStr);
42 }
43
44 void stop()
45 {
46 indicator->hide();
47 label->clear();
48 }
49
50 QString labelStr;
51 QLabel *label = nullptr;
52 KBusyIndicatorWidget *indicator = nullptr;
54};
55
57 : QWidget(parent)
58 , d(new ProgressIndicatorLabelPrivate(label, this))
59{
60 d->stop();
61}
62
64 : QWidget(parent)
65 , d(new ProgressIndicatorLabelPrivate(QString(), this))
66{
67 d->stop();
68}
69
70ProgressIndicatorLabel::~ProgressIndicatorLabel() = default;
71
72void ProgressIndicatorLabel::start()
73{
74 d->start();
75}
76
77void ProgressIndicatorLabel::stop()
78{
79 d->stop();
80}
81
82void ProgressIndicatorLabel::setActiveLabel(const QString &label)
83{
84 d->setActiveLabel(label);
85}
86
87#include "moc_progressindicatorlabel.cpp"
The ProgressIndicatorLabel class.
ProgressIndicatorLabel(const QString &labelStr, QWidget *parent=nullptr)
Class KCheckComboBox::KCheckComboBoxPrivate.
void clear()
void setText(const QString &)
void hide()
bool isHidden() const const
void show()
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 16:58:12 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.