source: trunk/qt/PathButton.h @ 14539

Last change on this file since 14539 was 14539, checked in by mikedld, 6 years ago

Unify/prettify Qt client headers style

  • Property svn:keywords set to Date Rev Author Id
File size: 1.1 KB
Line 
1/*
2 * This file Copyright (C) 2014-2015 Mnemosyne LLC
3 *
4 * It may be used under the GNU GPL versions 2 or 3
5 * or any future license endorsed by Mnemosyne LLC.
6 *
7 * $Id: PathButton.h 14539 2015-06-12 22:12:12Z mikedld $
8 */
9
10#ifndef QTR_PATH_BUTTON_H
11#define QTR_PATH_BUTTON_H
12
13#include <QToolButton>
14
15class PathButton: public QToolButton
16{
17    Q_OBJECT
18
19  public:
20    enum Mode
21    {
22      DirectoryMode,
23      FileMode
24    };
25
26  public:
27    PathButton (QWidget * parent = nullptr);
28
29    void setMode (Mode mode);
30    void setTitle (const QString& title);
31    void setNameFilter (const QString& nameFilter);
32
33    void setPath (const QString& path);
34    const QString& path () const;
35
36    // QWidget
37    virtual QSize sizeHint () const;
38
39  signals:
40    void pathChanged (const QString& path);
41
42  protected:
43    // QWidget
44    virtual void paintEvent (QPaintEvent * event);
45
46  private:
47    void updateAppearance ();
48
49    bool isDirMode () const;
50    QString effectiveTitle () const;
51
52  private slots:
53    void onClicked ();
54    void onFileSelected (const QString& path);
55
56  private:
57    Mode myMode;
58    QString myTitle;
59    QString myNameFilter;
60    QString myPath;
61};
62
63#endif // QTR_PATH_BUTTON_H
Note: See TracBrowser for help on using the repository browser.