/** Redefined to always display the same height for albums, even for those without one. */ QSize LibraryItemDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const { SettingsPrivate *settingsPrivate = SettingsPrivate::instance(); QStandardItem *item = _libraryModel->itemFromIndex(_proxy->mapToSource(index)); if (item->type() == Miam::IT_Album) { QFontMetrics fmf(settingsPrivate->font(SettingsPrivate::FF_Library)); return QSize(option.rect.width(), qMax(fmf.height(), Settings::instance()->coverSizeLibraryTree() + 2)); } else { QFontMetrics fmf(settingsPrivate->font(SettingsPrivate::FF_Library)); return QSize(option.rect.width(), fmf.height()); } }
PlaylistHeaderView::PlaylistHeaderView(Playlist *parent) : QHeaderView(Qt::Horizontal, parent) { this->setHighlightSections(false); this->setFrameShape(QFrame::NoFrame); this->setMinimumSectionSize(this->height()); this->setMouseTracking(true); this->setSectionResizeMode(QHeaderView::Interactive); this->setSectionsMovable(true); this->setStretchLastSection(true); this->installEventFilter(this); // Context menu on header of columns _columns = new QMenu(this); connect(_columns, &QMenu::triggered, this, [=](const QAction *action) { int columnIndex = action->data().toInt(); this->setSectionHidden(columnIndex, !this->isSectionHidden(columnIndex)); parent->resizeColumnToContents(columnIndex); }); // Initialize font from settings SettingsPrivate *settings = SettingsPrivate::instance(); this->setFont(settings->font(SettingsPrivate::FF_Playlist)); connect(settings, &SettingsPrivate::fontHasChanged, this, [=](SettingsPrivate::FontFamily ff, const QFont &newFont) { if (ff == SettingsPrivate::FF_Playlist) { this->setFont(newFont); } }); }
TabBar::TabBar(TabPlaylist *parent) : QTabBar(parent), lineEdit(new QLineEdit(this)), tabPlaylist(parent) { this->setAcceptDrops(true); this->setDocumentMode(true); this->setTabsClosable(true); this->setUsesScrollButtons(true); this->installEventFilter(this); lineEdit->setVisible(false); lineEdit->setAlignment(Qt::AlignCenter); lineEdit->setFrame(false); lineEdit->installEventFilter(this); lineEdit->setAttribute(Qt::WA_MacShowFocusRect, false); _timer = new QTimer(this); _timer->setInterval(300); _timer->setSingleShot(true); connect(lineEdit, &QLineEdit::returnPressed, this, &TabBar::renameTab); // Switch between tabs if the Drag & Drop isn't finished connect(_timer, &QTimer::timeout, [=]() { this->setCurrentIndex(tabAt(_targetRect.center())); _targetRect = tabRect(currentIndex()); }); SettingsPrivate *settings = SettingsPrivate::instance(); auto applyFont = [this, settings] (SettingsPrivate::FontFamily ff, const QFont &newFont) { if (ff == SettingsPrivate::FF_Playlist) { QFont font = newFont; font.setPointSizeF(font.pointSizeF() * 0.8); this->setFont(font); int h = fontMetrics().height() * 1.25; if (h >= 30) { this->setMinimumHeight(h); this->setMaximumHeight(h); } else { this->setMinimumHeight(30); this->setMaximumHeight(30); } } }; // Init font from settings applyFont(SettingsPrivate::FF_Playlist, settings->font(SettingsPrivate::FF_Playlist)); connect(settings, &SettingsPrivate::fontHasChanged, this, applyFont); }
/** Default constructor. */ ExtendedTabBar::ExtendedTabBar(QWidget *parent) : QTabBar(parent) { SettingsPrivate *settings = SettingsPrivate::instance(); QFont f = settings->font(SettingsPrivate::FF_Library); f.setPointSizeF(f.pointSizeF() * 0.8); this->setFont(f); this->setMouseTracking(true); connect(settings, &SettingsPrivate::fontHasChanged, this, [=](SettingsPrivate::FontFamily ff, const QFont &newFont) { if (ff == SettingsPrivate::FF_Library) { this->setMinimumHeight(fontMetrics().height() * 1.25); this->setMaximumHeight(fontMetrics().height() * 1.25); QFont font = newFont; font.setPointSizeF(font.pointSizeF() * 0.8); this->setFont(font); } }); }
/** Load theme at startup. */ void CustomizeThemeDialog::loadTheme() { SettingsPrivate *settings = SettingsPrivate::instance(); customizeThemeCheckBox->setChecked(settings->isButtonThemeCustomized()); sizeButtonsSpinBox->setValue(settings->buttonsSize()); // Select the right drop-down item according to the theme int i = 0; while (Settings::instance()->theme() != themeComboBox->itemText(i).toLower()) { i++; } themeComboBox->setCurrentIndex(i); // Buttons for (MediaButton *b : _mainWindow->mediaButtons) { // Check or uncheck checkboxes in this customize interface QCheckBox *checkBox = findChild<QCheckBox *>(b->objectName().replace("Button", "CheckBox")); if (checkBox) { checkBox->setChecked(settings->isMediaButtonVisible(b->objectName())); } // Display customs icons, if any QPushButton *pushButton = findChild<QPushButton *>(b->objectName().remove("Button")); if (pushButton) { pushButton->setIcon(b->icon()); } } // Extended Search Area settings->isExtendedSearchVisible() ? radioButtonShowExtendedSearch->setChecked(true) : radioButtonHideExtendedSearch->setChecked(true); // Volume bar radioButtonShowVolume->setChecked(settings->isVolumeBarTextAlwaysVisible()); spinBoxHideVolumeLabel->setValue(settings->volumeBarHideAfter()); // Fonts fontComboBoxPlaylist->setCurrentFont(settings->font(SettingsPrivate::FF_Playlist)); fontComboBoxLibrary->setCurrentFont(settings->font(SettingsPrivate::FF_Library)); fontComboBoxMenus->setCurrentFont(settings->font(SettingsPrivate::FF_Menu)); spinBoxPlaylist->setValue(settings->fontSize(SettingsPrivate::FF_Playlist)); spinBoxLibrary->blockSignals(true); spinBoxLibrary->setValue(settings->fontSize(SettingsPrivate::FF_Library)); spinBoxLibrary->blockSignals(false); spinBoxMenus->setValue(settings->fontSize(SettingsPrivate::FF_Menu)); // Library checkBoxDisplayCovers->setChecked(settings->isCoversEnabled()); spinBoxCoverSize->blockSignals(true); spinBoxCoverSize->setValue(settings->coverSize()); spinBoxCoverSize->blockSignals(false); // Colors settings->colorsAlternateBG() ? enableAlternateBGRadioButton->setChecked(true) : disableAlternateBGRadioButton->setChecked(true); settings->isCustomColors() ? enableCustomColorsRadioButton->setChecked(true) : disableCustomColorsRadioButton->setChecked(true); this->toggleCustomColors(settings->isCustomColors()); // Covers radioButtonEnableBigCover->setChecked(settings->isBigCoverEnabled()); spinBoxBigCoverOpacity->setValue(settings->bigCoverOpacity() * 100); // Tabs radioButtonTabsRect->setChecked(settings->isRectTabs()); overlapTabsSpinBox->setValue(settings->tabsOverlappingLength()); // Articles radioButtonEnableArticles->blockSignals(true); bool isFiltered = settings->isLibraryFilteredByArticles(); radioButtonEnableArticles->setChecked(isFiltered); std::list<QWidget*> enabled = { articlesLineEdit, labelReorderArtistsArticle, labelReorderArtistsArticleExample, radioButtonEnableReorderArtistsArticle, radioButtonDisableReorderArtistsArticle }; for (QWidget *w : enabled) { w->setEnabled(isFiltered); } radioButtonEnableReorderArtistsArticle->setChecked(settings->isReorderArtistsArticle()); radioButtonEnableArticles->blockSignals(false); // Star delegate if (settings->isStarDelegates()) { radioButtonEnableStarDelegate->setChecked(true); } else { radioButtonDisableStarDelegate->setChecked(true); } if (settings->isShowNeverScored()) { radioButtonShowNeverScoredTracks->setChecked(true); } else { radioButtonHideNeverScoredTracks->setChecked(true); } }
void CustomizeThemeDialog::setupActions() { SettingsPrivate *settings = SettingsPrivate::instance(); for (MediaButton *b : _mainWindow->mediaButtons) { connect(sizeButtonsSpinBox, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), b, &MediaButton::setSize); } // Select button theme and size connect(themeComboBox, static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentIndexChanged), this, &CustomizeThemeDialog::setThemeNameAndDialogButtons); connect(customizeThemeCheckBox, &QCheckBox::toggled, this, [=](bool b) { settings->setButtonThemeCustomized(b); if (!b) { // Restore all buttons when unchecked for (QCheckBox *button : customizeButtonsScrollArea->findChildren<QCheckBox*>()) { if (!button->isChecked()) { button->toggle(); } } // Restore default image for (MediaButton *b : _mainWindow->mediaButtons) { b->setIcon(QIcon()); } } }); connect(sizeButtonsSpinBox, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), settings, &SettingsPrivate::setButtonsSize); // Hide buttons or not for (MediaButton *b : _mainWindow->mediaButtons) { QCheckBox *checkBox = findChild<QCheckBox *>(b->objectName().replace("Button", "CheckBox")); if (checkBox) { connect(checkBox, &QCheckBox::toggled, [=] (bool visible) { b->setVisible(visible && !_mainWindow->tagEditor->isVisible()); settings->setMediaButtonVisible(b->objectName(), visible); }); } } // Connect a file dialog to every button if one wants to customize everything for (QPushButton *pushButton : customizeButtonsScrollArea->findChildren<QPushButton*>()) { connect(pushButton, &QPushButton::clicked, this, &CustomizeThemeDialog::openChooseIconDialog); } // Extended Search Area connect(radioButtonShowExtendedSearch, &QRadioButton::toggled, settings, &SettingsPrivate::setExtendedSearchVisible); // Volume bar connect(radioButtonShowVolume, &QRadioButton::toggled, this, [=](bool b) { settings->setVolumeBarTextAlwaysVisible(b); _mainWindow->volumeSlider->update(); }); connect(spinBoxHideVolumeLabel, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), settings, &SettingsPrivate::setVolumeBarHideAfter); // Fonts connect(fontComboBoxPlaylist, &QFontComboBox::currentFontChanged, [=](const QFont &font) { settings->setFont(SettingsPrivate::FF_Playlist, font); this->fade(); }); connect(fontComboBoxLibrary, &QFontComboBox::currentFontChanged, [=](const QFont &font) { settings->setFont(SettingsPrivate::FF_Library, font); this->fade(); _mainWindow->library->viewport()->update(); }); connect(fontComboBoxMenus, &QFontComboBox::currentFontChanged, [=](const QFont &font) { settings->setFont(SettingsPrivate::FF_Menu, font); this->fade(); _mainWindow->updateFonts(font); }); // And fonts size connect(spinBoxPlaylist, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), [=](int i) { settings->setFontPointSize(SettingsPrivate::FF_Playlist, i); this->fade(); }); connect(spinBoxLibrary, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), [=](int i) { settings->setFontPointSize(SettingsPrivate::FF_Library, i); _mainWindow->library->model()->layoutChanged(); QFont lowerFont = settings->font(SettingsPrivate::FF_Library); lowerFont.setPointSize(lowerFont.pointSizeF() * 0.7); _mainWindow->library->model()->setHeaderData(0, Qt::Horizontal, lowerFont, Qt::FontRole); this->fade(); }); connect(spinBoxMenus, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), [=](int i) { settings->setFontPointSize(SettingsPrivate::FF_Menu, i); _mainWindow->updateFonts(settings->font(SettingsPrivate::FF_Menu)); this->fade(); }); // Timer connect(_timer, &QTimer::timeout, [=]() { this->animate(0.5, 1.0); }); // Colors connect(enableCustomColorsRadioButton, &QCheckBox::toggled, this, &CustomizeThemeDialog::toggleCustomColors); connect(enableAlternateBGRadioButton, &QRadioButton::toggled, this, &CustomizeThemeDialog::toggleAlternativeBackgroundColor); for (QToolButton *b : groupBoxCustomColors->findChildren<QToolButton*>()) { connect(b, &QToolButton::clicked, this, &CustomizeThemeDialog::showColorDialog); } // Show covers in the Library connect(checkBoxDisplayCovers, &QCheckBox::toggled, [=](bool b) { settings->setCovers(b); if (_mainWindow->library->model()) { _mainWindow->library->model()->layoutChanged(); this->fade(); } }); // Change cover size QTimer *reloadCoverSizeTimer = new QTimer(this); reloadCoverSizeTimer->setSingleShot(true); connect(spinBoxCoverSize, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), [=](int cs) { settings->setCoverSize(cs); if (_mainWindow->library->model()) { _mainWindow->library->model()->layoutChanged(); this->fade(); } reloadCoverSizeTimer->start(1000); }); connect(reloadCoverSizeTimer, &QTimer::timeout, _mainWindow->library, &LibraryTreeView::aboutToUpdateCoverSize); // Change big cover opacity connect(radioButtonEnableBigCover, &QRadioButton::toggled, [=](bool b) { settings->setBigCovers(b); labelBigCoverOpacity->setEnabled(b); spinBoxBigCoverOpacity->setEnabled(b); this->fade(); _mainWindow->library->viewport()->repaint(); }); connect(spinBoxBigCoverOpacity, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), [=](int v) { settings->setBigCoverOpacity(v); this->fade(); _mainWindow->library->viewport()->repaint(); }); // Filter library connect(radioButtonEnableArticles, &QRadioButton::toggled, this, [=](bool b) { settings->setIsLibraryFilteredByArticles(b); // Don't reorder the library if one hasn't typed an article yet if (!settings->libraryFilteredByArticles().isEmpty()) { _mainWindow->library->model()->rebuildSeparators(); } }); connect(articlesLineEdit, &CustomizeThemeTagLineEdit::taglistHasChanged, this, [=](const QStringList &articles) { settings->setLibraryFilteredByArticles(articles); _mainWindow->library->model()->rebuildSeparators(); }); connect(radioButtonEnableReorderArtistsArticle, &QRadioButton::toggled, this, [=](bool b) { settings->setReorderArtistsArticle(b); this->fade(); _mainWindow->library->viewport()->repaint(); }); // Tabs connect(radioButtonTabsRect, &QRadioButton::toggled, [=](bool b) { settings->setTabsRect(b); this->fade(); _mainWindow->tabPlaylists->tabBar()->update(); _mainWindow->tabPlaylists->cornerWidget(Qt::TopRightCorner)->update(); }); connect(overlapTabsSpinBox, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), [=](int v) { settings->setTabsOverlappingLength(v); this->fade(); _mainWindow->tabPlaylists->tabBar()->update(); }); // Star delegates connect(radioButtonEnableStarDelegate, &QRadioButton::toggled, this, [=](bool b) { settings->setDelegates(b); labelLibraryDelegates->setEnabled(b); radioButtonShowNeverScoredTracks->setEnabled(b); radioButtonHideNeverScoredTracks->setEnabled(b); }); connect(radioButtonShowNeverScoredTracks, &QRadioButton::toggled, settings, &SettingsPrivate::setShowNeverScored); }
/** Albums have covers usually. */ void LibraryItemDelegate::drawAlbum(QPainter *painter, QStyleOptionViewItem &option, QStandardItem *item) const { /// XXX: reload cover with high resolution when one has increased coverSize (every 64px) static QImageReader imageReader; SettingsPrivate *settingsPrivate = SettingsPrivate::instance(); // Album has no picture yet bool itemHasNoIcon = item->icon().isNull(); if (itemHasNoIcon) { // Check first if an inner cover should be displayed if (item->data(Miam::DF_InternalCover).toString().isEmpty()) { QString coverPath = item->data(Miam::DF_CoverPath).toString(); if (!coverPath.isEmpty()) { // qDebug() << Q_FUNC_INFO << "loading external cover from harddrive"; imageReader.setFileName(QDir::fromNativeSeparators(coverPath)); imageReader.setScaledSize(QSize(_coverSize, _coverSize)); item->setIcon(QPixmap::fromImage(imageReader.read())); itemHasNoIcon = false; } } else { FileHelper fh(item->data(Miam::DF_InternalCover).toString()); std::unique_ptr<Cover> cover(fh.extractCover()); if (cover) { QPixmap p; if (p.loadFromData(cover->byteArray(), cover->format())) { if (!p.isNull()) { item->setIcon(p); itemHasNoIcon = false; } //} else { // qDebug() << Q_FUNC_INFO << "couldn't load data into QPixmap"; } //} else { // qDebug() << Q_FUNC_INFO << "couldn't extract inner cover"; } } } painter->save(); QRect cover; if (QGuiApplication::isLeftToRight()) { cover = QRect(option.rect.x() + 1, option.rect.y() + 1, _coverSize, _coverSize); } else { cover = QRect(option.rect.width() + 19 - _coverSize - 1, option.rect.y() + 1, _coverSize, _coverSize); } // If font size is greater than the cover, align it if (_coverSize < option.rect.height() - 2) { painter->translate(0, (option.rect.height() - 1 - _coverSize) / 2); } if (itemHasNoIcon) { if (_iconOpacity <= 0.25) { painter->setOpacity(_iconOpacity); } else { painter->setOpacity(0.25); } painter->drawPixmap(cover, QPixmap(":/icons/disc")); } else { painter->setOpacity(_iconOpacity); QPixmap p = option.icon.pixmap(QSize(_coverSize, _coverSize)); painter->drawPixmap(cover, p); } painter->restore(); // Add an icon on the right if album is from some remote location bool isRemote = item->data(Miam::DF_IsRemote).toBool(); int offsetWidth = 0; if (isRemote) { int iconSize = 31; QRect iconRemoteRect(option.rect.x() + option.rect.width() - (iconSize + 4), (option.rect.height() - iconSize)/ 2 + option.rect.y() + 2, iconSize, iconSize); QPixmap iconRemote(item->data(Miam::DF_IconPath).toString()); painter->save(); painter->setOpacity(0.5); painter->drawPixmap(iconRemoteRect, iconRemote); painter->restore(); offsetWidth = iconSize; } option.textElideMode = Qt::ElideRight; QRect rectText; // It's possible to have missing covers in your library, so we need to keep alignment. if (QGuiApplication::isLeftToRight()) { rectText = QRect(option.rect.x() + _coverSize + 5, option.rect.y(), option.rect.width() - (_coverSize + 7) - offsetWidth, option.rect.height() - 1); } else { rectText = QRect(option.rect.x(), option.rect.y(), option.rect.width() - _coverSize - 5, option.rect.height()); } QFontMetrics fmf(settingsPrivate->font(SettingsPrivate::FF_Library)); QString s = fmf.elidedText(option.text, Qt::ElideRight, rectText.width()); this->paintText(painter, option, rectText, s, item); }
/** 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); } }
void CustomizeThemeDialog::setupActions() { SettingsPrivate *settingsPrivate = SettingsPrivate::instance(); // Select button theme and size connect(themeComboBox, static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentIndexChanged), this, &CustomizeThemeDialog::setThemeNameAndDialogButtons); connect(customizeThemeCheckBox, &QCheckBox::toggled, this, [=](bool b) { settingsPrivate->setButtonThemeCustomized(b); if (!b) { // Restore all buttons when unchecked for (QCheckBox *button : customizeButtonsScrollArea->findChildren<QCheckBox*>()) { if (!button->isChecked()) { button->toggle(); } } for (QPushButton *pushButton : customizeButtonsScrollArea->findChildren<QPushButton*>()) { settingsPrivate->setCustomIcon(pushButton->objectName() + "Button", ""); } } }); Settings *settings = Settings::instance(); connect(sizeButtonsSpinBox, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), settings, &Settings::setButtonsSize); // Hide buttons or not QList<QCheckBox*> mediaPlayerButtons = buttonsListBox->findChildren<QCheckBox*>(); for (QCheckBox *mediaPlayerButton : mediaPlayerButtons) { connect(mediaPlayerButton, &QCheckBox::toggled, this, [=](bool value) { settings->setMediaButtonVisible(mediaPlayerButton->objectName().replace("CheckBox", "Button"), value); }); } // Connect a file dialog to every button if one wants to customize everything for (QPushButton *pushButton : customizeButtonsScrollArea->findChildren<QPushButton*>()) { connect(pushButton, &QPushButton::clicked, this, &CustomizeThemeDialog::openChooseIconDialog); } // Extended Search Area connect(radioButtonShowExtendedSearch, &QRadioButton::toggled, settingsPrivate, &SettingsPrivate::setExtendedSearchVisible); // Volume bar connect(radioButtonShowVolume, &QRadioButton::toggled, settings, &Settings::setVolumeBarTextAlwaysVisible); connect(spinBoxHideVolumeLabel, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), settingsPrivate, &SettingsPrivate::setVolumeBarHideAfter); // Fonts connect(fontComboBoxPlaylist, &QFontComboBox::currentFontChanged, [=](const QFont &font) { settingsPrivate->setFont(SettingsPrivate::FF_Playlist, font); this->fade(); }); connect(fontComboBoxLibrary, &QFontComboBox::currentFontChanged, [=](const QFont &font) { settingsPrivate->setFont(SettingsPrivate::FF_Library, font); this->fade(); }); connect(fontComboBoxMenus, &QFontComboBox::currentFontChanged, [=](const QFont &font) { settingsPrivate->setFont(SettingsPrivate::FF_Menu, font); this->fade(); }); // And fonts size connect(spinBoxPlaylist, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), [=](int i) { settingsPrivate->setFontPointSize(SettingsPrivate::FF_Playlist, i); this->fade(); }); connect(spinBoxLibrary, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), [=](int i) { settingsPrivate->setFontPointSize(SettingsPrivate::FF_Library, i); QFont lowerFont = settingsPrivate->font(SettingsPrivate::FF_Library); lowerFont.setPointSize(lowerFont.pointSizeF() * 0.7); this->fade(); }); connect(spinBoxMenus, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), [=](int i) { settingsPrivate->setFontPointSize(SettingsPrivate::FF_Menu, i); this->fade(); }); // Timer connect(_timer, &QTimer::timeout, [=]() { this->animate(0.5, 1.0); }); // Colors connect(enableAlternateBGRadioButton, &QRadioButton::toggled, settingsPrivate, &SettingsPrivate::setColorsAlternateBG); for (QToolButton *b : groupBoxCustomColors->findChildren<QToolButton*>()) { connect(b, &QToolButton::clicked, this, &CustomizeThemeDialog::showColorDialog); } connect(enableCustomColorsRadioButton, &QCheckBox::toggled, this, [=](bool b) { settingsPrivate->setCustomColors(b); this->toggleCustomColors(b); }); connect(enableCustomTextColorsRadioButton, &QCheckBox::toggled, this, [=](bool b) { settingsPrivate->setCustomTextColorOverride(b); this->toggleCustomTextColors(b); }); // Change cover size connect(spinBoxCoverSizeLibraryTree, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), [=](int cs) { settings->setCoverSizeLibraryTree(cs); this->fade(); }); // Change cover size connect(spinBoxCoverSizeUniqueLibrary, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), [=](int cs) { settings->setCoverSizeLibraryTree(cs); this->fade(); }); // Change big cover opacity connect(radioButtonEnableBigCover, &QRadioButton::toggled, [=](bool b) { qDebug() << Q_FUNC_INFO; settings->setCoverBelowTracksEnabled(b); labelBigCoverOpacity->setEnabled(b); spinBoxBigCoverOpacity->setEnabled(b); this->fade(); }); connect(spinBoxBigCoverOpacity, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), [=](int v) { settings->setCoverBelowTracksOpacity(v); this->fade(); }); // Filter library connect(radioButtonEnableArticles, &QRadioButton::toggled, this, [=](bool b) { settingsPrivate->setIsLibraryFilteredByArticles(b); // Don't reorder the library if one hasn't typed an article yet if (!settingsPrivate->libraryFilteredByArticles().isEmpty()) { /// FIXME //_mainWindow->library->model()->rebuildSeparators(); } }); connect(articlesLineEdit, &CustomizeThemeTagLineEdit::taglistHasChanged, this, [=](const QStringList &articles) { settingsPrivate->setLibraryFilteredByArticles(articles); /// FIXME //_mainWindow->library->model()->rebuildSeparators(); }); connect(radioButtonEnableReorderArtistsArticle, &QRadioButton::toggled, this, [=](bool b) { settingsPrivate->setReorderArtistsArticle(b); this->fade(); /// FIXME //_mainWindow->library->viewport()->repaint(); }); // Tabs connect(radioButtonTabsRect, &QRadioButton::toggled, [=](bool b) { settingsPrivate->setTabsRect(b); this->fade(); /// FIXME //_mainWindow->tabPlaylists->tabBar()->update(); //_mainWindow->tabPlaylists->cornerWidget(Qt::TopRightCorner)->update(); }); connect(overlapTabsSpinBox, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), [=](int v) { settingsPrivate->setTabsOverlappingLength(v); this->fade(); /// FIXME //_mainWindow->tabPlaylists->tabBar()->update(); }); // Star delegates connect(radioButtonEnableStarDelegate, &QRadioButton::toggled, this, [=](bool b) { settings->setStarsInLibrary(b); labelLibraryDelegates->setEnabled(b); radioButtonShowNeverScoredTracks->setEnabled(b); radioButtonHideNeverScoredTracks->setEnabled(b); }); connect(radioButtonShowNeverScoredTracks, &QRadioButton::toggled, settings, &Settings::setShowNeverScored); }