File indexing completed on 2024-04-28 11:36:33
0001 /* This file is part of the KDE libraries 0002 Copyright (C) 1997 Mark Donohoe (donohoe@kde.org) 0003 Copyright (C) 1997, 1998 1998 Sven Radej (sven@lisa.exp.univie.ac.at) 0004 Copyright (C) 2007 Aron Boström (aron.bostrom@gmail.com) 0005 0006 This library is free software; you can redistribute it and/or 0007 modify it under the terms of the GNU Library General Public 0008 License as published by the Free Software Foundation; either 0009 version 2 of the License, or (at your option) any later version. 0010 0011 This library is distributed in the hope that it will be useful, 0012 but WITHOUT ANY WARRANTY; without even the implied warranty of 0013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0014 Library General Public License for more details. 0015 0016 You should have received a copy of the GNU Library General Public License 0017 along with this library; see the file COPYING.LIB. If not, write to 0018 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0019 Boston, MA 02110-1301, USA. 0020 */ 0021 0022 #ifndef KSTATUSBAR_H 0023 #define KSTATUSBAR_H 0024 0025 #include <kdelibs4support_export.h> 0026 #include <QStatusBar> 0027 0028 class QObject; 0029 class QEvent; 0030 class KStatusBarPrivate; 0031 0032 /** 0033 * @short %KDE statusbar widget 0034 * 0035 * Display status messages. 0036 * 0037 * You can insert text labels or custom widgets. Their geometry is managed 0038 * internally. KStatusBar resizes itself, but positioning is left to 0039 * KMainWindow (or to you, if you don't use KMainWindow ). 0040 * 0041 * A special type of item is a message which is a temporary text-message 0042 * displayed on top of other items in full-width. Messages are visible for 0043 * specified time, or until you call the slot QStatusBar::clearMessage(). See 0044 * QStatusBar::showMessage for details. 0045 * 0046 * It is useful to connect the KActionCollection signals to the 0047 * QStatusBar::showMessage slots. 0048 * 0049 * KStatusBar inherits QStatusBar, you can freely use all QStatusBar 0050 * methods. 0051 * 0052 * Empty text items are not visible. They will become visible when you change 0053 * (add) text. 0054 * 0055 * @author Mark Donohoe <donohoe@kde.org> and Sven Radej <radej@kde.org> 0056 0057 * @see KActionCollection 0058 */ 0059 class KDELIBS4SUPPORT_DEPRECATED_EXPORT KStatusBar : public QStatusBar 0060 { 0061 Q_OBJECT 0062 0063 public: 0064 /** 0065 * Constructs a status bar. @p parent is usually KMainWindow. 0066 */ 0067 KDELIBS4SUPPORT_DEPRECATED explicit KStatusBar(QWidget *parent = nullptr); 0068 0069 /** 0070 * Destructor. 0071 * 0072 * Deletes all internal objects. 0073 */ 0074 ~KStatusBar() override; 0075 0076 /** 0077 * Inserts a temporary text label into the status bar. 0078 * Parameter @p stretch is passed to QStatusBar::addWidget . 0079 * 0080 * @param text The label's text string. 0081 * @param id id of item 0082 * @param stretch stretch passed to QStatusBar::addWidget 0083 * 0084 * @see QStatusbar::addWidget 0085 * 0086 */ 0087 void insertItem(const QString &text, int id, int stretch = 0); 0088 0089 /** 0090 * Inserts a permanent text label into the status bar. 0091 * Parameter @p stretch is passed to QStatusBar::addWidget . 0092 * 0093 * @param text The label's text string. 0094 * @param id id of item 0095 * @param stretch stretch passed to QStatusBar::addPermanentWidget 0096 * 0097 * @see QStatusbar::addPermanentWidget 0098 * 0099 */ 0100 void insertPermanentItem(const QString &text, int id, int stretch = 0); 0101 0102 /** 0103 * Inserts a fixed width temporary text label into status bar. The width 0104 * will be set according to @p text, but will remain fixed even if you 0105 * change text. You can change fixed width by calling setItemFixed. 0106 * 0107 * @param text The label's text string 0108 * @param id id of item 0109 */ 0110 void insertFixedItem(const QString &text, int id); 0111 0112 /** 0113 * Inserts a fixed width permanent text label into status bar. The width 0114 * will be set according to @p text, but will remain fixed even if you 0115 * change text. You can change fixed width by calling setItemFixed. 0116 * 0117 * @param text The label's text string 0118 * @param id id of item 0119 */ 0120 void insertPermanentFixedItem(const QString &text, int id); 0121 0122 /** 0123 * Removes an item. 0124 * 0125 * @param id The item to remove. 0126 */ 0127 void removeItem(int id); 0128 0129 /** 0130 * Returns true if an item with @p id exists already in KStatusBar, 0131 * otherwise returns false. 0132 * 0133 * @param id id of the item 0134 */ 0135 bool hasItem(int id) const; 0136 0137 /** 0138 * The text of an item, if it exists. 0139 */ 0140 QString itemText(int id) const; 0141 0142 /** 0143 * Changes the text in a status bar field. 0144 * 0145 * The item will be resized to fit the text. If you change text to be empty, 0146 * item will not be visible (until you add some text). 0147 * 0148 * @param text The label's text string 0149 * @param id The id of item. 0150 */ 0151 void changeItem(const QString &text, int id); 0152 0153 /** 0154 * Sets the alignment of item @p id. By default all fields are aligned 0155 * @p AlignHCenter | @p AlignVCenter. See QLabel::setAlignment for details. 0156 * 0157 */ 0158 void setItemAlignment(int id, Qt::Alignment alignment); 0159 0160 /** 0161 * Sets item @p id to have fixed width. This cannot be undone, but you can 0162 * always set new fixed width. 0163 * 0164 * @param id id of item 0165 * @param width fixed width in pixels. Default -1 is to adapt to text width. 0166 */ 0167 void setItemFixed(int id, int width = -1); 0168 0169 Q_SIGNALS: 0170 0171 /** 0172 * Emitted when mouse is pressed over item @p id. 0173 * 0174 * Connect to this signal if you want to respond to mouse press events. 0175 * 0176 */ 0177 void pressed(int); 0178 0179 /** 0180 * Emitted when mouse is released over item @p id. 0181 * 0182 * Connect to this signal if you want to respond to mouse release events (clicks). 0183 */ 0184 void released(int); 0185 0186 protected: 0187 bool eventFilter(QObject *object, QEvent *event) override; 0188 0189 private: 0190 KStatusBarPrivate *const d; 0191 }; 0192 0193 #endif // KSTATUSBAR_H 0194