1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-02-14 06:40:40 +00:00
OpenMW/apps/opencs/view/widget/pushbutton.hpp

65 lines
1.5 KiB
C++
Raw Normal View History

2014-07-10 11:03:55 +02:00
#ifndef CSV_WIDGET_PUSHBUTTON_H
#define CSV_WIDGET_PUSHBUTTON_H
#include <QPushButton>
namespace CSMPrefs
{
class Setting;
}
2014-07-10 11:03:55 +02:00
namespace CSVWidget
{
class PushButton : public QPushButton
{
2022-09-22 21:26:05 +03:00
Q_OBJECT
2014-07-10 11:03:55 +02:00
2022-09-22 21:26:05 +03:00
public:
enum Type
{
Type_TopMode, // top level button for mode selector panel
Type_TopAction, // top level button that triggers an action
Type_Mode, // mode button
Type_Toggle
};
2022-09-22 21:26:05 +03:00
private:
bool mKeepOpen;
Type mType;
QString mToolTip;
QString mProcessedToolTip;
2022-09-22 21:26:05 +03:00
private:
void processShortcuts();
void setExtendedToolTip();
2022-09-22 21:26:05 +03:00
protected:
void keyPressEvent(QKeyEvent* event) override;
2014-07-10 12:53:57 +02:00
2022-09-22 21:26:05 +03:00
void keyReleaseEvent(QKeyEvent* event) override;
2014-07-10 12:53:57 +02:00
2022-09-22 21:26:05 +03:00
void mouseReleaseEvent(QMouseEvent* event) override;
2014-07-10 11:03:55 +02:00
2022-09-22 21:26:05 +03:00
public:
/// \param push Do not maintain a toggle state
PushButton(const QIcon& icon, Type type, const QString& tooltip = "", QWidget* parent = nullptr);
2014-07-10 11:03:55 +02:00
2022-09-22 21:26:05 +03:00
/// \param push Do not maintain a toggle state
PushButton(Type type, const QString& tooltip = "", QWidget* parent = nullptr);
2014-07-10 11:03:55 +02:00
2022-09-22 21:26:05 +03:00
bool hasKeepOpen() const;
2022-09-22 21:26:05 +03:00
/// Return tooltip used at construction (without any button-specific modifications)
QString getBaseToolTip() const;
2014-07-10 11:03:55 +02:00
2022-09-22 21:26:05 +03:00
Type getType() const;
2014-07-10 11:03:55 +02:00
2022-09-22 21:26:05 +03:00
private slots:
2022-09-22 21:26:05 +03:00
void checkedStateChanged(bool checked);
void settingChanged(const CSMPrefs::Setting* setting);
2014-07-10 11:03:55 +02:00
};
}
#endif