mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-06-15 06:58:37 +02:00
Merge pull request #6362 from spycrab/qt_indicators
Qt/Mapping: Implement indicators
This commit is contained in:
@ -7,6 +7,9 @@
|
||||
#include <QMouseEvent>
|
||||
#include <QRegExp>
|
||||
#include <QString>
|
||||
#include <QTimer>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include "DolphinQt2/Config/Mapping/MappingButton.h"
|
||||
|
||||
@ -16,6 +19,7 @@
|
||||
#include "DolphinQt2/Config/Mapping/MappingWidget.h"
|
||||
#include "DolphinQt2/Config/Mapping/MappingWindow.h"
|
||||
#include "DolphinQt2/QtUtils/BlockUserInputFilter.h"
|
||||
#include "DolphinQt2/Settings.h"
|
||||
#include "InputCommon/ControlReference/ControlReference.h"
|
||||
#include "InputCommon/ControllerEmu/ControllerEmu.h"
|
||||
#include "InputCommon/ControllerInterface/ControllerInterface.h"
|
||||
@ -26,11 +30,41 @@ static QString EscapeAmpersand(QString&& string)
|
||||
return string.replace(QStringLiteral("&"), QStringLiteral("&&"));
|
||||
}
|
||||
|
||||
MappingButton::MappingButton(MappingWidget* widget, ControlReference* ref)
|
||||
MappingButton::MappingButton(MappingWidget* widget, ControlReference* ref, bool indicator)
|
||||
: ElidedButton(EscapeAmpersand(QString::fromStdString(ref->GetExpression()))), m_parent(widget),
|
||||
m_reference(ref)
|
||||
{
|
||||
Connect();
|
||||
setToolTip(
|
||||
tr("Left-click to detect input.\nMiddle-click to clear.\nRight-click for more options."));
|
||||
if (!m_reference->IsInput() || !indicator)
|
||||
return;
|
||||
|
||||
m_timer = new QTimer(this);
|
||||
connect(m_timer, &QTimer::timeout, this, [this] {
|
||||
if (!isActiveWindow())
|
||||
return;
|
||||
|
||||
Settings::Instance().SetControllerStateNeeded(true);
|
||||
|
||||
auto state = m_reference->State();
|
||||
|
||||
QFont f = m_parent->font();
|
||||
QPalette p = m_parent->palette();
|
||||
|
||||
if (state != 0)
|
||||
{
|
||||
f.setBold(true);
|
||||
p.setColor(QPalette::ButtonText, Qt::red);
|
||||
}
|
||||
|
||||
setFont(f);
|
||||
setPalette(p);
|
||||
|
||||
Settings::Instance().SetControllerStateNeeded(false);
|
||||
});
|
||||
|
||||
m_timer->start(1000 / 30);
|
||||
}
|
||||
|
||||
void MappingButton::Connect()
|
||||
@ -85,6 +119,7 @@ void MappingButton::Clear()
|
||||
{
|
||||
m_reference->SetExpression("");
|
||||
m_parent->SaveSettings();
|
||||
Update();
|
||||
}
|
||||
|
||||
void MappingButton::Update()
|
||||
@ -105,7 +140,7 @@ void MappingButton::mouseReleaseEvent(QMouseEvent* event)
|
||||
else
|
||||
emit AdvancedPressed();
|
||||
return;
|
||||
case Qt::MouseButton::MiddleButton:
|
||||
case Qt::MouseButton::MidButton:
|
||||
Clear();
|
||||
return;
|
||||
case Qt::MouseButton::RightButton:
|
||||
|
Reference in New Issue
Block a user