1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-01 03:21:41 +00:00
OpenMW/apps/opencs/view/widget/pushbutton.hpp
2022-10-31 21:04:01 +01:00

70 lines
1.6 KiB
C++

#ifndef CSV_WIDGET_PUSHBUTTON_H
#define CSV_WIDGET_PUSHBUTTON_H
#include <QPushButton>
class QKeyEvent;
class QMouseEvent;
class QObject;
class QWidget;
namespace CSMPrefs
{
class Setting;
}
namespace CSVWidget
{
class PushButton : public QPushButton
{
Q_OBJECT
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
};
private:
bool mKeepOpen;
Type mType;
QString mToolTip;
QString mProcessedToolTip;
private:
void processShortcuts();
void setExtendedToolTip();
protected:
void keyPressEvent(QKeyEvent* event) override;
void keyReleaseEvent(QKeyEvent* event) override;
void mouseReleaseEvent(QMouseEvent* event) override;
public:
/// \param push Do not maintain a toggle state
PushButton(const QIcon& icon, Type type, const QString& tooltip = "", QWidget* parent = nullptr);
/// \param push Do not maintain a toggle state
PushButton(Type type, const QString& tooltip = "", QWidget* parent = nullptr);
bool hasKeepOpen() const;
/// Return tooltip used at construction (without any button-specific modifications)
QString getBaseToolTip() const;
Type getType() const;
private slots:
void checkedStateChanged(bool checked);
void settingChanged(const CSMPrefs::Setting* setting);
};
}
#endif