forked from transmission/transmission
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPathButton.h
59 lines (45 loc) · 1.02 KB
/
PathButton.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/*
* This file Copyright (C) 2014-2015 Mnemosyne LLC
*
* It may be used under the GNU GPL versions 2 or 3
* or any future license endorsed by Mnemosyne LLC.
*
*/
#pragma once
#include <QToolButton>
class PathButton : public QToolButton
{
Q_OBJECT
public:
enum Mode
{
DirectoryMode,
FileMode
};
public:
PathButton(QWidget* parent = nullptr);
void setMode(Mode mode);
void setTitle(QString const& title);
void setNameFilter(QString const& nameFilter);
void setPath(QString const& path);
QString const& path() const;
// QWidget
virtual QSize sizeHint() const;
signals:
void pathChanged(QString const& path);
protected:
// QWidget
virtual void paintEvent(QPaintEvent* event);
private:
void updateAppearance();
bool isDirMode() const;
QString effectiveTitle() const;
private slots:
void onClicked();
void onFileSelected(QString const& path);
private:
Mode myMode;
QString myTitle;
QString myNameFilter;
QString myPath;
};