Skip to content

Commit

Permalink
0.1.5 release
Browse files Browse the repository at this point in the history
  • Loading branch information
jsmolka committed Jul 15, 2018
1 parent b12f3db commit baf634e
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 11 deletions.
2 changes: 1 addition & 1 deletion egg-player.pri
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
RC_ICONS = resource/images/egg/egg.ico

VERSION = 0.1.4.25
VERSION = 0.1.5.0

QMAKE_TARGET = Egg Player
QMAKE_TARGET_PRODUCT = Egg Player
Expand Down
8 changes: 8 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@ A Groove Music like music player.
### General
- rewrite library widget
- tweak smooth scrolling values
- fix bug with shuffle and first song
- tweak smooth tablewidget values
- see line 67
- create different sizes for icon button (make them less blurry)
- change directory structure
- split tag isaudiovalid
- disable scrollwheel on slider
- remove const from arguments passed by value

### Threading
- look into write-ahread-logging
Expand Down
53 changes: 45 additions & 8 deletions src/widgets/components/smoothtablewidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@

SmoothTableWidget::SmoothTableWidget(QWidget *parent)
: QTableWidget(parent)
, m_fps(145)
, m_duration(130)
, m_acceleration(1.2)
, m_totapSteps(m_fps * m_duration / 1000)
, m_fps(144)
, m_duration(145)
, m_acceleration(0.1)
, m_stepsLeft(0)
, m_smoothTimer(this)
, pm_lastEvent(nullptr)
{
setup();

connect(&m_smoothTimer, SIGNAL(timeout()), this, SLOT(onTimeout()));
}

Expand All @@ -18,6 +19,36 @@ SmoothTableWidget::~SmoothTableWidget()

}

void SmoothTableWidget::setFps(int fps)
{
m_fps = fps;
}

int SmoothTableWidget::fps()
{
return m_fps;
}

void SmoothTableWidget::setDuration(int duration)
{
m_duration = duration;
}

int SmoothTableWidget::duration()
{
return m_duration;
}

void SmoothTableWidget::setAcceleration(double acceleration)
{
m_acceleration = acceleration;
}

double SmoothTableWidget::acceleration()
{
return m_acceleration;
}

void SmoothTableWidget::wheelEvent(QWheelEvent *event)
{
static QQueue<qint64> scrollStamps;
Expand All @@ -32,11 +63,12 @@ void SmoothTableWidget::wheelEvent(QWheelEvent *event)
else
*pm_lastEvent = *event;

double delta = event->delta();
m_totalSteps = m_fps * m_duration / 1000;
double delta = (double)event->delta() * 0.8 ;
if (m_acceleration > 0)
delta += delta * m_acceleration * accerationRatio;

m_stepsLeft.push_back(qMakePair(delta, m_totapSteps));
m_stepsLeft.push_back(qMakePair(delta, m_totalSteps));
m_smoothTimer.start(1000 / m_fps);
}

Expand Down Expand Up @@ -70,10 +102,15 @@ void SmoothTableWidget::onTimeout()
}
}

void SmoothTableWidget::setup()
{
setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
}

double SmoothTableWidget::subDelta(double delta, int stepsLeft)
{
double m = m_totapSteps / 2.0;
double x = abs(m_totapSteps - stepsLeft - m);
double m = m_totalSteps / 2.0;
double x = abs(m_totalSteps - stepsLeft - m);

return (cos(x * M_PI / m) + 1.0) / (2.0 * m) * delta;
}
13 changes: 12 additions & 1 deletion src/widgets/components/smoothtablewidget.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,31 @@ class SmoothTableWidget : public QTableWidget
SmoothTableWidget(QWidget *parent = nullptr);
~SmoothTableWidget();

void setFps(int fps);
int fps();

void setDuration(int duration);
int duration();

void setAcceleration(double acceleration);
double acceleration();

protected:
void wheelEvent(QWheelEvent *event);

private slots:
void onTimeout();

private:
void setup();

double subDelta(double delta, int stepsLeft);

int m_fps;
int m_duration;
double m_acceleration;

int m_totapSteps;
int m_totalSteps;
QVector<QPair<double, int>> m_stepsLeft;

QTimer m_smoothTimer;
Expand Down
1 change: 0 additions & 1 deletion src/widgets/components/tablewidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ void TableWidget::setup()
setMouseTracking(true);
setSelectionMode(QAbstractItemView::NoSelection);
setShowGrid(false);
setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
setWordWrap(false);

horizontalHeader()->hide();
Expand Down

0 comments on commit baf634e

Please sign in to comment.