diff --git a/src/core/appearance.cpp b/src/core/appearance.cpp index cb6da82c7..bdd7360fd 100644 --- a/src/core/appearance.cpp +++ b/src/core/appearance.cpp @@ -32,19 +32,17 @@ #include "appearance.h" #include "settings/appearancesettingspage.h" -const char *Appearance::kUseCustomColorSet = "use-custom-set"; -const char *Appearance::kForegroundColor = "foreground-color"; -const char *Appearance::kBackgroundColor = "background-color"; - const QPalette Appearance::kDefaultPalette = QPalette(); Appearance::Appearance(QObject *parent) : QObject(parent) { + QPalette p = QApplication::palette(); + QSettings s; s.beginGroup(AppearanceSettingsPage::kSettingsGroup); - QPalette p = QApplication::palette(); - background_color_ = s.value(kBackgroundColor, p.color(QPalette::WindowText)).value(); - foreground_color_ = s.value(kForegroundColor, p.color(QPalette::Window)).value(); + background_color_ = s.value(AppearanceSettingsPage::kBackgroundColor, p.color(QPalette::WindowText)).value(); + foreground_color_ = s.value(AppearanceSettingsPage::kForegroundColor, p.color(QPalette::Window)).value(); + s.endGroup(); } @@ -52,7 +50,9 @@ void Appearance::LoadUserTheme() { QSettings s; s.beginGroup(AppearanceSettingsPage::kSettingsGroup); - bool use_a_custom_color_set = s.value(kUseCustomColorSet).toBool(); + bool use_a_custom_color_set = s.value(AppearanceSettingsPage::kUseCustomColorSet).toBool(); + s.endGroup(); + if (!use_a_custom_color_set) return; ChangeForegroundColor(foreground_color_); diff --git a/src/core/appearance.h b/src/core/appearance.h index f6d8622a5..ea5fdc437 100644 --- a/src/core/appearance.h +++ b/src/core/appearance.h @@ -30,18 +30,14 @@ class Appearance : public QObject { public: explicit Appearance(QObject *parent = nullptr); - // Load the user preferred theme, which could the default system theme or a custom set of colors that user has chosen + + static const QPalette kDefaultPalette; + void LoadUserTheme(); void ResetToSystemDefaultTheme(); void ChangeForegroundColor(const QColor &color); void ChangeBackgroundColor(const QColor &color); - static const char *kSettingsGroup; - static const char *kUseCustomColorSet; - static const char *kForegroundColor; - static const char *kBackgroundColor; - static const QPalette kDefaultPalette; - private: QColor foreground_color_; QColor background_color_; diff --git a/src/core/mainwindow.cpp b/src/core/mainwindow.cpp index 179e8bfb0..2ce47c39c 100644 --- a/src/core/mainwindow.cpp +++ b/src/core/mainwindow.cpp @@ -215,9 +215,9 @@ MainWindow::MainWindow(Application *app, SystemTrayIcon *tray_icon, OSD *osd, co saved_playback_position_(0), saved_playback_state_(Engine::Empty), playing_widget_(true), - doubleclick_addmode_(AddBehaviour_Append), - doubleclick_playmode_(PlayBehaviour_Never), - menu_playmode_(PlayBehaviour_Never) + doubleclick_addmode_(BehaviourSettingsPage::AddBehaviour_Append), + doubleclick_playmode_(BehaviourSettingsPage::PlayBehaviour_Never), + menu_playmode_(BehaviourSettingsPage::PlayBehaviour_Never) { qLog(Debug) << "Starting"; @@ -812,10 +812,10 @@ void MainWindow::ReloadSettings() { settings.beginGroup(BehaviourSettingsPage::kSettingsGroup); playing_widget_ = settings.value("playing_widget", true).toBool(); if (playing_widget_ != ui_->widget_playing->IsEnabled()) TabSwitched(); - doubleclick_addmode_ = AddBehaviour(settings.value("doubleclick_addmode", AddBehaviour_Append).toInt()); - doubleclick_playmode_ = PlayBehaviour(settings.value("doubleclick_playmode", PlayBehaviour_IfStopped).toInt()); - doubleclick_playlist_addmode_ = PlaylistAddBehaviour(settings.value("doubleclick_playlist_addmode", PlaylistAddBehaviour_Play).toInt()); - menu_playmode_ = PlayBehaviour(settings.value("menu_playmode", PlayBehaviour_IfStopped).toInt()); + doubleclick_addmode_ = BehaviourSettingsPage::AddBehaviour(settings.value("doubleclick_addmode", BehaviourSettingsPage::AddBehaviour_Append).toInt()); + doubleclick_playmode_ = BehaviourSettingsPage::PlayBehaviour(settings.value("doubleclick_playmode", BehaviourSettingsPage::PlayBehaviour_IfStopped).toInt()); + doubleclick_playlist_addmode_ = BehaviourSettingsPage::PlaylistAddBehaviour(settings.value("doubleclick_playlist_addmode", BehaviourSettingsPage::PlaylistAddBehaviour_Play).toInt()); + menu_playmode_ = BehaviourSettingsPage::PlayBehaviour(settings.value("menu_playmode", BehaviourSettingsPage::PlayBehaviour_IfStopped).toInt()); settings.endGroup(); settings.beginGroup(kSettingsGroup); @@ -1108,12 +1108,12 @@ void MainWindow::PlaylistDoubleClick(const QModelIndex &index) { QModelIndexList dummyIndexList; switch (doubleclick_playlist_addmode_) { - case PlaylistAddBehaviour_Play: + case BehaviourSettingsPage::PlaylistAddBehaviour_Play: app_->playlist_manager()->SetActiveToCurrent(); app_->player()->PlayAt(row, Engine::Manual, true); break; - case PlaylistAddBehaviour_Enqueue: + case BehaviourSettingsPage::PlaylistAddBehaviour_Enqueue: dummyIndexList.append(index); app_->playlist_manager()->current()->queue()->ToggleTracks(dummyIndexList); if (app_->player()->GetState() != Engine::Playing) { @@ -1241,42 +1241,42 @@ void MainWindow::UpdateTrackSliderPosition() { } -void MainWindow::ApplyAddBehaviour(MainWindow::AddBehaviour b, MimeData *data) const { +void MainWindow::ApplyAddBehaviour(BehaviourSettingsPage::AddBehaviour b, MimeData *data) const { switch (b) { - case AddBehaviour_Append: + case BehaviourSettingsPage::AddBehaviour_Append: data->clear_first_ = false; data->enqueue_now_ = false; break; - case AddBehaviour_Enqueue: + case BehaviourSettingsPage::AddBehaviour_Enqueue: data->clear_first_ = false; data->enqueue_now_ = true; break; - case AddBehaviour_Load: + case BehaviourSettingsPage::AddBehaviour_Load: data->clear_first_ = true; data->enqueue_now_ = false; break; - case AddBehaviour_OpenInNew: + case BehaviourSettingsPage::AddBehaviour_OpenInNew: data->open_in_new_playlist_ = true; break; } } -void MainWindow::ApplyPlayBehaviour(MainWindow::PlayBehaviour b, MimeData *data) const { +void MainWindow::ApplyPlayBehaviour(BehaviourSettingsPage::PlayBehaviour b, MimeData *data) const { switch (b) { - case PlayBehaviour_Always: + case BehaviourSettingsPage::PlayBehaviour_Always: data->play_now_ = true; break; - case PlayBehaviour_Never: + case BehaviourSettingsPage::PlayBehaviour_Never: data->play_now_ = false; break; - case PlayBehaviour_IfStopped: + case BehaviourSettingsPage::PlayBehaviour_IfStopped: data->play_now_ = !(app_->player()->GetState() == Engine::Playing); break; } @@ -1834,7 +1834,7 @@ void MainWindow::CommandlineOptionsReceived(const CommandlineOptions &options) { break; case CommandlineOptions::UrlList_CreateNew: data->name_for_new_playlist_ = options.playlist_name(); - ApplyAddBehaviour(AddBehaviour_OpenInNew, data); + ApplyAddBehaviour(BehaviourSettingsPage::AddBehaviour_OpenInNew, data); break; } diff --git a/src/core/mainwindow.h b/src/core/mainwindow.h index 128c43743..597e9a962 100644 --- a/src/core/mainwindow.h +++ b/src/core/mainwindow.h @@ -55,6 +55,7 @@ #include "collection/collectionmodel.h" #include "playlist/playlistitem.h" #include "settings/settingsdialog.h" +#include "settings/behavioursettingspage.h" using std::unique_ptr; @@ -108,27 +109,6 @@ class MainWindow : public QMainWindow, public PlatformInterface { 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, - }; - void SetHiddenInTray(bool hidden); void CommandlineOptionsReceived(const CommandlineOptions& options); @@ -278,8 +258,8 @@ signals: private: - void ApplyAddBehaviour(AddBehaviour b, MimeData *data) const; - void ApplyPlayBehaviour(PlayBehaviour b, MimeData *data) const; + void ApplyAddBehaviour(BehaviourSettingsPage::AddBehaviour b, MimeData *data) const; + void ApplyPlayBehaviour(BehaviourSettingsPage::PlayBehaviour b, MimeData *data) const; void CheckFullRescanRevisions(); @@ -370,10 +350,10 @@ signals: int saved_playback_position_; Engine::State saved_playback_state_; bool playing_widget_; - AddBehaviour doubleclick_addmode_; - PlayBehaviour doubleclick_playmode_; - PlaylistAddBehaviour doubleclick_playlist_addmode_; - PlayBehaviour menu_playmode_; + BehaviourSettingsPage::AddBehaviour doubleclick_addmode_; + BehaviourSettingsPage::PlayBehaviour doubleclick_playmode_; + BehaviourSettingsPage::PlaylistAddBehaviour doubleclick_playlist_addmode_; + BehaviourSettingsPage::PlayBehaviour menu_playmode_; Song song_; Song song_playing_; diff --git a/src/playlist/playlistview.cpp b/src/playlist/playlistview.cpp index af676f903..7cdec1a87 100644 --- a/src/playlist/playlistview.cpp +++ b/src/playlist/playlistview.cpp @@ -83,11 +83,6 @@ const int PlaylistView::kGlowIntensitySteps = 24; const int PlaylistView::kAutoscrollGraceTimeout = 30; // seconds const int PlaylistView::kDropIndicatorWidth = 2; const int PlaylistView::kDropIndicatorGradientWidth = 5; -const char *PlaylistView::kSettingBackgroundImageType = "playlistview_background_type"; -const char *PlaylistView::kSettingBackgroundImageFilename = "playlistview_background_image_file"; - -const int PlaylistView::kDefaultBlurRadius = 0; -const int PlaylistView::kDefaultOpacityLevel = 40; PlaylistProxyStyle::PlaylistProxyStyle(QStyle *base) : QProxyStyle(base), common_style_(new QCommonStyle) {} @@ -133,19 +128,27 @@ PlaylistView::PlaylistView(QWidget *parent) style_(new PlaylistProxyStyle(style())), playlist_(nullptr), header_(new PlaylistHeader(Qt::Horizontal, this, this)), + background_image_type_(AppearanceSettingsPage::BackgroundImageType_Default), + background_image_position_(AppearanceSettingsPage::BackgroundImagePosition_BottomRight), + background_image_maxsize_(0), + background_image_stretch_(false), + background_image_keep_aspect_ratio_(true), + blur_radius_(AppearanceSettingsPage::kDefaultBlurRadius), + opacity_level_(AppearanceSettingsPage::kDefaultOpacityLevel), initialized_(false), + background_initialized_(false), setting_initial_header_layout_(false), read_only_settings_(true), header_loaded_(false), - background_initialized_(false), - background_image_type_(Default), - blur_radius_(kDefaultBlurRadius), - opacity_level_(kDefaultOpacityLevel), previous_background_image_opacity_(0.0), fade_animation_(new QTimeLine(1000, this)), + force_background_redraw_(false), last_height_(-1), last_width_(-1), - force_background_redraw_(false), + current_background_image_x_(0), + current_background_image_y_(0), + previous_background_image_x_(0), + previous_background_image_y_(0), glow_enabled_(true), currently_glowing_(false), glow_intensity_step_(0), @@ -339,6 +342,7 @@ void PlaylistView::SaveGeometry() { QSettings settings; settings.beginGroup(Playlist::kSettingsGroup); settings.setValue("state", header_->SaveState()); + settings.endGroup(); } @@ -780,7 +784,7 @@ void PlaylistView::paintEvent(QPaintEvent *event) { // The cached pixmap gets invalidated in dragLeaveEvent, dropEvent and scrollContentsBy. // Draw background - if (background_image_type_ == Custom || background_image_type_ == Album) { + if (background_image_type_ == AppearanceSettingsPage::BackgroundImageType_Custom || background_image_type_ == AppearanceSettingsPage::BackgroundImageType_Album) { if (!background_image_.isNull() || !previous_background_image_.isNull()) { QPainter background_painter(viewport()); @@ -791,7 +795,19 @@ void PlaylistView::paintEvent(QPaintEvent *event) { cached_scaled_background_image_ = QPixmap(); } else { - cached_scaled_background_image_ = QPixmap::fromImage(background_image_.scaled(width(), height(), Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation)); + if (background_image_stretch_) { + if (background_image_keep_aspect_ratio_) { + cached_scaled_background_image_ = QPixmap::fromImage(background_image_.scaled(width(), height(), Qt::KeepAspectRatio, Qt::SmoothTransformation)); + } + else { + cached_scaled_background_image_ = QPixmap::fromImage(background_image_.scaled(width(), height(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation)); + } + } + else { + int resize_width = qMin(qMin(background_image_.size().width(), width()), background_image_maxsize_); + int resize_height = qMin(qMin(background_image_.size().height(), height()), background_image_maxsize_); + cached_scaled_background_image_ = QPixmap::fromImage(background_image_.scaled(resize_width, resize_height, Qt::KeepAspectRatio, Qt::SmoothTransformation)); + } } last_height_ = height(); @@ -805,12 +821,34 @@ void PlaylistView::paintEvent(QPaintEvent *event) { if (!qFuzzyCompare(previous_background_image_opacity_, qreal(0.0))) { background_painter.setOpacity(1.0 - previous_background_image_opacity_); } - background_painter.drawPixmap((width() - cached_scaled_background_image_.width()) / 2, (height() - cached_scaled_background_image_.height()) / 2, cached_scaled_background_image_); + switch (background_image_position_) { + case AppearanceSettingsPage::BackgroundImagePosition_UpperLeft: + current_background_image_x_ = 0; + current_background_image_y_ = 0; + break; + case AppearanceSettingsPage::BackgroundImagePosition_UpperRight: + current_background_image_x_ = (width() - cached_scaled_background_image_.width() - 0); + current_background_image_y_ = 0; + break; + case AppearanceSettingsPage::BackgroundImagePosition_Middle: + current_background_image_x_ = ((width() - cached_scaled_background_image_.width()) / 2); + current_background_image_y_ = ((height() - cached_scaled_background_image_.height()) / 2); + break; + case AppearanceSettingsPage::BackgroundImagePosition_BottomLeft: + current_background_image_x_ = 0; + current_background_image_y_ = (height() - cached_scaled_background_image_.height() - 25); + break; + case AppearanceSettingsPage::BackgroundImagePosition_BottomRight: + default: + current_background_image_x_ = (width() - cached_scaled_background_image_.width() - 0); + current_background_image_y_ = (height() - cached_scaled_background_image_.height() - 25); + } + background_painter.drawPixmap(current_background_image_x_, current_background_image_y_, cached_scaled_background_image_); } // Draw the previous background image if we're fading if (!previous_background_image_.isNull()) { background_painter.setOpacity(previous_background_image_opacity_); - background_painter.drawPixmap((width() - previous_background_image_.width()) / 2, (height() - previous_background_image_.height()) / 2, previous_background_image_); + background_painter.drawPixmap(previous_background_image_x_, previous_background_image_y_, previous_background_image_); } } } @@ -920,18 +958,29 @@ void PlaylistView::ReloadSettings() { s.beginGroup(PlaylistSettingsPage::kSettingsGroup); glow_enabled_ = s.value("glow_effect", true).toBool(); + bool editmetadatainline = s.value("editmetadatainline", false).toBool(); + s.endGroup(); + + s.beginGroup(Playlist::kSettingsGroup); + bool stretch = s.value("stretch", true).toBool(); + column_alignment_ = s.value("column_alignments").value(); + s.endGroup(); + + s.beginGroup(AppearanceSettingsPage::kSettingsGroup); + QVariant background_image_type_var = s.value(AppearanceSettingsPage::kBackgroundImageType); + QVariant background_image_position_var = s.value(AppearanceSettingsPage::kBackgroundImagePosition); + int background_image_maxsize = s.value(AppearanceSettingsPage::kBackgroundImageMaxSize).toInt(); + if (background_image_maxsize <= 10) background_image_maxsize = 9000; + QString background_image_filename = s.value(AppearanceSettingsPage::kBackgroundImageFilename).toString(); + bool background_image_stretch = s.value(AppearanceSettingsPage::kBackgroundImageStretch, false).toBool(); + bool background_image_keep_aspect_ratio = s.value(AppearanceSettingsPage::kBackgroundImageKeepAspectRatio, true).toBool(); + int blur_radius = s.value(AppearanceSettingsPage::kBlurRadius, AppearanceSettingsPage::kDefaultBlurRadius).toInt(); + int opacity_level = s.value(AppearanceSettingsPage::kOpacityLevel, AppearanceSettingsPage::kDefaultOpacityLevel).toInt(); s.endGroup(); if (setting_initial_header_layout_) { - s.beginGroup(Playlist::kSettingsGroup); - header_->SetStretchEnabled(s.value("stretch", true).toBool()); - s.endGroup(); - } - if (currently_glowing_ && glow_enabled_ && isVisible()) StartGlowing(); - if (!glow_enabled_) StopGlowing(); - - if (setting_initial_header_layout_) { + header_->SetStretchEnabled(stretch); header_->SetColumnWidth(Playlist::Column_Track, 0.02); header_->SetColumnWidth(Playlist::Column_Title, 0.16); @@ -945,83 +994,84 @@ void PlaylistView::ReloadSettings() { header_->SetColumnWidth(Playlist::Column_Source, 0.06); setting_initial_header_layout_ = false; + } - s.beginGroup(Playlist::kSettingsGroup); - column_alignment_ = s.value("column_alignments").value(); - s.endGroup(); + if (currently_glowing_ && glow_enabled_ && isVisible()) StartGlowing(); + if (!glow_enabled_) StopGlowing(); + if (column_alignment_.isEmpty()) { column_alignment_ = DefaultColumnAlignment(); } - emit ColumnAlignmentChanged(column_alignment_); + // Background: - s.beginGroup(AppearanceSettingsPage::kSettingsGroup); - QVariant q_playlistview_background_type = s.value(kSettingBackgroundImageType); - s.endGroup(); - BackgroundImageType background_type(Default); - // bg_enabled should also be checked for backward compatibility (in releases <= 1.0, there was just a boolean to activate/deactivate the background) - s.beginGroup(Playlist::kSettingsGroup); - QVariant bg_enabled = s.value("bg_enabled"); - s.endGroup(); - if (q_playlistview_background_type.isValid()) { - background_type = static_cast(q_playlistview_background_type.toInt()); - } - else if (bg_enabled.isValid()) { - if (bg_enabled.toBool()) { - background_type = Default; - } - else { - background_type = None; - } + AppearanceSettingsPage::BackgroundImageType background_image_type(AppearanceSettingsPage::BackgroundImageType_Default); + if (background_image_type_var.isValid()) { + background_image_type = static_cast(background_image_type_var.toInt()); } else { - background_type = Default; + background_image_type = AppearanceSettingsPage::BackgroundImageType_Default; } - s.beginGroup(AppearanceSettingsPage::kSettingsGroup); - QString background_image_filename = s.value(kSettingBackgroundImageFilename).toString(); - int blur_radius = s.value("blur_radius", kDefaultBlurRadius).toInt(); - int opacity_level = s.value("opacity_level", kDefaultOpacityLevel).toInt(); - s.endGroup(); + + AppearanceSettingsPage::BackgroundImagePosition background_image_position(AppearanceSettingsPage::BackgroundImagePosition_BottomRight); + if (background_image_position_var.isValid()) { + background_image_position = static_cast(background_image_position_var.toInt()); + } + else { + background_image_position = AppearanceSettingsPage::BackgroundImagePosition_BottomRight; + } + // Check if background properties have changed. // We change properties only if they have actually changed, to avoid to call set_background_image when it is not needed, // as this will cause the fading animation to start again. // This also avoid to do useless "force_background_redraw". - if (!background_initialized_ || background_image_filename != background_image_filename_ || background_type != background_image_type_ || blur_radius_ != blur_radius || opacity_level_ != opacity_level) { + if ( + !background_initialized_ || + background_image_type != background_image_type_ || + background_image_filename != background_image_filename_ || + background_image_position != background_image_position_ || + background_image_maxsize != background_image_maxsize_ || + background_image_stretch != background_image_stretch_ || + background_image_keep_aspect_ratio != background_image_keep_aspect_ratio_ || + blur_radius_ != blur_radius || + opacity_level_ != opacity_level + ) { + background_initialized_ = true; - // Store background properties - background_image_type_ = background_type; + background_image_type_ = background_image_type; background_image_filename_ = background_image_filename; + background_image_position_ = background_image_position; + background_image_maxsize_ = background_image_maxsize; + background_image_stretch_ = background_image_stretch; + background_image_keep_aspect_ratio_ = background_image_keep_aspect_ratio; blur_radius_ = blur_radius; opacity_level_ = opacity_level; - if (background_image_type_ == Custom) { + + if (background_image_type_ == AppearanceSettingsPage::BackgroundImageType_Custom) { set_background_image(QImage(background_image_filename)); } - else if (background_image_type_ == Album) { + else if (background_image_type_ == AppearanceSettingsPage::BackgroundImageType_Album) { set_background_image(current_song_cover_art_); } else { // User changed background image type to something that will not be painted through paintEvent: reset all background images. // This avoid to use old (deprecated) images for fading when selecting Album or Custom background image type later. - //set_background_image(QImage(":/pictures/playlistbg.png")); set_background_image(QImage()); cached_scaled_background_image_ = QPixmap(); previous_background_image_ = QPixmap(); } - setProperty("default_background_enabled", background_image_type_ == Default); + setProperty("default_background_enabled", background_image_type_ == AppearanceSettingsPage::BackgroundImageType_Default); emit BackgroundPropertyChanged(); force_background_redraw_ = true; } - s.beginGroup(PlaylistSettingsPage::kSettingsGroup); - if(!s.value("editmetadatainline", false).toBool()) - setEditTriggers(editTriggers() & ~QAbstractItemView::SelectedClicked); - else + if (editmetadatainline) setEditTriggers(editTriggers() | QAbstractItemView::SelectedClicked); - - s.endGroup(); + else + setEditTriggers(editTriggers() & ~QAbstractItemView::SelectedClicked); } @@ -1036,7 +1086,7 @@ void PlaylistView::SaveSettings() { s.endGroup(); s.beginGroup(AppearanceSettingsPage::kSettingsGroup); - s.setValue(kSettingBackgroundImageType, background_image_type_); + s.setValue(AppearanceSettingsPage::kBackgroundImageType, background_image_type_); s.endGroup(); s.beginGroup(Playlist::kSettingsGroup); @@ -1046,9 +1096,11 @@ void PlaylistView::SaveSettings() { } void PlaylistView::StretchChanged(bool stretch) { + if (!initialized_) return; setHorizontalScrollBarPolicy(stretch ? Qt::ScrollBarAlwaysOff : Qt::ScrollBarAsNeeded); SaveGeometry(); + } bool PlaylistView::eventFilter(QObject *object, QEvent *event) { @@ -1140,7 +1192,7 @@ void PlaylistView::CurrentSongChanged(const Song &song, const QString &uri, cons if (current_song_cover_art_ == song_art) return; current_song_cover_art_ = song_art; - if (background_image_type_ == Album) { + if (background_image_type_ == AppearanceSettingsPage::BackgroundImageType_Album) { if (song.art_automatic().isEmpty() && song.art_manual().isEmpty()) { set_background_image(QImage()); } @@ -1157,6 +1209,8 @@ void PlaylistView::set_background_image(const QImage &image) { // Save previous image, for fading previous_background_image_ = cached_scaled_background_image_; + previous_background_image_x_ = current_background_image_x_; + previous_background_image_y_ = current_background_image_y_; if (image.isNull() || image.format() == QImage::Format_ARGB32) { background_image_ = image; diff --git a/src/playlist/playlistview.h b/src/playlist/playlistview.h index e0802df8c..6ec6282b8 100644 --- a/src/playlist/playlistview.h +++ b/src/playlist/playlistview.h @@ -50,6 +50,7 @@ #include #include +#include "settings/appearancesettingspage.h" #include "playlist.h" class QEvent; @@ -89,23 +90,10 @@ public: class PlaylistView : public QTreeView { Q_OBJECT public: - enum BackgroundImageType { - Default, - None, - Custom, - Album - }; PlaylistView(QWidget *parent = nullptr); ~PlaylistView(); - // Constants for settings: are persistent, values should not be changed - static const char *kSettingBackgroundImageType; - static const char *kSettingBackgroundImageFilename; - - static const int kDefaultBlurRadius; - static const int kDefaultOpacityLevel; - static ColumnAlignmentMap DefaultColumnAlignment(); void SetApplication(Application *app); @@ -116,7 +104,7 @@ class PlaylistView : public QTreeView { void SetReadOnlySettings(bool read_only) { read_only_settings_ = read_only; } Playlist *playlist() const { return playlist_; } - BackgroundImageType background_image_type() const { return background_image_type_; } + AppearanceSettingsPage::BackgroundImageType background_image_type() const { return background_image_type_; } Qt::Alignment column_alignment(int section) const; // QTreeView @@ -193,7 +181,7 @@ class PlaylistView : public QTreeView { QList LoadBarPixmap(const QString &filename); void UpdateCachedCurrentRowPixmap(QStyleOptionViewItem option, const QModelIndex &index); - void set_background_image_type(BackgroundImageType bg) { + void set_background_image_type(AppearanceSettingsPage::BackgroundImageType bg) { background_image_type_ = bg; emit BackgroundPropertyChanged(); } @@ -215,21 +203,23 @@ class PlaylistView : public QTreeView { PlaylistProxyStyle *style_; Playlist *playlist_; PlaylistHeader *header_; + + AppearanceSettingsPage::BackgroundImageType background_image_type_; + QString background_image_filename_; + AppearanceSettingsPage::BackgroundImagePosition background_image_position_; + int background_image_maxsize_; + bool background_image_stretch_; + bool background_image_keep_aspect_ratio_; + int blur_radius_; + int opacity_level_; + bool initialized_; + bool background_initialized_; bool setting_initial_header_layout_; bool read_only_settings_; bool header_loaded_; - bool background_initialized_; - BackgroundImageType background_image_type_; - // Stores the background image to be displayed. - // As we want this image to be particular (in terms of format, opacity), - // you should probably use set_background_image_type instead of modifying background_image_ directly QImage background_image_; - int blur_radius_; - int opacity_level_; - // Used if background image is a filemane - QString background_image_filename_; QImage current_song_cover_art_; QPixmap cached_scaled_background_image_; @@ -239,9 +229,13 @@ class PlaylistView : public QTreeView { QTimeLine *fade_animation_; // To know if we should redraw the background or not + bool force_background_redraw_; int last_height_; int last_width_; - bool force_background_redraw_; + int current_background_image_x_; + int current_background_image_y_; + int previous_background_image_x_; + int previous_background_image_y_; bool glow_enabled_; bool currently_glowing_; diff --git a/src/settings/appearancesettingspage.cpp b/src/settings/appearancesettingspage.cpp index 1eed999e1..51d883d39 100644 --- a/src/settings/appearancesettingspage.cpp +++ b/src/settings/appearancesettingspage.cpp @@ -44,33 +44,60 @@ const char *AppearanceSettingsPage::kSettingsGroup = "Appearance"; +const char *AppearanceSettingsPage::kUseCustomColorSet = "use-custom-set"; +const char *AppearanceSettingsPage::kForegroundColor = "foreground-color"; +const char *AppearanceSettingsPage::kBackgroundColor = "background-color"; + +const char *AppearanceSettingsPage::kBackgroundImageType = "background_image_type"; +const char *AppearanceSettingsPage::kBackgroundImageFilename = "background_image_file"; +const char *AppearanceSettingsPage::kBackgroundImagePosition = "background_image_position"; +const char *AppearanceSettingsPage::kBackgroundImageStretch = "background_image_stretch"; +const char *AppearanceSettingsPage::kBackgroundImageKeepAspectRatio = "background_image_keep_aspect_ratio"; +const char *AppearanceSettingsPage::kBackgroundImageMaxSize = "background_image_max_size"; + +const char *AppearanceSettingsPage::kBlurRadius = "blur_radius"; +const char *AppearanceSettingsPage::kOpacityLevel = "opacity_level"; + +const int AppearanceSettingsPage::kDefaultBlurRadius = 0; +const int AppearanceSettingsPage::kDefaultOpacityLevel = 40; + +const char *AppearanceSettingsPage::kSystemThemeIcons = "system_icons"; + AppearanceSettingsPage::AppearanceSettingsPage(SettingsDialog *dialog) : SettingsPage(dialog), ui_(new Ui_AppearanceSettingsPage), original_use_a_custom_color_set_(false), - playlist_view_background_image_type_(PlaylistView::Default) { + background_image_type_(BackgroundImageType_Default) { ui_->setupUi(this); setWindowIcon(IconLoader::Load("view-media-visualization")); + ui_->combobox_backgroundimageposition->setItemData(0, BackgroundImagePosition_UpperLeft); + ui_->combobox_backgroundimageposition->setItemData(1, BackgroundImagePosition_UpperRight); + ui_->combobox_backgroundimageposition->setItemData(2, BackgroundImagePosition_Middle); + ui_->combobox_backgroundimageposition->setItemData(3, BackgroundImagePosition_BottomLeft); + ui_->combobox_backgroundimageposition->setItemData(4, BackgroundImagePosition_BottomRight); + connect(ui_->blur_slider, SIGNAL(valueChanged(int)), SLOT(BlurLevelChanged(int))); connect(ui_->opacity_slider, SIGNAL(valueChanged(int)), SLOT(OpacityLevelChanged(int))); - Load(); - + connect(ui_->use_a_custom_color_set, SIGNAL(toggled(bool)), SLOT(UseCustomColorSetOptionChanged(bool))); connect(ui_->select_foreground_color, SIGNAL(pressed()), SLOT(SelectForegroundColor())); connect(ui_->select_background_color, SIGNAL(pressed()), SLOT(SelectBackgroundColor())); - connect(ui_->use_a_custom_color_set, SIGNAL(toggled(bool)), SLOT(UseCustomColorSetOptionChanged(bool))); + + connect(ui_->use_default_background, SIGNAL(toggled(bool)), ui_->widget_custom_background_image_options, SLOT(setDisabled(bool))); + connect(ui_->use_no_background, SIGNAL(toggled(bool)), ui_->widget_custom_background_image_options, SLOT(setDisabled(bool))); + connect(ui_->use_custom_background_image, SIGNAL(toggled(bool)), ui_->widget_custom_background_image_options, SLOT(setEnabled(bool))); + connect(ui_->use_album_cover_background, SIGNAL(toggled(bool)), ui_->widget_custom_background_image_options, SLOT(setEnabled(bool))); connect(ui_->select_background_image_filename_button, SIGNAL(pressed()), SLOT(SelectBackgroundImage())); connect(ui_->use_custom_background_image, SIGNAL(toggled(bool)), ui_->background_image_filename, SLOT(setEnabled(bool))); connect(ui_->use_custom_background_image, SIGNAL(toggled(bool)), ui_->select_background_image_filename_button, SLOT(setEnabled(bool))); - connect(ui_->use_custom_background_image, SIGNAL(toggled(bool)), ui_->blur_slider, SLOT(setEnabled(bool))); - connect(ui_->use_album_cover_background, SIGNAL(toggled(bool)), ui_->blur_slider, SLOT(setEnabled(bool))); + connect(ui_->checkbox_background_image_stretch, SIGNAL(toggled(bool)), ui_->checkbox_background_image_keep_aspect_ratio, SLOT(setEnabled(bool))); + connect(ui_->checkbox_background_image_stretch, SIGNAL(toggled(bool)), ui_->spinbox_background_image_maxsize, SLOT(setDisabled(bool))); - connect(ui_->use_default_background, SIGNAL(toggled(bool)), SLOT(DisableBlurAndOpacitySliders(bool))); - connect(ui_->use_no_background, SIGNAL(toggled(bool)), SLOT(DisableBlurAndOpacitySliders(bool))); + Load(); } @@ -86,11 +113,11 @@ void AppearanceSettingsPage::Load() { QPalette p = QApplication::palette(); // Keep in mind originals colors, in case the user clicks on Cancel, to be able to restore colors - original_use_a_custom_color_set_ = s.value(Appearance::kUseCustomColorSet, false).toBool(); + original_use_a_custom_color_set_ = s.value(kUseCustomColorSet, false).toBool(); - original_foreground_color_ = s.value(Appearance::kForegroundColor, p.color(QPalette::WindowText)).value(); + original_foreground_color_ = s.value(kForegroundColor, p.color(QPalette::WindowText)).value(); current_foreground_color_ = original_foreground_color_; - original_background_color_ = s.value(Appearance::kBackgroundColor, p.color(QPalette::Window)).value(); + original_background_color_ = s.value(kBackgroundColor, p.color(QPalette::Window)).value(); current_background_color_ = original_background_color_; InitColorSelectorsColors(); @@ -99,32 +126,35 @@ void AppearanceSettingsPage::Load() { // Playlist settings s.beginGroup(kSettingsGroup); - playlist_view_background_image_type_ = static_cast(s.value(PlaylistView::kSettingBackgroundImageType).toInt()); - playlist_view_background_image_filename_ = s.value(PlaylistView::kSettingBackgroundImageFilename).toString(); + background_image_type_ = static_cast(s.value(kBackgroundImageType).toInt()); + background_image_filename_ = s.value(kBackgroundImageFilename).toString(); ui_->use_system_color_set->setChecked(!original_use_a_custom_color_set_); ui_->use_a_custom_color_set->setChecked(original_use_a_custom_color_set_); - switch (playlist_view_background_image_type_) { - case PlaylistView::None: + switch (background_image_type_) { + case BackgroundImageType_None: ui_->use_no_background->setChecked(true); - DisableBlurAndOpacitySliders(true); break; - case PlaylistView::Album: + case BackgroundImageType_Album: ui_->use_album_cover_background->setChecked(true); break; - case PlaylistView::Custom: + case BackgroundImageType_Custom: ui_->use_custom_background_image->setChecked(true); break; - case PlaylistView::Default: + case BackgroundImageType_Default: default: ui_->use_default_background->setChecked(true); - DisableBlurAndOpacitySliders(true); } - ui_->background_image_filename->setText(playlist_view_background_image_filename_); - ui_->blur_slider->setValue(s.value("blur_radius", PlaylistView::kDefaultBlurRadius).toInt()); - ui_->opacity_slider->setValue(s.value("opacity_level", PlaylistView::kDefaultOpacityLevel).toInt()); - ui_->checkbox_system_icons->setChecked(s.value("system_icons", false).toBool()); + ui_->background_image_filename->setText(background_image_filename_); + + ui_->combobox_backgroundimageposition->setCurrentIndex(ui_->combobox_backgroundimageposition->findData(s.value(kBackgroundImagePosition, BackgroundImagePosition_BottomRight).toInt())); + ui_->spinbox_background_image_maxsize->setValue(s.value(kBackgroundImageMaxSize, 0).toInt()); + ui_->checkbox_background_image_stretch->setChecked(s.value(kBackgroundImageStretch, false).toBool()); + ui_->checkbox_background_image_keep_aspect_ratio->setChecked(s.value(kBackgroundImageKeepAspectRatio, true).toBool()); + ui_->blur_slider->setValue(s.value(kBlurRadius, kDefaultBlurRadius).toInt()); + ui_->opacity_slider->setValue(s.value(kOpacityLevel, kDefaultOpacityLevel).toInt()); + ui_->checkbox_system_icons->setChecked(s.value(kSystemThemeIcons, false).toBool()); s.endGroup(); @@ -136,33 +166,41 @@ void AppearanceSettingsPage::Save() { s.beginGroup(kSettingsGroup); bool use_a_custom_color_set = ui_->use_a_custom_color_set->isChecked(); - s.setValue(Appearance::kUseCustomColorSet, use_a_custom_color_set); + s.setValue(kUseCustomColorSet, use_a_custom_color_set); if (use_a_custom_color_set) { - s.setValue(Appearance::kBackgroundColor, current_background_color_); - s.setValue(Appearance::kForegroundColor, current_foreground_color_); + s.setValue(kBackgroundColor, current_background_color_); + s.setValue(kForegroundColor, current_foreground_color_); } else { dialog()->appearance()->ResetToSystemDefaultTheme(); } - playlist_view_background_image_filename_ = ui_->background_image_filename->text(); + background_image_filename_ = ui_->background_image_filename->text(); if (ui_->use_no_background->isChecked()) { - playlist_view_background_image_type_ = PlaylistView::None; + background_image_type_ = BackgroundImageType_None; } else if (ui_->use_album_cover_background->isChecked()) { - playlist_view_background_image_type_ = PlaylistView::Album; + background_image_type_ = BackgroundImageType_Album; } else if (ui_->use_default_background->isChecked()) { - playlist_view_background_image_type_ = PlaylistView::Default; + background_image_type_ = BackgroundImageType_Default; } else if (ui_->use_custom_background_image->isChecked()) { - playlist_view_background_image_type_ = PlaylistView::Custom; - s.setValue(PlaylistView::kSettingBackgroundImageFilename, playlist_view_background_image_filename_); + background_image_type_ = BackgroundImageType_Custom; + s.setValue(kBackgroundImageFilename, background_image_filename_); } - s.setValue(PlaylistView::kSettingBackgroundImageType, playlist_view_background_image_type_); - s.setValue("blur_radius", ui_->blur_slider->value()); - s.setValue("opacity_level", ui_->opacity_slider->value()); - s.setValue("system_icons", ui_->checkbox_system_icons->isChecked()); + s.setValue(kBackgroundImageType, background_image_type_); + + BackgroundImagePosition backgroundimageposition = BackgroundImagePosition(ui_->combobox_backgroundimageposition->itemData(ui_->combobox_backgroundimageposition->currentIndex()).toInt()); + s.setValue(kBackgroundImageMaxSize, ui_->spinbox_background_image_maxsize->value()); + s.setValue(kBackgroundImagePosition, backgroundimageposition); + s.setValue(kBackgroundImageStretch, ui_->checkbox_background_image_stretch->isChecked()); + s.setValue(kBackgroundImageKeepAspectRatio, ui_->checkbox_background_image_keep_aspect_ratio->isChecked()); + + s.setValue(kBlurRadius, ui_->blur_slider->value()); + s.setValue(kOpacityLevel, ui_->opacity_slider->value()); + + s.setValue(kSystemThemeIcons, ui_->checkbox_system_icons->isChecked()); s.endGroup(); @@ -228,10 +266,10 @@ void AppearanceSettingsPage::UpdateColorSelectorColor(QWidget *color_selector, c void AppearanceSettingsPage::SelectBackgroundImage() { - QString selected_filename = QFileDialog::getOpenFileName(this, tr("Select background image"), playlist_view_background_image_filename_, tr(AlbumCoverChoiceController::kLoadImageFileFilter) + ";;" + tr(AlbumCoverChoiceController::kAllFilesFilter)); + QString selected_filename = QFileDialog::getOpenFileName(this, tr("Select background image"), background_image_filename_, tr(AlbumCoverChoiceController::kLoadImageFileFilter) + ";;" + tr(AlbumCoverChoiceController::kAllFilesFilter)); if (selected_filename.isEmpty()) return; - playlist_view_background_image_filename_ = selected_filename; - ui_->background_image_filename->setText(playlist_view_background_image_filename_); + background_image_filename_ = selected_filename; + ui_->background_image_filename->setText(background_image_filename_); } @@ -242,17 +280,3 @@ void AppearanceSettingsPage::BlurLevelChanged(int value) { void AppearanceSettingsPage::OpacityLevelChanged(int percent) { ui_->background_opacity_label->setText(QString("%1\%").arg(percent)); } - -void AppearanceSettingsPage::DisableBlurAndOpacitySliders(bool checked) { - - // Blur slider - ui_->blur_slider->setDisabled(checked); - ui_->background_blur_radius_label->setDisabled(checked); - ui_->select_background_blur_label->setDisabled(checked); - - // Opacity slider - ui_->opacity_slider->setDisabled(checked); - ui_->background_opacity_label->setDisabled(checked); - ui_->select_opacity_level_label->setDisabled(checked); - -} diff --git a/src/settings/appearancesettingspage.h b/src/settings/appearancesettingspage.h index 62eace3e7..e0f031816 100644 --- a/src/settings/appearancesettingspage.h +++ b/src/settings/appearancesettingspage.h @@ -30,7 +30,6 @@ #include #include -#include "playlist/playlistview.h" #include "settingspage.h" class SettingsDialog; @@ -42,22 +41,56 @@ class AppearanceSettingsPage : public SettingsPage { public: AppearanceSettingsPage(SettingsDialog *dialog); ~AppearanceSettingsPage(); + static const char *kSettingsGroup; + static const char *kUseCustomColorSet; + static const char *kForegroundColor; + static const char *kBackgroundColor; + + static const char *kBackgroundImageType; + static const char *kBackgroundImageFilename; + static const char *kBackgroundImagePosition; + static const char *kBackgroundImageStretch; + static const char *kBackgroundImageKeepAspectRatio; + static const char *kBackgroundImageMaxSize; + + static const char *kBlurRadius; + static const char *kOpacityLevel; + + static const int kDefaultBlurRadius; + static const int kDefaultOpacityLevel; + + static const char *kSystemThemeIcons; + + enum BackgroundImageType { + BackgroundImageType_Default, + BackgroundImageType_None, + BackgroundImageType_Custom, + BackgroundImageType_Album + }; + + enum BackgroundImagePosition { + BackgroundImagePosition_UpperLeft = 1, + BackgroundImagePosition_UpperRight = 2, + BackgroundImagePosition_Middle = 3, + BackgroundImagePosition_BottomLeft = 4, + BackgroundImagePosition_BottomRight = 5 + }; + void Load(); void Save(); void Cancel(); -private slots: + private slots: void SelectForegroundColor(); void SelectBackgroundColor(); void UseCustomColorSetOptionChanged(bool); void SelectBackgroundImage(); void BlurLevelChanged(int); void OpacityLevelChanged(int); - void DisableBlurAndOpacitySliders(bool); -private: + private: // Set the widget's background to new_color void UpdateColorSelectorColor(QWidget *color_selector, const QColor &new_color); @@ -65,13 +98,14 @@ private: void InitColorSelectorsColors(); Ui_AppearanceSettingsPage *ui_; + bool original_use_a_custom_color_set_; QColor original_foreground_color_; QColor original_background_color_; QColor current_foreground_color_; QColor current_background_color_; - PlaylistView::BackgroundImageType playlist_view_background_image_type_; - QString playlist_view_background_image_filename_; + BackgroundImageType background_image_type_; + QString background_image_filename_; }; diff --git a/src/settings/appearancesettingspage.ui b/src/settings/appearancesettingspage.ui index 6b29d9f3c..7703771c5 100644 --- a/src/settings/appearancesettingspage.ui +++ b/src/settings/appearancesettingspage.ui @@ -7,19 +7,19 @@ 0 0 596 - 566 + 627 Appearance - + - + Colors - + @@ -35,7 +35,7 @@ - + @@ -59,7 +59,7 @@ - + @@ -86,11 +86,11 @@ - + Background image - + @@ -98,6 +98,13 @@ + + + + &No background image + + + @@ -109,14 +116,7 @@ - - - &No background image - - - - - + @@ -144,80 +144,211 @@ - - - - - true - - - Blur amount - - - - - - - 0 - - - 10 - - - Qt::Horizontal - - - QSlider::TicksBelow - - - 1 - - - - - - - true - - - 0px - - - - - - - Opacity - - - - - - - 100 - - - 10 - - - Qt::Horizontal - - - QSlider::TicksBelow - - - 10 - - - - - - - 40% - - - - + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + Position + + + + + + + + Upper Left + + + + + Upper Right + + + + + Middle + + + + + Bottom Left + + + + + Bottom Right + + + + + + + + Max cover size + + + + + + + 9000 + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + Stretch background image to fill playlist background + + + + + + + Keep aspect ratio + + + + + + + + + + + + true + + + Blur amount + + + + + + + 0 + + + 10 + + + Qt::Horizontal + + + QSlider::TicksBelow + + + 1 + + + + + + + true + + + 0px + + + + + + + Opacity + + + + + + + 100 + + + 10 + + + Qt::Horizontal + + + QSlider::TicksBelow + + + 10 + + + + + + + 40% + + + + + + + @@ -230,7 +361,7 @@ - + Qt::Vertical diff --git a/src/settings/behavioursettingspage.cpp b/src/settings/behavioursettingspage.cpp index d13a66a2a..c5f00a380 100644 --- a/src/settings/behavioursettingspage.cpp +++ b/src/settings/behavioursettingspage.cpp @@ -70,18 +70,18 @@ BehaviourSettingsPage::BehaviourSettingsPage(SettingsDialog *dialog) : SettingsP } #endif - ui_->combobox_doubleclickaddmode->setItemData(0, MainWindow::AddBehaviour_Append); - ui_->combobox_doubleclickaddmode->setItemData(1, MainWindow::AddBehaviour_Load); - ui_->combobox_doubleclickaddmode->setItemData(2, MainWindow::AddBehaviour_OpenInNew); - ui_->combobox_doubleclickaddmode->setItemData(3, MainWindow::AddBehaviour_Enqueue); + ui_->combobox_doubleclickaddmode->setItemData(0, AddBehaviour_Append); + ui_->combobox_doubleclickaddmode->setItemData(1, AddBehaviour_Load); + ui_->combobox_doubleclickaddmode->setItemData(2, AddBehaviour_OpenInNew); + ui_->combobox_doubleclickaddmode->setItemData(3, AddBehaviour_Enqueue); - ui_->combobox_doubleclickplaymode->setItemData(0, MainWindow::PlayBehaviour_Never); - ui_->combobox_doubleclickplaymode->setItemData(1, MainWindow::PlayBehaviour_IfStopped); - ui_->combobox_doubleclickplaymode->setItemData(2, MainWindow::PlayBehaviour_Always); + ui_->combobox_doubleclickplaymode->setItemData(0, PlayBehaviour_Never); + ui_->combobox_doubleclickplaymode->setItemData(1, PlayBehaviour_IfStopped); + ui_->combobox_doubleclickplaymode->setItemData(2, PlayBehaviour_Always); - ui_->combobox_menuplaymode->setItemData(0, MainWindow::PlayBehaviour_Never); - ui_->combobox_menuplaymode->setItemData(1, MainWindow::PlayBehaviour_IfStopped); - ui_->combobox_menuplaymode->setItemData(2, MainWindow::PlayBehaviour_Always); + ui_->combobox_menuplaymode->setItemData(0, PlayBehaviour_Never); + ui_->combobox_menuplaymode->setItemData(1, PlayBehaviour_IfStopped); + ui_->combobox_menuplaymode->setItemData(2, PlayBehaviour_Always); #ifdef HAVE_TRANSLATIONS // Populate the language combo box. We do this by looking at all the compiled in translations. @@ -159,9 +159,9 @@ void BehaviourSettingsPage::Load() { ui_->checkbox_resumeplayback->setChecked(s.value("resumeplayback", false).toBool()); - ui_->combobox_doubleclickaddmode->setCurrentIndex(ui_->combobox_doubleclickaddmode->findData(s.value("doubleclick_addmode", MainWindow::AddBehaviour_Append).toInt())); - ui_->combobox_doubleclickplaymode->setCurrentIndex(ui_->combobox_doubleclickplaymode->findData(s.value("doubleclick_playmode", MainWindow::PlayBehaviour_Never).toInt())); - ui_->combobox_menuplaymode->setCurrentIndex(ui_->combobox_menuplaymode->findData(s.value("menu_playmode", MainWindow::PlayBehaviour_Never).toInt())); + ui_->combobox_doubleclickaddmode->setCurrentIndex(ui_->combobox_doubleclickaddmode->findData(s.value("doubleclick_addmode", AddBehaviour_Append).toInt())); + ui_->combobox_doubleclickplaymode->setCurrentIndex(ui_->combobox_doubleclickplaymode->findData(s.value("doubleclick_playmode", PlayBehaviour_Never).toInt())); + ui_->combobox_menuplaymode->setCurrentIndex(ui_->combobox_menuplaymode->findData(s.value("menu_playmode", PlayBehaviour_Never).toInt())); ui_->spinbox_seekstepsec->setValue(s.value("seek_step_sec", 10).toInt()); @@ -185,9 +185,9 @@ void BehaviourSettingsPage::Save() { if (ui_->radiobutton_alwaysshow->isChecked()) behaviour = MainWindow::Startup_AlwaysShow; if (ui_->radiobutton_remember->isChecked()) behaviour = MainWindow::Startup_Remember; - MainWindow::AddBehaviour doubleclick_addmode = MainWindow::AddBehaviour(ui_->combobox_doubleclickaddmode->itemData(ui_->combobox_doubleclickaddmode->currentIndex()).toInt()); - MainWindow::PlayBehaviour doubleclick_playmode = MainWindow::PlayBehaviour(ui_->combobox_doubleclickplaymode->itemData(ui_->combobox_doubleclickplaymode->currentIndex()).toInt()); - MainWindow::PlayBehaviour menu_playmode = MainWindow::PlayBehaviour(ui_->combobox_menuplaymode->itemData(ui_->combobox_menuplaymode->currentIndex()).toInt()); + AddBehaviour doubleclick_addmode = AddBehaviour(ui_->combobox_doubleclickaddmode->itemData(ui_->combobox_doubleclickaddmode->currentIndex()).toInt()); + PlayBehaviour doubleclick_playmode = PlayBehaviour(ui_->combobox_doubleclickplaymode->itemData(ui_->combobox_doubleclickplaymode->currentIndex()).toInt()); + PlayBehaviour menu_playmode = PlayBehaviour(ui_->combobox_menuplaymode->itemData(ui_->combobox_menuplaymode->currentIndex()).toInt()); s.setValue("showtrayicon", ui_->checkbox_showtrayicon->isChecked()); s.setValue("scrolltrayicon", ui_->checkbox_scrolltrayicon->isChecked()); diff --git a/src/settings/behavioursettingspage.h b/src/settings/behavioursettingspage.h index 4d84e19f7..ac7ea345c 100644 --- a/src/settings/behavioursettingspage.h +++ b/src/settings/behavioursettingspage.h @@ -40,8 +40,30 @@ class BehaviourSettingsPage : public SettingsPage { public: BehaviourSettingsPage(SettingsDialog *dialog); ~BehaviourSettingsPage(); + static const char *kSettingsGroup; + // 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, + }; + void Load(); void Save();