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

WTrackProperty: double-clicked property field is focused in DlgTrackInfo #11764

Merged
merged 1 commit into from
Jul 26, 2023
Merged
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
26 changes: 26 additions & 0 deletions src/library/dlgtrackinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,22 @@ void DlgTrackInfo::init() {
setupUi(this);
setWindowIcon(QIcon(MIXXX_ICON_PATH));

// Store tag edit widget pointers to allow focusing a specific widgets when
// this is opened by double-clicking a WTrackProperty label.
// Associate with property strings taken from library/dao/trackdao.h
m_propertyWidgets.insert("artist", txtArtist);
m_propertyWidgets.insert("title", txtTrackName);
m_propertyWidgets.insert("album", txtAlbum);
m_propertyWidgets.insert("album_artist", txtAlbumArtist);
m_propertyWidgets.insert("composer", txtComposer);
m_propertyWidgets.insert("genre", txtGenre);
m_propertyWidgets.insert("year", txtYear);
m_propertyWidgets.insert("bpm", spinBpm);
m_propertyWidgets.insert("tracknumber", txtTrackNumber);
m_propertyWidgets.insert("key", txtKey);
m_propertyWidgets.insert("grouping", txtGrouping);
m_propertyWidgets.insert("comment", txtComment);

coverLayout->setAlignment(Qt::AlignRight | Qt::AlignTop);
coverLayout->setSpacing(0);
coverLayout->setContentsMargins(0, 0, 0, 0);
Expand Down Expand Up @@ -484,6 +500,16 @@ void DlgTrackInfo::loadTrack(const QModelIndex& index) {
}
}

void DlgTrackInfo::focusField(const QString& property) {
if (property.isEmpty()) {
return;
}
QWidget* w = m_propertyWidgets.find(property).value();
if (w) {
w->setFocus();
}
}

void DlgTrackInfo::slotCoverFound(
const QObject* pRequestor,
const CoverInfo& coverInfo,
Expand Down
4 changes: 4 additions & 0 deletions src/library/dlgtrackinfo.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once

#include <QDialog>
#include <QHash>
#include <QModelIndex>
#include <memory>

Expand Down Expand Up @@ -40,6 +41,7 @@ class DlgTrackInfo : public QDialog, public Ui::DlgTrackInfo {
// directly!
void loadTrack(TrackPointer pTrack);
void loadTrack(const QModelIndex& index);
void focusField(const QString& property);

signals:
void next();
Expand Down Expand Up @@ -121,6 +123,8 @@ class DlgTrackInfo : public QDialog, public Ui::DlgTrackInfo {
TapFilter m_tapFilter;
mixxx::Bpm m_lastTapedBpm;

QHash<QString, QWidget*> m_propertyWidgets;

parented_ptr<WCoverArtMenu> m_pWCoverArtMenu;
parented_ptr<WCoverArtLabel> m_pWCoverArtLabel;
parented_ptr<WStarRating> m_pWStarRating;
Expand Down
10 changes: 10 additions & 0 deletions src/widget/wtrackmenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2181,6 +2181,16 @@ void WTrackMenu::slotShowDlgTrackInfo() {
m_pDlgTrackInfo->show();
}

void WTrackMenu::showDlgTrackInfo(const QString& property) {
if (isEmpty()) {
return;
}
slotShowDlgTrackInfo();
if (m_pDlgTrackInfo->isVisible()) {
m_pDlgTrackInfo->focusField(property);
}
}

void WTrackMenu::slotShowDlgTagFetcher() {
if (isEmpty()) {
return;
Expand Down
1 change: 1 addition & 0 deletions src/widget/wtrackmenu.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ class WTrackMenu : public QMenu {
// This has been done on purpose to ensure menu doesn't popup without loaded track(s).
void popup(const QPoint& pos, QAction* at = nullptr);
void slotShowDlgTrackInfo();
void showDlgTrackInfo(const QString& property = QString());
// Library management
void slotRemoveFromDisk();

Expand Down
2 changes: 1 addition & 1 deletion src/widget/wtrackproperty.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ void WTrackProperty::mouseDoubleClickEvent(QMouseEvent* event) {
Q_UNUSED(event);
if (m_pCurrentTrack) {
m_pTrackMenu->loadTrack(m_pCurrentTrack, m_group);
m_pTrackMenu->slotShowDlgTrackInfo();
m_pTrackMenu->showDlgTrackInfo(m_property);
}
}

Expand Down