Add love button
This commit is contained in:
@@ -359,7 +359,8 @@ MainWindow::MainWindow(Application *app, SystemTrayIcon *tray_icon, OSD *osd, co
|
||||
|
||||
// Scrobble
|
||||
|
||||
ui_->action_toggle_scrobbling->setIcon(IconLoader::Load("scrobble-disabled", 22));
|
||||
ui_->action_toggle_scrobbling->setIcon(IconLoader::Load("scrobble-disabled"));
|
||||
ui_->action_love->setIcon(IconLoader::Load("love"));
|
||||
|
||||
// File view connections
|
||||
connect(file_view_, SIGNAL(AddToPlaylist(QMimeData*)), SLOT(AddToPlaylist(QMimeData*)));
|
||||
@@ -419,6 +420,7 @@ MainWindow::MainWindow(Application *app, SystemTrayIcon *tray_icon, OSD *osd, co
|
||||
#endif
|
||||
|
||||
connect(ui_->action_toggle_scrobbling, SIGNAL(triggered()), app_->scrobbler(), SLOT(ToggleScrobbling()));
|
||||
connect(ui_->action_love, SIGNAL(triggered()), SLOT(Love()));
|
||||
connect(app_->scrobbler(), SIGNAL(ErrorMessage(QString)), SLOT(ShowErrorDialog(QString)));
|
||||
|
||||
// Playlist view actions
|
||||
@@ -435,6 +437,7 @@ MainWindow::MainWindow(Application *app, SystemTrayIcon *tray_icon, OSD *osd, co
|
||||
ui_->pause_play_button->setDefaultAction(ui_->action_play_pause);
|
||||
ui_->stop_button->setDefaultAction(ui_->action_stop);
|
||||
ui_->button_scrobble->setDefaultAction(ui_->action_toggle_scrobbling);
|
||||
ui_->button_love->setDefaultAction(ui_->action_love);
|
||||
|
||||
ui_->playlist->SetActions(ui_->action_new_playlist, ui_->action_load_playlist, ui_->action_save_playlist, ui_->action_clear_playlist, ui_->action_next_playlist, /* These two actions aren't associated */ ui_->action_previous_playlist /* to a button but to the main window */ );
|
||||
|
||||
@@ -615,13 +618,14 @@ MainWindow::MainWindow(Application *app, SystemTrayIcon *tray_icon, OSD *osd, co
|
||||
|
||||
connect(app_->scrobbler(), SIGNAL(ScrobblingEnabledChanged(bool)), SLOT(ScrobblingEnabledChanged(bool)));
|
||||
connect(app_->scrobbler(), SIGNAL(ScrobbleButtonVisibilityChanged(bool)), SLOT(ScrobbleButtonVisibilityChanged(bool)));
|
||||
connect(app_->scrobbler(), SIGNAL(LoveButtonVisibilityChanged(bool)), SLOT(LoveButtonVisibilityChanged(bool)));
|
||||
|
||||
#ifdef Q_OS_MACOS
|
||||
mac::SetApplicationHandler(this);
|
||||
#endif
|
||||
// Tray icon
|
||||
if (tray_icon_) {
|
||||
tray_icon_->SetupMenu(ui_->action_previous_track, ui_->action_play_pause, ui_->action_stop, ui_->action_stop_after_this_track, ui_->action_next_track, ui_->action_mute, ui_->action_quit);
|
||||
tray_icon_->SetupMenu(ui_->action_previous_track, ui_->action_play_pause, ui_->action_stop, ui_->action_stop_after_this_track, ui_->action_next_track, ui_->action_mute, ui_->action_love, ui_->action_quit);
|
||||
connect(tray_icon_, SIGNAL(PlayPause()), app_->player(), SLOT(PlayPause()));
|
||||
connect(tray_icon_, SIGNAL(SeekForward()), app_->player(), SLOT(SeekForward()));
|
||||
connect(tray_icon_, SIGNAL(SeekBackward()), app_->player(), SLOT(SeekBackward()));
|
||||
@@ -632,7 +636,7 @@ MainWindow::MainWindow(Application *app, SystemTrayIcon *tray_icon, OSD *osd, co
|
||||
}
|
||||
|
||||
// Windows 7 thumbbar buttons
|
||||
thumbbar_->SetActions(QList<QAction*>() << ui_->action_previous_track << ui_->action_play_pause << ui_->action_stop << ui_->action_next_track << nullptr); // spacer
|
||||
thumbbar_->SetActions(QList<QAction*>() << ui_->action_previous_track << ui_->action_play_pause << ui_->action_stop << ui_->action_next_track << nullptr << ui_->action_love);
|
||||
|
||||
#if (defined(Q_OS_MACOS) && defined(HAVE_SPARKLE))
|
||||
// Add check for updates item to application menu.
|
||||
@@ -659,6 +663,7 @@ MainWindow::MainWindow(Application *app, SystemTrayIcon *tray_icon, OSD *osd, co
|
||||
connect(global_shortcuts_, SIGNAL(ShowOSD()), app_->player(), SLOT(ShowOSD()));
|
||||
connect(global_shortcuts_, SIGNAL(TogglePrettyOSD()), app_->player(), SLOT(TogglePrettyOSD()));
|
||||
connect(global_shortcuts_, SIGNAL(ToggleScrobbling()), app_->scrobbler(), SLOT(ToggleScrobbling()));
|
||||
connect(global_shortcuts_, SIGNAL(Love()), app_->scrobbler(), SLOT(Love()));
|
||||
#endif
|
||||
|
||||
// Fancy tabs
|
||||
@@ -725,6 +730,7 @@ MainWindow::MainWindow(Application *app, SystemTrayIcon *tray_icon, OSD *osd, co
|
||||
connect(app_->playlist_manager()->sequence(), SIGNAL(ShuffleModeChanged(PlaylistSequence::ShuffleMode)), osd_, SLOT(ShuffleModeChanged(PlaylistSequence::ShuffleMode)));
|
||||
|
||||
ScrobbleButtonVisibilityChanged(app_->scrobbler()->ScrobbleButton());
|
||||
LoveButtonVisibilityChanged(app_->scrobbler()->LoveButton());
|
||||
ScrobblingEnabledChanged(app_->scrobbler()->IsEnabled());
|
||||
|
||||
// Load settings
|
||||
@@ -913,6 +919,10 @@ void MainWindow::MediaStopped() {
|
||||
|
||||
ui_->action_play_pause->setEnabled(true);
|
||||
|
||||
ui_->action_love->setEnabled(false);
|
||||
ui_->button_love->setEnabled(false);
|
||||
if (tray_icon_) tray_icon_->LoveStateChanged(false);
|
||||
|
||||
track_position_timer_->stop();
|
||||
track_slider_timer_->stop();
|
||||
ui_->track_slider->SetStopped();
|
||||
@@ -925,6 +935,8 @@ void MainWindow::MediaStopped() {
|
||||
song_ = Song();
|
||||
image_original_ = QImage();
|
||||
|
||||
app_->scrobbler()->ClearPlaying();
|
||||
|
||||
}
|
||||
|
||||
void MainWindow::MediaPaused() {
|
||||
@@ -939,7 +951,9 @@ void MainWindow::MediaPaused() {
|
||||
track_position_timer_->stop();
|
||||
track_slider_timer_->stop();
|
||||
|
||||
if (tray_icon_) tray_icon_->SetPaused();
|
||||
if (tray_icon_) {
|
||||
tray_icon_->SetPaused();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -971,6 +985,9 @@ void MainWindow::MediaPlaying() {
|
||||
if (app_->scrobbler()->IsEnabled() && playlist && !playlist->nowplaying() && item->Metadata().is_metadata_good() && item->Metadata().length_nanosec() > 0) {
|
||||
app_->scrobbler()->UpdateNowPlaying(item->Metadata());
|
||||
playlist->set_nowplaying(true);
|
||||
ui_->action_love->setEnabled(true);
|
||||
ui_->button_love->setEnabled(true);
|
||||
if (tray_icon_) tray_icon_->LoveStateChanged(true);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2409,12 +2426,24 @@ void MainWindow::ScrobblingEnabledChanged(bool value) {
|
||||
}
|
||||
|
||||
void MainWindow::ScrobbleButtonVisibilityChanged(bool value) {
|
||||
|
||||
ui_->button_scrobble->setVisible(value);
|
||||
ui_->action_toggle_scrobbling->setVisible(value);
|
||||
if (value) SetToggleScrobblingIcon(app_->scrobbler()->IsEnabled());
|
||||
|
||||
}
|
||||
|
||||
void MainWindow::LoveButtonVisibilityChanged(bool value) {
|
||||
|
||||
if (value)
|
||||
ui_->widget_love->show();
|
||||
else
|
||||
ui_->widget_love->hide();
|
||||
|
||||
if (tray_icon_) tray_icon_->LoveVisibilityChanged(value);
|
||||
|
||||
}
|
||||
|
||||
void MainWindow::SetToggleScrobblingIcon(bool value) {
|
||||
|
||||
if (value) {
|
||||
@@ -2428,3 +2457,12 @@ void MainWindow::SetToggleScrobblingIcon(bool value) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void MainWindow::Love() {
|
||||
|
||||
app_->scrobbler()->Love();
|
||||
ui_->button_love->setEnabled(false);
|
||||
ui_->action_love->setEnabled(false);
|
||||
if (tray_icon_) tray_icon_->LoveStateChanged(false);
|
||||
|
||||
}
|
||||
|
||||
@@ -255,6 +255,8 @@ signals:
|
||||
|
||||
void ScrobblingEnabledChanged(bool value);
|
||||
void ScrobbleButtonVisibilityChanged(bool value);
|
||||
void LoveButtonVisibilityChanged(bool value);
|
||||
void Love();
|
||||
|
||||
private:
|
||||
|
||||
|
||||
@@ -178,6 +178,41 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="widget_love" native="true">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<property name="spacing">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="Line" name="line_love">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="button_love">
|
||||
<property name="autoRaise">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Line" name="line_buttons">
|
||||
<property name="orientation">
|
||||
@@ -407,7 +442,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>1131</width>
|
||||
<height>27</height>
|
||||
<height>24</height>
|
||||
</rect>
|
||||
</property>
|
||||
<widget class="QMenu" name="menu_music">
|
||||
@@ -424,6 +459,7 @@
|
||||
<addaction name="separator"/>
|
||||
<addaction name="action_mute"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="action_love"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="action_quit"/>
|
||||
</widget>
|
||||
@@ -528,6 +564,17 @@
|
||||
<string>Ctrl+Alt+V</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="action_love">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Love</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string notr="true">Ctrl+L</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="action_clear_playlist">
|
||||
<property name="text">
|
||||
<string>&Clear playlist</string>
|
||||
|
||||
@@ -131,7 +131,7 @@ bool QtSystemTrayIcon::eventFilter(QObject *object, QEvent *event) {
|
||||
|
||||
}
|
||||
|
||||
void QtSystemTrayIcon::SetupMenu(QAction *previous, QAction *play, QAction *stop, QAction *stop_after, QAction *next, QAction *mute, QAction *quit) {
|
||||
void QtSystemTrayIcon::SetupMenu(QAction *previous, QAction *play, QAction *stop, QAction *stop_after, QAction *next, QAction *mute, QAction *love, QAction *quit) {
|
||||
|
||||
// Creating new actions and connecting them to old ones.
|
||||
// This allows us to use old actions without displaying shortcuts that can not be used when Strawberry's window is hidden
|
||||
@@ -147,6 +147,9 @@ void QtSystemTrayIcon::SetupMenu(QAction *previous, QAction *play, QAction *stop
|
||||
action_mute_->setChecked(mute->isChecked());
|
||||
|
||||
menu_->addSeparator();
|
||||
action_love_ = menu_->addAction(love->icon(), love->text(), love, SLOT(trigger()));
|
||||
action_love_->setVisible(love->isVisible());
|
||||
action_love_->setEnabled(love->isEnabled());
|
||||
menu_->addSeparator();
|
||||
menu_->addAction(quit->icon(), quit->text(), quit, SLOT(trigger()));
|
||||
|
||||
@@ -216,6 +219,8 @@ void QtSystemTrayIcon::SetStopped() {
|
||||
|
||||
action_play_pause_->setEnabled(true);
|
||||
|
||||
action_love_->setEnabled(false);
|
||||
|
||||
}
|
||||
|
||||
void QtSystemTrayIcon::MuteButtonStateChanged(bool value) {
|
||||
@@ -278,3 +283,11 @@ void QtSystemTrayIcon::SetNowPlaying(const Song &song, const QString &image_path
|
||||
void QtSystemTrayIcon::ClearNowPlaying() {
|
||||
tray_->setToolTip(app_name_);
|
||||
}
|
||||
|
||||
void QtSystemTrayIcon::LoveVisibilityChanged(bool value) {
|
||||
action_love_->setVisible(value);
|
||||
}
|
||||
|
||||
void QtSystemTrayIcon::LoveStateChanged(bool value) {
|
||||
action_love_->setEnabled(value);
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ class QtSystemTrayIcon : public SystemTrayIcon {
|
||||
QtSystemTrayIcon(QObject *parent = nullptr);
|
||||
~QtSystemTrayIcon();
|
||||
|
||||
void SetupMenu(QAction *previous, QAction *play, QAction *stop, QAction *stop_after, QAction *next, QAction *mute, QAction *quit);
|
||||
void SetupMenu(QAction *previous, QAction *play, QAction *stop, QAction *stop_after, QAction *next, QAction *mute, QAction *love, QAction *quit);
|
||||
bool IsVisible() const;
|
||||
void SetVisible(bool visible);
|
||||
|
||||
@@ -65,6 +65,8 @@ class QtSystemTrayIcon : public SystemTrayIcon {
|
||||
void SetPlaying(bool enable_play_pause = false);
|
||||
void SetStopped();
|
||||
void MuteButtonStateChanged(bool value);
|
||||
void LoveVisibilityChanged(bool value);
|
||||
void LoveStateChanged(bool value);
|
||||
|
||||
// QObject
|
||||
bool eventFilter(QObject *, QEvent *);
|
||||
@@ -84,6 +86,7 @@ class QtSystemTrayIcon : public SystemTrayIcon {
|
||||
QAction *action_stop_;
|
||||
QAction *action_stop_after_this_track_;
|
||||
QAction *action_mute_;
|
||||
QAction *action_love_;
|
||||
|
||||
#ifndef Q_OS_WIN
|
||||
QString de_;
|
||||
|
||||
@@ -39,7 +39,7 @@ class SystemTrayIcon : public QObject {
|
||||
SystemTrayIcon(QObject *parent = nullptr);
|
||||
|
||||
// Called once to create the icon's context menu
|
||||
virtual void SetupMenu(QAction *previous, QAction *play, QAction *stop, QAction *stop_after, QAction *next, QAction *mute, QAction *quit) = 0;
|
||||
virtual void SetupMenu(QAction *previous, QAction *play, QAction *stop, QAction *stop_after, QAction *next, QAction *mute, QAction *love, QAction *quit) = 0;
|
||||
|
||||
virtual bool IsVisible() const { return true; }
|
||||
virtual void SetVisible(bool visible) {}
|
||||
@@ -60,6 +60,8 @@ class SystemTrayIcon : public QObject {
|
||||
virtual void SetPaused();
|
||||
virtual void SetPlaying(bool enable_play_pause = false);
|
||||
virtual void SetStopped();
|
||||
virtual void LoveVisibilityChanged(bool value) {}
|
||||
virtual void LoveStateChanged(bool value) {}
|
||||
virtual void MuteButtonStateChanged(bool value) {}
|
||||
|
||||
signals:
|
||||
|
||||
Reference in New Issue
Block a user