Initial commit.

This commit is contained in:
Jonas Kvinge
2018-02-27 18:06:05 +01:00
parent 85d9664df7
commit b2b1ba7abe
1393 changed files with 177311 additions and 1 deletions

View File

@@ -0,0 +1,255 @@
/*
* Strawberry Music Player
* This file was part of Clementine.
* Copyright 2012, David Sansome <me@davidsansome.com>
*
* Strawberry 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.
*
* Strawberry 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 Strawberry. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include "config.h"
#include <QApplication>
#include <QColorDialog>
#include <QFileDialog>
#include <QPainter>
#include <QSettings>
#include "appearancesettingspage.h"
#include "ui_appearancesettingspage.h"
#include "settingsdialog.h"
#include "core/application.h"
#include "core/mainwindow.h"
#include "core/appearance.h"
#include "core/logging.h"
#include "core/iconloader.h"
#include "playlist/playlistview.h"
#include "covermanager/albumcoverchoicecontroller.h"
const char *AppearanceSettingsPage::kSettingsGroup = "Appearance";
AppearanceSettingsPage::AppearanceSettingsPage(SettingsDialog *dialog)
: SettingsPage(dialog),
ui_(new Ui_AppearanceSettingsPage),
original_use_a_custom_color_set_(false),
playlist_view_background_image_type_(PlaylistView::Default) {
ui_->setupUi(this);
setWindowIcon(IconLoader::Load("view-media-visualization"));
connect(ui_->blur_slider, SIGNAL(valueChanged(int)), SLOT(BlurLevelChanged(int)));
connect(ui_->opacity_slider, SIGNAL(valueChanged(int)), SLOT(OpacityLevelChanged(int)));
Load();
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_->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_->use_default_background, SIGNAL(toggled(bool)), SLOT(DisableBlurAndOpacitySliders(bool)));
connect(ui_->use_no_background, SIGNAL(toggled(bool)), SLOT(DisableBlurAndOpacitySliders(bool)));
}
AppearanceSettingsPage::~AppearanceSettingsPage() {
delete ui_;
}
void AppearanceSettingsPage::Load() {
QSettings s;
s.beginGroup(kSettingsGroup);
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_foreground_color_ = s.value(Appearance::kForegroundColor, p.color(QPalette::WindowText)).value<QColor>();
current_foreground_color_ = original_foreground_color_;
original_background_color_ = s.value(Appearance::kBackgroundColor, p.color(QPalette::Window)).value<QColor>();
current_background_color_ = original_background_color_;
InitColorSelectorsColors();
s.endGroup();
// Playlist settings
s.beginGroup(kSettingsGroup);
playlist_view_background_image_type_ = static_cast<PlaylistView::BackgroundImageType>(s.value(PlaylistView::kSettingBackgroundImageType).toInt());
playlist_view_background_image_filename_ = s.value(PlaylistView::kSettingBackgroundImageFilename).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:
ui_->use_no_background->setChecked(true);
DisableBlurAndOpacitySliders(true);
break;
case PlaylistView::Album:
ui_->use_album_cover_background->setChecked(true);
break;
case PlaylistView::Custom:
ui_->use_custom_background_image->setChecked(true);
break;
case PlaylistView::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());
s.endGroup();
}
void AppearanceSettingsPage::Save() {
QSettings s;
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);
if (use_a_custom_color_set) {
s.setValue(Appearance::kBackgroundColor, current_background_color_);
s.setValue(Appearance::kForegroundColor, current_foreground_color_);
}
else {
dialog()->appearance()->ResetToSystemDefaultTheme();
}
playlist_view_background_image_filename_ = ui_->background_image_filename->text();
if (ui_->use_no_background->isChecked()) {
playlist_view_background_image_type_ = PlaylistView::None;
}
else if (ui_->use_album_cover_background->isChecked()) {
playlist_view_background_image_type_ = PlaylistView::Album;
}
else if (ui_->use_default_background->isChecked()) {
playlist_view_background_image_type_ = PlaylistView::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_);
}
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.endGroup();
}
void AppearanceSettingsPage::Cancel() {
if (original_use_a_custom_color_set_) {
dialog()->appearance()->ChangeForegroundColor(original_foreground_color_);
dialog()->appearance()->ChangeBackgroundColor(original_background_color_);
}
else {
dialog()->appearance()->ResetToSystemDefaultTheme();
}
}
void AppearanceSettingsPage::SelectForegroundColor() {
QColor color_selected = QColorDialog::getColor(current_foreground_color_);
if (!color_selected.isValid()) return;
current_foreground_color_ = color_selected;
dialog()->appearance()->ChangeForegroundColor(color_selected);
UpdateColorSelectorColor(ui_->select_foreground_color, color_selected);
}
void AppearanceSettingsPage::SelectBackgroundColor() {
QColor color_selected = QColorDialog::getColor(current_background_color_);
if (!color_selected.isValid()) return;
current_background_color_ = color_selected;
dialog()->appearance()->ChangeBackgroundColor(color_selected);
UpdateColorSelectorColor(ui_->select_background_color, color_selected);
}
void AppearanceSettingsPage::UseCustomColorSetOptionChanged(bool checked) {
if (checked) {
dialog()->appearance()->ChangeForegroundColor(current_foreground_color_);
dialog()->appearance()->ChangeBackgroundColor(current_background_color_);
}
else {
dialog()->appearance()->ResetToSystemDefaultTheme();
}
}
void AppearanceSettingsPage::InitColorSelectorsColors() {
UpdateColorSelectorColor(ui_->select_foreground_color, current_foreground_color_);
UpdateColorSelectorColor(ui_->select_background_color, current_background_color_);
}
void AppearanceSettingsPage::UpdateColorSelectorColor(QWidget *color_selector, const QColor &color) {
QString css = QString("background-color: rgb(%1, %2, %3); color: rgb(255, 255, 255)").arg(color.red()).arg(color.green()).arg(color.blue());
color_selector->setStyleSheet(css);
}
void AppearanceSettingsPage::SelectBackgroundImage() {
//qLog(Debug) << __PRETTY_FUNCTION__;
QString selected_filename = QFileDialog::getOpenFileName(this, tr("Select background image"), playlist_view_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_);
}
void AppearanceSettingsPage::BlurLevelChanged(int value) {
ui_->background_blur_radius_label->setText(QString("%1px").arg(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);
}

View File

@@ -0,0 +1,73 @@
/*
* Strawberry Music Player
* This file was part of Clementine.
* Copyright 2012, David Sansome <me@davidsansome.com>
*
* Strawberry 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.
*
* Strawberry 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 Strawberry. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef APPEARANCESETTINGSPAGE_H
#define APPEARANCESETTINGSPAGE_H
#include "config.h"
#include "settingspage.h"
#include "playlist/playlistview.h"
class QWidget;
class Ui_AppearanceSettingsPage;
class AppearanceSettingsPage : public SettingsPage {
Q_OBJECT
public:
AppearanceSettingsPage(SettingsDialog *dialog);
~AppearanceSettingsPage();
static const char *kSettingsGroup;
void Load();
void Save();
void Cancel();
private slots:
void SelectForegroundColor();
void SelectBackgroundColor();
void UseCustomColorSetOptionChanged(bool);
void SelectBackgroundImage();
void BlurLevelChanged(int);
void OpacityLevelChanged(int);
void DisableBlurAndOpacitySliders(bool);
private:
// Set the widget's background to new_color
void UpdateColorSelectorColor(QWidget *color_selector, const QColor &new_color);
// Init (or refresh) the colorSelectors colors
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_;
};
#endif // APPEARANCESETTINGSPAGE_H

View File

@@ -0,0 +1,307 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>AppearanceSettingsPage</class>
<widget class="QWidget" name="AppearanceSettingsPage">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>596</width>
<height>566</height>
</rect>
</property>
<property name="windowTitle">
<string>Appearance</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Colors</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QRadioButton" name="use_system_color_set">
<property name="text">
<string>Use the system default color set</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="use_a_custom_color_set">
<property name="text">
<string>Use a custom color set</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="select_foreground_color_label">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Select foreground color:</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="select_foreground_color">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="select_background_color_label">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Select background color:</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="select_background_color">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>Background image</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QRadioButton" name="use_default_background">
<property name="text">
<string>Default background image</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="use_album_cover_background">
<property name="toolTip">
<string>The album cover of the currently playing song</string>
</property>
<property name="text">
<string>Album cover</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="use_no_background">
<property name="text">
<string>No background image</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QRadioButton" name="use_custom_background_image">
<property name="text">
<string>Custom image:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="background_image_filename">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="select_background_image_filename_button">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Browse...</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="select_background_blur_label">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>Blur amount</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QSlider" name="blur_slider">
<property name="minimum">
<number>0</number>
</property>
<property name="maximum">
<number>10</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="tickPosition">
<enum>QSlider::TicksBelow</enum>
</property>
<property name="tickInterval">
<number>1</number>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QLabel" name="background_blur_radius_label">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>0px</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="select_opacity_level_label">
<property name="text">
<string>Opacity</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QSlider" name="opacity_slider">
<property name="maximum">
<number>100</number>
</property>
<property name="singleStep">
<number>10</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="tickPosition">
<enum>QSlider::TicksBelow</enum>
</property>
<property name="tickInterval">
<number>10</number>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QLabel" name="background_opacity_label">
<property name="text">
<string>40%</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>use_a_custom_color_set</sender>
<signal>toggled(bool)</signal>
<receiver>select_background_color</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>301</x>
<y>72</y>
</hint>
<hint type="destinationlabel">
<x>440</x>
<y>139</y>
</hint>
</hints>
</connection>
<connection>
<sender>use_a_custom_color_set</sender>
<signal>toggled(bool)</signal>
<receiver>select_background_color_label</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>301</x>
<y>72</y>
</hint>
<hint type="destinationlabel">
<x>162</x>
<y>139</y>
</hint>
</hints>
</connection>
<connection>
<sender>use_a_custom_color_set</sender>
<signal>toggled(bool)</signal>
<receiver>select_foreground_color</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>301</x>
<y>72</y>
</hint>
<hint type="destinationlabel">
<x>440</x>
<y>104</y>
</hint>
</hints>
</connection>
<connection>
<sender>use_a_custom_color_set</sender>
<signal>toggled(bool)</signal>
<receiver>select_foreground_color_label</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>301</x>
<y>72</y>
</hint>
<hint type="destinationlabel">
<x>162</x>
<y>104</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@@ -0,0 +1,550 @@
/*
* Strawberry Music Player
* Copyright 2013, Jonas Kvinge <jonas@strawbs.net>
*
* Strawberry 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.
*
* Strawberry 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 Strawberry. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include "config.h"
#include "backendsettingspage.h"
#include "ui_backendsettingspage.h"
#include <QVariant>
#include <QMessageBox>
#include <QErrorMessage>
#include "settingsdialog.h"
#include "core/application.h"
#include "core/player.h"
#include "core/logging.h"
#include "core/utilities.h"
#include "core/iconloader.h"
#include "engine/enginetype.h"
#include "engine/enginebase.h"
#include "engine/gstengine.h"
#include "engine/xineengine.h"
#include "engine/devicefinder.h"
const char *BackendSettingsPage::kSettingsGroup = "Backend";
const char *BackendSettingsPage::EngineText_Xine = "Xine";
const char *BackendSettingsPage::EngineText_GStreamer = "GStreamer";
const char *BackendSettingsPage::EngineText_Phonon = "Phonon";
const char *BackendSettingsPage::EngineText_VLC = "VLC";
BackendSettingsPage::BackendSettingsPage(SettingsDialog *dialog) : SettingsPage(dialog), ui_(new Ui_BackendSettingsPage) {
//qLog(Debug) << __PRETTY_FUNCTION__;
ui_->setupUi(this);
setWindowIcon(IconLoader::Load("soundcard"));
connect(ui_->combobox_engine, SIGNAL(currentIndexChanged(int)), SLOT(EngineChanged(int)));
connect(ui_->combobox_output, SIGNAL(currentIndexChanged(int)), SLOT(OutputChanged(int)));
connect(ui_->combobox_device, SIGNAL(currentIndexChanged(int)), SLOT(DeviceSelectionChanged(int)));
connect(ui_->lineedit_device, SIGNAL(textChanged(const QString &)), SLOT(DeviceStringChanged()));
connect(ui_->slider_bufferminfill, SIGNAL(valueChanged(int)), SLOT(BufferMinFillChanged(int)));
ui_->label_bufferminfillvalue->setMinimumWidth(QFontMetrics(ui_->label_bufferminfillvalue->font()).width("WW%"));
connect(ui_->stickslider_replaygainpreamp, SIGNAL(valueChanged(int)), SLOT(RgPreampChanged(int)));
ui_->label_replaygainpreamp->setMinimumWidth(QFontMetrics(ui_->label_replaygainpreamp->font()).width("-WW.W dB"));
RgPreampChanged(ui_->stickslider_replaygainpreamp->value());
s_.beginGroup(BackendSettingsPage::kSettingsGroup);
}
BackendSettingsPage::~BackendSettingsPage() {
//qLog(Debug) << __PRETTY_FUNCTION__;
//dialog()->app()->player()->CreateEngine(engineloaded_);
//dialog()->app()->player()->ReloadSettings();
//dialog()->app()->player()->Init();
s_.endGroup();
delete ui_;
}
void BackendSettingsPage::Load() {
//qLog(Debug) << __PRETTY_FUNCTION__;
configloaded_ = false;
engineloaded_ = Engine::None;
Engine::EngineType enginetype = Engine::EngineTypeFromName(s_.value("engine", EngineText_Xine).toString());
ui_->combobox_engine->clear();
#ifdef HAVE_XINE
ui_->combobox_engine->addItem(IconLoader::Load("xine"), EngineText_Xine, Engine::Xine);
#endif
#ifdef HAVE_GSTREAMER
ui_->combobox_engine->addItem(IconLoader::Load("gstreamer"), EngineText_GStreamer, Engine::GStreamer);
#endif
#ifdef HAVE_PHONON
ui_->combobox_engine->addItem(IconLoader::Load("speaker"), EngineText_Phonon, Engine::Phonon);
#endif
#ifdef HAVE_VLC
ui_->combobox_engine->addItem(IconLoader::Load("vlc"), EngineText_VLC, Engine::VLC);
#endif
configloaded_ = true;
ui_->combobox_engine->setCurrentIndex(ui_->combobox_engine->findData(enginetype));
if (enginetype != engineloaded_) Load_Engine(enginetype);
ui_->spinbox_bufferduration->setValue(s_.value("bufferduration", 4000).toInt());
ui_->checkbox_monoplayback->setChecked(s_.value("monoplayback", false).toBool());
ui_->slider_bufferminfill->setValue(s_.value("bufferminfill", 33).toInt());
ui_->checkbox_replaygain->setChecked(s_.value("rgenabled", false).toBool());
ui_->combobox_replaygainmode->setCurrentIndex(s_.value("rgmode", 0).toInt());
ui_->stickslider_replaygainpreamp->setValue(s_.value("rgpreamp", 0.0).toDouble() * 10 + 150);
ui_->checkbox_replaygaincompression->setChecked(s_.value("rgcompression", true).toBool());
}
void BackendSettingsPage::Load_Engine(Engine::EngineType enginetype) {
//qLog(Debug) << __PRETTY_FUNCTION__;
output_ = s_.value("output", "").toString();
device_ = s_.value("device", "").toString();
ui_->combobox_output->clear();
ui_->combobox_device->clear();
ui_->combobox_output->setEnabled(false);
ui_->combobox_device->setEnabled(false);
ui_->lineedit_device->setEnabled(false);
ui_->lineedit_device->setText("");
// If a engine is loaded (!= Engine::None) AND engine has been switched reset output and device.
if ((engineloaded_ != Engine::None) && (engineloaded_ != enginetype)) {
output_ = "";
device_ = "";
s_.setValue("output", "");
s_.setValue("device", "");
}
if (dialog()->app()->player()->engine()->type() != enginetype) {
dialog()->app()->player()->CreateEngine(enginetype);
dialog()->app()->player()->ReloadSettings();
dialog()->app()->player()->Init();
}
switch(enginetype) {
#ifdef HAVE_XINE
case Engine::Xine:
Xine_Load();
break;
#endif
#ifdef HAVE_GSTREAMER
case Engine::GStreamer:
Gst_Load();
break;
#endif
#ifdef HAVE_PHONON
case Engine::Phonon:
Phonon_Load();
break;
#endif
#ifdef HAVE_VLC
case Engine::VLC:
VLC_Load();
break;
#endif
default:
QMessageBox messageBox;
QString msg = QString("Missing engine %1!").arg(Engine::EngineNameFromType(enginetype));
messageBox.critical(nullptr, "Error", msg);
messageBox.setFixedSize(500, 200);
return;
}
}
void BackendSettingsPage::Load_Device(QString output) {
//qLog(Debug) << __PRETTY_FUNCTION__;
ui_->combobox_device->setEnabled(false);
ui_->combobox_device->clear();
ui_->lineedit_device->setEnabled(false);
ui_->lineedit_device->setText("");
ui_->combobox_device->addItem(IconLoader::Load("soundcard"), "Automatically select", "");
ui_->combobox_device->addItem(IconLoader::Load("soundcard"), "Custom", "");
int i = 0;
for (DeviceFinder *finder : dialog()->app()->enginedevice()->device_finders_) {
if (finder->output() != output) continue;
for (const DeviceFinder::Device &device : finder->ListDevices()) {
i++;
ui_->combobox_device->addItem(IconLoader::Load(device.iconname), device.description, device.string);
}
}
if (i > 0) {
ui_->combobox_device->setEnabled(true);
ui_->lineedit_device->setEnabled(true);
ui_->lineedit_device->setText(device_);
}
}
#ifdef HAVE_GSTREAMER
void BackendSettingsPage::Gst_Load() {
//qLog(Debug) << __PRETTY_FUNCTION__;
if (output_ == "") output_ = GstEngine::kAutoSink;
if (dialog()->app()->player()->engine()->type() != Engine::GStreamer) {
QMessageBox messageBox;
messageBox.critical(nullptr, "Error", "GStramer not initialized! Please restart.");
messageBox.setFixedSize(500, 200);
return;
}
GstEngine *gstengine = qobject_cast<GstEngine*>(dialog()->app()->player()->engine());
ui_->combobox_output->clear();
int i = 0;
for (const EngineBase::OutputDetails &output : gstengine->GetOutputsList()) {
i++;
ui_->combobox_output->addItem(IconLoader::Load(output.iconname), output.description, QVariant::fromValue(output));
//qLog(Debug) << output.description;
}
if (i > 0) ui_->combobox_output->setEnabled(true);
for (int i = 0; i < ui_->combobox_output->count(); ++i) {
EngineBase::OutputDetails details = ui_->combobox_output->itemData(i).value<EngineBase::OutputDetails>();
if (details.name == output_) {
ui_->combobox_output->setCurrentIndex(i);
break;
}
}
engineloaded_=Engine::GStreamer;
}
#endif
#ifdef HAVE_XINE
void BackendSettingsPage::Xine_Load() {
//qLog(Debug) << __PRETTY_FUNCTION__;
if (output_ == "") output_ = "auto";
if (dialog()->app()->player()->engine()->type() != Engine::Xine) {
QMessageBox messageBox;
messageBox.critical(nullptr, "Error", "Xine not initialized! Please restart.");
messageBox.setFixedSize(500, 200);
return;
}
XineEngine *xineengine = qobject_cast<XineEngine*>(dialog()->app()->player()->engine());
ui_->combobox_output->clear();
int i = 0;
for (const EngineBase::OutputDetails &output : xineengine->GetOutputsList()) {
i++;
ui_->combobox_output->addItem(IconLoader::Load(output.iconname), output.description, QVariant::fromValue(output));
//qLog(Debug) << output.description;
}
if (i > 0) ui_->combobox_output->setEnabled(true);
for (int i = 0; i < ui_->combobox_output->count(); ++i) {
EngineBase::OutputDetails details = ui_->combobox_output->itemData(i).value<EngineBase::OutputDetails>();
if (details.name == output_) {
ui_->combobox_output->setCurrentIndex(i);
break;
}
}
engineloaded_=Engine::Xine;
}
#endif
#ifdef HAVE_PHONON
void BackendSettingsPage::Phonon_Load() {
//qLog(Debug) << __PRETTY_FUNCTION__;
ui_->combobox_output->clear();
ui_->combobox_device->clear();
ui_->lineedit_device->setText("");
engineloaded_=Engine::Phonon;
}
#endif
#ifdef HAVE_VLC
void BackendSettingsPage::VLC_Load() {
//qLog(Debug) << __PRETTY_FUNCTION__;
ui_->combobox_output->clear();
ui_->combobox_device->clear();
ui_->lineedit_device->setText("");
engineloaded_=Engine::VLC;
}
#endif
void BackendSettingsPage::Save() {
//qLog(Debug) << __PRETTY_FUNCTION__;
s_.setValue("engine", ui_->combobox_engine->itemText(ui_->combobox_engine->currentIndex()).toLower());
QVariant myVariant = ui_->combobox_engine->itemData(ui_->combobox_engine->currentIndex());
Engine::EngineType enginetype = myVariant.value<Engine::EngineType>();
switch(enginetype) {
#ifdef HAVE_XINE
case Engine::Xine:
Xine_Save();
break;
#endif
#ifdef HAVE_GSTREAMER
case Engine::GStreamer:
Gst_Save();
break;
#endif
#ifdef HAVE_PHONON
case Engine::Phonon:
Phonon_Save();
break;
#endif
#ifdef HAVE_VLC
case Engine::VLC:
VLC_Save();
break;
#endif
default:
break;
}
s_.setValue("device", ui_->lineedit_device->text());
s_.setValue("bufferduration", ui_->spinbox_bufferduration->value());
s_.setValue("monoplayback", ui_->checkbox_monoplayback->isChecked());
s_.setValue("bufferminfill", ui_->slider_bufferminfill->value());
s_.setValue("rgenabled", ui_->checkbox_replaygain->isChecked());
s_.setValue("rgmode", ui_->combobox_replaygainmode->currentIndex());
s_.setValue("rgpreamp", float(ui_->stickslider_replaygainpreamp->value()) / 10 - 15);
s_.setValue("rgcompression", ui_->checkbox_replaygaincompression->isChecked());
}
#ifdef HAVE_XINE
void BackendSettingsPage::Xine_Save() {
//qLog(Debug) << __PRETTY_FUNCTION__;
XineEngine *xineengine = qobject_cast<XineEngine*>(dialog()->app()->player()->engine());
EngineBase::OutputDetails output = ui_->combobox_output->itemData(ui_->combobox_output->currentIndex()).value<EngineBase::OutputDetails>();
s_.setValue("output", output.name);
for (EngineBase::OutputDetails &output : xineengine->GetOutputsList()) {
if (xineengine->ALSADeviceSupport(output.name)) output.device_property_value = QVariant(ui_->lineedit_device->text());
else output.device_property_value = QVariant(ui_->combobox_device->itemData(ui_->combobox_device->currentIndex()));
}
}
#endif
#ifdef HAVE_GSTREAMER
void BackendSettingsPage::Gst_Save() {
//qLog(Debug) << __PRETTY_FUNCTION__;
GstEngine *gstengine = qobject_cast<GstEngine*>(dialog()->app()->player()->engine());
EngineBase::OutputDetails output = ui_->combobox_output->itemData(ui_->combobox_output->currentIndex()).value<EngineBase::OutputDetails>();
s_.setValue("output", output.name);
for (EngineBase::OutputDetails &output : gstengine->GetOutputsList()) {
if (GstEngine::ALSADeviceSupport(output.name)) output.device_property_value = QVariant(ui_->lineedit_device->text());
else output.device_property_value = QVariant(ui_->combobox_device->itemData(ui_->combobox_device->currentIndex()));
}
}
#endif
#ifdef HAVE_PHONON
void BackendSettingsPage::Phonon_Save() {
//qLog(Debug) << __PRETTY_FUNCTION__;
}
#endif
#ifdef HAVE_VLC
void BackendSettingsPage::VLC_Save() {
//qLog(Debug) << __PRETTY_FUNCTION__;
}
#endif
void BackendSettingsPage::EngineChanged(int index) {
if (configloaded_ == false) return;
//qLog(Debug) << __PRETTY_FUNCTION__;
QVariant myVariant = ui_->combobox_engine->itemData(index);
Engine::EngineType enginetype = myVariant.value<Engine::EngineType>();
Load_Engine(enginetype);
}
void BackendSettingsPage::OutputChanged(int index) {
//qLog(Debug) << __PRETTY_FUNCTION__;
QVariant myVariant = ui_->combobox_engine->itemData(ui_->combobox_engine->currentIndex());
Engine::EngineType enginetype = myVariant.value<Engine::EngineType>();
OutputChanged(index, enginetype);
}
void BackendSettingsPage::OutputChanged(int index, Engine::EngineType enginetype) {
//qLog(Debug) << __PRETTY_FUNCTION__;
switch(enginetype) {
case Engine::Xine:
#ifdef HAVE_XINE
Xine_OutputChanged(index);
break;
#endif
case Engine::GStreamer:
#ifdef HAVE_GSTREAMER
Gst_OutputChanged(index);
break;
#endif
case Engine::Phonon:
#ifdef HAVE_PHONON
Phonon_OutputChanged(index);
break;
#endif
case Engine::VLC:
#ifdef HAVE_VLC
VLC_OutputChanged(index);
break;
#endif
default:
break;
}
}
#ifdef HAVE_XINE
void BackendSettingsPage::Xine_OutputChanged(int index) {
//qLog(Debug) << __PRETTY_FUNCTION__;
EngineBase::OutputDetails details = ui_->combobox_output->itemData(index).value<EngineBase::OutputDetails>();
QString name = details.name;
if (XineEngine::ALSADeviceSupport(name)) Load_Device("alsa");
else Load_Device(name);
}
#endif
#ifdef HAVE_GSTREAMER
void BackendSettingsPage::Gst_OutputChanged(int index) {
//qLog(Debug) << __PRETTY_FUNCTION__;
EngineBase::OutputDetails details = ui_->combobox_output->itemData(index).value<EngineBase::OutputDetails>();
QString name = details.name;
if (GstEngine::ALSADeviceSupport(name)) Load_Device("alsa");
else Load_Device(name);
}
#endif
#ifdef HAVE_PHONON
void BackendSettingsPage::Phonon_OutputChanged(int index) {
//qLog(Debug) << __PRETTY_FUNCTION__;
Load_Device("");
}
#endif
#ifdef HAVE_VLC
void BackendSettingsPage::VLC_OutputChanged(int index) {
//qLog(Debug) << __PRETTY_FUNCTION__;
Load_Device("");
}
#endif
void BackendSettingsPage::DeviceSelectionChanged(int index) {
//qLog(Debug) << __PRETTY_FUNCTION__;
if (index == 1) return;
QString string = ui_->combobox_device->itemData(index).value<QString>();
ui_->lineedit_device->setText(string);
}
void BackendSettingsPage::DeviceStringChanged() {
//qLog(Debug) << __PRETTY_FUNCTION__;
QString string = ui_->lineedit_device->text();
for (int i = 0; i < ui_->combobox_device->count(); ++i) {
QString s = ui_->combobox_device->itemData(i).value<QString>();
if (s == string ) {
ui_->combobox_device->setCurrentIndex(i);
return;
}
}
ui_->combobox_device->setCurrentIndex(1);
}
void BackendSettingsPage::RgPreampChanged(int value) {
//qLog(Debug) << __PRETTY_FUNCTION__;
float db = float(value) / 10 - 15;
QString db_str;
db_str.sprintf("%+.1f dB", db);
ui_->label_replaygainpreamp->setText(db_str);
}
void BackendSettingsPage::BufferMinFillChanged(int value) {
//qLog(Debug) << __PRETTY_FUNCTION__;
ui_->label_bufferminfillvalue->setText(QString::number(value) + "%");
}

View File

@@ -0,0 +1,102 @@
/*
* Strawberry Music Player
* Copyright 2013, Jonas Kvinge <jonas@strawbs.net>
*
* Strawberry 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.
*
* Strawberry 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 Strawberry. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef BACKENDSETTINGSPAGE_H
#define BACKENDSETTINGSPAGE_H
#include "config.h"
#include <QString>
#include <QSettings>
#include "backendsettingspage.h"
#include "settingspage.h"
#include "engine/engine_fwd.h"
#include "engine/enginetype.h"
class Ui_BackendSettingsPage;
class BackendSettingsPage : public SettingsPage {
Q_OBJECT
public:
BackendSettingsPage(SettingsDialog *dialog);
~BackendSettingsPage();
static const char *kSettingsGroup;
static const char *EngineText_Xine;
static const char *EngineText_GStreamer;
static const char *EngineText_Phonon;
static const char *EngineText_VLC;
void Load();
void Save();
private slots:
void EngineChanged(int index);
void OutputChanged(int index);
void DeviceSelectionChanged(int index);
void DeviceStringChanged();
void RgPreampChanged(int value);
void BufferMinFillChanged(int value);
private:
Ui_BackendSettingsPage *ui_;
void EngineChanged(Engine::EngineType enginetype);
void OutputChanged(int index, Engine::EngineType enginetype);
void Load_Engine(Engine::EngineType enginetype);
void Load_Device(QString output);
#ifdef HAVE_XINE
void Xine_Load();
void Xine_Save();
void Xine_OutputChanged(int index);
#endif
#ifdef HAVE_GSTREAMER
void Gst_Load();
void Gst_Save();
void Gst_OutputChanged(int index);
#endif
#ifdef HAVE_PHONON
void Phonon_Load();
void Phonon_Save();
void Phonon_OutputChanged(int index);
#endif
#ifdef HAVE_VLC
void VLC_Load();
void VLC_Save();
void VLC_OutputChanged(int index);
#endif
bool configloaded_;
Engine::EngineType engineloaded_;
QString output_;
QString device_;
QSettings s_;
};
#endif // BACKENDSETTINGSPAGE_H

View File

@@ -0,0 +1,299 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>BackendSettingsPage</class>
<widget class="QWidget" name="BackendSettingsPage">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>596</width>
<height>638</height>
</rect>
</property>
<property name="windowTitle">
<string>Backend</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QGroupBox" name="groupbox_output">
<property name="title">
<string>Audio output</string>
</property>
<layout class="QFormLayout" name="formLayout_3">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label_engine">
<property name="text">
<string>Engine</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="combobox_engine"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_output">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>Output</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="combobox_output">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_device">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>Device</string>
</property>
</widget>
</item>
<item row="3" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_device" stretch="0,0">
<item>
<widget class="QComboBox" name="combobox_device">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="LineEdit" name="lineedit_device" native="true">
<property name="enabled">
<bool>false</bool>
</property>
<property name="maximumSize">
<size>
<width>80</width>
<height>16777215</height>
</size>
</property>
<property name="sizeIncrement">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="baseSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="toolTip">
<string extracomment="Leave blank for the default."/>
</property>
<property name="hint" stdset="0">
<string/>
</property>
</widget>
</item>
</layout>
</item>
<item row="6" column="0">
<widget class="QLabel" name="label_bufferduration">
<property name="text">
<string>Buffer duration</string>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QSpinBox" name="spinbox_bufferduration">
<property name="suffix">
<string> ms</string>
</property>
<property name="maximum">
<number>60000</number>
</property>
<property name="singleStep">
<number>100</number>
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QLabel" name="label_bufferminfill">
<property name="text">
<string>Minimum buffer fill</string>
</property>
</widget>
</item>
<item row="7" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_buffer">
<item>
<widget class="QLabel" name="label_bufferminfillvalue">
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<widget class="QSlider" name="slider_bufferminfill">
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>50</number>
</property>
<property name="value">
<number>33</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="tickInterval">
<number>1</number>
</property>
</widget>
</item>
</layout>
</item>
<item row="8" column="0" colspan="2">
<widget class="QCheckBox" name="checkbox_monoplayback">
<property name="toolTip">
<string>Changing mono playback preference will be effective for the next playing songs</string>
</property>
<property name="text">
<string>Mono playback</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupbox_replaygain">
<property name="title">
<string>Replay Gain</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QCheckBox" name="checkbox_replaygain">
<property name="text">
<string>Use Replay Gain metadata if it is available</string>
</property>
</widget>
</item>
<item>
<widget class="QWidget" name="widget" native="true">
<property name="enabled">
<bool>false</bool>
</property>
<layout class="QFormLayout" name="formLayout_4">
<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 row="0" column="0">
<widget class="QLabel" name="label_regainmode">
<property name="text">
<string>Replay Gain mode</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="combobox_replaygainmode">
<item>
<property name="text">
<string>Radio (equal loudness for all tracks)</string>
</property>
</item>
<item>
<property name="text">
<string>Album (ideal loudness for all tracks)</string>
</property>
</item>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_preamp">
<property name="text">
<string>Pre-amp</string>
</property>
</widget>
</item>
<item row="1" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QLabel" name="label_replaygainpreamp"/>
</item>
<item>
<widget class="StickySlider" name="stickslider_replaygainpreamp">
<property name="maximum">
<number>300</number>
</property>
<property name="value">
<number>150</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sticky_center" stdset="0">
<number>150</number>
</property>
</widget>
</item>
</layout>
</item>
<item row="2" column="0" colspan="2">
<widget class="QCheckBox" name="checkbox_replaygaincompression">
<property name="text">
<string>Apply compression to prevent clipping</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>114</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>StickySlider</class>
<extends>QSlider</extends>
<header>widgets/stickyslider.h</header>
</customwidget>
<customwidget>
<class>LineEdit</class>
<extends>QWidget</extends>
<header>widgets/lineedit.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

View File

@@ -0,0 +1,108 @@
/*
* Strawberry Music Player
* This file was part of Clementine.
* Copyright 2010, David Sansome <me@davidsansome.com>
*
* Strawberry 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.
*
* Strawberry 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 Strawberry. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include "config.h"
#include <QDir>
#include "behavioursettingspage.h"
#include "core/iconloader.h"
#include "core/mainwindow.h"
#include "ui_behavioursettingspage.h"
const char *BehaviourSettingsPage::kSettingsGroup = "Behaviour";
namespace {
bool LocaleAwareCompare(const QString& a, const QString& b) {
return a.localeAwareCompare(b) < 0;
}
} // namespace
BehaviourSettingsPage::BehaviourSettingsPage(SettingsDialog *dialog) : SettingsPage(dialog), ui_(new Ui_BehaviourSettingsPage) {
ui_->setupUi(this);
setWindowIcon(IconLoader::Load("strawberry"));
connect(ui_->checkbox_showtrayicon, SIGNAL(toggled(bool)), SLOT(ShowTrayIconToggled(bool)));
#ifdef Q_OS_DARWIN
ui_->checkbox_showtrayicon->setEnabled(false);
ui_->startup_group->setEnabled(false);
#endif
}
BehaviourSettingsPage::~BehaviourSettingsPage() {
delete ui_;
}
void BehaviourSettingsPage::Load() {
QSettings s;
s.beginGroup(kSettingsGroup);
ui_->checkbox_showtrayicon->setChecked(s.value("showtrayicon", true).toBool());
ui_->checkbox_scrolltrayicon->setChecked(s.value("scrolltrayicon", ui_->checkbox_showtrayicon->isChecked()).toBool());
ui_->checkbox_keeprunning->setChecked(s.value("keeprunning", false).toBool());
MainWindow::StartupBehaviour behaviour = MainWindow::StartupBehaviour(s.value("startupbehaviour", MainWindow::Startup_Remember).toInt());
switch (behaviour) {
case MainWindow::Startup_AlwaysHide: ui_->radiobutton_alwayshide->setChecked(true); break;
case MainWindow::Startup_AlwaysShow: ui_->radiobutton_alwaysshow->setChecked(true); break;
case MainWindow::Startup_Remember: ui_->radiobutton_remember->setChecked(true); break;
}
ui_->checkbox_resumeplayback->setChecked(s.value("resumeplayback", false).toBool());
ui_->spinbox_seekstepsec->setValue(s.value("seek_step_sec", 10).toInt());
s.endGroup();
}
void BehaviourSettingsPage::Save() {
QSettings s;
MainWindow::StartupBehaviour behaviour = MainWindow::Startup_Remember;
if (ui_->radiobutton_alwayshide->isChecked()) behaviour = MainWindow::Startup_AlwaysHide;
if (ui_->radiobutton_alwaysshow->isChecked()) behaviour = MainWindow::Startup_AlwaysShow;
if (ui_->radiobutton_remember->isChecked()) behaviour = MainWindow::Startup_Remember;
s.beginGroup(kSettingsGroup);
s.setValue("showtrayicon", ui_->checkbox_showtrayicon->isChecked());
s.setValue("scrolltrayicon", ui_->checkbox_scrolltrayicon->isChecked());
s.setValue("keeprunning", ui_->checkbox_keeprunning->isChecked());
s.setValue("startupbehaviour", int(behaviour));
s.setValue("resumeplayback", ui_->checkbox_resumeplayback->isChecked());
s.endGroup();
}
void BehaviourSettingsPage::ShowTrayIconToggled(bool on) {
ui_->radiobutton_alwayshide->setEnabled(on);
if (!on && ui_->radiobutton_alwayshide->isChecked()) ui_->radiobutton_remember->setChecked(true);
ui_->checkbox_keeprunning->setEnabled(on);
ui_->checkbox_keeprunning->setChecked(on);
ui_->checkbox_scrolltrayicon->setEnabled(on);
}

View File

@@ -0,0 +1,51 @@
/*
* Strawberry Music Player
* This file was part of Clementine.
* Copyright 2010, David Sansome <me@davidsansome.com>
*
* Strawberry 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.
*
* Strawberry 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 Strawberry. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef BEHAVIOURSETTINGSPAGE_H
#define BEHAVIOURSETTINGSPAGE_H
#include "config.h"
#include "settingspage.h"
#include <QMap>
class Ui_BehaviourSettingsPage;
class BehaviourSettingsPage : public SettingsPage {
Q_OBJECT
public:
BehaviourSettingsPage(SettingsDialog *dialog);
~BehaviourSettingsPage();
static const char *kSettingsGroup;
void Load();
void Save();
private slots:
void ShowTrayIconToggled(bool on);
private:
Ui_BehaviourSettingsPage *ui_;
};
#endif // BEHAVIOURSETTINGSPAGE_H

View File

@@ -0,0 +1,178 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>BehaviourSettingsPage</class>
<widget class="QWidget" name="BehaviourSettingsPage">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>516</width>
<height>851</height>
</rect>
</property>
<property name="windowTitle">
<string>Behavior</string>
</property>
<layout class="QVBoxLayout" name="layout_showtrayicon">
<item>
<widget class="QCheckBox" name="checkbox_showtrayicon">
<property name="text">
<string>Show system tray icon</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkbox_scrolltrayicon">
<property name="text">
<string>Scroll over icon to change track</string>
</property>
<property name="checked">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkbox_keeprunning">
<property name="text">
<string>Keep running in the background when the window is closed</string>
</property>
<property name="checked">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupbox_startupgroup">
<property name="title">
<string>When Strawberry starts</string>
</property>
<layout class="QVBoxLayout" name="layout_mainwindow">
<item>
<widget class="QRadioButton" name="radiobutton_alwaysshow">
<property name="text">
<string>Always show the main window</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radiobutton_alwayshide">
<property name="text">
<string>Always hide the main window</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radiobutton_remember">
<property name="text">
<string>Remember from last time</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="spacer_1">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>10</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QCheckBox" name="checkbox_resumeplayback">
<property name="text">
<string>Resume playback on start</string>
</property>
<property name="checked">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupbox_seekstep">
<property name="title">
<string>Seeking using a keyboard shortcut or mouse wheel</string>
</property>
<layout class="QHBoxLayout" name="layout_seekstep">
<item>
<widget class="QLabel" name="label_seekstep">
<property name="text">
<string>Time step</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="spinbox_seekstepsec">
<property name="suffix">
<string> s</string>
</property>
<property name="prefix">
<string/>
</property>
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>20</number>
</property>
<property name="value">
<number>10</number>
</property>
</widget>
</item>
<item>
<spacer name="spacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="spacer_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>5</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@@ -0,0 +1,131 @@
/*
* Strawberry Music Player
* This file was part of Clementine.
* Copyright 2010, David Sansome <me@davidsansome.com>
*
* Strawberry 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.
*
* Strawberry 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 Strawberry. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include "config.h"
#include <QDir>
#include <QFileDialog>
#include <QMessageBox>
#include <QSettings>
#include <QtConcurrentRun>
#include "collectionsettingspage.h"
#include "ui_collectionsettingspage.h"
#include "settings/settingsdialog.h"
#include "core/application.h"
#include "core/utilities.h"
#include "core/iconloader.h"
#include "playlist/playlistdelegates.h"
#include "collection/collectionbackend.h"
#include "collection/collectiondirectorymodel.h"
#include "collection/collectionmodel.h"
#include "collection/collectionview.h"
#include "collection/collectionwatcher.h"
const char *CollectionSettingsPage::kSettingsGroup = "Collection";
CollectionSettingsPage::CollectionSettingsPage(SettingsDialog* dialog)
: SettingsPage(dialog),
ui_(new Ui_CollectionSettingsPage),
initialised_model_(false) {
ui_->setupUi(this);
ui_->list->setItemDelegate(new NativeSeparatorsDelegate(this));
// Icons
setWindowIcon(IconLoader::Load("vinyl"));
ui_->add->setIcon(IconLoader::Load("document-open-folder"));
connect(ui_->add, SIGNAL(clicked()), SLOT(Add()));
connect(ui_->remove, SIGNAL(clicked()), SLOT(Remove()));
}
CollectionSettingsPage::~CollectionSettingsPage() { delete ui_; }
void CollectionSettingsPage::Add() {
QSettings settings;
settings.beginGroup(kSettingsGroup);
QString path(settings.value("last_path", Utilities::GetConfigPath(Utilities::Path_DefaultMusicCollection)).toString());
path = QFileDialog::getExistingDirectory(this, tr("Add directory..."), path);
if (!path.isNull()) {
dialog()->collection_directory_model()->AddDirectory(path);
}
settings.setValue("last_path", path);
}
void CollectionSettingsPage::Remove() {
dialog()->collection_directory_model()->RemoveDirectory(ui_->list->currentIndex());
}
void CollectionSettingsPage::CurrentRowChanged(const QModelIndex& index) {
ui_->remove->setEnabled(index.isValid());
}
void CollectionSettingsPage::Save() {
QSettings s;
s.beginGroup(kSettingsGroup);
s.setValue("auto_open", ui_->auto_open->isChecked());
s.setValue("pretty_covers", ui_->pretty_covers->isChecked());
s.setValue("show_dividers", ui_->show_dividers->isChecked());
s.setValue("startup_scan", ui_->startup_scan->isChecked());
s.setValue("monitor", ui_->monitor->isChecked());
QString filter_text = ui_->cover_art_patterns->text();
QStringList filters = filter_text.split(',', QString::SkipEmptyParts);
s.setValue("cover_art_patterns", filters);
s.endGroup();
}
void CollectionSettingsPage::Load() {
if (!initialised_model_) {
if (ui_->list->selectionModel()) {
disconnect(ui_->list->selectionModel(), SIGNAL(currentRowChanged(QModelIndex, QModelIndex)), this, SLOT(CurrentRowChanged(QModelIndex)));
}
ui_->list->setModel(dialog()->collection_directory_model());
initialised_model_ = true;
connect(ui_->list->selectionModel(), SIGNAL(currentRowChanged(QModelIndex, QModelIndex)), SLOT(CurrentRowChanged(QModelIndex)));
}
QSettings s;
s.beginGroup(kSettingsGroup);
ui_->auto_open->setChecked(s.value("auto_open", true).toBool());
ui_->pretty_covers->setChecked(s.value("pretty_covers", true).toBool());
ui_->show_dividers->setChecked(s.value("show_dividers", true).toBool());
ui_->startup_scan->setChecked(s.value("startup_scan", true).toBool());
ui_->monitor->setChecked(s.value("monitor", true).toBool());
QStringList filters = s.value("cover_art_patterns", QStringList() << "front" << "cover").toStringList();
ui_->cover_art_patterns->setText(filters.join(","));
s.endGroup();
}

View File

@@ -0,0 +1,56 @@
/*
* Strawberry Music Player
* This file was part of Clementine.
* Copyright 2010, David Sansome <me@davidsansome.com>
*
* Strawberry 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.
*
* Strawberry 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 Strawberry. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef LIBRARYSETTINGSPAGE_H
#define LIBRARYSETTINGSPAGE_H
#include "config.h"
#include "settingspage.h"
class Ui_CollectionSettingsPage;
class CollectionDirectoryModel;
class QModelIndex;
class CollectionSettingsPage : public SettingsPage {
Q_OBJECT
public:
CollectionSettingsPage(SettingsDialog *dialog);
~CollectionSettingsPage();
static const char *kSettingsGroup;
void Load();
void Save();
private slots:
void Add();
void Remove();
void CurrentRowChanged(const QModelIndex &index);
private:
Ui_CollectionSettingsPage *ui_;
bool initialised_model_;
};
#endif // LIBRARYSETTINGSPAGE_H

View File

@@ -0,0 +1,152 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>CollectionSettingsPage</class>
<widget class="QWidget" name="CollectionSettingsPage">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>509</width>
<height>452</height>
</rect>
</property>
<property name="windowTitle">
<string>Collection</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>These folders will be scanned for music to make up your collection</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QListView" name="list">
<property name="iconSize">
<size>
<width>16</width>
<height>16</height>
</size>
</property>
<property name="uniformItemSizes">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QPushButton" name="add">
<property name="text">
<string>Add new folder...</string>
</property>
<property name="flat">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="remove">
<property name="text">
<string>Remove folder</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</item>
<item>
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>Automatic updating</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<widget class="QCheckBox" name="startup_scan">
<property name="text">
<string>Update the collection when Strawberry starts</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="monitor">
<property name="text">
<string>Monitor the collection for changes</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>Preferred album art filenames (comma separated)</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="cover_art_patterns">
<property name="toolTip">
<string>When looking for album art Strawberry will first look for picture files that contain one of these words.
If there are no matches then it will use the largest image in the directory.</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Display options</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QCheckBox" name="auto_open">
<property name="text">
<string>Automatically open single categories in the collection tree</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="pretty_covers">
<property name="text">
<string>Show album cover art in collection</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="show_dividers">
<property name="text">
<string>Show dividers</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<tabstops>
<tabstop>list</tabstop>
<tabstop>add</tabstop>
<tabstop>remove</tabstop>
</tabstops>
<resources/>
<connections/>
</ui>

View File

@@ -0,0 +1,94 @@
/*
* Strawberry Music Player
* This file was part of Clementine.
* Copyright 2010, David Sansome <me@davidsansome.com>
*
* Strawberry 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.
*
* Strawberry 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 Strawberry. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include "config.h"
#include "networkproxysettingspage.h"
#include "ui_networkproxysettingspage.h"
#include "core/iconloader.h"
#include "core/networkproxyfactory.h"
#include <QSettings>
const char *NetworkProxySettingsPage::kSettingsGroup = "NetworkProxy";
NetworkProxySettingsPage::NetworkProxySettingsPage(SettingsDialog* dialog)
: SettingsPage(dialog), ui_(new Ui_NetworkProxySettingsPage) {
ui_->setupUi(this);
setWindowIcon(IconLoader::Load("applications-internet"));
}
NetworkProxySettingsPage::~NetworkProxySettingsPage() { delete ui_; }
void NetworkProxySettingsPage::Load() {
QSettings s;
s.beginGroup(NetworkProxyFactory::kSettingsGroup);
NetworkProxyFactory::Mode mode = NetworkProxyFactory::Mode(s.value("mode", NetworkProxyFactory::Mode_System).toInt());
switch (mode) {
case NetworkProxyFactory::Mode_Manual:
ui_->proxy_manual->setChecked(true);
break;
case NetworkProxyFactory::Mode_Direct:
ui_->proxy_direct->setChecked(true);
break;
case NetworkProxyFactory::Mode_System:
default:
ui_->proxy_system->setChecked(true);
break;
}
ui_->proxy_type->setCurrentIndex(s.value("type", QNetworkProxy::HttpProxy).toInt() == QNetworkProxy::HttpProxy ? 0 : 1);
ui_->proxy_hostname->setText(s.value("hostname").toString());
ui_->proxy_port->setValue(s.value("port").toInt());
ui_->proxy_auth->setChecked(s.value("use_authentication", false).toBool());
ui_->proxy_username->setText(s.value("username").toString());
ui_->proxy_password->setText(s.value("password").toString());
s.endGroup();
}
void NetworkProxySettingsPage::Save() {
QSettings s;
NetworkProxyFactory::Mode mode = NetworkProxyFactory::Mode_System;
if (ui_->proxy_direct->isChecked()) mode = NetworkProxyFactory::Mode_Direct;
else if (ui_->proxy_system->isChecked()) mode = NetworkProxyFactory::Mode_System;
else if (ui_->proxy_manual->isChecked()) mode = NetworkProxyFactory::Mode_Manual;
s.beginGroup(NetworkProxyFactory::kSettingsGroup);
s.setValue("mode", mode);
s.setValue("type", ui_->proxy_type->currentIndex() == 0 ? QNetworkProxy::HttpProxy : QNetworkProxy::Socks5Proxy);
s.setValue("hostname", ui_->proxy_hostname->text());
s.setValue("port", ui_->proxy_port->value());
s.setValue("use_authentication", ui_->proxy_auth->isChecked());
s.setValue("username", ui_->proxy_username->text());
s.setValue("password", ui_->proxy_password->text());
s.endGroup();
NetworkProxyFactory::Instance()->ReloadSettings();
}

View File

@@ -0,0 +1,45 @@
/*
* Strawberry Music Player
* This file was part of Clementine.
* Copyright 2010, David Sansome <me@davidsansome.com>
*
* Strawberry 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.
*
* Strawberry 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 Strawberry. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef NETWORKPROXYSETTINGSPAGE_H
#define NETWORKPROXYSETTINGSPAGE_H
#include "config.h"
#include "settingspage.h"
class Ui_NetworkProxySettingsPage;
class NetworkProxySettingsPage : public SettingsPage {
Q_OBJECT
public:
NetworkProxySettingsPage(SettingsDialog* dialog);
~NetworkProxySettingsPage();
static const char *kSettingsGroup;
void Load();
void Save();
private:
Ui_NetworkProxySettingsPage* ui_;
};
#endif // NETWORKPROXYSETTINGSPAGE_H

View File

@@ -0,0 +1,167 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>NetworkProxySettingsPage</class>
<widget class="QWidget" name="NetworkProxySettingsPage">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Network Proxy</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QRadioButton" name="proxy_system">
<property name="text">
<string>Use the system proxy settings</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="proxy_direct">
<property name="text">
<string>Direct internet connection</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="proxy_manual">
<property name="text">
<string>Manual proxy configuration</string>
</property>
</widget>
</item>
<item>
<widget class="QWidget" name="proxy_manual_container" native="true">
<property name="enabled">
<bool>false</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout_5">
<property name="leftMargin">
<number>24</number>
</property>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QComboBox" name="proxy_type">
<item>
<property name="text">
<string>HTTP proxy</string>
</property>
</item>
<item>
<property name="text">
<string>SOCKS proxy</string>
</property>
</item>
</widget>
</item>
<item>
<widget class="QLineEdit" name="proxy_hostname"/>
</item>
<item>
<widget class="QLabel" name="label_15">
<property name="text">
<string>Port</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="proxy_port">
<property name="maximum">
<number>65535</number>
</property>
<property name="value">
<number>8080</number>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QGroupBox" name="proxy_auth">
<property name="title">
<string>Use authentication</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>false</bool>
</property>
<layout class="QFormLayout" name="formLayout_7">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label_16">
<property name="text">
<string>Username</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="proxy_username"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_17">
<property name="text">
<string>Password</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="proxy_password">
<property name="echoMode">
<enum>QLineEdit::Password</enum>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer_5">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>36</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>proxy_manual</sender>
<signal>toggled(bool)</signal>
<receiver>proxy_manual_container</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>39</x>
<y>76</y>
</hint>
<hint type="destinationlabel">
<x>29</x>
<y>99</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@@ -0,0 +1,325 @@
/*
* Strawberry Music Player
* This file was part of Clementine.
* Copyright 2010, David Sansome <me@davidsansome.com>
*
* Strawberry 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.
*
* Strawberry 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 Strawberry. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include "config.h"
#include "notificationssettingspage.h"
#include "ui_notificationssettingspage.h"
#include "settingsdialog.h"
#include "core/iconloader.h"
#include "widgets/osdpretty.h"
#include <QColorDialog>
#include <QFontDialog>
#include <QMenu>
#include <QToolTip>
const char *NotificationsSettingsPage::kSettingsGroup = "Notifications";
NotificationsSettingsPage::NotificationsSettingsPage(SettingsDialog* dialog)
: SettingsPage(dialog), ui_(new Ui_NotificationsSettingsPage), pretty_popup_(new OSDPretty(OSDPretty::Mode_Draggable)) {
ui_->setupUi(this);
setWindowIcon(IconLoader::Load("help-hint"));
pretty_popup_->SetMessage(tr("OSD Preview"), tr("Drag to reposition"), QImage(":pictures/nocover.png"));
ui_->notifications_bg_preset->setItemData(0, QColor(OSDPretty::kPresetBlue), Qt::DecorationRole);
ui_->notifications_bg_preset->setItemData(1, QColor(OSDPretty::kPresetOrange), Qt::DecorationRole);
// Create and populate the helper menus
QMenu* menu = new QMenu(this);
menu->addAction(ui_->action_artist);
menu->addAction(ui_->action_album);
menu->addAction(ui_->action_title);
menu->addAction(ui_->action_albumartist);
menu->addAction(ui_->action_year);
menu->addAction(ui_->action_composer);
menu->addAction(ui_->action_performer);
menu->addAction(ui_->action_grouping);
menu->addAction(ui_->action_length);
menu->addAction(ui_->action_disc);
menu->addAction(ui_->action_track);
menu->addAction(ui_->action_genre);
menu->addAction(ui_->action_playcount);
menu->addAction(ui_->action_skipcount);
menu->addAction(ui_->action_filename);
menu->addAction(ui_->action_rating);
menu->addAction(ui_->action_score);
menu->addSeparator();
menu->addAction(ui_->action_newline);
ui_->notifications_exp_chooser1->setMenu(menu);
ui_->notifications_exp_chooser2->setMenu(menu);
ui_->notifications_exp_chooser1->setPopupMode(QToolButton::InstantPopup);
ui_->notifications_exp_chooser2->setPopupMode(QToolButton::InstantPopup);
// We need this because by default menus don't show tooltips
connect(menu, SIGNAL(hovered(QAction*)), SLOT(ShowMenuTooltip(QAction*)));
connect(ui_->notifications_none, SIGNAL(toggled(bool)), SLOT(NotificationTypeChanged()));
connect(ui_->notifications_native, SIGNAL(toggled(bool)), SLOT(NotificationTypeChanged()));
connect(ui_->notifications_tray, SIGNAL(toggled(bool)), SLOT(NotificationTypeChanged()));
connect(ui_->notifications_pretty, SIGNAL(toggled(bool)), SLOT(NotificationTypeChanged()));
connect(ui_->notifications_opacity, SIGNAL(valueChanged(int)), SLOT(PrettyOpacityChanged(int)));
connect(ui_->notifications_bg_preset, SIGNAL(activated(int)), SLOT(PrettyColorPresetChanged(int)));
connect(ui_->notifications_fg_choose, SIGNAL(clicked()), SLOT(ChooseFgColor()));
connect(ui_->notifications_font_choose, SIGNAL(clicked()), SLOT(ChooseFont()));
connect(ui_->notifications_exp_chooser1, SIGNAL(triggered(QAction*)), SLOT(InsertVariableFirstLine(QAction*)));
connect(ui_->notifications_exp_chooser2, SIGNAL(triggered(QAction*)), SLOT(InsertVariableSecondLine(QAction*)));
connect(ui_->notifications_disable_duration, SIGNAL(toggled(bool)), ui_->notifications_duration, SLOT(setDisabled(bool)));
if (!OSD::SupportsNativeNotifications())
ui_->notifications_native->setEnabled(false);
if (!OSD::SupportsTrayPopups()) ui_->notifications_tray->setEnabled(false);
connect(ui_->notifications_pretty, SIGNAL(toggled(bool)), SLOT(UpdatePopupVisible()));
connect(ui_->notifications_custom_text_enabled, SIGNAL(toggled(bool)), SLOT(NotificationCustomTextChanged(bool)));
connect(ui_->notifications_preview, SIGNAL(clicked()), SLOT(PrepareNotificationPreview()));
// Icons
ui_->notifications_exp_chooser1->setIcon(IconLoader::Load("list-add"));
ui_->notifications_exp_chooser2->setIcon(IconLoader::Load("list-add"));
}
NotificationsSettingsPage::~NotificationsSettingsPage() {
delete pretty_popup_;
delete ui_;
}
void NotificationsSettingsPage::showEvent(QShowEvent*) {
UpdatePopupVisible();
}
void NotificationsSettingsPage::hideEvent(QHideEvent*) {
UpdatePopupVisible();
}
void NotificationsSettingsPage::Load() {
QSettings s;
s.beginGroup(OSD::kSettingsGroup);
OSD::Behaviour osd_behaviour = OSD::Behaviour(s.value("Behaviour", OSD::Native).toInt());
switch (osd_behaviour) {
case OSD::Native:
if (OSD::SupportsNativeNotifications()) {
ui_->notifications_native->setChecked(true);
break;
}
// Fallthrough
case OSD::Pretty:
ui_->notifications_pretty->setChecked(true);
break;
case OSD::TrayPopup:
if (OSD::SupportsTrayPopups()) {
ui_->notifications_tray->setChecked(true);
break;
}
// Fallthrough
case OSD::Disabled:
default:
ui_->notifications_none->setChecked(true);
break;
}
ui_->notifications_duration->setValue(s.value("Timeout", 5000).toInt() / 1000);
ui_->notifications_volume->setChecked( s.value("ShowOnVolumeChange", false).toBool());
ui_->notifications_play_mode->setChecked( s.value("ShowOnPlayModeChange", true).toBool());
ui_->notifications_pause->setChecked(s.value("ShowOnPausePlayback", true).toBool());
ui_->notifications_art->setChecked(s.value("ShowArt", true).toBool());
ui_->notifications_custom_text_enabled->setChecked(s.value("CustomTextEnabled", false).toBool());
ui_->notifications_custom_text1->setText(s.value("CustomText1").toString());
ui_->notifications_custom_text2->setText(s.value("CustomText2").toString());
s.endGroup();
#ifdef Q_OS_DARWIN
ui_->notifications_options->setEnabled(ui_->notifications_pretty->isChecked());
#endif
// Pretty OSD
pretty_popup_->ReloadSettings();
ui_->notifications_opacity->setValue(pretty_popup_->background_opacity() * 100);
QRgb color = pretty_popup_->background_color();
if (color == OSDPretty::kPresetBlue)
ui_->notifications_bg_preset->setCurrentIndex(0);
else if (color == OSDPretty::kPresetOrange)
ui_->notifications_bg_preset->setCurrentIndex(1);
else
ui_->notifications_bg_preset->setCurrentIndex(2);
ui_->notifications_bg_preset->setItemData(2, QColor(color), Qt::DecorationRole);
ui_->notifications_disable_duration->setChecked(pretty_popup_->disable_duration());
UpdatePopupVisible();
}
void NotificationsSettingsPage::Save() {
QSettings s;
OSD::Behaviour osd_behaviour = OSD::Disabled;
if (ui_->notifications_none->isChecked()) osd_behaviour = OSD::Disabled;
else if (ui_->notifications_native->isChecked()) osd_behaviour = OSD::Native;
else if (ui_->notifications_tray->isChecked()) osd_behaviour = OSD::TrayPopup;
else if (ui_->notifications_pretty->isChecked()) osd_behaviour = OSD::Pretty;
s.beginGroup(OSD::kSettingsGroup);
s.setValue("Behaviour", int(osd_behaviour));
s.setValue("Timeout", ui_->notifications_duration->value() * 1000);
s.setValue("ShowOnVolumeChange", ui_->notifications_volume->isChecked());
s.setValue("ShowOnPlayModeChange", ui_->notifications_play_mode->isChecked());
s.setValue("ShowOnPausePlayback", ui_->notifications_pause->isChecked());
s.setValue("ShowArt", ui_->notifications_art->isChecked());
s.setValue("CustomTextEnabled", ui_->notifications_custom_text_enabled->isChecked());
s.setValue("CustomText1", ui_->notifications_custom_text1->text());
s.setValue("CustomText2", ui_->notifications_custom_text2->text());
s.endGroup();
s.beginGroup(OSDPretty::kSettingsGroup);
s.setValue("foreground_color", pretty_popup_->foreground_color());
s.setValue("background_color", pretty_popup_->background_color());
s.setValue("background_opacity", pretty_popup_->background_opacity());
s.setValue("popup_display", pretty_popup_->popup_display());
s.setValue("popup_pos", pretty_popup_->popup_pos());
s.setValue("font", pretty_popup_->font().toString());
s.setValue("disable_duration", ui_->notifications_disable_duration->isChecked());
s.endGroup();
}
void NotificationsSettingsPage::PrettyOpacityChanged(int value) {
pretty_popup_->set_background_opacity(qreal(value) / 100.0);
}
void NotificationsSettingsPage::UpdatePopupVisible() {
pretty_popup_->setVisible(isVisible() && ui_->notifications_pretty->isChecked());
}
void NotificationsSettingsPage::PrettyColorPresetChanged(int index) {
if (dialog()->is_loading_settings()) return;
switch (index) {
case 0:
pretty_popup_->set_background_color(OSDPretty::kPresetBlue);
break;
case 1:
pretty_popup_->set_background_color(OSDPretty::kPresetOrange);
break;
case 2:
default:
ChooseBgColor();
break;
}
}
void NotificationsSettingsPage::ChooseBgColor() {
QColor color = QColorDialog::getColor(pretty_popup_->background_color(), this);
if (!color.isValid())
return;
pretty_popup_->set_background_color(color.rgb());
ui_->notifications_bg_preset->setItemData(2, color, Qt::DecorationRole);
}
void NotificationsSettingsPage::ChooseFgColor() {
QColor color = QColorDialog::getColor(pretty_popup_->foreground_color(), this);
if (!color.isValid())
return;
pretty_popup_->set_foreground_color(color.rgb());
}
void NotificationsSettingsPage::ChooseFont() {
bool ok;
QFont font = QFontDialog::getFont(&ok, pretty_popup_->font(), this);
if (ok) pretty_popup_->set_font(font);
}
void NotificationsSettingsPage::NotificationCustomTextChanged(bool enabled) {
ui_->notifications_custom_text1->setEnabled(enabled);
ui_->notifications_custom_text2->setEnabled(enabled);
ui_->notifications_exp_chooser1->setEnabled(enabled);
ui_->notifications_exp_chooser2->setEnabled(enabled);
ui_->notifications_preview->setEnabled(enabled);
ui_->label_19->setEnabled(enabled);
ui_->label_20->setEnabled(enabled);
}
void NotificationsSettingsPage::PrepareNotificationPreview() {
OSD::Behaviour notificationType = OSD::Disabled;
if (ui_->notifications_native->isChecked()) {
notificationType = OSD::Native;
}
else if (ui_->notifications_pretty->isChecked()) {
notificationType = OSD::Pretty;
}
else if (ui_->notifications_tray->isChecked()) {
notificationType = OSD::TrayPopup;
}
// If user changes timeout or other options, that won't be reflected in the preview
emit NotificationPreview(notificationType, ui_->notifications_custom_text1->text(), ui_->notifications_custom_text2->text());
}
void NotificationsSettingsPage::InsertVariableFirstLine(QAction* action) {
// We use action name, therefore those shouldn't be translatable
ui_->notifications_custom_text1->insert(action->text());
}
void NotificationsSettingsPage::InsertVariableSecondLine(QAction* action) {
// We use action name, therefore those shouldn't be translatable
ui_->notifications_custom_text2->insert(action->text());
}
void NotificationsSettingsPage::ShowMenuTooltip(QAction* action) {
QToolTip::showText(QCursor::pos(), action->toolTip());
}
void NotificationsSettingsPage::NotificationTypeChanged() {
bool enabled = !ui_->notifications_none->isChecked();
bool pretty = ui_->notifications_pretty->isChecked();
ui_->notifications_general->setEnabled(enabled);
ui_->notifications_pretty_group->setEnabled(pretty);
ui_->notifications_custom_text_group->setEnabled(enabled);
#ifdef Q_OS_DARWIN
ui_->notifications_options->setEnabled(pretty);
#endif
ui_->notifications_duration->setEnabled(!pretty || (pretty && !ui_->notifications_disable_duration->isChecked()));
ui_->notifications_disable_duration->setEnabled(pretty);
}

View File

@@ -0,0 +1,66 @@
/*
* Strawberry Music Player
* This file was part of Clementine.
* Copyright 2010, David Sansome <me@davidsansome.com>
*
* Strawberry 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.
*
* Strawberry 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 Strawberry. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef NOTIFICATIONSSETTINGSPAGE_H
#define NOTIFICATIONSSETTINGSPAGE_H
#include "config.h"
#include "settingspage.h"
class Ui_NotificationsSettingsPage;
class NotificationsSettingsPage : public SettingsPage {
Q_OBJECT
public:
NotificationsSettingsPage(SettingsDialog *dialog);
~NotificationsSettingsPage();
static const char *kSettingsGroup;
void Load();
void Save();
protected:
void hideEvent(QHideEvent*);
void showEvent(QShowEvent*);
private slots:
void NotificationTypeChanged();
void NotificationCustomTextChanged(bool enabled);
void PrepareNotificationPreview();
void InsertVariableFirstLine(QAction *action);
void InsertVariableSecondLine(QAction *action);
void ShowMenuTooltip(QAction *action);
void PrettyOpacityChanged(int value);
void PrettyColorPresetChanged(int index);
void ChooseBgColor();
void ChooseFgColor();
void ChooseFont();
void UpdatePopupVisible();
private:
Ui_NotificationsSettingsPage *ui_;
OSDPretty *pretty_popup_;
};
#endif // NOTIFICATIONSSETTINGSPAGE_H

View File

@@ -0,0 +1,487 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>NotificationsSettingsPage</class>
<widget class="QWidget" name="NotificationsSettingsPage">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>526</width>
<height>642</height>
</rect>
</property>
<property name="windowTitle">
<string>Notifications</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>Strawberry can show a message when the track changes.</string>
</property>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_4">
<property name="title">
<string>Notification type</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_7">
<item>
<widget class="QRadioButton" name="notifications_none">
<property name="text">
<string comment="Refers to a disabled notification type in Notification settings.">Disabled</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="notifications_native">
<property name="text">
<string>Show a native desktop notification</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="notifications_pretty">
<property name="text">
<string>Show a pretty OSD</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="notifications_tray">
<property name="text">
<string>Show a popup from the system tray</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="notifications_general">
<property name="title">
<string>General settings</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_6">
<item>
<widget class="QWidget" name="notifications_options" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_8">
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="label_3">
<property name="text">
<string>Popup duration</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="notifications_duration">
<property name="suffix">
<string> seconds</string>
</property>
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>20</number>
</property>
<property name="value">
<number>5</number>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="notifications_disable_duration">
<property name="text">
<string>Disable duration</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QCheckBox" name="notifications_volume">
<property name="text">
<string>Show a notification when I change the volume</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="notifications_play_mode">
<property name="text">
<string>Show a notification when I change the repeat/shuffle mode</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="notifications_pause">
<property name="text">
<string>Show a notification when I pause playback</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="notifications_art">
<property name="text">
<string>Include album art in the notification</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="notifications_custom_text_group">
<property name="title">
<string>Custom message settings</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_26">
<item>
<widget class="QFrame" name="frame_2">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="lineWidth">
<number>0</number>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_7">
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="QCheckBox" name="notifications_custom_text_enabled">
<property name="text">
<string>Use a custom message for notifications</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="notifications_preview">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Preview</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QFrame" name="frame">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="lineWidth">
<number>0</number>
</property>
<layout class="QGridLayout" name="gridLayout">
<property name="topMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item row="0" column="1">
<widget class="QLineEdit" name="notifications_custom_text1">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QToolButton" name="notifications_exp_chooser1">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_19">
<property name="text">
<string>Summary</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_20">
<property name="text">
<string>Body</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="notifications_custom_text2">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QToolButton" name="notifications_exp_chooser2">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="notifications_pretty_group">
<property name="title">
<string>Pretty OSD options</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Background opacity</string>
</property>
</widget>
</item>
<item row="0" column="1" colspan="2">
<widget class="QSlider" name="notifications_opacity">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Background color</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="notifications_bg_preset">
<item>
<property name="text">
<string>Basic Blue</string>
</property>
</item>
<item>
<property name="text">
<string>Strawberry Orange</string>
</property>
</item>
<item>
<property name="text">
<string>Custom...</string>
</property>
</item>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Text options</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QPushButton" name="notifications_fg_choose">
<property name="text">
<string>Choose color...</string>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QPushButton" name="notifications_font_choose">
<property name="text">
<string>Choose font...</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>32</height>
</size>
</property>
</spacer>
</item>
</layout>
<action name="action_artist">
<property name="text">
<string notr="true">%artist%</string>
</property>
<property name="toolTip">
<string>Add song artist tag</string>
</property>
</action>
<action name="action_album">
<property name="text">
<string notr="true">%album%</string>
</property>
<property name="toolTip">
<string>Add song album tag</string>
</property>
</action>
<action name="action_title">
<property name="text">
<string notr="true">%title%</string>
</property>
<property name="toolTip">
<string>Add song title tag</string>
</property>
</action>
<action name="action_albumartist">
<property name="text">
<string notr="true">%albumartist%</string>
</property>
<property name="toolTip">
<string>Add song albumartist tag</string>
</property>
</action>
<action name="action_year">
<property name="text">
<string notr="true">%year%</string>
</property>
<property name="toolTip">
<string>Add song year tag</string>
</property>
</action>
<action name="action_composer">
<property name="text">
<string notr="true">%composer%</string>
</property>
<property name="toolTip">
<string>Add song composer tag</string>
</property>
</action>
<action name="action_performer">
<property name="text">
<string notr="true">%performer%</string>
</property>
<property name="toolTip">
<string>Add song performer tag</string>
</property>
</action>
<action name="action_grouping">
<property name="text">
<string notr="true">%grouping%</string>
</property>
<property name="toolTip">
<string>Add song grouping tag</string>
</property>
</action>
<action name="action_disc">
<property name="text">
<string notr="true">%disc%</string>
</property>
<property name="toolTip">
<string>Add song disc tag</string>
</property>
</action>
<action name="action_track">
<property name="text">
<string notr="true">%track%</string>
</property>
<property name="toolTip">
<string>Add song track tag</string>
</property>
</action>
<action name="action_genre">
<property name="text">
<string notr="true">%genre%</string>
</property>
<property name="toolTip">
<string>Add song genre tag</string>
</property>
</action>
<action name="action_length">
<property name="text">
<string notr="true">%length%</string>
</property>
<property name="toolTip">
<string>Add song length tag</string>
</property>
</action>
<action name="action_playcount">
<property name="text">
<string notr="true">%playcount%</string>
</property>
<property name="toolTip">
<string>Add song play count</string>
</property>
</action>
<action name="action_skipcount">
<property name="text">
<string notr="true">%skipcount%</string>
</property>
<property name="toolTip">
<string>Add song skip count</string>
</property>
</action>
<action name="action_rating">
<property name="text">
<string notr="true">%rating%</string>
</property>
<property name="toolTip">
<string>Add song rating</string>
</property>
</action>
<action name="action_score">
<property name="text">
<string notr="true">%score%</string>
</property>
<property name="toolTip">
<string>Add song auto score</string>
</property>
</action>
<action name="action_newline">
<property name="text">
<string notr="true">%newline%</string>
</property>
<property name="toolTip">
<string>Add a new line if supported by the notification type</string>
</property>
</action>
<action name="action_filename">
<property name="text">
<string>%filename%</string>
</property>
<property name="toolTip">
<string>Add song filename</string>
</property>
</action>
</widget>
<resources/>
<connections/>
</ui>

View File

@@ -0,0 +1,86 @@
/*
* Strawberry Music Player
* This file was part of Clementine.
* Copyright 2010, David Sansome <me@davidsansome.com>
*
* Strawberry 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.
*
* Strawberry 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 Strawberry. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include "config.h"
#include "playbacksettingspage.h"
#include "ui_playbacksettingspage.h"
#include "core/iconloader.h"
#include "settingsdialog.h"
#include "playlist/playlist.h"
const char *PlaybackSettingsPage::kSettingsGroup = "Playback";
PlaybackSettingsPage::PlaybackSettingsPage(SettingsDialog *dialog) : SettingsPage(dialog), ui_(new Ui_PlaybackSettingsPage) {
ui_->setupUi(this);
setWindowIcon(IconLoader::Load("media-play"));
connect(ui_->fading_cross, SIGNAL(toggled(bool)), SLOT(FadingOptionsChanged()));
connect(ui_->fading_out, SIGNAL(toggled(bool)), SLOT(FadingOptionsChanged()));
connect(ui_->fading_auto, SIGNAL(toggled(bool)), SLOT(FadingOptionsChanged()));
}
PlaybackSettingsPage::~PlaybackSettingsPage() {
delete ui_;
}
void PlaybackSettingsPage::Load() {
QSettings s;
s.beginGroup(kSettingsGroup);
ui_->current_glow->setChecked(s.value("glow_effect", true).toBool());
ui_->fading_out->setChecked(s.value("FadeoutEnabled", false).toBool());
ui_->fading_cross->setChecked(s.value("CrossfadeEnabled", false).toBool());
ui_->fading_auto->setChecked(s.value("AutoCrossfadeEnabled", false).toBool());
ui_->fading_duration->setValue(s.value("FadeoutDuration", 2000).toInt());
ui_->fading_samealbum->setChecked(s.value("NoCrossfadeSameAlbum", true).toBool());
ui_->fadeout_pause->setChecked(s.value("FadeoutPauseEnabled", false).toBool());
ui_->fading_pause_duration->setValue(s.value("FadeoutPauseDuration", 250).toInt());
s.endGroup();
}
void PlaybackSettingsPage::Save() {
QSettings s;
s.beginGroup(kSettingsGroup);
s.setValue("glow_effect", ui_->current_glow->isChecked());
s.setValue("FadeoutEnabled", ui_->fading_out->isChecked());
s.setValue("FadeoutDuration", ui_->fading_duration->value());
s.setValue("CrossfadeEnabled", ui_->fading_cross->isChecked());
s.setValue("AutoCrossfadeEnabled", ui_->fading_auto->isChecked());
s.setValue("NoCrossfadeSameAlbum", ui_->fading_samealbum->isChecked());
s.setValue("FadeoutPauseEnabled", ui_->fadeout_pause->isChecked());
s.setValue("FadeoutPauseDuration", ui_->fading_pause_duration->value());
s.endGroup();
}
void PlaybackSettingsPage::FadingOptionsChanged() {
ui_->fading_options->setEnabled(ui_->fading_out->isChecked() || ui_->fading_cross->isChecked() || ui_->fading_auto->isChecked());
}

View File

@@ -0,0 +1,48 @@
/*
* Strawberry Music Player
* This file was part of Clementine.
* Copyright 2010, David Sansome <me@davidsansome.com>
*
* Strawberry 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.
*
* Strawberry 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 Strawberry. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef PLAYBACKSETTINGSPAGE_H
#define PLAYBACKSETTINGSPAGE_H
#include "config.h"
#include "settingspage.h"
class Ui_PlaybackSettingsPage;
class PlaybackSettingsPage : public SettingsPage {
Q_OBJECT
public:
PlaybackSettingsPage(SettingsDialog* dialog);
~PlaybackSettingsPage();
static const char *kSettingsGroup;
void Load();
void Save();
private slots:
void FadingOptionsChanged();
private:
Ui_PlaybackSettingsPage* ui_;
};
#endif // PLAYBACKSETTINGSPAGE_H

View File

@@ -0,0 +1,231 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>PlaybackSettingsPage</class>
<widget class="QWidget" name="PlaybackSettingsPage">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>596</width>
<height>638</height>
</rect>
</property>
<property name="windowTitle">
<string>Playback</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QCheckBox" name="current_glow">
<property name="text">
<string>Show a glowing animation on the current track</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Fading</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QCheckBox" name="fading_out">
<property name="text">
<string>Fade out when stopping a track</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="fading_cross">
<property name="text">
<string>Cross-fade when changing tracks manually</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="fading_auto">
<property name="text">
<string>Cross-fade when changing tracks automatically</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="fading_samealbum">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Except between tracks on the same album or in the same CUE sheet</string>
</property>
</widget>
</item>
<item>
<widget class="QWidget" name="fading_options" native="true">
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Fading duration</string>
</property>
<property name="indent">
<number>22</number>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="fading_duration">
<property name="suffix">
<string> ms</string>
</property>
<property name="maximum">
<number>10000</number>
</property>
<property name="singleStep">
<number>1000</number>
</property>
<property name="value">
<number>2000</number>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>257</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QCheckBox" name="fadeout_pause">
<property name="text">
<string>Fade out on pause / fade in on resume</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>Fading duration</string>
</property>
<property name="indent">
<number>22</number>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="fading_pause_duration">
<property name="suffix">
<string> ms</string>
</property>
<property name="maximum">
<number>10000</number>
</property>
<property name="singleStep">
<number>50</number>
</property>
<property name="value">
<number>250</number>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>114</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>StickySlider</class>
<extends>QSlider</extends>
<header>widgets/stickyslider.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections>
<connection>
<sender>replaygain</sender>
<signal>toggled(bool)</signal>
<receiver>widget</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>89</x>
<y>259</y>
</hint>
<hint type="destinationlabel">
<x>143</x>
<y>285</y>
</hint>
</hints>
</connection>
<connection>
<sender>fading_auto</sender>
<signal>toggled(bool)</signal>
<receiver>fading_samealbum</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>109</x>
<y>133</y>
</hint>
<hint type="destinationlabel">
<x>113</x>
<y>153</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@@ -0,0 +1,133 @@
/*
* Strawberry Music Player
* This file was part of Clementine.
* Copyright 2010, David Sansome <me@davidsansome.com>
*
* Strawberry 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.
*
* Strawberry 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 Strawberry. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include "config.h"
#include <QDir>
#include "playlistsettingspage.h"
#include "core/mainwindow.h"
#include "core/iconloader.h"
#include "ui_playlistsettingspage.h"
#include "playlist/playlist.h"
#include "playlist/playlisttabbar.h"
#include "settings/playlistsettingspage.h"
const char *PlaylistSettingsPage::kSettingsGroup = "Playlist";
namespace {
bool LocaleAwareCompare(const QString &a, const QString &b) {
return a.localeAwareCompare(b) < 0;
}
} // namespace
PlaylistSettingsPage::PlaylistSettingsPage(SettingsDialog* dialog) : SettingsPage(dialog), ui_(new Ui_PlaylistSettingsPage) {
ui_->setupUi(this);
setWindowIcon(IconLoader::Load("document-new"));
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_doubleclickplaymode->setItemData(0, MainWindow::PlayBehaviour_Never);
ui_->combobox_doubleclickplaymode->setItemData(1, MainWindow::PlayBehaviour_IfStopped);
ui_->combobox_doubleclickplaymode->setItemData(2, MainWindow::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);
}
PlaylistSettingsPage::~PlaylistSettingsPage() {
delete ui_;
}
void PlaylistSettingsPage::Load() {
QSettings s;
s.beginGroup(PlaylistSettingsPage::kSettingsGroup);
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_->checkbox_greyoutdeleted->setChecked(s.value("greyoutdeleted", false).toBool());
Playlist::Path path = Playlist::Path(s.value(Playlist::kPathType, Playlist::Path_Automatic).toInt());
switch (path) {
case Playlist::Path_Automatic:
ui_->radiobutton_automaticpath->setChecked(true);
break;
case Playlist::Path_Absolute:
ui_->radiobutton_absolutepath->setChecked(true);
break;
case Playlist::Path_Relative:
ui_->radiobutton_relativepath->setChecked(true);
break;
case Playlist::Path_Ask_User:
ui_->radiobutton_askpath->setChecked(true);
}
ui_->checkbox_warncloseplaylist->setChecked(s.value("warn_close_playlist", true).toBool());
ui_->checkbox_editmetadatainline->setChecked(s.value("editmetadatainline", false).toBool());
ui_->checkbox_writemetadata->setChecked(s.value(Playlist::kWriteMetadata, false).toBool());
s.endGroup();
}
void PlaylistSettingsPage::Save() {
QSettings s;
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());
Playlist::Path path = Playlist::Path_Automatic;
if (ui_->radiobutton_automaticpath->isChecked()) {
path = Playlist::Path_Automatic;
}
else if (ui_->radiobutton_absolutepath->isChecked()) {
path = Playlist::Path_Absolute;
}
else if (ui_->radiobutton_relativepath->isChecked()) {
path = Playlist::Path_Relative;
}
else if (ui_->radiobutton_askpath->isChecked()) {
path = Playlist::Path_Ask_User;
}
s.beginGroup(PlaylistSettingsPage::kSettingsGroup);
s.setValue("doubleclick_addmode", doubleclick_addmode);
s.setValue("doubleclick_playmode", doubleclick_playmode);
s.setValue("menu_playmode", menu_playmode);
s.setValue("greyoutdeleted", ui_->checkbox_greyoutdeleted->isChecked());
s.setValue(Playlist::kPathType, static_cast<int>(path));
s.setValue("warn_close_playlist", ui_->checkbox_warncloseplaylist->isChecked());
s.setValue("editmetadatainline", ui_->checkbox_editmetadatainline->isChecked());
s.setValue(Playlist::kWriteMetadata, ui_->checkbox_writemetadata->isChecked());
s.endGroup();
}

View File

@@ -0,0 +1,50 @@
/*
* Strawberry Music Player
* This file was part of Clementine.
* Copyright 2010, David Sansome <me@davidsansome.com>
*
* Strawberry 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.
*
* Strawberry 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 Strawberry. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef PLAYLISTSETTINGSPAGE_H
#define PLAYLISTSETTINGSPAGE_H
#include "config.h"
#include "settingspage.h"
#include <QMap>
class Ui_PlaylistSettingsPage;
class PlaylistSettingsPage : public SettingsPage {
Q_OBJECT
public:
PlaylistSettingsPage(SettingsDialog* dialog);
~PlaylistSettingsPage();
static const char *kSettingsGroup;
void Load();
void Save();
private slots:
private:
Ui_PlaylistSettingsPage* ui_;
};
#endif // PLAYLISTSETTINGSPAGE_H

View File

@@ -0,0 +1,274 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>PlaylistSettingsPage</class>
<widget class="QWidget" name="PlaylistSettingsPage">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>516</width>
<height>851</height>
</rect>
</property>
<property name="windowTitle">
<string>Playlist</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QCheckBox" name="checkbox_warncloseplaylist">
<property name="text">
<string>Warn me when closing a playlist tab</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkbox_greyoutdeleted">
<property name="text">
<string>Grey out non existent songs in my playlists</string>
</property>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_8">
<property name="title">
<string>Using the menu to add a song will...</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_18">
<item>
<widget class="QComboBox" name="combobox_menuplaymode">
<property name="currentIndex">
<number>0</number>
</property>
<item>
<property name="text">
<string>Never start playing</string>
</property>
</item>
<item>
<property name="text">
<string>Play if there is nothing already playing</string>
</property>
</item>
<item>
<property name="text">
<string>Always start playing</string>
</property>
</item>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupbox_previous">
<property name="title">
<string>Pressing &quot;Previous&quot; in player will...</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_19">
<item>
<widget class="QComboBox" name="combobox_previousmode">
<property name="currentIndex">
<number>0</number>
</property>
<item>
<property name="text">
<string>Jump to previous song right away</string>
</property>
</item>
<item>
<property name="text">
<string>Restart song, then jump to previous if pressed again</string>
</property>
</item>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupbox_doubleclickaddmode">
<property name="title">
<string>Double clicking a song will...</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_6">
<item>
<widget class="QComboBox" name="combobox_doubleclickaddmode">
<property name="currentIndex">
<number>0</number>
</property>
<item>
<property name="text">
<string>Append to the playlist</string>
</property>
</item>
<item>
<property name="text">
<string>Replace the playlist</string>
</property>
</item>
<item>
<property name="text">
<string>Open in new playlist</string>
</property>
</item>
<item>
<property name="text">
<string>Add to the queue</string>
</property>
</item>
</widget>
</item>
<item>
<widget class="QComboBox" name="combobox_doubleclickplaymode">
<property name="currentIndex">
<number>1</number>
</property>
<item>
<property name="text">
<string>Never start playing</string>
</property>
</item>
<item>
<property name="text">
<string>Play if there is nothing already playing</string>
</property>
</item>
<item>
<property name="text">
<string>Always start playing</string>
</property>
</item>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupbox_doubleclickplaylist">
<property name="title">
<string>Double clicking a song in the playlist will...</string>
</property>
<layout class="QVBoxLayout" name="layout_doubleclick_playlist">
<item>
<widget class="QComboBox" name="combobox_doubleclickplaylistaddmode">
<property name="currentIndex">
<number>0</number>
</property>
<item>
<property name="text">
<string>Change the currently playing song</string>
</property>
</item>
<item>
<property name="text">
<string>Add to the queue</string>
</property>
</item>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_9">
<property name="title">
<string>When saving a playlist, file paths should be</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QRadioButton" name="radiobutton_automaticpath">
<property name="text">
<string>Automatic</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radiobutton_absolutepath">
<property name="text">
<string>Absolute</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radiobutton_relativepath">
<property name="text">
<string>Relative</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radiobutton_askpath">
<property name="text">
<string>Ask when saving</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_7">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>10</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupbox_editmetadatainline">
<property name="title">
<string>Metadata</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_editmetadatainline">
<item>
<widget class="QCheckBox" name="checkbox_editmetadatainline">
<property name="toolTip">
<string>If activated, clicking a selected song in the playlist view will let you edit the tag value directly</string>
</property>
<property name="text">
<string>Enable song metadata inline edition with click</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkbox_writemetadata">
<property name="text">
<string>Write metadata when saving playlists</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>5</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@@ -0,0 +1,267 @@
/*
* Strawberry Music Player
* This file was part of Clementine.
* Copyright 2010, David Sansome <me@davidsansome.com>
*
* Strawberry 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.
*
* Strawberry 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 Strawberry. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include "config.h"
#include <QAbstractButton>
#include <QDesktopWidget>
#include <QPainter>
#include <QPushButton>
#include <QScrollArea>
#include "settingsdialog.h"
#include "behavioursettingspage.h"
#include "collectionsettingspage.h"
#include "backendsettingspage.h"
#include "playbacksettingspage.h"
#include "playlistsettingspage.h"
#include "shortcutssettingspage.h"
#include "transcodersettingspage.h"
#include "appearancesettingspage.h"
#include "networkproxysettingspage.h"
#include "notificationssettingspage.h"
#include "core/application.h"
#include "core/mainwindow.h"
#include "core/player.h"
#include "core/logging.h"
#include "core/networkproxyfactory.h"
#include "core/player.h"
#include "core/iconloader.h"
#include "engine/enginebase.h"
#include "engine/gstengine.h"
#include "playlist/playlistview.h"
#include "widgets/groupediconview.h"
#include "widgets/osdpretty.h"
#include "ui_settingsdialog.h"
SettingsItemDelegate::SettingsItemDelegate(QObject *parent)
: QStyledItemDelegate(parent)
{
}
QSize SettingsItemDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const {
const bool is_separator = index.data(SettingsDialog::Role_IsSeparator).toBool();
QSize ret = QStyledItemDelegate::sizeHint(option, index);
if (is_separator) {
ret.setHeight(ret.height() * 2);
}
return ret;
}
void SettingsItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const {
const bool is_separator = index.data(SettingsDialog::Role_IsSeparator).toBool();
if (is_separator) {
GroupedIconView::DrawHeader(painter, option.rect, option.font, option.palette, index.data().toString());
}
else {
QStyledItemDelegate::paint(painter, option, index);
}
}
SettingsDialog::SettingsDialog(Application *app, QWidget *parent)
: QDialog(parent),
app_(app),
//player_(app_->player()),
model_(app_->collection_model()->directory_model()),
//gst_engine_(qobject_cast<GstEngine*>(app_->player()->engine())),
//engine_(app_->player()->engine()),
appearance_(app_->appearance()),
ui_(new Ui_SettingsDialog),
//mui_(parent),
loading_settings_(false) {
ui_->setupUi(this);
ui_->list->setItemDelegate(new SettingsItemDelegate(this));
QTreeWidgetItem *general = AddCategory(tr("General"));
AddPage(Page_Behaviour, new BehaviourSettingsPage(this), general);
AddPage(Page_Collection, new CollectionSettingsPage(this), general);
AddPage(Page_Backend, new BackendSettingsPage(this), general);
AddPage(Page_Playback, new PlaybackSettingsPage(this), general);
AddPage(Page_Playlist, new PlaylistSettingsPage(this), general);
AddPage(Page_Proxy, new NetworkProxySettingsPage(this), general);
#ifdef HAVE_GSTREAMER
AddPage(Page_Transcoding, new TranscoderSettingsPage(this), general);
#endif
// User interface
QTreeWidgetItem *iface = AddCategory(tr("User interface"));
AddPage(Page_GlobalShortcuts, new GlobalShortcutsSettingsPage(this), iface);
AddPage(Page_Appearance, new AppearanceSettingsPage(this), iface);
AddPage(Page_Notifications, new NotificationsSettingsPage(this), iface);
// List box
connect(ui_->list, SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)), SLOT(CurrentItemChanged(QTreeWidgetItem*)));
ui_->list->setCurrentItem(pages_[Page_Behaviour].item_);
// Make sure the list is big enough to show all the items
ui_->list->setMinimumWidth(static_cast<QAbstractItemView*>(ui_->list)->sizeHintForColumn(0));
ui_->buttonBox->button(QDialogButtonBox::Cancel)->setShortcut(QKeySequence::Close);
}
SettingsDialog::~SettingsDialog() {
delete ui_;
}
QTreeWidgetItem *SettingsDialog::AddCategory(const QString &name) {
QTreeWidgetItem *item = new QTreeWidgetItem;
item->setText(0, name);
item->setData(0, Role_IsSeparator, true);
item->setFlags(Qt::ItemIsEnabled);
ui_->list->invisibleRootItem()->addChild(item);
item->setExpanded(true);
return item;
}
void SettingsDialog::AddPage(Page id, SettingsPage *page, QTreeWidgetItem *parent) {
if (!parent) parent = ui_->list->invisibleRootItem();
// Connect page's signals to the settings dialog's signals
connect(page, SIGNAL(NotificationPreview(OSD::Behaviour,QString,QString)), SIGNAL(NotificationPreview(OSD::Behaviour,QString,QString)));
// Create the list item
QTreeWidgetItem *item = new QTreeWidgetItem;
item->setText(0, page->windowTitle());
item->setIcon(0, page->windowIcon());
item->setData(0, Role_IsSeparator, false);
if (!page->IsEnabled()) {
item->setFlags(Qt::NoItemFlags);
}
parent->addChild(item);
// Create a scroll area containing the page
QScrollArea *area = new QScrollArea;
area->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
area->setWidget(page);
area->setWidgetResizable(true);
area->setFrameShape(QFrame::NoFrame);
area->setMinimumWidth(page->layout()->minimumSize().width());
// Add the page to the stack
ui_->stacked_widget->addWidget(area);
// Remember where the page is
PageData data;
data.item_ = item;
data.scroll_area_ = area;
data.page_ = page;
pages_[id] = data;
}
void SettingsDialog::Save() {
for (const PageData &data : pages_.values()) {
data.page_->Save();
}
}
void SettingsDialog::accept() {
Save();
QDialog::accept();
}
void SettingsDialog::reject() {
// Notify each page that user clicks on Cancel
for (const PageData &data : pages_.values()) {
data.page_->Cancel();
}
QDialog::reject();
}
void SettingsDialog::DialogButtonClicked(QAbstractButton *button) {
// While we only connect Apply at the moment, this might change in the future
if (ui_->buttonBox->button(QDialogButtonBox::Apply) == button) {
Save();
}
}
void SettingsDialog::showEvent(QShowEvent *e) {
// Load settings
loading_settings_ = true;
for (const PageData &data : pages_.values()) {
data.page_->Load();
}
loading_settings_ = false;
// Resize the dialog if it's too big
const QSize available = QApplication::desktop()->availableGeometry(this).size();
if (available.height() < height()) {
resize(width(), sizeHint().height());
}
QDialog::showEvent(e);
}
void SettingsDialog::OpenAtPage(Page page) {
if (!pages_.contains(page)) {
return;
}
ui_->list->setCurrentItem(pages_[page].item_);
show();
}
void SettingsDialog::CurrentItemChanged(QTreeWidgetItem *item) {
if (!(item->flags() & Qt::ItemIsSelectable)) {
return;
}
// Set the title
ui_->title->setText("<b>" + item->text(0) + "</b>");
// Display the right page
for (const PageData &data : pages_.values()) {
if (data.item_ == item) {
ui_->stacked_widget->setCurrentWidget(data.scroll_area_);
break;
}
}
}

View File

@@ -0,0 +1,135 @@
/*
* Strawberry Music Player
* This file was part of Clementine.
* Copyright 2010, David Sansome <me@davidsansome.com>
*
* Strawberry 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.
*
* Strawberry 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 Strawberry. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef SETTINGSDIALOG_H
#define SETTINGSDIALOG_H
#include "config.h"
#include <QDialog>
#include <QStyledItemDelegate>
#include "widgets/osd.h"
class QAbstractButton;
class QScrollArea;
class QTreeWidgetItem;
class Application;
class Player;
class Appearance;
class GlobalShortcuts;
class CollectionDirectoryModel;
class SettingsPage;
class Ui_MainWindow;
class Ui_SettingsDialog;
class GstEngine;
class SettingsItemDelegate : public QStyledItemDelegate {
public:
SettingsItemDelegate(QObject *parent);
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const;
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const;
};
class SettingsDialog : public QDialog {
Q_OBJECT
public:
SettingsDialog(Application *app, QWidget *parent = nullptr);
~SettingsDialog();
enum Page {
Page_Behaviour,
Page_Collection,
Page_Backend,
Page_Playback,
Page_Playlist,
Page_GlobalShortcuts,
Page_Appearance,
Page_Notifications,
Page_Proxy,
Page_Transcoding,
};
enum Role {
Role_IsSeparator = Qt::UserRole
};
void SetGlobalShortcutManager(GlobalShortcuts *manager) { manager_ = manager; }
bool is_loading_settings() const { return loading_settings_; }
Application *app() const { return app_; }
//Player *player() const { return player_; }
CollectionDirectoryModel *collection_directory_model() const { return model_; }
GlobalShortcuts *global_shortcuts_manager() const { return manager_; }
//const EngineBase *engine() const { return engine_; }
//const GstEngine *gst_engine() const { return gst_engine_; }
Appearance *appearance() const { return appearance_; }
void OpenAtPage(Page page);
// QDialog
void accept();
void reject();
// QWidget
void showEvent(QShowEvent *e);
signals:
void NotificationPreview(OSD::Behaviour, QString, QString);
private slots:
void CurrentItemChanged(QTreeWidgetItem *item);
void DialogButtonClicked(QAbstractButton *button);
private:
struct PageData {
QTreeWidgetItem *item_;
QScrollArea *scroll_area_;
SettingsPage *page_;
};
QTreeWidgetItem *AddCategory(const QString &name);
void AddPage(Page id, SettingsPage *page, QTreeWidgetItem *parent = nullptr);
void Save();
private:
Application *app_;
//Player *player_;
CollectionDirectoryModel *model_;
GlobalShortcuts *manager_;
//const EngineBase *engine_;
Appearance *appearance_;
//const GstEngine *gst_engine_;
Ui_SettingsDialog *ui_;
//Ui_MainWindow *mui_;
bool loading_settings_;
QMap<Page, PageData> pages_;
};
#endif // SETTINGSDIALOG_H

View File

@@ -0,0 +1,151 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>SettingsDialog</class>
<widget class="QDialog" name="SettingsDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>827</width>
<height>768</height>
</rect>
</property>
<property name="windowTitle">
<string>Settings</string>
</property>
<property name="windowIcon">
<iconset resource="../../data/data.qrc">
<normaloff>:/icons/64x64/strawberry.png</normaloff>:/icons/64x64/strawberry.png</iconset>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QTreeWidget" name="list">
<property name="maximumSize">
<size>
<width>220</width>
<height>16777215</height>
</size>
</property>
<property name="horizontalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<property name="iconSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
<property name="rootIsDecorated">
<bool>false</bool>
</property>
<property name="itemsExpandable">
<bool>false</bool>
</property>
<property name="expandsOnDoubleClick">
<bool>false</bool>
</property>
<attribute name="headerVisible">
<bool>false</bool>
</attribute>
<column>
<property name="text">
<string notr="true">1</string>
</property>
</column>
</widget>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QLabel" name="title"/>
</item>
<item>
<widget class="Line" name="line_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<widget class="QStackedWidget" name="stacked_widget">
<property name="currentIndex">
<number>-1</number>
</property>
</widget>
</item>
<item>
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="standardButtons">
<set>QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<tabstops>
<tabstop>list</tabstop>
<tabstop>buttonBox</tabstop>
</tabstops>
<resources>
<include location="../../data/data.qrc"/>
</resources>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>SettingsDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>816</x>
<y>757</y>
</hint>
<hint type="destinationlabel">
<x>521</x>
<y>545</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>SettingsDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>816</x>
<y>757</y>
</hint>
<hint type="destinationlabel">
<x>322</x>
<y>549</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>clicked(QAbstractButton*)</signal>
<receiver>SettingsDialog</receiver>
<slot>DialogButtonClicked(QAbstractButton*)</slot>
<hints>
<hint type="sourcelabel">
<x>20</x>
<y>20</y>
</hint>
<hint type="destinationlabel">
<x>20</x>
<y>20</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@@ -0,0 +1,26 @@
/*
* Strawberry Music Player
* This file was part of Clementine.
* Copyright 2010, David Sansome <me@davidsansome.com>
*
* Strawberry 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.
*
* Strawberry 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 Strawberry. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include "config.h"
#include "settingsdialog.h"
#include "settingspage.h"
SettingsPage::SettingsPage(SettingsDialog *dialog) : QWidget(dialog), dialog_(dialog) { }

View File

@@ -0,0 +1,57 @@
/*
* Strawberry Music Player
* This file was part of Clementine.
* Copyright 2010, David Sansome <me@davidsansome.com>
*
* Strawberry 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.
*
* Strawberry 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 Strawberry. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef SETTINGSPAGE_H
#define SETTINGSPAGE_H
#include "config.h"
#include <QWidget>
#include "widgets/osd.h"
class SettingsDialog;
class SettingsPage : public QWidget {
Q_OBJECT
public:
SettingsPage(SettingsDialog* dialog);
// Return false to grey out the page's item in the list.
virtual bool IsEnabled() const { return true; }
// Load is called when the dialog is shown, Save when the user clicks OK, and
// Cancel when the user clicks on Cancel
virtual void Load() = 0;
virtual void Save() = 0;
virtual void Cancel() {}
// The dialog that this page belongs to.
SettingsDialog *dialog() const { return dialog_; }
signals:
void NotificationPreview(OSD::Behaviour, QString, QString);
private:
SettingsDialog *dialog_;
};
#endif // SETTINGSPAGE_H

View File

@@ -0,0 +1,201 @@
/*
* Strawberry Music Player
* This file was part of Clementine.
* Copyright 2010, David Sansome <me@davidsansome.com>
*
* Strawberry 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.
*
* Strawberry 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 Strawberry. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include "config.h"
#include <QKeyEvent>
#include <QMessageBox>
#include <QProcess>
#include <QPushButton>
#include <QSettings>
#include <QShortcut>
#include <QtDebug>
#include "shortcutssettingspage.h"
#include "ui_shortcutssettingspage.h"
#include "globalshortcuts/globalshortcuts.h"
#include "globalshortcuts/globalshortcutgrabber.h"
#include "core/logging.h"
#include "core/utilities.h"
#include "core/iconloader.h"
#include "settings/settingsdialog.h"
const char *GlobalShortcutsSettingsPage::kSettingsGroup = "GlobalShortcuts";
GlobalShortcutsSettingsPage::GlobalShortcutsSettingsPage(SettingsDialog *dialog)
: SettingsPage(dialog),
ui_(new Ui_GlobalShortcutsSettingsPage),
initialised_(false),
grabber_(new GlobalShortcutGrabber) {
ui_->setupUi(this);
ui_->shortcut_options->setEnabled(false);
ui_->list->header()->setSectionResizeMode(QHeaderView::ResizeToContents);
setWindowIcon(IconLoader::Load("keyboard"));
settings_.beginGroup(kSettingsGroup);
connect(ui_->list, SIGNAL(currentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*)), SLOT(ItemClicked(QTreeWidgetItem*)));
connect(ui_->radio_none, SIGNAL(clicked()), SLOT(NoneClicked()));
connect(ui_->radio_default, SIGNAL(clicked()), SLOT(DefaultClicked()));
connect(ui_->radio_custom, SIGNAL(clicked()), SLOT(ChangeClicked()));
connect(ui_->change, SIGNAL(clicked()), SLOT(ChangeClicked()));
connect(ui_->gnome_open, SIGNAL(clicked()), SLOT(OpenGnomeKeybindingProperties()));
}
GlobalShortcutsSettingsPage::~GlobalShortcutsSettingsPage() { delete ui_; }
bool GlobalShortcutsSettingsPage::IsEnabled() const {
#ifdef Q_OS_MAC
qLog(Debug) << Utilities::GetMacVersion();
if (Utilities::GetMacVersion() < 6) { // Leopard and earlier.
return false;
}
#endif
return true;
}
void GlobalShortcutsSettingsPage::Load() {
GlobalShortcuts *manager = dialog()->global_shortcuts_manager();
if (!initialised_) {
initialised_ = true;
connect(ui_->mac_open, SIGNAL(clicked()), manager, SLOT(ShowMacAccessibilityDialog()));
if (!manager->IsGsdAvailable()) {
ui_->gnome_container->hide();
}
for (const GlobalShortcuts::Shortcut &s : manager->shortcuts().values()) {
Shortcut shortcut;
shortcut.s = s;
shortcut.key = s.action->shortcut();
shortcut.item = new QTreeWidgetItem(ui_->list, QStringList() << s.action->text() << s.action->shortcut().toString(QKeySequence::NativeText));
shortcut.item->setData(0, Qt::UserRole, s.id);
shortcuts_[s.id] = shortcut;
}
ui_->list->sortItems(0, Qt::AscendingOrder);
ItemClicked(ui_->list->topLevelItem(0));
}
for (const Shortcut &s : shortcuts_.values()) {
SetShortcut(s.s.id, s.s.action->shortcut());
}
bool use_gnome = settings_.value("use_gnome", true).toBool();
if (ui_->gnome_container->isVisibleTo(this)) {
ui_->gnome_checkbox->setChecked(use_gnome);
}
ui_->mac_container->setVisible(!manager->IsMacAccessibilityEnabled());
#ifdef Q_OS_DARWIN
qint32 mac_version = Utilities::GetMacVersion();
ui_->mac_label->setVisible(mac_version < 9);
ui_->mac_label_mavericks->setVisible(mac_version >= 9);
#endif // Q_OS_DARWIN
}
void GlobalShortcutsSettingsPage::SetShortcut(const QString &id, const QKeySequence &key) {
Shortcut &shortcut = shortcuts_[id];
shortcut.key = key;
shortcut.item->setText(1, key.toString(QKeySequence::NativeText));
}
void GlobalShortcutsSettingsPage::Save() {
for (const Shortcut &s : shortcuts_.values()) {
s.s.action->setShortcut(s.key);
s.s.shortcut->setKey(s.key);
settings_.setValue(s.s.id, s.key.toString());
}
settings_.setValue("use_gnome", ui_->gnome_checkbox->isChecked());
dialog()->global_shortcuts_manager()->ReloadSettings();
}
void GlobalShortcutsSettingsPage::ItemClicked(QTreeWidgetItem *item) {
current_id_ = item->data(0, Qt::UserRole).toString();
Shortcut &shortcut = shortcuts_[current_id_];
// Enable options
ui_->shortcut_options->setEnabled(true);
ui_->shortcut_options->setTitle(tr("Shortcut for %1").arg(shortcut.s.action->text()));
if (shortcut.key == shortcut.s.default_key)
ui_->radio_default->setChecked(true);
else if (shortcut.key.isEmpty())
ui_->radio_none->setChecked(true);
else
ui_->radio_custom->setChecked(true);
}
void GlobalShortcutsSettingsPage::NoneClicked() {
SetShortcut(current_id_, QKeySequence());
}
void GlobalShortcutsSettingsPage::DefaultClicked() {
SetShortcut(current_id_, shortcuts_[current_id_].s.default_key);
}
void GlobalShortcutsSettingsPage::ChangeClicked() {
GlobalShortcuts *manager = dialog()->global_shortcuts_manager();
manager->Unregister();
QKeySequence key = grabber_->GetKey(shortcuts_[current_id_].s.action->text());
manager->Register();
if (key.isEmpty()) return;
// Check if this key sequence is used by any other actions
for (const QString &id : shortcuts_.keys()) {
if (shortcuts_[id].key == key) SetShortcut(id, QKeySequence());
}
ui_->radio_custom->setChecked(true);
SetShortcut(current_id_, key);
}
void GlobalShortcutsSettingsPage::OpenGnomeKeybindingProperties() {
if (!QProcess::startDetached("gnome-keybinding-properties")) {
if (!QProcess::startDetached("gnome-control-center", QStringList() << "keyboard")) {
QMessageBox::warning(this, "Error",
tr("The \"%1\" command could not be started.")
.arg("gnome-keybinding-properties"));
}
}
}

View File

@@ -0,0 +1,81 @@
/*
* Strawberry Music Player
* This file was part of Clementine.
* Copyright 2010, David Sansome <me@davidsansome.com>
*
* Strawberry 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.
*
* Strawberry 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 Strawberry. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef GLOBALSHORTCUTSSETTINGSPAGE_H
#define GLOBALSHORTCUTSSETTINGSPAGE_H
#include "config.h"
#include <memory>
#include <QMap>
#include <QSettings>
#include "globalshortcuts/globalshortcuts.h"
#include "settings/settingspage.h"
class QTreeWidgetItem;
class Ui_GlobalShortcutsSettingsPage;
class GlobalShortcutGrabber;
class GlobalShortcutsSettingsPage : public SettingsPage {
Q_OBJECT
public:
GlobalShortcutsSettingsPage(SettingsDialog *dialog);
~GlobalShortcutsSettingsPage();
static const char *kSettingsGroup;
bool IsEnabled() const;
void Load();
void Save();
private slots:
void ItemClicked(QTreeWidgetItem *);
void NoneClicked();
void DefaultClicked();
void ChangeClicked();
void OpenGnomeKeybindingProperties();
private:
struct Shortcut {
GlobalShortcuts::Shortcut s;
QKeySequence key;
QTreeWidgetItem *item;
};
void SetShortcut(const QString &id, const QKeySequence &key);
private:
Ui_GlobalShortcutsSettingsPage *ui_;
bool initialised_;
std::unique_ptr<GlobalShortcutGrabber> grabber_;
QSettings settings_;
QMap<QString, Shortcut> shortcuts_;
QString current_id_;
};
#endif // GLOBALSHORTCUTSSETTINGSPAGE_H

View File

@@ -0,0 +1,232 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>GlobalShortcutsSettingsPage</class>
<widget class="QWidget" name="GlobalShortcutsSettingsPage">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>507</width>
<height>393</height>
</rect>
</property>
<property name="windowTitle">
<string>Shortcuts</string>
</property>
<property name="windowIcon">
<iconset resource="../../data/data.qrc">
<normaloff>:/icons/64x64/strawberry.png</normaloff>:/icons/64x64/strawberry.png</iconset>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QWidget" name="gnome_container" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="QCheckBox" name="gnome_checkbox">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Use Gnome's shortcut keys</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="gnome_open">
<property name="text">
<string>Open...</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QWidget" name="mac_container" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<property name="spacing">
<number>0</number>
</property>
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="mac_label">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>You need to launch System Preferences and turn on &quot;&lt;span style=&quot; font-style:italic;&quot;&gt;Enable access for assistive devices&lt;/span&gt;&quot; to use global shortcuts in Strawberry.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="mac_label_mavericks">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>You need to launch System Preferences and allow Strawberry to &quot;&lt;span style=&quot;font-style:italic&quot;&gt;control your computer&lt;/span&gt;&quot; to use global shortcuts in Strawberry.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="mac_open">
<property name="text">
<string>Open...</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QTreeWidget" name="list">
<property name="editTriggers">
<set>QAbstractItemView::NoEditTriggers</set>
</property>
<property name="alternatingRowColors">
<bool>true</bool>
</property>
<property name="rootIsDecorated">
<bool>false</bool>
</property>
<property name="allColumnsShowFocus">
<bool>true</bool>
</property>
<column>
<property name="text">
<string comment="Category label">Action</string>
</property>
</column>
<column>
<property name="text">
<string>Shortcut</string>
</property>
</column>
</widget>
</item>
<item>
<widget class="QGroupBox" name="shortcut_options">
<property name="enabled">
<bool>true</bool>
</property>
<property name="title">
<string>Shortcut for %1</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QRadioButton" name="radio_none">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>&amp;None</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radio_default">
<property name="text">
<string>De&amp;fault</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radio_custom">
<property name="text">
<string>&amp;Custom</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="change">
<property name="text">
<string>Change shortcut...</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<tabstops>
<tabstop>list</tabstop>
<tabstop>radio_none</tabstop>
<tabstop>radio_default</tabstop>
<tabstop>radio_custom</tabstop>
<tabstop>change</tabstop>
</tabstops>
<resources>
<include location="../../data/data.qrc"/>
</resources>
<connections>
<connection>
<sender>gnome_checkbox</sender>
<signal>toggled(bool)</signal>
<receiver>list</receiver>
<slot>setDisabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>63</x>
<y>25</y>
</hint>
<hint type="destinationlabel">
<x>82</x>
<y>63</y>
</hint>
</hints>
</connection>
<connection>
<sender>gnome_checkbox</sender>
<signal>toggled(bool)</signal>
<receiver>shortcut_options</receiver>
<slot>setDisabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>244</x>
<y>26</y>
</hint>
<hint type="destinationlabel">
<x>122</x>
<y>298</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@@ -0,0 +1,56 @@
/*
* Strawberry Music Player
* This file was part of Clementine.
* Copyright 2010, David Sansome <me@davidsansome.com>
*
* Strawberry 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.
*
* Strawberry 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 Strawberry. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include "config.h"
#include "transcodersettingspage.h"
#include "ui_transcodersettingspage.h"
#include "core/iconloader.h"
TranscoderSettingsPage::TranscoderSettingsPage(SettingsDialog* dialog)
: SettingsPage(dialog), ui_(new Ui_TranscoderSettingsPage) {
ui_->setupUi(this);
setWindowIcon(IconLoader::Load("tools-wizard"));
}
TranscoderSettingsPage::~TranscoderSettingsPage() {
delete ui_;
}
void TranscoderSettingsPage::Load() {
ui_->transcoding_aac->Load();
ui_->transcoding_flac->Load();
ui_->transcoding_mp3->Load();
ui_->transcoding_speex->Load();
ui_->transcoding_vorbis->Load();
ui_->transcoding_wma->Load();
ui_->transcoding_opus->Load();
}
void TranscoderSettingsPage::Save() {
ui_->transcoding_aac->Save();
ui_->transcoding_flac->Save();
ui_->transcoding_mp3->Save();
ui_->transcoding_speex->Save();
ui_->transcoding_vorbis->Save();
ui_->transcoding_wma->Save();
ui_->transcoding_opus->Save();
}

View File

@@ -0,0 +1,46 @@
/*
* Strawberry Music Player
* This file was part of Clementine.
* Copyright 2010, David Sansome <me@davidsansome.com>
*
* Strawberry 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.
*
* Strawberry 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 Strawberry. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef TRANSCODERSETTINGSPAGE_H
#define TRANSCODERSETTINGSPAGE_H
#include "config.h"
#include "settingspage.h"
class Ui_TranscoderSettingsPage;
class TranscoderSettingsPage : public SettingsPage {
Q_OBJECT
public:
TranscoderSettingsPage(SettingsDialog* dialog);
~TranscoderSettingsPage();
static const char *kSettingsGroup;
void Load();
void Save();
private:
Ui_TranscoderSettingsPage* ui_;
};
#endif // TRANSCODERSETTINGSPAGE_H

View File

@@ -0,0 +1,194 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>TranscoderSettingsPage</class>
<widget class="QWidget" name="TranscoderSettingsPage">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Transcoding</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="label_18">
<property name="text">
<string>These settings are used in the &quot;Transcode Music&quot; dialog, and when converting music before copying it to a device.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="tab">
<attribute name="title">
<string>MP3</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_20">
<property name="spacing">
<number>0</number>
</property>
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="TranscoderOptionsMP3" name="transcoding_mp3" native="true"/>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_2">
<attribute name="title">
<string>Vorbis</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_25">
<property name="spacing">
<number>0</number>
</property>
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="TranscoderOptionsVorbis" name="transcoding_vorbis" native="true"/>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_3">
<attribute name="title">
<string>FLAC</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_24">
<property name="spacing">
<number>0</number>
</property>
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="TranscoderOptionsFlac" name="transcoding_flac" native="true"/>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_4">
<attribute name="title">
<string>Speex</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_23">
<property name="spacing">
<number>0</number>
</property>
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="TranscoderOptionsSpeex" name="transcoding_speex" native="true"/>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_5">
<attribute name="title">
<string>AAC</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_22">
<property name="spacing">
<number>0</number>
</property>
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="TranscoderOptionsAAC" name="transcoding_aac" native="true"/>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_6">
<attribute name="title">
<string>WMA</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_21">
<property name="spacing">
<number>0</number>
</property>
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="TranscoderOptionsWma" name="transcoding_wma" native="true"/>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_7">
<attribute name="title">
<string>Opus</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_26">
<property name="spacing">
<number>0</number>
</property>
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="TranscoderOptionsOpus" name="transcoding_opus" native="true"/>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>TranscoderOptionsMP3</class>
<extends>QWidget</extends>
<header>transcoder/transcoderoptionsmp3.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>TranscoderOptionsVorbis</class>
<extends>QWidget</extends>
<header>transcoder/transcoderoptionsvorbis.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>TranscoderOptionsSpeex</class>
<extends>QWidget</extends>
<header>transcoder/transcoderoptionsspeex.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>TranscoderOptionsAAC</class>
<extends>QWidget</extends>
<header>transcoder/transcoderoptionsaac.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>TranscoderOptionsFlac</class>
<extends>QWidget</extends>
<header>transcoder/transcoderoptionsflac.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>TranscoderOptionsWma</class>
<extends>QWidget</extends>
<header>transcoder/transcoderoptionswma.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>TranscoderOptionsOpus</class>
<extends>QWidget</extends>
<header>transcoder/transcoderoptionsopus.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>