Skip to content

Commit

Permalink
Merge branch 'main' into stopped-explicit
Browse files Browse the repository at this point in the history
  • Loading branch information
ywwg committed Jun 6, 2021
2 parents daba011 + edfa039 commit 7b56e59
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 36 deletions.
15 changes: 12 additions & 3 deletions src/library/basetracktablemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -618,11 +618,16 @@ QVariant BaseTrackTableModel::roleValue(
return QString("(%1)").arg(timesPlayed);
}
case ColumnCache::COLUMN_LIBRARYTABLE_DATETIMEADDED:
case ColumnCache::COLUMN_PLAYLISTTRACKSTABLE_DATETIMEADDED:
case ColumnCache::COLUMN_PLAYLISTTRACKSTABLE_DATETIMEADDED: {
VERIFY_OR_DEBUG_ASSERT(rawValue.canConvert<QDateTime>()) {
return QVariant();
}
return mixxx::localDateTimeFromUtc(rawValue.toDateTime());
QDateTime dt = mixxx::localDateTimeFromUtc(rawValue.toDateTime());
if (role == Qt::ToolTipRole || role == kDataExportRole) {
return dt;
}
return dt.date();
}
case ColumnCache::COLUMN_LIBRARYTABLE_LAST_PLAYED_AT: {
QDateTime lastPlayedAt;
if (rawValue.type() == QVariant::String) {
Expand All @@ -636,7 +641,11 @@ QVariant BaseTrackTableModel::roleValue(
return QVariant();
}
DEBUG_ASSERT(lastPlayedAt.timeSpec() == Qt::UTC);
return mixxx::localDateTimeFromUtc(lastPlayedAt);
QDateTime dt = mixxx::localDateTimeFromUtc(lastPlayedAt);
if (role == Qt::ToolTipRole || role == kDataExportRole) {
return dt;
}
return dt.date();
}
case ColumnCache::COLUMN_LIBRARYTABLE_BPM: {
mixxx::Bpm bpm;
Expand Down
30 changes: 12 additions & 18 deletions src/preferences/dialog/dlgprefinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,7 @@ DlgPrefInterface::DlgPrefInterface(
ComboBoxSkinconf->setCurrentIndex(index);
// schemes must be updated here to populate the drop-down box and set m_colorScheme
slotUpdateSchemes();
QPixmap preview = m_pSkin->preview(m_colorScheme);
preview.setDevicePixelRatio(m_dDevicePixelRatio);
skinPreviewLabel->setPixmap(preview.scaled(
QSize(640, 360) * m_dDevicePixelRatio,
Qt::KeepAspectRatio,
Qt::SmoothTransformation));
slotSetSkinPreview();
const auto* const pScreen = getScreen();
if (m_pSkin->fitsScreenSize(*pScreen)) {
warningLabel->hide();
Expand Down Expand Up @@ -348,12 +343,7 @@ void DlgPrefInterface::slotSetScheme(int) {
m_colorScheme = newScheme;
m_bRebootMixxxView = true;
}
QPixmap preview = m_pSkin->preview(m_colorScheme);
preview.setDevicePixelRatio(m_dDevicePixelRatio);
skinPreviewLabel->setPixmap(preview.scaled(
QSize(640, 360) * m_dDevicePixelRatio,
Qt::KeepAspectRatio,
Qt::SmoothTransformation));
slotSetSkinPreview();
}

void DlgPrefInterface::slotSetSkinDescription() {
Expand All @@ -366,6 +356,15 @@ void DlgPrefInterface::slotSetSkinDescription() {
}
}

void DlgPrefInterface::slotSetSkinPreview() {
QPixmap preview = m_pSkin->preview(m_colorScheme);
preview.setDevicePixelRatio(m_dDevicePixelRatio);
skinPreviewLabel->setPixmap(preview.scaled(
QSize(640, 360) * m_dDevicePixelRatio,
Qt::KeepAspectRatio,
Qt::SmoothTransformation));
}

void DlgPrefInterface::slotSetSkin(int) {
QString newSkinName = ComboBoxSkinconf->currentText();
if (newSkinName == m_pSkin->name()) {
Expand All @@ -386,12 +385,7 @@ void DlgPrefInterface::slotSetSkin(int) {
}
slotUpdateSchemes();
slotSetSkinDescription();
QPixmap preview = m_pSkin->preview(m_colorScheme);
preview.setDevicePixelRatio(m_dDevicePixelRatio);
skinPreviewLabel->setPixmap(preview.scaled(
QSize(640, 360) * m_dDevicePixelRatio,
Qt::KeepAspectRatio,
Qt::SmoothTransformation));
slotSetSkinPreview();
}

void DlgPrefInterface::slotApply() {
Expand Down
3 changes: 2 additions & 1 deletion src/preferences/dialog/dlgprefinterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,10 @@ class DlgPrefInterface : public DlgPreferencePage, public Ui::DlgPrefControlsDlg

private slots:
void slotSetTooltips();
void slotSetSkinDescription();
void slotSetSkin(int);
void slotSetScheme(int);
void slotSetSkinDescription();
void slotSetSkinPreview();
void slotUpdateSchemes();
void slotSetScaleFactor(double newValue);
void slotSetScaleFactorAuto(bool checked);
Expand Down
12 changes: 10 additions & 2 deletions src/skin/qml/qmlplayermanagerproxy.cpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
#include "skin/qml/qmlplayermanagerproxy.h"

#include <QQmlEngine>

#include "mixer/playermanager.h"
#include "skin/qml/qmlplayerproxy.h"

namespace mixxx {
namespace skin {
namespace qml {

QmlPlayerManagerProxy::QmlPlayerManagerProxy(PlayerManager* pPlayerManager, QObject* parent)
QmlPlayerManagerProxy::QmlPlayerManagerProxy(
std::shared_ptr<PlayerManager> pPlayerManager, QObject* parent)
: QObject(parent), m_pPlayerManager(pPlayerManager) {
}

Expand All @@ -17,7 +20,12 @@ QObject* QmlPlayerManagerProxy::getPlayer(const QString& group) {
qWarning() << "PlayerManagerProxy failed to find player for group" << group;
return nullptr;
}
return new QmlPlayerProxy(pPlayer, this);

// Don't set a parent here, so that the QML engine deletes the object when
// the corresponding JS object is garbage collected.
QmlPlayerProxy* pPlayerProxy = new QmlPlayerProxy(pPlayer);
QQmlEngine::setObjectOwnership(pPlayerProxy, QQmlEngine::JavaScriptOwnership);
return pPlayerProxy;
}

} // namespace qml
Expand Down
8 changes: 5 additions & 3 deletions src/skin/qml/qmlplayermanagerproxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include <QObject>
#include <QString>

class PlayerManager;
#include "mixer/playermanager.h"

namespace mixxx {
namespace skin {
Expand All @@ -11,12 +11,14 @@ namespace qml {
class QmlPlayerManagerProxy : public QObject {
Q_OBJECT
public:
explicit QmlPlayerManagerProxy(PlayerManager* pPlayerManager, QObject* parent = nullptr);
explicit QmlPlayerManagerProxy(
std::shared_ptr<PlayerManager> pPlayerManager,
QObject* parent = nullptr);

Q_INVOKABLE QObject* getPlayer(const QString& deck);

private:
const PlayerManager* m_pPlayerManager;
const std::shared_ptr<PlayerManager> m_pPlayerManager;
};

} // namespace qml
Expand Down
2 changes: 1 addition & 1 deletion src/skin/qml/qmlplayerproxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ namespace mixxx {
namespace skin {
namespace qml {

QmlPlayerProxy::QmlPlayerProxy(BaseTrackPlayer* pTrackPlayer, QObject* parent = nullptr)
QmlPlayerProxy::QmlPlayerProxy(BaseTrackPlayer* pTrackPlayer, QObject* parent)
: QObject(parent), m_pTrackPlayer(pTrackPlayer) {
connect(m_pTrackPlayer,
&BaseTrackPlayer::loadingTrack,
Expand Down
8 changes: 4 additions & 4 deletions src/skin/qml/qmlplayerproxy.h
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#include <QColor>
#include <QObject>
#include <QPointer>
#include <QString>
#include <QUrl>

#include "mixer/basetrackplayer.h"
#include "track/track.h"

class BaseTrackPlayer;

namespace mixxx {
namespace skin {
namespace qml {
Expand All @@ -31,7 +31,7 @@ class QmlPlayerProxy : public QObject {
Q_PROPERTY(QUrl coverArtUrl READ getCoverArtUrl NOTIFY coverArtUrlChanged)

public:
explicit QmlPlayerProxy(BaseTrackPlayer* pTrackPlayer, QObject* parent);
explicit QmlPlayerProxy(BaseTrackPlayer* pTrackPlayer, QObject* parent = nullptr);

QString getTrack() const;
QString getTitle() const;
Expand Down Expand Up @@ -90,7 +90,7 @@ class QmlPlayerProxy : public QObject {
void coverArtUrlChanged();

private:
BaseTrackPlayer* m_pTrackPlayer;
QPointer<BaseTrackPlayer> m_pTrackPlayer;
TrackPointer m_pCurrentTrack;
};

Expand Down
2 changes: 1 addition & 1 deletion src/skin/qml/qmlskin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ QWidget* QmlSkin::loadSkin(QWidget* pParent,

QmlPlayerManagerProxy* pPlayerManagerProxy =
new QmlPlayerManagerProxy(
pCoreServices->getPlayerManager().get(),
pCoreServices->getPlayerManager(),
pEngine);
return pPlayerManagerProxy;
}));
Expand Down
6 changes: 3 additions & 3 deletions tools/qmlformat.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
import sys

QMLFORMAT_MISSING_MESSAGE = """
qmlformat is not installed. It is included in Qt 5.15 and later. If that Qt
version is not available on your system, please use the SKIP environment
variable when committing:
qmlformat is not installed or not in your $PATH. It is included in Qt 5.15
and later. If that Qt version is not available on your system, please
use the SKIP environment variable when committing:
$ SKIP=qmlformat git commit
"""
Expand Down

0 comments on commit 7b56e59

Please sign in to comment.