Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Key Colors for the Key text in the decks #13608

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 19 additions & 5 deletions src/widget/wkey.cpp
Original file line number Diff line number Diff line change
@@ -1,18 +1,25 @@
#include "widget/wkey.h"

#include <qboxlayout.h>
#include <qevent.h>
Comment on lines +3 to +4
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not

Suggested change
#include <qboxlayout.h>
#include <qevent.h>
#include <QBoxlayout>
#include <QEvent>

like elsewhere?


#include "library/library_prefs.h"
#include "moc_wkey.cpp"
#include "skin/legacy/skincontext.h"
#include "track/keyutils.h"
#include "util/color/color.h"
#include "widget/wlabel.h"
#include "widget/wwidgetgroup.h"

WKey::WKey(const QString& group, QWidget* pParent)
: WLabel(pParent),
: WWidgetGroup(pParent),
m_dOldValue(0),
m_keyNotation(mixxx::library::prefs::kKeyNotationConfigKey, this),
m_engineKeyDistance(group,
"visual_key_distance",
this,
ControlFlag::AllowMissingOrInvalid) {
ControlFlag::AllowMissingOrInvalid),
m_keyLabel() {
setValue(m_dOldValue);
m_keyNotation.connectValueChanged(this, &WKey::keyNotationChanged);
m_engineKeyDistance.connectValueChanged(this, &WKey::setCents);
Expand All @@ -26,7 +33,8 @@
}

void WKey::setup(const QDomNode& node, const SkinContext& context) {
WLabel::setup(node, context);
WWidgetGroup::setup(node, context);
m_keyLabel.setup(node, context);
m_displayCents = context.selectBool(node, "DisplayCents", false);
m_displayKey = context.selectBool(node, "DisplayKey", true);
}
Expand All @@ -52,9 +60,15 @@
}
keyStr.append(QString(" %1%2c").arg(sign).arg(qAbs(cents_to_display)));
}
setText(keyStr);
m_keyLabel.setText(keyStr);

QColor keyColor = KeyUtils::keyToColor(key);

Check failure on line 65 in src/widget/wkey.cpp

View workflow job for this annotation

GitHub Actions / clazy

too few arguments to function call, expected 2, have 1

Check failure on line 65 in src/widget/wkey.cpp

View workflow job for this annotation

GitHub Actions / coverage

no matching function for call to ‘KeyUtils::keyToColor(mixxx::track::io::key::ChromaticKey&)’
QString colorStr = keyColor.name();
QString textColor = Color::chooseContrastColor(keyColor, 140).name();
m_keyLabel.setStyleSheet(QString("QLabel { background-color : %1; color : %2 }")
.arg(colorStr, textColor));
} else {
setText("");
m_keyLabel.setText("");
}
}

Expand Down
8 changes: 6 additions & 2 deletions src/widget/wkey.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
#pragma once

#include "widget/wlabel.h"
#include <qboxlayout.h>

#include "control/controlproxy.h"
#include "widget/wlabel.h"
#include "widget/wwidgetgroup.h"

class WKey : public WLabel {
class WKey : public WWidgetGroup {
Q_OBJECT
public:
explicit WKey(const QString& group, QWidget* pParent = nullptr);
Expand All @@ -22,4 +25,5 @@ class WKey : public WLabel {
bool m_displayKey;
ControlProxy m_keyNotation;
ControlProxy m_engineKeyDistance;
WLabel m_keyLabel;
};
Loading