Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/2.4' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
daschuer committed Jan 20, 2024
2 parents a21e050 + b2a8ba7 commit 25c5d24
Show file tree
Hide file tree
Showing 18 changed files with 258 additions and 180 deletions.
9 changes: 0 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1951,7 +1951,6 @@ if(WIN32 AND NOT QT6)
unofficial::angle::libGLESv2
CONFIGURATIONS RelWithDebInfo Release
DESTINATION "${MIXXX_INSTALL_BINDIR}"
RUNTIME_DEPENDENCY_SET mixxx
COMPONENT applocal)
set(APPLOCAL_COMPONENT_DEFINED true)
endif()
Expand Down Expand Up @@ -2721,15 +2720,13 @@ else()
# QJpegPlugin dependency
libjpeg-turbo::jpeg
DESTINATION "${MIXXX_INSTALL_DATADIR}"
RUNTIME_DEPENDENCY_SET mixxx
COMPONENT applocal)

install(IMPORTED_RUNTIME_ARTIFACTS
# platform plugins
Qt${QT_VERSION_MAJOR}::QOffscreenIntegrationPlugin
Qt${QT_VERSION_MAJOR}::QMinimalIntegrationPlugin
DESTINATION "${MIXXX_INSTALL_DATADIR}/platforms"
RUNTIME_DEPENDENCY_SET mixxx
COMPONENT applocal)

install(IMPORTED_RUNTIME_ARTIFACTS
Expand All @@ -2738,33 +2735,27 @@ else()
Qt${QT_VERSION_MAJOR}::QJpegPlugin
Qt${QT_VERSION_MAJOR}::QSvgPlugin
DESTINATION "${MIXXX_INSTALL_DATADIR}/imageformats"
RUNTIME_DEPENDENCY_SET mixxx
COMPONENT applocal)

install(IMPORTED_RUNTIME_ARTIFACTS
Qt${QT_VERSION_MAJOR}::QSQLiteDriverPlugin
DESTINATION "${MIXXX_INSTALL_DATADIR}/sqldrivers"
RUNTIME_DEPENDENCY_SET mixxx
COMPONENT applocal)

if(WIN32)
install(IMPORTED_RUNTIME_ARTIFACTS Qt${QT_VERSION_MAJOR}::QWindowsIntegrationPlugin
DESTINATION "${MIXXX_INSTALL_DATADIR}/platforms"
RUNTIME_DEPENDENCY_SET mixxx
COMPONENT applocal)
install(IMPORTED_RUNTIME_ARTIFACTS Qt${QT_VERSION_MAJOR}::QWindowsVistaStylePlugin
DESTINATION "${MIXXX_INSTALL_DATADIR}/styles"
RUNTIME_DEPENDENCY_SET mixxx
COMPONENT applocal)
endif()
if(APPLE)
install(IMPORTED_RUNTIME_ARTIFACTS Qt${QT_VERSION_MAJOR}::QCocoaIntegrationPlugin
DESTINATION "${MIXXX_INSTALL_DATADIR}/platforms"
RUNTIME_DEPENDENCY_SET mixxx
COMPONENT applocal)
install(IMPORTED_RUNTIME_ARTIFACTS Qt${QT_VERSION_MAJOR}::QMacStylePlugin
DESTINATION "${MIXXX_INSTALL_DATADIR}/styles"
RUNTIME_DEPENDENCY_SET mixxx
COMPONENT applocal)
endif()

Expand Down
3 changes: 2 additions & 1 deletion src/dialog/dlgabout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,8 @@ DlgAbout::DlgAbout()
<< "Alexandre Bique"
<< "Milkii Brewster"
<< "djantti"
<< "Eugene Erokhin";
<< "Eugene Erokhin"
<< "Ben Duval";

QStringList specialThanks;
specialThanks
Expand Down
6 changes: 6 additions & 0 deletions src/engine/controls/loopingcontrol.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,12 @@ class LoopingControl : public EngineControl {
bool isLoopingEnabled() {
return m_bLoopingEnabled;
}
bool isAdjustLoopInActive() {
return m_bAdjustingLoopIn;
}
bool isAdjustLoopOutActive() {
return m_bAdjustingLoopOut;
}
bool isLoopRollActive() {
return m_bLoopRollActive;
}
Expand Down
4 changes: 4 additions & 0 deletions src/engine/enginebuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,8 @@ void EngineBuffer::ejectTrack() {
0.0,
SlipModeState::Disabled,
false,
false,
false,
0.0,
0.0,
0.0,
Expand Down Expand Up @@ -1438,6 +1440,8 @@ void EngineBuffer::updateIndicators(double speed, int iBufferSize) {
effectiveSlipRate,
m_slipModeState,
m_pLoopingControl->isLoopingEnabled(),
m_pLoopingControl->isAdjustLoopInActive(),
m_pLoopingControl->isAdjustLoopOutActive(),
fFractionalLoopStartPos,
fFractionalLoopEndPos,
tempoTrackSeconds,
Expand Down
17 changes: 1 addition & 16 deletions src/library/colordelegate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,6 @@ void ColorDelegate::paintItem(

// Draw a border if the color cell has focus
if (option.state & QStyle::State_HasFocus) {
// This uses a color from the stylesheet:
// WTrackTableView {
// qproperty-focusBorderColor: red;
// }
QPen borderPen(
m_pFocusBorderColor,
1,
Qt::SolidLine,
Qt::SquareCap);
painter->setPen(borderPen);
painter->setBrush(QBrush(Qt::transparent));
painter->drawRect(
option.rect.left(),
option.rect.top(),
option.rect.width() - 1,
option.rect.height() - 1);
drawBorder(painter, m_pFocusBorderColor, option.rect);
}
}
17 changes: 1 addition & 16 deletions src/library/coverartdelegate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,21 +168,6 @@ void CoverArtDelegate::paintItem(

// Draw a border if the cover art cell has focus
if (option.state & QStyle::State_HasFocus) {
// This uses a color from the stylesheet:
// WTrackTableView {
// qproperty-focusBorderColor: red;
// }
QPen borderPen(
m_pFocusBorderColor,
1,
Qt::SolidLine,
Qt::SquareCap);
painter->setPen(borderPen);
painter->setBrush(QBrush(Qt::transparent));
painter->drawRect(
option.rect.left(),
option.rect.top(),
option.rect.width() - 1,
option.rect.height() - 1);
drawBorder(painter, m_pFocusBorderColor, option.rect);
}
}
4 changes: 3 additions & 1 deletion src/library/stardelegate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ QWidget* StarDelegate::createEditor(QWidget* parent,
QStyleOptionViewItem newOption = option;
initStyleOption(&newOption, index);

StarEditor* editor = new StarEditor(parent, m_pTableView, index, newOption);
StarEditor* editor =
new StarEditor(parent, m_pTableView, index, newOption, m_pFocusBorderColor);
connect(editor,
&StarEditor::editingFinished,
this,
Expand Down Expand Up @@ -76,6 +77,7 @@ void StarDelegate::cellEntered(const QModelIndex& index) {
// StarRating.
if (index.data().canConvert<StarRating>()) {
if (m_isOneCellInEditMode) {
// Don't close other editors when hovering the stars cell!
m_pTableView->closePersistentEditor(m_currentEditedCellIndex);
}
m_pTableView->openPersistentEditor(index);
Expand Down
148 changes: 80 additions & 68 deletions src/library/stareditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

#include <QItemSelectionModel>
#include <QMouseEvent>
#include <QPainter>
#include <QTableView>

#include "library/starrating.h"
#include "library/tableitemdelegate.h"
#include "moc_stareditor.cpp"
#include "util/painterscope.h"

// We enable mouse tracking on the widget so we can follow the cursor even
// when the user doesn't hold down any mouse button. We also turn on
Expand All @@ -18,103 +19,114 @@
///
/// The class has been adapted from the official "Star Delegate Example",
/// see http://doc.trolltech.com/4.5/itemviews-stardelegate.html
StarEditor::StarEditor(QWidget *parent, QTableView* pTableView,
const QModelIndex& index,
const QStyleOptionViewItem& option)
StarEditor::StarEditor(QWidget* parent,
QTableView* pTableView,
const QModelIndex& index,
const QStyleOptionViewItem& option,
const QColor& focusBorderColor)
: QWidget(parent),
m_pTableView(pTableView),
m_index(index),
m_styleOption(option) {
m_styleOption(option),
m_pFocusBorderColor(focusBorderColor),
m_starCount(StarRating::kMinStarCount) {
DEBUG_ASSERT(m_pTableView);
setMouseTracking(true);
installEventFilter(this);
}

QSize StarEditor::sizeHint() const {
return m_starRating.sizeHint();
}

// static
void StarEditor::renderHelper(QPainter* painter,
QTableView* pTableView,
const QStyleOptionViewItem& option,
StarRating* pStarRating) {
PainterScope painterScope(painter);
void StarEditor::paintEvent(QPaintEvent*) {
// If a StarEditor is open, by definition the mouse is hovering over us.
m_styleOption.state |= QStyle::State_MouseOver;
m_styleOption.rect = rect();

painter->setClipRect(option.rect);
// If the editor cell is selected set the respective flag so we can use the
// palette's 'HighlightedText' font color for the brush StarRating will use
// to fill the star/diamond polygons with.
QItemSelectionModel* selectionModel = m_pTableView->selectionModel();
if (selectionModel && selectionModel->isSelected(m_index)) {
m_styleOption.state |= QStyle::State_Selected;
}

if (pTableView != nullptr) {
QStyle* style = pTableView->style();
if (style != nullptr) {
style->drawControl(QStyle::CE_ItemViewItem, &option, painter,
pTableView);
}
QPainter painter(this);

painter.setClipRect(m_styleOption.rect);

// Draw standard item with the table view's style
QStyle* style = m_pTableView->style();
if (style) {
style->drawControl(QStyle::CE_ItemViewItem, &m_styleOption, &painter, m_pTableView);
}

// Draw a border if the color cell has focus
if (m_styleOption.state & QStyle::State_Selected) {
// QPainterScope in drawBorder() and shift down?
TableItemDelegate::drawBorder(&painter, m_pFocusBorderColor, m_styleOption.rect);
}

// Starrating scales the painter so do this after painting the border.
// Set the palette appropriately based on whether the row is selected or
// not. We also have to check if it is inactive or not and use the
// appropriate ColorGroup.
QPalette::ColorGroup cg = option.state & QStyle::State_Enabled
? QPalette::Normal : QPalette::Disabled;
if (cg == QPalette::Normal && !(option.state & QStyle::State_Active)) {
QPalette::ColorGroup cg = m_styleOption.state & QStyle::State_Enabled
? QPalette::Normal
: QPalette::Disabled;
if (cg == QPalette::Normal && !(m_styleOption.state & QStyle::State_Active)) {
cg = QPalette::Inactive;
}

if (option.state & QStyle::State_Selected) {
painter->setBrush(option.palette.color(cg, QPalette::HighlightedText));
if (m_styleOption.state & QStyle::State_Selected) {
painter.setBrush(m_styleOption.palette.color(cg, QPalette::HighlightedText));
} else {
painter->setBrush(option.palette.color(cg, QPalette::Text));
painter.setBrush(m_styleOption.palette.color(cg, QPalette::Text));
}

pStarRating->paint(painter, option.rect);
m_starRating.paint(&painter, m_styleOption.rect);
}

void StarEditor::paintEvent(QPaintEvent*) {
// If a StarEditor is open, by definition the mouse is hovering over us.
m_styleOption.state |= QStyle::State_MouseOver;
m_styleOption.rect = rect();

if (m_pTableView) {
QItemSelectionModel* selectionModel = m_pTableView->selectionModel();
if (selectionModel && selectionModel->isSelected(m_index)) {
m_styleOption.state |= QStyle::State_Selected;
}
bool StarEditor::eventFilter(QObject* obj, QEvent* event) {
switch (event->type()) {
case QEvent::Leave:
case QEvent::ContextMenu: {
// Note: it seems with Qt5 we do not reliably get a Leave event when
// invoking the track menu via right click, so reset the rating now.
// The event is forwarded to parent QTableView.
resetRating();
break;
}

QPainter painter(this);
renderHelper(&painter, m_pTableView, m_styleOption, &m_starRating);
}

void StarEditor::mouseMoveEvent(QMouseEvent *event) {
case QEvent::MouseButtonRelease: {
emit editingFinished();
break;
}
case QEvent::MouseMove: {
// Change rating only if no button is pressed.
// This allows dragging the row also by grabbing the star cell
QMouseEvent* me = static_cast<QMouseEvent*>(event);
if (me->buttons().testFlag(Qt::NoButton)) {
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
const int eventPosition = static_cast<int>(event->position().x());
const int eventPosition = static_cast<int>(me->position().x());
#else
const int eventPosition = event->x();
const int eventPosition = me->x();
#endif
int star = starAtPosition(eventPosition);

if (star != m_starRating.starCount() && star != -1) {
m_starRating.setStarCount(star);
update();
int star = m_starRating.starAtPosition(eventPosition, m_styleOption.rect);

if (star <= StarRating::kInvalidStarCount) {
resetRating();
} else if (star != m_starRating.starCount()) {
// Apply star rating if it changed
m_starRating.setStarCount(star);
update();
}
}
break;
}
}

void StarEditor::leaveEvent(QEvent*) {
m_starRating.setStarCount(0);
update();
}

void StarEditor::mouseReleaseEvent(QMouseEvent* /* event */) {
emit editingFinished();
}

int StarEditor::starAtPosition(int x) {
// If the mouse is very close to the left edge, set 0 stars.
if (x < m_starRating.sizeHint().width() * 0.05) {
return 0;
default:
break;
}
int star = (x / (m_starRating.sizeHint().width() / m_starRating.maxStarCount())) + 1;

if (star <= 0 || star > m_starRating.maxStarCount()) {
return 0;
}
return star;
return QWidget::eventFilter(obj, event);
}
Loading

0 comments on commit 25c5d24

Please sign in to comment.