mirror of
https://github.com/transmission/transmission
synced 2024-12-31 20:16:57 +00:00
3e072f9bd4
* (C++) Macros should not be used to define constants * (C++) Memory should not be managed manually * (C++) "void*" should not be used in typedefs, member variables, function parameters or return type * (C++) When the "Rule-of-Zero" is not applicable, the "Rule-of-Five" should be followed * (C++) "switch" statements should have "default" clauses * (C++) "explicit" should be used on single-parameter constructors and conversiosn operators * (C++) Non-const global variables should not be used
60 lines
1.1 KiB
C++
60 lines
1.1 KiB
C++
/*
|
|
* 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>
|
|
|
|
#include <libtransmission/tr-macros.h>
|
|
|
|
class PathButton : public QToolButton
|
|
{
|
|
Q_OBJECT
|
|
TR_DISABLE_COPY_MOVE(PathButton)
|
|
|
|
public:
|
|
enum Mode
|
|
{
|
|
DirectoryMode,
|
|
FileMode
|
|
};
|
|
|
|
explicit PathButton(QWidget* parent = nullptr);
|
|
|
|
void setMode(Mode mode);
|
|
void setTitle(QString const& title);
|
|
void setNameFilter(QString const& name_filter);
|
|
|
|
void setPath(QString const& path);
|
|
QString const& path() const;
|
|
|
|
// QWidget
|
|
QSize sizeHint() const override;
|
|
|
|
signals:
|
|
void pathChanged(QString const& path);
|
|
|
|
protected:
|
|
// QWidget
|
|
void paintEvent(QPaintEvent* event) override;
|
|
|
|
private slots:
|
|
void onClicked() const;
|
|
void onFileSelected(QString const& path);
|
|
|
|
private:
|
|
void updateAppearance();
|
|
|
|
bool isDirMode() const;
|
|
QString effectiveTitle() const;
|
|
|
|
QString name_filter_;
|
|
QString path_;
|
|
QString title_;
|
|
Mode mode_ = DirectoryMode;
|
|
};
|