DolphinQt: Add the ability to show a tooltip for custom graphics controls

This commit is contained in:
iwubcode 2020-10-17 00:05:43 -05:00
parent af0161cafd
commit a9271aa167
9 changed files with 19 additions and 17 deletions

View File

@ -3,6 +3,7 @@
// Refer to the license.txt file included. // Refer to the license.txt file included.
#include "DolphinQt/Config/Graphics/GraphicsBool.h" #include "DolphinQt/Config/Graphics/GraphicsBool.h"
#include "DolphinQt/Config/Graphics/BalloonTip.h"
#include <QSignalBlocker> #include <QSignalBlocker>
@ -10,10 +11,11 @@
#include "DolphinQt/Settings.h" #include "DolphinQt/Settings.h"
#include <QEvent>
#include <QFont> #include <QFont>
GraphicsBool::GraphicsBool(const QString& label, const Config::Info<bool>& setting, bool reverse) GraphicsBool::GraphicsBool(const QString& label, const Config::Info<bool>& setting, bool reverse)
: QCheckBox(label), m_setting(setting), m_reverse(reverse) : ToolTipCheckBox(label), m_setting(setting), m_reverse(reverse)
{ {
connect(this, &QCheckBox::toggled, this, &GraphicsBool::Update); connect(this, &QCheckBox::toggled, this, &GraphicsBool::Update);
setChecked(Config::Get(m_setting) ^ reverse); setChecked(Config::Get(m_setting) ^ reverse);
@ -35,7 +37,7 @@ void GraphicsBool::Update()
GraphicsBoolEx::GraphicsBoolEx(const QString& label, const Config::Info<bool>& setting, GraphicsBoolEx::GraphicsBoolEx(const QString& label, const Config::Info<bool>& setting,
bool reverse) bool reverse)
: QRadioButton(label), m_setting(setting), m_reverse(reverse) : ToolTipRadioButton(label), m_setting(setting), m_reverse(reverse)
{ {
connect(this, &QCheckBox::toggled, this, &GraphicsBoolEx::Update); connect(this, &QCheckBox::toggled, this, &GraphicsBoolEx::Update);
setChecked(Config::Get(m_setting) ^ reverse); setChecked(Config::Get(m_setting) ^ reverse);

View File

@ -4,8 +4,8 @@
#pragma once #pragma once
#include <QCheckBox> #include "DolphinQt/Config/ToolTipControls/ToolTipCheckBox.h"
#include <QRadioButton> #include "DolphinQt/Config/ToolTipControls/ToolTipRadioButton.h"
namespace Config namespace Config
{ {
@ -13,7 +13,7 @@ template <typename T>
struct Info; struct Info;
} }
class GraphicsBool : public QCheckBox class GraphicsBool : public ToolTipCheckBox
{ {
Q_OBJECT Q_OBJECT
public: public:
@ -26,7 +26,7 @@ private:
bool m_reverse; bool m_reverse;
}; };
class GraphicsBoolEx : public QRadioButton class GraphicsBoolEx : public ToolTipRadioButton
{ {
Q_OBJECT Q_OBJECT
public: public:

View File

@ -4,11 +4,11 @@
#pragma once #pragma once
#include <QComboBox> #include "DolphinQt/Config/ToolTipControls/ToolTipComboBox.h"
#include "Common/Config/Config.h" #include "Common/Config/Config.h"
class GraphicsChoice : public QComboBox class GraphicsChoice : public ToolTipComboBox
{ {
Q_OBJECT Q_OBJECT
public: public:

View File

@ -12,7 +12,7 @@
GraphicsInteger::GraphicsInteger(int minimum, int maximum, const Config::Info<int>& setting, GraphicsInteger::GraphicsInteger(int minimum, int maximum, const Config::Info<int>& setting,
int step) int step)
: QSpinBox(), m_setting(setting) : ToolTipSpinBox(), m_setting(setting)
{ {
setMinimum(minimum); setMinimum(minimum);
setMaximum(maximum); setMaximum(maximum);

View File

@ -4,7 +4,7 @@
#pragma once #pragma once
#include <QSpinBox> #include "DolphinQt/Config/ToolTipControls/ToolTipSpinBox.h"
namespace Config namespace Config
{ {
@ -12,7 +12,7 @@ template <typename T>
struct Info; struct Info;
} }
class GraphicsInteger : public QSpinBox class GraphicsInteger : public ToolTipSpinBox
{ {
Q_OBJECT Q_OBJECT
public: public:

View File

@ -12,7 +12,7 @@
GraphicsRadioInt::GraphicsRadioInt(const QString& label, const Config::Info<int>& setting, GraphicsRadioInt::GraphicsRadioInt(const QString& label, const Config::Info<int>& setting,
int value) int value)
: QRadioButton(label), m_setting(setting), m_value(value) : ToolTipRadioButton(label), m_setting(setting), m_value(value)
{ {
setChecked(Config::Get(m_setting) == m_value); setChecked(Config::Get(m_setting) == m_value);
connect(this, &QRadioButton::toggled, this, &GraphicsRadioInt::Update); connect(this, &QRadioButton::toggled, this, &GraphicsRadioInt::Update);

View File

@ -4,11 +4,11 @@
#pragma once #pragma once
#include <QRadioButton> #include "DolphinQt/Config/ToolTipControls/ToolTipRadioButton.h"
#include "Common/Config/Config.h" #include "Common/Config/Config.h"
class GraphicsRadioInt : public QRadioButton class GraphicsRadioInt : public ToolTipRadioButton
{ {
Q_OBJECT Q_OBJECT
public: public:

View File

@ -11,7 +11,7 @@
#include "DolphinQt/Settings.h" #include "DolphinQt/Settings.h"
GraphicsSlider::GraphicsSlider(int minimum, int maximum, const Config::Info<int>& setting, int tick) GraphicsSlider::GraphicsSlider(int minimum, int maximum, const Config::Info<int>& setting, int tick)
: QSlider(Qt::Horizontal), m_setting(setting) : ToolTipSlider(Qt::Horizontal), m_setting(setting)
{ {
setMinimum(minimum); setMinimum(minimum);
setMaximum(maximum); setMaximum(maximum);

View File

@ -4,7 +4,7 @@
#pragma once #pragma once
#include <QSlider> #include "DolphinQt/Config/ToolTipControls/ToolTipSlider.h"
namespace Config namespace Config
{ {
@ -12,7 +12,7 @@ template <typename T>
struct Info; struct Info;
} }
class GraphicsSlider : public QSlider class GraphicsSlider : public ToolTipSlider
{ {
Q_OBJECT Q_OBJECT
public: public: