Skip to content

Commit

Permalink
fixup! refactor: move unique_ptr::get() to improve usability
Browse files Browse the repository at this point in the history
  • Loading branch information
Swiftb0y committed Nov 13, 2024
1 parent 2c78d23 commit abf5fe6
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 17 deletions.
6 changes: 4 additions & 2 deletions src/test/wpushbutton_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "control/controlpushbutton.h"
#include "util/valuetransformer.h"
#include "widget/controlwidgetconnection.h"
#include "widget/wbasewidget.h"

class WPushButtonTest : public ::testing::Test {
public:
Expand All @@ -22,13 +23,14 @@ class WPushButtonTest : public ::testing::Test {
WPushButtonTest() {
pushControl.setButtonMode(mixxx::control::ButtonMode::LongPressLatching);
pushButton.setStates(2);
pushButton.addLeftConnection(
pushButton.addConnection(
std::make_unique<ControlParameterWidgetConnection>(
&pushButton,
pushControl.getKey(),
nullptr,
ControlParameterWidgetConnection::DIR_FROM_AND_TO_WIDGET,
ControlParameterWidgetConnection::EMIT_ON_PRESS_AND_RELEASE));
ControlParameterWidgetConnection::EMIT_ON_PRESS_AND_RELEASE),
WBaseWidget::ConnectionSide::Left);
}
};

Expand Down
31 changes: 16 additions & 15 deletions src/widget/whotcuebutton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "track/track.h"
#include "util/valuetransformer.h"
#include "widget/controlwidgetconnection.h"
#include "widget/wbasewidget.h"

namespace {
constexpr int kDefaultDimBrightThreshold = 127;
Expand Down Expand Up @@ -69,21 +70,21 @@ void WHotcueButton::setup(const QDomNode& node, const SkinContext& context) {
m_pCoType->connectValueChanged(this, &WHotcueButton::slotTypeChanged);
slotTypeChanged(m_pCoType->get());

addLeftConnection(std::make_unique<ControlParameterWidgetConnection>(
this,
getLeftClickConfigKey(), // "activate"
nullptr,
ControlParameterWidgetConnection::DIR_FROM_WIDGET,
ControlParameterWidgetConnection::EMIT_ON_PRESS_AND_RELEASE));

auto pDisplayConnection = std::make_unique<ControlParameterWidgetConnection>(
this,
createConfigKey(QStringLiteral("status")),
nullptr,
ControlParameterWidgetConnection::DIR_TO_WIDGET,
ControlParameterWidgetConnection::EMIT_NEVER);
setDisplayConnection(pDisplayConnection.get());
addConnection(std::move(pDisplayConnection));
addConnection(std::make_unique<ControlParameterWidgetConnection>(
this,
getLeftClickConfigKey(), // "activate"
nullptr,
ControlParameterWidgetConnection::DIR_FROM_WIDGET,
ControlParameterWidgetConnection::EMIT_ON_PRESS_AND_RELEASE),
WBaseWidget::ConnectionSide::Left);

setDisplayConnection(std::make_unique<ControlParameterWidgetConnection>(
this,
createConfigKey(QStringLiteral("status")),
nullptr,
ControlParameterWidgetConnection::DIR_TO_WIDGET,
ControlParameterWidgetConnection::EMIT_NEVER),
WBaseWidget::ConnectionSide::None);

QDomNode con = context.selectNode(node, QStringLiteral("Connection"));
if (!con.isNull()) {
Expand Down

0 comments on commit abf5fe6

Please sign in to comment.