Skip to content

Commit

Permalink
Add Miniplayer
Browse files Browse the repository at this point in the history
  • Loading branch information
nilsding committed Feb 16, 2019
1 parent be3db51 commit 982a109
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 3 deletions.
38 changes: 38 additions & 0 deletions mainwindow.cpp
Expand Up @@ -4,6 +4,7 @@
#include <QIcon>
#include <QMimeData>
#include <QFileDialog>
#include <QPropertyAnimation>

#include "m3uparser.h"
#include "m3uwriter.h"
Expand Down Expand Up @@ -191,6 +192,43 @@ void MainWindow::on_qaSavePlaylist_triggered()
savePlaylistToFile(playlistPath);
}

void MainWindow::on_qaMiniplayer_triggered(bool checked)
{
static int previousHeight = 320;
auto animation = new QPropertyAnimation(this, "size");
animation->setDuration(500);
animation->setEasingCurve(QEasingCurve::InOutQuart);

connect(animation, &QPropertyAnimation::finished, this, [=]()
{
if (checked)
{
setMaximumHeight(height());
}
else
{
ui->tableView->show();
}
});

if (checked)
{
previousHeight = height();
animation->setStartValue(QSize(width(), previousHeight));
animation->setEndValue(QSize(width(), ui->toolBar->height()));
}
else
{
setMaximumHeight(maximumWidth()); // maximumWidth is always max
animation->setStartValue(QSize(width(), height()));
animation->setEndValue(QSize(width(), previousHeight));
}

ui->toolBar->setMovable(!checked);
ui->tableView->hide();
animation->start();
}

void MainWindow::onSongChange(QString songName)
{
slInfo->setFirstLine(songName);
Expand Down
1 change: 1 addition & 0 deletions mainwindow.h
Expand Up @@ -45,6 +45,7 @@ private slots:
void on_qaPrevious_triggered();
void on_qaLoadPlaylist_triggered();
void on_qaSavePlaylist_triggered();
void on_qaMiniplayer_triggered(bool checked);

void onSongChange(QString songName);
void onRowUpdate(int row, int pattern, int channels);
Expand Down
33 changes: 30 additions & 3 deletions mainwindow.ui
Expand Up @@ -6,10 +6,16 @@
<rect>
<x>0</x>
<y>0</y>
<width>573</width>
<height>275</height>
<width>600</width>
<height>320</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>600</width>
<height>0</height>
</size>
</property>
<property name="windowTitle">
<string>🦊📦</string>
</property>
Expand Down Expand Up @@ -47,7 +53,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>573</width>
<width>600</width>
<height>22</height>
</rect>
</property>
Expand All @@ -58,7 +64,14 @@
<addaction name="qaLoadPlaylist"/>
<addaction name="qaSavePlaylist"/>
</widget>
<widget class="QMenu" name="menu_View">
<property name="title">
<string>&amp;View</string>
</property>
<addaction name="qaMiniplayer"/>
</widget>
<addaction name="menu_File"/>
<addaction name="menu_View"/>
</widget>
<widget class="QToolBar" name="toolBar">
<property name="windowTitle">
Expand All @@ -70,6 +83,9 @@
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="floatable">
<bool>false</bool>
</property>
<attribute name="toolBarArea">
<enum>TopToolBarArea</enum>
</attribute>
Expand Down Expand Up @@ -135,6 +151,17 @@
<string>Ctrl+S</string>
</property>
</action>
<action name="qaMiniplayer">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>&amp;Miniplayer</string>
</property>
<property name="shortcut">
<string>Ctrl+M</string>
</property>
</action>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources>
Expand Down

0 comments on commit 982a109

Please sign in to comment.