示例#1
0
/** Load an icon from a chosen theme in options. */
void MediaButton::setIconFromTheme(const QString &theme)
{
	SettingsPrivate *settingsPrivate = SettingsPrivate::instance();
	if (settingsPrivate->isButtonThemeCustomized() && settingsPrivate->hasCustomIcon(objectName())) {
		setIcon(QIcon(settingsPrivate->customIcon(objectName())));
	} else {
		// The objectName in the UI file MUST match the alias in the QRC file!
		QString iconFile = ":/player/" + theme.toLower() + "/" + this->objectName().remove("Button");
		QIcon icon(iconFile);
		if (!icon.isNull()) {
			QPushButton::setIcon(QIcon(iconFile));
		}
	}
}
/** Changes the current theme and updates this dialog too. */
void CustomizeThemeDialog::setThemeNameAndDialogButtons(QString newTheme)
{
	SettingsPrivate *settings = SettingsPrivate::instance();
	// Check for each button if there is a custom icon
	for (QPushButton *button : customizeButtonsScrollArea->findChildren<QPushButton*>()) {
		if (button) {
			// Keep the custom icon provided by one
			if (settings->hasCustomIcon(button->objectName())) {
				button->setIcon(QIcon(settings->customIcon(button->objectName())));
			} else {
				button->setIcon(QIcon(":/player/" + newTheme.toLower() + "/" + button->objectName()));
			}
		}
	}
	Settings::instance()->setThemeName(newTheme);
	for (MediaButton *m : mainWindow->mediaButtons) {
		m->setIconFromTheme(newTheme);
	}
}
示例#3
0
/** Changes the current theme and updates this dialog too. */
void CustomizeThemeDialog::setThemeNameAndDialogButtons(QString newTheme)
{
	SettingsPrivate *settings = SettingsPrivate::instance();
	// Check for each button if there is a custom icon
	for (QPushButton *button : customizeButtonsScrollArea->findChildren<QPushButton*>()) {
		if (button) {
			// Keep the custom icon provided by one
			if (settings->hasCustomIcon(button->objectName())) {
				button->setIcon(QIcon(settings->customIcon(button->objectName())));
			} else {
				QIcon i(":/player/" + newTheme.replace(" ", "").toLower() + "/" + button->objectName());
				if (!i.isNull()) {
					button->setIcon(i);
				}
			}
		}
	}
	Settings::instance()->setThemeName(newTheme);
}
示例#4
0
/** Load theme at startup. */
void CustomizeThemeDialog::loadTheme()
{
	SettingsPrivate *settingsPrivate = SettingsPrivate::instance();
	customizeThemeCheckBox->setChecked(settingsPrivate->isButtonThemeCustomized());

	Settings *settings = Settings::instance();
	sizeButtonsSpinBox->setValue(settings->buttonsSize());

	// Select the right drop-down item according to the theme
	int i = 0;
	while (settings->theme() != themeComboBox->itemText(i).toLower()) {
		i++;
	}
	themeComboBox->setCurrentIndex(i);

	// Buttons
	QList<QPushButton*> mediaPlayerButtons = buttonsListBox->findChildren<QPushButton*>();
	for (QPushButton *mediaPlayerButton : mediaPlayerButtons) {
		QString mediaButton = mediaPlayerButton->objectName() + "Button";
		QCheckBox *checkbox = this->findChild<QCheckBox*>(mediaPlayerButton->objectName() + "CheckBox");
		if (checkbox) {
			checkbox->setChecked(settings->isMediaButtonVisible(mediaButton));
		}
		// Replace icon of the button in this dialog too
		if (settingsPrivate->hasCustomIcon(mediaButton)) {
			QString customIcon = settingsPrivate->customIcon(mediaButton);
			mediaPlayerButton->setIcon(QIcon(customIcon));
		}

	}

	// Extended Search Area
	settingsPrivate->isExtendedSearchVisible() ? radioButtonShowExtendedSearch->setChecked(true) : radioButtonHideExtendedSearch->setChecked(true);

	// Volume bar
	radioButtonShowVolume->setChecked(settings->isVolumeBarTextAlwaysVisible());
	spinBoxHideVolumeLabel->setValue(settingsPrivate->volumeBarHideAfter());

	// Fonts
	fontComboBoxPlaylist->setCurrentFont(settingsPrivate->font(SettingsPrivate::FF_Playlist));
	fontComboBoxLibrary->setCurrentFont(settingsPrivate->font(SettingsPrivate::FF_Library));
	fontComboBoxMenus->setCurrentFont(settingsPrivate->font(SettingsPrivate::FF_Menu));
	spinBoxPlaylist->setValue(settingsPrivate->fontSize(SettingsPrivate::FF_Playlist));
	spinBoxLibrary->blockSignals(true);
	spinBoxLibrary->setValue(settingsPrivate->fontSize(SettingsPrivate::FF_Library));
	spinBoxLibrary->blockSignals(false);
	spinBoxMenus->setValue(settingsPrivate->fontSize(SettingsPrivate::FF_Menu));

	// Colors
	// Alternate background colors in playlists
	if (settingsPrivate->colorsAlternateBG()) {
		enableAlternateBGRadioButton->setChecked(true);
	} else {
		disableAlternateBGRadioButton->setChecked(true);
	}

	bool customColors = settingsPrivate->isCustomColors();
	this->toggleCustomColors(customColors);
	// Custom text color can be enabled only if custom colors are enabled first!
	this->toggleCustomTextColors(customColors && settingsPrivate->isCustomTextColorOverriden());

	// Covers
	settings->isCoverBelowTracksEnabled() ? radioButtonEnableBigCover->setChecked(true) : radioButtonDisableBigCover->setChecked(true);
	spinBoxBigCoverOpacity->setValue(settings->coverBelowTracksOpacity() * 100);

	// Tabs
	radioButtonTabsRect->setChecked(settingsPrivate->isRectTabs());
	overlapTabsSpinBox->setValue(settingsPrivate->tabsOverlappingLength());

	// Articles
	radioButtonEnableArticles->blockSignals(true);
	bool isFiltered = settingsPrivate->isLibraryFilteredByArticles();
	radioButtonEnableArticles->setChecked(isFiltered);
	std::list<QWidget*> enabled = { articlesLineEdit, labelReorderArtistsArticle, labelReorderArtistsArticleExample, radioButtonEnableReorderArtistsArticle, radioButtonDisableReorderArtistsArticle };
	for (QWidget *w : enabled) {
		w->setEnabled(isFiltered);
	}
	radioButtonEnableReorderArtistsArticle->setChecked(settingsPrivate->isReorderArtistsArticle());
	radioButtonEnableArticles->blockSignals(false);

	// Star delegate
	if (settings->libraryHasStars()) {
		radioButtonEnableStarDelegate->setChecked(true);
	} else {
		radioButtonDisableStarDelegate->setChecked(true);
	}
	if (settings->isShowNeverScored()) {
		radioButtonShowNeverScoredTracks->setChecked(true);
	} else {
		radioButtonHideNeverScoredTracks->setChecked(true);
	}
}