Clementine-audio-player-Mac.../src/ui/mainwindow.h

412 lines
11 KiB
C
Raw Permalink Normal View History

/* This file is part of Clementine.
Copyright 2010, David Sansome <me@davidsansome.com>
Clementine is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Clementine is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Clementine. If not, see <http://www.gnu.org/licenses/>.
*/
2009-12-24 20:16:07 +01:00
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include <QSettings>
2009-12-24 20:16:07 +01:00
#include <QSystemTrayIcon>
2020-09-18 16:15:19 +02:00
#include <memory>
2009-12-24 20:16:07 +01:00
#include "config.h"
2016-02-12 13:25:35 +01:00
#include "core/lazy.h"
2010-06-14 15:27:45 +02:00
#include "core/mac_startup.h"
#include "core/tagreaderclient.h"
#include "engines/engine_fwd.h"
#include "library/librarymodel.h"
#include "playlist/playlistitem.h"
#include "songinfo/streamdiscoverer.h"
2016-02-12 13:25:35 +01:00
#include "ui/organisedialog.h"
2010-08-27 17:42:58 +02:00
#include "ui/settingsdialog.h"
#include "ui/streamdetailsdialog.h"
2009-12-24 20:16:07 +01:00
2010-02-03 21:45:32 +01:00
class About;
class AddStreamDialog;
class AlbumCoverManager;
2012-01-09 20:08:09 +01:00
class Appearance;
class Application;
class ArtistInfoView;
class BackgroundStreams;
class CommandlineOptions;
class Console;
2011-07-23 20:34:41 +02:00
class CoverProviders;
class Database;
class DeviceManager;
class DeviceView;
class DeviceViewContainer;
class EditTagDialog;
2020-07-26 20:38:14 +02:00
class LoveDialog;
class Equalizer;
class ErrorDialog;
class FileView;
class GlobalSearch;
class GlobalSearchView;
class GlobalShortcuts;
class GroupByDialog;
class Library;
class LibraryViewContainer;
class MimeData;
class MultiLoadingIndicator;
class OSD;
class Player;
class PlaylistBackend;
class PlaylistListContainer;
class PlaylistManager;
2010-07-11 17:37:40 +02:00
class QueueManager;
class InternetItem;
class InternetModel;
class InternetViewContainer;
class RipCDDialog;
class Song;
class SongInfoBase;
class SongInfoView;
class StreamDetailsDialog;
class SystemTrayIcon;
class TagFetcher;
class TaskManager;
class TrackSelectionDialog;
class TranscodeDialog;
class VisualisationContainer;
2010-08-25 15:51:30 +02:00
class WiimotedevShortcuts;
class Windows7ThumbBar;
class Ui_MainWindow;
2009-12-24 20:16:07 +01:00
class QSortFilterProxyModel;
2010-06-14 15:27:45 +02:00
class MainWindow : public QMainWindow, public PlatformInterface {
2009-12-24 20:16:07 +01:00
Q_OBJECT
public:
MainWindow(Application* app, SystemTrayIcon* tray_icon, OSD* osd,
const CommandlineOptions& options, QWidget* parent = nullptr);
2009-12-24 20:16:07 +01:00
~MainWindow();
static const char* kSettingsGroup;
static const char* kAllFilesFilterSpec;
// Don't change the values
enum StartupBehaviour {
Startup_Remember = 1,
Startup_AlwaysShow = 2,
Startup_AlwaysHide = 3,
};
// Don't change the values
enum AddBehaviour {
AddBehaviour_Append = 1,
AddBehaviour_Enqueue = 2,
AddBehaviour_Load = 3,
AddBehaviour_OpenInNew = 4
};
// Don't change the values
enum PlayBehaviour {
PlayBehaviour_Never = 1,
PlayBehaviour_IfStopped = 2,
PlayBehaviour_Always = 3,
};
// Don't change the values
enum PlaylistAddBehaviour {
PlaylistAddBehaviour_Play = 1,
PlaylistAddBehaviour_Enqueue = 2,
};
2009-12-24 20:16:07 +01:00
void SetHiddenInTray(bool hidden);
void CommandlineOptionsReceived(const CommandlineOptions& options);
2009-12-24 20:16:07 +01:00
protected:
2020-11-01 20:55:45 +01:00
void keyPressEvent(QKeyEvent*);
void changeEvent(QEvent*);
void resizeEvent(QResizeEvent*);
2020-11-01 20:55:45 +01:00
void closeEvent(QCloseEvent*);
void hideEvent(QHideEvent*);
void showEvent(QShowEvent*);
2009-12-24 20:16:07 +01:00
#ifdef Q_OS_WIN32
bool winEvent(MSG* message, long* result);
#endif
2010-06-15 23:56:33 +02:00
// PlatformInterface
2010-06-14 15:27:45 +02:00
void Activate();
2010-06-15 23:56:33 +02:00
bool LoadUrl(const QString& url);
2020-09-18 16:15:19 +02:00
signals:
// Signals that stop playing after track was toggled.
void StopAfterToggled(bool stop);
void IntroPointReached();
void NewDebugConsole(Console* console);
2009-12-24 20:16:07 +01:00
private slots:
void SetNextAlbumEnabled(PlaylistSequence::RepeatMode mode);
void FilePathChanged(const QString& path);
void SaveSettings(QSettings* settings);
2009-12-24 20:16:07 +01:00
void MediaStopped();
void MediaPaused();
void MediaPlaying();
void TrackSkipped(PlaylistItemPtr item);
void ForceShowOSD(const Song& song, const bool toggle);
2009-12-24 20:16:07 +01:00
2010-01-15 17:22:19 +01:00
void PlaylistRightClick(const QPoint& global_pos, const QModelIndex& index);
void PlaylistCurrentChanged(const QModelIndex& current);
void PlaylistViewSelectionModelChanged();
2010-01-15 17:22:19 +01:00
void PlaylistPlay();
void PlaylistStopAfter();
2010-07-11 17:37:40 +02:00
void PlaylistQueue();
2018-03-18 19:43:44 +01:00
void PlaylistQueuePlayNext();
2014-01-14 06:29:23 +01:00
void PlaylistSkip();
void PlaylistRemoveCurrent();
void PlaylistEditFinished(const QModelIndex& index);
2010-01-16 17:12:47 +01:00
void EditTracks();
void EditTagDialogAccepted();
void DiscoverStreamDetails();
void ShowStreamDetails(const StreamDetails& details);
void RenumberTracks();
void SelectionSetValue();
void EditValue();
void AutoCompleteTags();
void AutoCompleteTagsAccepted();
void PlaylistUndoRedoChanged(QAction* undo, QAction* redo);
void AddFilesToTranscoder();
2010-01-15 17:22:19 +01:00
void SearchForArtist();
void SearchForAlbum();
void PlaylistCopyToLibrary();
void PlaylistMoveToLibrary();
void PlaylistCopyToDevice();
void PlaylistOrganiseSelected(bool copy);
void PlaylistDelete();
void PlaylistOpenInBrowser();
void ShowInLibrary();
void ChangeLibraryQueryMode(QAction* action);
2009-12-24 20:16:07 +01:00
void PlayIndex(const QModelIndex& index);
void PlaylistDoubleClick(const QModelIndex& index);
2009-12-24 20:16:07 +01:00
void StopAfterCurrent();
void SongChanged(const Song& song);
void VolumeChanged(int volume);
void CopyFilesToLibrary(const QList<QUrl>& urls);
void MoveFilesToLibrary(const QList<QUrl>& urls);
2010-09-18 11:54:33 +02:00
void CopyFilesToDevice(const QList<QUrl>& urls);
void EditFileTags(const QList<QUrl>& urls);
void AddToPlaylist(QMimeData* data);
void AddToPlaylist(QAction* action);
2009-12-24 20:16:07 +01:00
void VolumeWheelEvent(int delta);
void ToggleShowHide();
2009-12-24 20:16:07 +01:00
void Seeked(qlonglong microseconds);
2009-12-29 20:57:33 +01:00
void UpdateTrackPosition();
void UpdateTrackSliderPosition();
2009-12-29 20:57:33 +01:00
// Handle visibility of LastFM icons
void LastFMButtonVisibilityChanged(bool value);
void ScrobbleButtonVisibilityChanged(bool value);
void SetToggleScrobblingIcon(bool value);
#ifdef HAVE_LIBLASTFM
void ScrobblingEnabledChanged(bool value);
void ScrobbledRadioStream();
#endif
void Love();
2009-12-29 21:48:50 +01:00
void TaskCountChanged(int count);
void ShowLibraryConfig();
void ReloadSettings();
2011-01-02 15:50:17 +01:00
void ReloadAllSettings();
void RefreshStyleSheet();
void SetHiddenInTray() { SetHiddenInTray(true); }
void AddFile();
void AddFolder();
void AddStream();
void AddStreamAccepted();
void OpenRipCDDialog();
void AddCDTracks();
void AddPodcast();
void CommandlineOptionsReceived(const QString& string_options);
void CheckForUpdates();
void NowPlayingWidgetPositionChanged(bool above_status_bar);
void SongSaveComplete(TagReaderReply* reply,
const QPersistentModelIndex& index);
2010-08-27 17:42:58 +02:00
void ShowCoverManager();
bool IsLastFmEnabled();
#ifdef HAVE_LIBLASTFM
void CachedToScrobble();
2012-06-25 12:30:53 +02:00
void ScrobbleError(int value);
#endif
2010-08-27 17:42:58 +02:00
void ShowAboutDialog();
void ShowTranscodeDialog();
void ShowErrorDialog(const QString& message);
void ShowQueueManager();
void ShowVisualisations();
SettingsDialog* CreateSettingsDialog();
EditTagDialog* CreateEditTagDialog();
2020-07-26 20:38:14 +02:00
LoveDialog* CreateLoveDialog();
StreamDiscoverer* CreateStreamDiscoverer();
Console* CreateDebugConsole();
2010-08-27 17:42:58 +02:00
void OpenSettingsDialog();
void OpenSettingsDialogAtPage(SettingsDialog::Page page);
void ShowSongInfoConfig();
2010-08-27 17:42:58 +02:00
void SaveGeometry(QSettings* settings);
void SavePlaybackStatus(QSettings* settings);
void LoadPlaybackStatus();
void ResumePlayback();
void ResumePlaybackPosition();
void AddSongInfoGenerator(smart_playlists::GeneratorPtr gen);
void DeleteFinished(const SongList& songs_with_errors);
void Raise();
void Exit();
void HandleNotificationPreview(OSD::Behaviour type, QString line1,
QString line2);
void ScrollToInternetIndex(const QModelIndex& index);
void FocusLibraryTab();
void FocusGlobalSearchField();
void DoGlobalSearch(const QString& query);
2012-09-26 18:36:47 +02:00
void ShowConsole();
private:
void ConnectInfoView(SongInfoBase* view);
void ApplyAddBehaviour(AddBehaviour b, MimeData* data) const;
void ApplyPlayBehaviour(PlayBehaviour b, MimeData* data) const;
void CheckFullRescanRevisions();
// creates the icon by painting the full one depending on the current position
QPixmap CreateOverlayedIcon(int position, int scrobble_point);
2009-12-24 20:16:07 +01:00
private:
Ui_MainWindow* ui_;
Windows7ThumbBar* thumbbar_;
2010-08-27 17:42:58 +02:00
Application* app_;
2009-12-29 20:57:33 +01:00
SystemTrayIcon* tray_icon_;
2010-01-08 15:52:05 +01:00
OSD* osd_;
Lazy<EditTagDialog> edit_tag_dialog_;
2020-07-26 20:38:14 +02:00
Lazy<LoveDialog> love_dialog_;
2016-02-12 17:01:35 +01:00
Lazy<About> about_dialog_;
Lazy<StreamDiscoverer> stream_discoverer_;
Lazy<Console> debug_console_;
2009-12-24 20:16:07 +01:00
GlobalShortcuts* global_shortcuts_;
2009-12-24 20:16:07 +01:00
GlobalSearchView* global_search_view_;
LibraryViewContainer* library_view_;
FileView* file_view_;
#ifdef HAVE_AUDIOCD
std::unique_ptr<RipCDDialog> rip_cd_dialog_;
#endif
PlaylistListContainer* playlist_list_;
InternetViewContainer* internet_view_;
DeviceViewContainer* device_view_container_;
DeviceView* device_view_;
SongInfoView* song_info_view_;
ArtistInfoView* artist_info_view_;
Lazy<SettingsDialog> settings_dialog_;
2016-02-12 17:10:24 +01:00
Lazy<AddStreamDialog> add_stream_dialog_;
Lazy<AlbumCoverManager> cover_manager_;
std::unique_ptr<Equalizer> equalizer_;
2016-02-12 17:01:35 +01:00
Lazy<TranscodeDialog> transcode_dialog_;
Lazy<ErrorDialog> error_dialog_;
2016-02-12 13:25:35 +01:00
Lazy<OrganiseDialog> organise_dialog_;
2016-02-12 17:10:24 +01:00
Lazy<QueueManager> queue_manager_;
std::unique_ptr<TagFetcher> tag_fetcher_;
std::unique_ptr<TrackSelectionDialog> track_selection_dialog_;
PlaylistItemList autocomplete_tag_items_;
#ifdef HAVE_VISUALISATIONS
std::unique_ptr<VisualisationContainer> visualisation_;
#endif
2010-02-03 19:32:48 +01:00
#ifdef HAVE_WIIMOTEDEV
std::unique_ptr<WiimotedevShortcuts> wiimotedev_shortcuts_;
#endif
QAction* library_show_all_;
QAction* library_show_duplicates_;
QAction* library_show_untagged_;
2010-01-15 17:22:19 +01:00
QMenu* playlist_menu_;
QAction* playlist_play_pause_;
QAction* playlist_stop_after_;
QAction* playlist_undoredo_;
QAction* playlist_organise_;
QAction* playlist_show_in_library_;
QAction* playlist_copy_to_library_;
QAction* playlist_move_to_library_;
QAction* playlist_copy_to_device_;
QAction* playlist_delete_;
QAction* playlist_open_in_browser_;
2010-07-11 17:37:40 +02:00
QAction* playlist_queue_;
2018-03-18 19:43:44 +01:00
QAction* playlist_queue_play_next_;
2014-01-14 06:29:23 +01:00
QAction* playlist_skip_;
QAction* playlist_add_to_another_;
QList<QAction*> playlistitem_actions_;
QAction* playlistitem_actions_separator_;
2010-01-15 17:22:19 +01:00
QModelIndex playlist_menu_index_;
QAction* search_for_artist_;
QAction* search_for_album_;
2009-12-24 20:16:07 +01:00
QSortFilterProxyModel* library_sort_model_;
2009-12-29 20:57:33 +01:00
QTimer* track_position_timer_;
QTimer* track_slider_timer_;
QSettings settings_;
bool initialized_;
bool dirty_geometry_;
bool dirty_playback_;
bool was_maximized_;
int saved_playback_position_;
Engine::State saved_playback_state_;
AddBehaviour doubleclick_addmode_;
PlayBehaviour doubleclick_playmode_;
PlaylistAddBehaviour doubleclick_playlist_addmode_;
PlayBehaviour menu_playmode_;
BackgroundStreams* background_streams_;
2009-12-24 20:16:07 +01:00
};
#endif // MAINWINDOW_H