Libkdepim

progressdialog.h
1/* -*- c++ -*-
2 * progressdialog.h
3 *
4 * SPDX-FileCopyrightText: 2004 Till Adam <adam@kde.org>
5 * based on imapprogressdialog.cpp ,which is
6 * SPDX-FileCopyrightText: 2002-2003 Klarälvdalens Datakonsult AB
7 *
8 * SPDX-License-Identifier: GPL-2.0-or-later
9 */
10
11#pragma once
12
13#include "kdepim_export.h"
14
15#include "progressmanager.h"
16
17#include <QMap>
18#include <QScrollArea>
19
20class QProgressBar;
21class QFrame;
22class QLabel;
23class QPushButton;
24
25namespace KPIM
26{
27class TransactionItem;
28class SSLLabel;
29
30/**
31 * This is a widget that can align itself with another one, without using a layout,
32 * so that it can actually be on top of other widgets.
33 * Currently the only supported type of alignment is "right aligned, on top of the other widget".
34 *
35 */
36class OverlayWidgetPrivate;
37class KDEPIM_EXPORT OverlayWidget : public QFrame
38{
39 Q_OBJECT
40
41public:
42 OverlayWidget(QWidget *alignWidget, QWidget *parent);
43 ~OverlayWidget() override;
44
45 [[nodiscard]] QWidget *alignWidget() const;
46 void setAlignWidget(QWidget *alignWidget);
47
48protected:
49 void resizeEvent(QResizeEvent *ev) override;
50 [[nodiscard]] bool eventFilter(QObject *o, QEvent *e) override;
51
52private:
53 KDEPIM_NO_EXPORT void reposition();
54
55private:
56 std::unique_ptr<OverlayWidgetPrivate> const d;
57};
58
59class TransactionItemView : public QScrollArea
60{
62public:
63 explicit TransactionItemView(QWidget *parent = nullptr, const QString &name = QString());
64
65 ~TransactionItemView() override;
66
67 TransactionItem *addTransactionItem(ProgressItem *item, bool first);
68
69 [[nodiscard]] QSize sizeHint() const override;
70 [[nodiscard]] QSize minimumSizeHint() const override;
71
72public Q_SLOTS:
73 void slotLayoutFirstItem();
74
75protected:
76 void resizeEvent(QResizeEvent *event) override;
77
78private:
79 QWidget *mBigBox = nullptr;
80};
81
82class TransactionItem : public QWidget
83{
85public:
86 TransactionItem(QWidget *parent, ProgressItem *item, bool first);
87
88 ~TransactionItem() override;
89
90 void hideHLine();
91
92 void setProgress(int progress);
93 void setLabel(const QString &);
94
95 // the given text is interpreted as RichText, so you might need to
96 // .toHtmlEscaped() it before passing
97 void setStatus(const QString &);
98
99 void setCryptoStatus(KPIM::ProgressItem::CryptoStatus);
100 void setTotalSteps(int totalSteps);
101
102 [[nodiscard]] ProgressItem *item() const
103 {
104 return mItem;
105 }
106
107 void addSubTransaction(ProgressItem *item);
108
109 // The progressitem is deleted immediately, we take 5s to go out,
110 // so better not use mItem during this time.
111 void setItemComplete()
112 {
113 mItem = nullptr;
114 }
115
116public Q_SLOTS:
117 void slotItemCanceled();
118
119protected:
120 QProgressBar *mProgress = nullptr;
121 QPushButton *mCancelButton = nullptr;
122 QLabel *mItemLabel = nullptr;
123 QLabel *mItemStatus = nullptr;
124 QFrame *mFrame = nullptr;
125 SSLLabel *mSSLLabel = nullptr;
126 ProgressItem *mItem = nullptr;
127};
128
129class KDEPIM_EXPORT ProgressDialog : public OverlayWidget
130{
131 Q_OBJECT
132public:
133 ProgressDialog(QWidget *alignWidget, QWidget *parent);
134 ~ProgressDialog() override;
135 void setVisible(bool b) override;
136
137 void setShowTypeProgressItem(unsigned int type);
138
139 [[nodiscard]] bool wasLastShown() const;
140
141public Q_SLOTS:
142 void slotToggleVisibility();
143
144protected Q_SLOTS:
145 void slotTransactionAdded(KPIM::ProgressItem *item);
146 void slotTransactionCompleted(KPIM::ProgressItem *item);
147 void slotTransactionCanceled(KPIM::ProgressItem *item);
148 void slotTransactionProgress(KPIM::ProgressItem *item, unsigned int progress);
149 void slotTransactionStatus(KPIM::ProgressItem *item, const QString &);
150 void slotTransactionLabel(KPIM::ProgressItem *item, const QString &);
151 void slotTransactionCryptoStatus(KPIM::ProgressItem *item, KPIM::ProgressItem::CryptoStatus);
152 void slotTransactionUsesBusyIndicator(KPIM::ProgressItem *, bool);
153
154 void slotClose();
155 void slotShow();
156 void slotHide();
157
158Q_SIGNALS:
159 void visibilityChanged(bool);
160
161protected:
162 void closeEvent(QCloseEvent *) override;
163
164 TransactionItemView *mScrollView = nullptr;
165 QMap<const ProgressItem *, TransactionItem *> mTransactionsToListviewItems;
166 unsigned int mShowTypeProgressItem = 0;
167 bool mWasLastShown = false;
168};
169} // namespace KPIM
The ProgressItem class.
Class KCheckComboBox::KCheckComboBoxPrivate.
Q_OBJECTQ_OBJECT
Q_SLOTSQ_SLOTS
QObject * parent() const const
virtual bool event(QEvent *e) override
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:18:17 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.