PCManFM-Qt
statusbar.h
1 /*
2  This program is free software; you can redistribute it and/or modify
3  it under the terms of the GNU General Public License as published by
4  the Free Software Foundation; either version 2 of the License, or
5  (at your option) any later version.
6 
7  This program is distributed in the hope that it will be useful,
8  but WITHOUT ANY WARRANTY; without even the implied warranty of
9  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  GNU General Public License for more details.
11 
12  You should have received a copy of the GNU General Public License along
13  with this program; if not, write to the Free Software Foundation, Inc.,
14  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
15 */
16 
17 #ifndef FM_STATUSBAR_H
18 #define FM_STATUSBAR_H
19 
20 #include <QStatusBar>
21 #include <QLabel>
22 #include <QTimer>
23 
24 namespace PCManFM {
25 
26 class Label : public QLabel {
27 Q_OBJECT
28 
29 public:
30  explicit Label(QWidget *parent = 0, Qt::WindowFlags f = Qt::WindowFlags());
31 
32 protected:
33  void paintEvent(QPaintEvent *event) override;
34 
35 private:
36  QString elidedText_;
37  QString lastText_;
38  int lastWidth_;
39 };
40 
41 class StatusBar : public QStatusBar {
42 Q_OBJECT
43 
44 public:
45  explicit StatusBar(QWidget *parent = 0);
46  ~StatusBar();
47 
48 public Q_SLOTS:
49  void showMessage(const QString &message, int timeout = 0);
50 
51 protected Q_SLOTS:
52  void reallyShowMessage();
53 
54 private:
55  Label* statusLabel_; // for a stable (elided) text
56  QTimer* messageTimer_;
57  QString lastMessage_;
58  int lastTimeOut_;
59 };
60 
61 }
62 
63 #endif // FM_STATUSBAR_H
PCManFM::Label
Definition: statusbar.h:26
PCManFM::StatusBar
Definition: statusbar.h:41