Add more background image options

This commit is contained in:
Jonas Kvinge
2019-03-25 22:00:40 +01:00
parent 0025cb9f53
commit 7aaad124d0
11 changed files with 553 additions and 318 deletions

View File

@@ -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<QColor>();
foreground_color_ = s.value(kForegroundColor, p.color(QPalette::Window)).value<QColor>();
background_color_ = s.value(AppearanceSettingsPage::kBackgroundColor, p.color(QPalette::WindowText)).value<QColor>();
foreground_color_ = s.value(AppearanceSettingsPage::kForegroundColor, p.color(QPalette::Window)).value<QColor>();
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_);

View File

@@ -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_;

View File

@@ -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;
}

View File

@@ -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_;