diff --git a/Source/Core/DolphinQt/CMakeLists.txt b/Source/Core/DolphinQt/CMakeLists.txt index 73811e4839..e0d21f0754 100644 --- a/Source/Core/DolphinQt/CMakeLists.txt +++ b/Source/Core/DolphinQt/CMakeLists.txt @@ -171,6 +171,17 @@ add_executable(dolphin-emu Config/PropertiesDialog.h Config/SettingsWindow.cpp Config/SettingsWindow.h + Config/ToolTipControls/ToolTipCheckBox.cpp + Config/ToolTipControls/ToolTipCheckBox.h + Config/ToolTipControls/ToolTipComboBox.cpp + Config/ToolTipControls/ToolTipComboBox.h + Config/ToolTipControls/ToolTipRadioButton.cpp + Config/ToolTipControls/ToolTipRadioButton.h + Config/ToolTipControls/ToolTipSlider.cpp + Config/ToolTipControls/ToolTipSlider.h + Config/ToolTipControls/ToolTipSpinBox.cpp + Config/ToolTipControls/ToolTipSpinBox.h + Config/ToolTipControls/ToolTipWidget.h Config/VerifyWidget.cpp Config/VerifyWidget.h Debugger/BreakpointWidget.cpp diff --git a/Source/Core/DolphinQt/Config/ToolTipControls/ToolTipCheckBox.cpp b/Source/Core/DolphinQt/Config/ToolTipControls/ToolTipCheckBox.cpp new file mode 100644 index 0000000000..0a6a3769ff --- /dev/null +++ b/Source/Core/DolphinQt/Config/ToolTipControls/ToolTipCheckBox.cpp @@ -0,0 +1,27 @@ +// Copyright 2020 Dolphin Emulator Project +// Licensed under GPLv2+ +// Refer to the license.txt file included. + +#include "DolphinQt/Config/ToolTipControls/ToolTipCheckBox.h" + +#include +#include + +ToolTipCheckBox::ToolTipCheckBox(const QString& label) : ToolTipWidget(label) +{ + SetTitle(label); +} + +QPoint ToolTipCheckBox::GetToolTipPosition() const +{ + int checkbox_width = 18; + if (style()) + { + QStyleOptionButton opt; + initStyleOption(&opt); + checkbox_width = + style()->subElementRect(QStyle::SubElement::SE_CheckBoxIndicator, &opt, this).width(); + } + + return pos() + QPoint(checkbox_width / 2, height() / 2); +} diff --git a/Source/Core/DolphinQt/Config/ToolTipControls/ToolTipCheckBox.h b/Source/Core/DolphinQt/Config/ToolTipControls/ToolTipCheckBox.h new file mode 100644 index 0000000000..88f840b3d9 --- /dev/null +++ b/Source/Core/DolphinQt/Config/ToolTipControls/ToolTipCheckBox.h @@ -0,0 +1,18 @@ +// Copyright 2020 Dolphin Emulator Project +// Licensed under GPLv2+ +// Refer to the license.txt file included. + +#pragma once + +#include "DolphinQt/Config/ToolTipControls/ToolTipWidget.h" + +#include + +class ToolTipCheckBox : public ToolTipWidget +{ +public: + explicit ToolTipCheckBox(const QString& label); + +private: + QPoint GetToolTipPosition() const override; +}; diff --git a/Source/Core/DolphinQt/Config/ToolTipControls/ToolTipComboBox.cpp b/Source/Core/DolphinQt/Config/ToolTipControls/ToolTipComboBox.cpp new file mode 100644 index 0000000000..cbf267197c --- /dev/null +++ b/Source/Core/DolphinQt/Config/ToolTipControls/ToolTipComboBox.cpp @@ -0,0 +1,10 @@ +// Copyright 2020 Dolphin Emulator Project +// Licensed under GPLv2+ +// Refer to the license.txt file included. + +#include "DolphinQt/Config/ToolTipControls/ToolTipComboBox.h" + +QPoint ToolTipComboBox::GetToolTipPosition() const +{ + return pos() + QPoint(width() / 2, height() / 2); +} diff --git a/Source/Core/DolphinQt/Config/ToolTipControls/ToolTipComboBox.h b/Source/Core/DolphinQt/Config/ToolTipControls/ToolTipComboBox.h new file mode 100644 index 0000000000..e8fb586514 --- /dev/null +++ b/Source/Core/DolphinQt/Config/ToolTipControls/ToolTipComboBox.h @@ -0,0 +1,15 @@ +// Copyright 2020 Dolphin Emulator Project +// Licensed under GPLv2+ +// Refer to the license.txt file included. + +#pragma once + +#include "DolphinQt/Config/ToolTipControls/ToolTipWidget.h" + +#include + +class ToolTipComboBox : public ToolTipWidget +{ +private: + QPoint GetToolTipPosition() const override; +}; diff --git a/Source/Core/DolphinQt/Config/ToolTipControls/ToolTipRadioButton.cpp b/Source/Core/DolphinQt/Config/ToolTipControls/ToolTipRadioButton.cpp new file mode 100644 index 0000000000..5e9f35727e --- /dev/null +++ b/Source/Core/DolphinQt/Config/ToolTipControls/ToolTipRadioButton.cpp @@ -0,0 +1,27 @@ +// Copyright 2020 Dolphin Emulator Project +// Licensed under GPLv2+ +// Refer to the license.txt file included. + +#include "DolphinQt/Config/ToolTipControls/ToolTipRadioButton.h" + +#include +#include + +ToolTipRadioButton::ToolTipRadioButton(const QString& label) : ToolTipWidget(label) +{ + SetTitle(label); +} + +QPoint ToolTipRadioButton::GetToolTipPosition() const +{ + int radio_button_width = 18; + if (style()) + { + QStyleOptionButton opt; + initStyleOption(&opt); + radio_button_width = + style()->subElementRect(QStyle::SubElement::SE_RadioButtonIndicator, &opt, this).width(); + } + + return pos() + QPoint(radio_button_width / 2, height() / 2); +} diff --git a/Source/Core/DolphinQt/Config/ToolTipControls/ToolTipRadioButton.h b/Source/Core/DolphinQt/Config/ToolTipControls/ToolTipRadioButton.h new file mode 100644 index 0000000000..5c9cbf9e16 --- /dev/null +++ b/Source/Core/DolphinQt/Config/ToolTipControls/ToolTipRadioButton.h @@ -0,0 +1,18 @@ +// Copyright 2020 Dolphin Emulator Project +// Licensed under GPLv2+ +// Refer to the license.txt file included. + +#pragma once + +#include "DolphinQt/Config/ToolTipControls/ToolTipWidget.h" + +#include + +class ToolTipRadioButton : public ToolTipWidget +{ +public: + explicit ToolTipRadioButton(const QString& label); + +private: + QPoint GetToolTipPosition() const override; +}; diff --git a/Source/Core/DolphinQt/Config/ToolTipControls/ToolTipSlider.cpp b/Source/Core/DolphinQt/Config/ToolTipControls/ToolTipSlider.cpp new file mode 100644 index 0000000000..304ce30a38 --- /dev/null +++ b/Source/Core/DolphinQt/Config/ToolTipControls/ToolTipSlider.cpp @@ -0,0 +1,26 @@ +// Copyright 2020 Dolphin Emulator Project +// Licensed under GPLv2+ +// Refer to the license.txt file included. + +#include "DolphinQt/Config/ToolTipControls/ToolTipSlider.h" + +#include +#include + +ToolTipSlider::ToolTipSlider(Qt::Orientation orientation) : ToolTipWidget(orientation) +{ +} + +QPoint ToolTipSlider::GetToolTipPosition() const +{ + QRect handle_rect(0, 0, 15, 15); + if (style()) + { + QStyleOptionSlider opt; + initStyleOption(&opt); + handle_rect = style()->subControlRect(QStyle::ComplexControl::CC_Slider, &opt, + QStyle::SubControl::SC_SliderHandle, this); + } + + return pos() + handle_rect.center(); +} diff --git a/Source/Core/DolphinQt/Config/ToolTipControls/ToolTipSlider.h b/Source/Core/DolphinQt/Config/ToolTipControls/ToolTipSlider.h new file mode 100644 index 0000000000..0c21fd644e --- /dev/null +++ b/Source/Core/DolphinQt/Config/ToolTipControls/ToolTipSlider.h @@ -0,0 +1,18 @@ +// Copyright 2020 Dolphin Emulator Project +// Licensed under GPLv2+ +// Refer to the license.txt file included. + +#pragma once + +#include "DolphinQt/Config/ToolTipControls/ToolTipWidget.h" + +#include + +class ToolTipSlider : public ToolTipWidget +{ +public: + explicit ToolTipSlider(Qt::Orientation orientation); + +private: + QPoint GetToolTipPosition() const override; +}; diff --git a/Source/Core/DolphinQt/Config/ToolTipControls/ToolTipSpinBox.cpp b/Source/Core/DolphinQt/Config/ToolTipControls/ToolTipSpinBox.cpp new file mode 100644 index 0000000000..d00c588845 --- /dev/null +++ b/Source/Core/DolphinQt/Config/ToolTipControls/ToolTipSpinBox.cpp @@ -0,0 +1,10 @@ +// Copyright 2020 Dolphin Emulator Project +// Licensed under GPLv2+ +// Refer to the license.txt file included. + +#include "DolphinQt/Config/ToolTipControls/ToolTipSpinBox.h" + +QPoint ToolTipSpinBox::GetToolTipPosition() const +{ + return pos() + QPoint(width() / 2, height() / 2); +} diff --git a/Source/Core/DolphinQt/Config/ToolTipControls/ToolTipSpinBox.h b/Source/Core/DolphinQt/Config/ToolTipControls/ToolTipSpinBox.h new file mode 100644 index 0000000000..296e627138 --- /dev/null +++ b/Source/Core/DolphinQt/Config/ToolTipControls/ToolTipSpinBox.h @@ -0,0 +1,15 @@ +// Copyright 2020 Dolphin Emulator Project +// Licensed under GPLv2+ +// Refer to the license.txt file included. + +#pragma once + +#include "DolphinQt/Config/ToolTipControls/ToolTipWidget.h" + +#include + +class ToolTipSpinBox : public ToolTipWidget +{ +private: + QPoint GetToolTipPosition() const override; +}; diff --git a/Source/Core/DolphinQt/Config/ToolTipControls/ToolTipWidget.h b/Source/Core/DolphinQt/Config/ToolTipControls/ToolTipWidget.h new file mode 100644 index 0000000000..8b5ffe5518 --- /dev/null +++ b/Source/Core/DolphinQt/Config/ToolTipControls/ToolTipWidget.h @@ -0,0 +1,55 @@ +// Copyright 2020 Dolphin Emulator Project +// Licensed under GPLv2+ +// Refer to the license.txt file included. + +#pragma once + +#include + +#include + +#include "DolphinQt/Config/Graphics/BalloonTip.h" + +template +class ToolTipWidget : public Derived +{ +public: + using Derived::Derived; + + void SetTitle(QString title) { m_title = std::move(title); } + + void SetDescription(QString description) { m_description = std::move(description); } + +private: + void enterEvent(QEvent* event) override + { + if (m_timer_id) + return; + m_timer_id = this->startTimer(300); + } + + void leaveEvent(QEvent* event) override + { + if (m_timer_id) + { + this->killTimer(*m_timer_id); + m_timer_id.reset(); + } + BalloonTip::HideBalloon(); + } + + void timerEvent(QTimerEvent* event) override + { + this->killTimer(*m_timer_id); + m_timer_id.reset(); + + BalloonTip::ShowBalloon(QIcon(), m_title, m_description, + this->parentWidget()->mapToGlobal(GetToolTipPosition()), this); + } + + virtual QPoint GetToolTipPosition() const = 0; + + std::optional m_timer_id; + QString m_title; + QString m_description; +}; diff --git a/Source/Core/DolphinQt/DolphinQt.vcxproj b/Source/Core/DolphinQt/DolphinQt.vcxproj index 45d95b552e..de63050059 100644 --- a/Source/Core/DolphinQt/DolphinQt.vcxproj +++ b/Source/Core/DolphinQt/DolphinQt.vcxproj @@ -105,6 +105,11 @@ + + + + + @@ -263,6 +268,12 @@ + + + + + +