Warning, file /plasma/drkonqi/src/statuswidget.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /******************************************************************* 0002 * statuswidget.h 0003 * SPDX-FileCopyrightText: 2009, 2010 Dario Andres Rodriguez <andresbajotierra@gmail.com> 0004 * 0005 * SPDX-License-Identifier: GPL-2.0-or-later 0006 * 0007 ******************************************************************/ 0008 #ifndef STATUSWIDGET__H 0009 #define STATUSWIDGET__H 0010 0011 #include <QEvent> 0012 #include <QLabel> 0013 #include <QStackedWidget> 0014 #include <QTextDocument> 0015 0016 class WrapLabel; 0017 class KBusyIndicatorWidget; 0018 class QHideEvent; 0019 0020 class StatusWidget : public QStackedWidget 0021 { 0022 Q_OBJECT 0023 public: 0024 explicit StatusWidget(QWidget *parent = nullptr); 0025 0026 void setBusy(const QString &); 0027 void setIdle(const QString &); 0028 0029 void addCustomStatusWidget(QWidget *); 0030 0031 private: 0032 void showEvent(QShowEvent *) override; 0033 void hideEvent(QHideEvent *) override; 0034 0035 void setBusyCursor(); 0036 void setIdleCursor(); 0037 0038 WrapLabel *m_statusLabel; 0039 0040 KBusyIndicatorWidget *m_throbberWidget; 0041 WrapLabel *m_busyLabel; 0042 0043 QWidget *m_statusPage; 0044 QWidget *m_busyPage; 0045 0046 int m_cursorStackCount; 0047 bool m_busy; 0048 }; 0049 0050 // Dummy class to avoid a QLabel+wordWrap height bug 0051 class WrapLabel : public QLabel 0052 { 0053 Q_OBJECT 0054 public: 0055 explicit WrapLabel(QWidget *parent = nullptr) 0056 : QLabel(parent) 0057 { 0058 setWordWrap(true); 0059 } 0060 0061 void setText(const QString &text) 0062 { 0063 QLabel::setText(text); 0064 adjustHeight(); 0065 } 0066 0067 bool event(QEvent *e) override 0068 { 0069 if (e->type() == QEvent::ApplicationFontChange || e->type() == QEvent::Resize) { 0070 adjustHeight(); 0071 } 0072 return QLabel::event(e); 0073 } 0074 0075 private: 0076 void adjustHeight() 0077 { 0078 QTextDocument document(text()); 0079 document.setTextWidth(width()); 0080 setMaximumHeight(document.size().height()); 0081 } 0082 }; 0083 0084 #endif