2018-02-27 18:06:05 +01:00
/*
* Strawberry Music Player
* This file was part of Clementine .
* Copyright 2010 , David Sansome < me @ davidsansome . com >
2024-05-12 21:40:51 +02:00
* Copyright 2018 - 2024 , Jonas Kvinge < jonas @ jkvinge . net >
2018-02-27 18:06:05 +01:00
*
* 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/>.
2018-08-09 18:39:44 +02:00
*
2018-02-27 18:06:05 +01:00
*/
# include "config.h"
2021-01-12 20:36:10 +01:00
# include <limits>
2018-05-01 00:41:33 +02:00
# include <QStandardPaths>
# include <QAbstractItemModel>
# include <QItemSelectionModel>
# include <QString>
# include <QStringList>
2024-05-12 21:40:51 +02:00
# include <QDir>
2018-02-27 18:06:05 +01:00
# include <QFileDialog>
2018-05-01 00:41:33 +02:00
# include <QCheckBox>
# include <QLineEdit>
# include <QListView>
# include <QPushButton>
2020-02-09 02:29:35 +01:00
# include <QComboBox>
# include <QGroupBox>
# include <QLabel>
# include <QRadioButton>
# include <QSpinBox>
2018-02-27 18:06:05 +01:00
# include <QSettings>
2021-10-24 16:08:17 +02:00
# include <QMessageBox>
2018-02-27 18:06:05 +01:00
2020-02-07 23:18:18 +01:00
# include "core/application.h"
2018-02-27 18:06:05 +01:00
# include "core/iconloader.h"
2024-04-11 02:56:01 +02:00
# include "core/settings.h"
2022-12-28 03:12:00 +01:00
# include "utilities/strutils.h"
# include "utilities/timeutils.h"
2021-10-24 16:08:17 +02:00
# include "collection/collection.h"
2024-05-12 21:40:51 +02:00
# include "collection/collectionbackend.h"
2020-04-29 00:33:38 +02:00
# include "collection/collectionmodel.h"
2024-05-12 21:40:51 +02:00
# include "collection/collectiondirectory.h"
2018-02-27 18:06:05 +01:00
# include "collection/collectiondirectorymodel.h"
2018-05-01 00:41:33 +02:00
# include "collectionsettingspage.h"
2024-05-12 21:40:51 +02:00
# include "collectionsettingsdirectorymodel.h"
2018-05-01 00:41:33 +02:00
# include "playlist/playlistdelegates.h"
# include "settings/settingsdialog.h"
# include "settings/settingspage.h"
# include "ui_collectionsettingspage.h"
2018-02-27 18:06:05 +01:00
const char * CollectionSettingsPage : : kSettingsGroup = " Collection " ;
2020-02-07 23:18:18 +01:00
const char * CollectionSettingsPage : : kSettingsCacheSize = " cache_size " ;
const char * CollectionSettingsPage : : kSettingsCacheSizeUnit = " cache_size_unit " ;
const char * CollectionSettingsPage : : kSettingsDiskCacheEnable = " disk_cache_enable " ;
const char * CollectionSettingsPage : : kSettingsDiskCacheSize = " disk_cache_size " ;
const char * CollectionSettingsPage : : kSettingsDiskCacheSizeUnit = " disk_cache_size_unit " ;
2020-04-29 00:33:38 +02:00
const int CollectionSettingsPage : : kSettingsCacheSizeDefault = 160 ;
const int CollectionSettingsPage : : kSettingsDiskCacheSizeDefault = 360 ;
2020-02-07 23:18:18 +01:00
2021-06-20 19:04:08 +02:00
CollectionSettingsPage : : CollectionSettingsPage ( SettingsDialog * dialog , QWidget * parent )
: SettingsPage ( dialog , parent ) ,
2018-02-27 18:06:05 +01:00
ui_ ( new Ui_CollectionSettingsPage ) ,
2024-05-12 21:40:51 +02:00
collection_backend_ ( dialog - > app ( ) - > collection_backend ( ) ) ,
collectionsettings_directory_model_ ( new CollectionSettingsDirectoryModel ( this ) ) ,
collection_directory_model_ ( dialog - > collection_directory_model ( ) ) ,
2021-07-11 07:40:57 +02:00
initialized_model_ ( false ) {
2019-03-11 23:07:11 +01:00
2018-02-27 18:06:05 +01:00
ui_ - > setupUi ( this ) ;
ui_ - > list - > setItemDelegate ( new NativeSeparatorsDelegate ( this ) ) ;
// Icons
2024-04-09 23:20:26 +02:00
setWindowIcon ( IconLoader : : Load ( QStringLiteral ( " library-music " ) , true , 0 , 32 ) ) ;
2024-05-12 21:40:51 +02:00
ui_ - > add_directory - > setIcon ( IconLoader : : Load ( QStringLiteral ( " document-open-folder " ) ) ) ;
2018-02-27 18:06:05 +01:00
2024-04-09 23:20:26 +02:00
ui_ - > combobox_cache_size - > addItem ( QStringLiteral ( " KB " ) , static_cast < int > ( CacheSizeUnit : : KB ) ) ;
ui_ - > combobox_cache_size - > addItem ( QStringLiteral ( " MB " ) , static_cast < int > ( CacheSizeUnit : : MB ) ) ;
2020-04-29 00:33:38 +02:00
2024-04-09 23:20:26 +02:00
ui_ - > combobox_disk_cache_size - > addItem ( QStringLiteral ( " KB " ) , static_cast < int > ( CacheSizeUnit : : KB ) ) ;
ui_ - > combobox_disk_cache_size - > addItem ( QStringLiteral ( " MB " ) , static_cast < int > ( CacheSizeUnit : : MB ) ) ;
ui_ - > combobox_disk_cache_size - > addItem ( QStringLiteral ( " GB " ) , static_cast < int > ( CacheSizeUnit : : GB ) ) ;
2023-02-18 14:09:27 +01:00
2024-05-12 21:40:51 +02:00
QObject : : connect ( ui_ - > add_directory , & QPushButton : : clicked , this , & CollectionSettingsPage : : AddDirectory ) ;
QObject : : connect ( ui_ - > remove_directory , & QPushButton : : clicked , this , & CollectionSettingsPage : : RemoveDirectory ) ;
2019-03-11 23:07:11 +01:00
2021-04-25 21:16:44 +02:00
# ifdef HAVE_SONGFINGERPRINTING
QObject : : connect ( ui_ - > song_tracking , & QCheckBox : : toggled , this , & CollectionSettingsPage : : SongTrackingToggled ) ;
# endif
2024-05-24 02:13:48 +02:00
# if QT_VERSION >= QT_VERSION_CHECK(6, 7, 0)
QObject : : connect ( ui_ - > checkbox_disk_cache , & QCheckBox : : checkStateChanged , this , & CollectionSettingsPage : : DiskCacheEnable ) ;
# else
2021-01-26 16:48:04 +01:00
QObject : : connect ( ui_ - > checkbox_disk_cache , & QCheckBox : : stateChanged , this , & CollectionSettingsPage : : DiskCacheEnable ) ;
2024-05-24 02:13:48 +02:00
# endif
2021-01-26 16:48:04 +01:00
QObject : : connect ( ui_ - > button_clear_disk_cache , & QPushButton : : clicked , dialog - > app ( ) , & Application : : ClearPixmapDiskCache ) ;
QObject : : connect ( ui_ - > button_clear_disk_cache , & QPushButton : : clicked , this , & CollectionSettingsPage : : ClearPixmapDiskCache ) ;
2020-04-29 00:33:38 +02:00
2021-01-26 16:48:04 +01:00
QObject : : connect ( ui_ - > combobox_cache_size , QOverload < int > : : of ( & QComboBox : : currentIndexChanged ) , this , & CollectionSettingsPage : : CacheSizeUnitChanged ) ;
QObject : : connect ( ui_ - > combobox_disk_cache_size , QOverload < int > : : of ( & QComboBox : : currentIndexChanged ) , this , & CollectionSettingsPage : : DiskCacheSizeUnitChanged ) ;
2021-01-12 20:36:10 +01:00
2021-10-24 16:08:17 +02:00
QObject : : connect ( ui_ - > button_save_stats , & QPushButton : : clicked , this , & CollectionSettingsPage : : WriteAllSongsStatisticsToFiles ) ;
2021-04-25 21:16:44 +02:00
# ifndef HAVE_SONGFINGERPRINTING
ui_ - > song_tracking - > hide ( ) ;
# endif
2023-06-27 03:59:45 +02:00
# ifndef HAVE_EBUR128
ui_ - > song_ebur128_loudness_analysis - > hide ( ) ;
# endif
2018-02-27 18:06:05 +01:00
}
CollectionSettingsPage : : ~ CollectionSettingsPage ( ) { delete ui_ ; }
void CollectionSettingsPage : : Load ( ) {
2020-10-17 17:29:09 +02:00
if ( ! initialized_model_ ) {
2018-02-27 18:06:05 +01:00
if ( ui_ - > list - > selectionModel ( ) ) {
2021-01-26 16:48:04 +01:00
QObject : : disconnect ( ui_ - > list - > selectionModel ( ) , & QItemSelectionModel : : currentRowChanged , this , & CollectionSettingsPage : : CurrentRowChanged ) ;
2018-02-27 18:06:05 +01:00
}
2024-05-12 21:40:51 +02:00
ui_ - > list - > setModel ( collectionsettings_directory_model_ ) ;
2020-10-17 17:29:09 +02:00
initialized_model_ = true ;
2018-02-27 18:06:05 +01:00
2021-01-26 16:48:04 +01:00
QObject : : connect ( ui_ - > list - > selectionModel ( ) , & QItemSelectionModel : : currentRowChanged , this , & CollectionSettingsPage : : CurrentRowChanged ) ;
2018-02-27 18:06:05 +01:00
}
2024-05-12 21:40:51 +02:00
ui_ - > list - > model ( ) - > removeRows ( 0 , ui_ - > list - > model ( ) - > rowCount ( ) ) ;
for ( const QString & path : collection_directory_model_ - > paths ( ) ) {
collectionsettings_directory_model_ - > AddDirectory ( path ) ;
}
2024-04-11 02:56:01 +02:00
Settings s ;
2018-02-27 18:06:05 +01:00
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 ( ) ) ;
2024-03-11 11:09:33 +01:00
ui_ - > sort_skips_articles - > setChecked ( s . value ( " sort_skips_articles " , true ) . toBool ( ) ) ;
2018-02-27 18:06:05 +01:00
ui_ - > startup_scan - > setChecked ( s . value ( " startup_scan " , true ) . toBool ( ) ) ;
ui_ - > monitor - > setChecked ( s . value ( " monitor " , true ) . toBool ( ) ) ;
2021-04-25 21:16:44 +02:00
ui_ - > song_tracking - > setChecked ( s . value ( " song_tracking " , false ) . toBool ( ) ) ;
2023-06-27 03:59:45 +02:00
ui_ - > song_ebur128_loudness_analysis - > setChecked ( s . value ( " song_ebur128_loudness_analysis " , false ) . toBool ( ) ) ;
2021-04-25 21:16:44 +02:00
ui_ - > mark_songs_unavailable - > setChecked ( ui_ - > song_tracking - > isChecked ( ) ? true : s . value ( " mark_songs_unavailable " , true ) . toBool ( ) ) ;
ui_ - > expire_unavailable_songs_days - > setValue ( s . value ( " expire_unavailable_songs " , 60 ) . toInt ( ) ) ;
2018-02-27 18:06:05 +01:00
2024-04-09 23:20:26 +02:00
QStringList filters = s . value ( " cover_art_patterns " , QStringList ( ) < < QStringLiteral ( " front " ) < < QStringLiteral ( " cover " ) ) . toStringList ( ) ;
ui_ - > cover_art_patterns - > setText ( filters . join ( QStringLiteral ( " , " ) ) ) ;
2018-02-27 18:06:05 +01:00
2020-04-29 00:33:38 +02:00
ui_ - > spinbox_cache_size - > setValue ( s . value ( kSettingsCacheSize , kSettingsCacheSizeDefault ) . toInt ( ) ) ;
2023-02-18 14:09:27 +01:00
ui_ - > combobox_cache_size - > setCurrentIndex ( ui_ - > combobox_cache_size - > findData ( s . value ( kSettingsCacheSizeUnit , static_cast < int > ( CacheSizeUnit : : MB ) ) . toInt ( ) ) ) ;
2020-02-07 23:18:18 +01:00
ui_ - > checkbox_disk_cache - > setChecked ( s . value ( kSettingsDiskCacheEnable , false ) . toBool ( ) ) ;
2020-04-29 00:33:38 +02:00
ui_ - > spinbox_disk_cache_size - > setValue ( s . value ( kSettingsDiskCacheSize , kSettingsDiskCacheSizeDefault ) . toInt ( ) ) ;
2023-02-18 14:09:27 +01:00
ui_ - > combobox_disk_cache_size - > setCurrentIndex ( ui_ - > combobox_disk_cache_size - > findData ( s . value ( kSettingsDiskCacheSizeUnit , static_cast < int > ( CacheSizeUnit : : MB ) ) . toInt ( ) ) ) ;
2020-02-07 23:18:18 +01:00
2021-10-24 16:08:17 +02:00
ui_ - > checkbox_save_playcounts - > setChecked ( s . value ( " save_playcounts " , false ) . toBool ( ) ) ;
ui_ - > checkbox_save_ratings - > setChecked ( s . value ( " save_ratings " , false ) . toBool ( ) ) ;
2022-06-05 04:59:50 +02:00
ui_ - > checkbox_overwrite_playcount - > setChecked ( s . value ( " overwrite_playcount " , false ) . toBool ( ) ) ;
2021-10-31 23:24:32 +01:00
ui_ - > checkbox_overwrite_rating - > setChecked ( s . value ( " overwrite_rating " , false ) . toBool ( ) ) ;
2021-10-24 16:08:17 +02:00
2020-08-19 22:11:03 +02:00
# if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
2020-08-19 22:02:35 +02:00
ui_ - > checkbox_delete_files - > setChecked ( s . value ( " delete_files " , false ) . toBool ( ) ) ;
2020-08-19 22:11:03 +02:00
# else
ui_ - > checkbox_delete_files - > setChecked ( false ) ;
ui_ - > checkbox_delete_files - > hide ( ) ;
# endif
2020-08-19 22:02:35 +02:00
2018-02-27 18:06:05 +01:00
s . endGroup ( ) ;
2019-03-11 23:07:11 +01:00
2020-04-29 00:33:38 +02:00
DiskCacheEnable ( ui_ - > checkbox_disk_cache - > checkState ( ) ) ;
2024-04-09 23:20:26 +02:00
ui_ - > disk_cache_in_use - > setText ( ( dialog ( ) - > app ( ) - > collection_model ( ) - > icon_cache_disk_size ( ) = = 0 ? QStringLiteral ( " empty " ) : Utilities : : PrettySize ( dialog ( ) - > app ( ) - > collection_model ( ) - > icon_cache_disk_size ( ) ) ) ) ;
2020-04-29 00:33:38 +02:00
2020-05-25 23:56:54 +02:00
Init ( ui_ - > layout_collectionsettingspage - > parentWidget ( ) ) ;
2024-04-11 02:56:01 +02:00
if ( ! Settings ( ) . childGroups ( ) . contains ( QLatin1String ( kSettingsGroup ) ) ) set_changed ( ) ;
2020-05-25 23:56:54 +02:00
2019-03-11 23:07:11 +01:00
}
void CollectionSettingsPage : : Save ( ) {
2024-04-11 02:56:01 +02:00
Settings s ;
2019-03-11 23:07:11 +01:00
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 ( ) ) ;
2024-03-11 11:09:33 +01:00
s . setValue ( " sort_skips_articles " , ui_ - > sort_skips_articles - > isChecked ( ) ) ;
2019-03-11 23:07:11 +01:00
s . setValue ( " startup_scan " , ui_ - > startup_scan - > isChecked ( ) ) ;
s . setValue ( " monitor " , ui_ - > monitor - > isChecked ( ) ) ;
2021-04-25 21:16:44 +02:00
s . setValue ( " song_tracking " , ui_ - > song_tracking - > isChecked ( ) ) ;
2023-06-27 03:59:45 +02:00
s . setValue ( " song_ebur128_loudness_analysis " , ui_ - > song_ebur128_loudness_analysis - > isChecked ( ) ) ;
2021-04-25 21:16:44 +02:00
s . setValue ( " mark_songs_unavailable " , ui_ - > song_tracking - > isChecked ( ) ? true : ui_ - > mark_songs_unavailable - > isChecked ( ) ) ;
s . setValue ( " expire_unavailable_songs " , ui_ - > expire_unavailable_songs_days - > value ( ) ) ;
2019-03-11 23:07:11 +01:00
QString filter_text = ui_ - > cover_art_patterns - > text ( ) ;
2020-05-29 17:40:11 +02:00
# if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
2024-04-11 02:56:01 +02:00
QStringList filters = filter_text . split ( QLatin1Char ( ' , ' ) , Qt : : SkipEmptyParts ) ;
2020-05-29 17:40:11 +02:00
# else
2024-04-11 02:56:01 +02:00
QStringList filters = filter_text . split ( QLatin1Char ( ' , ' ) , QString : : SkipEmptyParts ) ;
2020-05-29 17:40:11 +02:00
# endif
2019-03-11 23:07:11 +01:00
s . setValue ( " cover_art_patterns " , filters ) ;
2020-02-07 23:18:18 +01:00
s . setValue ( kSettingsCacheSize , ui_ - > spinbox_cache_size - > value ( ) ) ;
2023-02-18 14:09:27 +01:00
s . setValue ( kSettingsCacheSizeUnit , ui_ - > combobox_cache_size - > currentData ( ) . toInt ( ) ) ;
2020-02-07 23:18:18 +01:00
s . setValue ( kSettingsDiskCacheEnable , ui_ - > checkbox_disk_cache - > isChecked ( ) ) ;
s . setValue ( kSettingsDiskCacheSize , ui_ - > spinbox_disk_cache_size - > value ( ) ) ;
2023-02-18 14:09:27 +01:00
s . setValue ( kSettingsDiskCacheSizeUnit , ui_ - > combobox_disk_cache_size - > currentData ( ) . toInt ( ) ) ;
2020-02-07 23:18:18 +01:00
2021-10-24 16:08:17 +02:00
s . setValue ( " save_playcounts " , ui_ - > checkbox_save_playcounts - > isChecked ( ) ) ;
s . setValue ( " save_ratings " , ui_ - > checkbox_save_ratings - > isChecked ( ) ) ;
2022-06-05 04:59:50 +02:00
s . setValue ( " overwrite_playcount " , ui_ - > checkbox_overwrite_playcount - > isChecked ( ) ) ;
2021-10-31 23:24:32 +01:00
s . setValue ( " overwrite_rating " , ui_ - > checkbox_overwrite_rating - > isChecked ( ) ) ;
2021-10-24 16:08:17 +02:00
2020-08-19 22:02:35 +02:00
s . setValue ( " delete_files " , ui_ - > checkbox_delete_files - > isChecked ( ) ) ;
2019-03-11 23:07:11 +01:00
s . endGroup ( ) ;
2024-05-12 21:40:51 +02:00
for ( const CollectionDirectory & dir : collection_directory_model_ - > directories ( ) ) {
if ( ! collectionsettings_directory_model_ - > paths ( ) . contains ( dir . path ) ) {
collection_backend_ - > RemoveDirectoryAsync ( dir ) ;
}
}
for ( const QString & path : collectionsettings_directory_model_ - > paths ( ) ) {
if ( ! collection_directory_model_ - > paths ( ) . contains ( path ) ) {
collection_backend_ - > AddDirectoryAsync ( path ) ;
}
}
}
void CollectionSettingsPage : : AddDirectory ( ) {
Settings s ;
s . beginGroup ( kSettingsGroup ) ;
QString path = s . value ( " last_path " , QStandardPaths : : writableLocation ( QStandardPaths : : MusicLocation ) ) . toString ( ) ;
path = QDir : : cleanPath ( QFileDialog : : getExistingDirectory ( this , tr ( " Add directory... " ) , path ) ) ;
if ( ! path . isEmpty ( ) ) {
collectionsettings_directory_model_ - > AddDirectory ( path ) ;
}
s . setValue ( " last_path " , path ) ;
set_changed ( ) ;
}
void CollectionSettingsPage : : RemoveDirectory ( ) {
collectionsettings_directory_model_ - > RemoveDirectory ( ui_ - > list - > currentIndex ( ) ) ;
set_changed ( ) ;
}
void CollectionSettingsPage : : CurrentRowChanged ( const QModelIndex & idx ) {
ui_ - > remove_directory - > setEnabled ( idx . isValid ( ) ) ;
}
void CollectionSettingsPage : : SongTrackingToggled ( ) {
ui_ - > mark_songs_unavailable - > setEnabled ( ! ui_ - > song_tracking - > isChecked ( ) ) ;
if ( ui_ - > song_tracking - > isChecked ( ) ) {
ui_ - > mark_songs_unavailable - > setChecked ( true ) ;
}
}
2024-05-24 02:13:48 +02:00
# if QT_VERSION >= QT_VERSION_CHECK(6, 7, 0)
void CollectionSettingsPage : : DiskCacheEnable ( const Qt : : CheckState state ) {
# else
2024-05-12 21:40:51 +02:00
void CollectionSettingsPage : : DiskCacheEnable ( const int state ) {
2024-05-24 02:13:48 +02:00
# endif
2024-05-12 21:40:51 +02:00
2024-05-24 02:13:48 +02:00
const bool checked = state = = Qt : : Checked ;
2024-05-12 21:40:51 +02:00
ui_ - > label_disk_cache_size - > setEnabled ( checked ) ;
ui_ - > spinbox_disk_cache_size - > setEnabled ( checked ) ;
ui_ - > combobox_disk_cache_size - > setEnabled ( checked ) ;
ui_ - > label_disk_cache_in_use - > setEnabled ( checked ) ;
ui_ - > disk_cache_in_use - > setEnabled ( checked ) ;
ui_ - > button_clear_disk_cache - > setEnabled ( checked ) ;
2019-03-11 23:07:11 +01:00
}
2020-04-29 00:33:38 +02:00
void CollectionSettingsPage : : ClearPixmapDiskCache ( ) {
2024-04-09 23:20:26 +02:00
ui_ - > disk_cache_in_use - > setText ( QStringLiteral ( " empty " ) ) ;
2020-04-29 00:33:38 +02:00
}
2021-01-12 20:36:10 +01:00
void CollectionSettingsPage : : CacheSizeUnitChanged ( int index ) {
2023-02-18 14:09:27 +01:00
const CacheSizeUnit cache_size_unit = static_cast < CacheSizeUnit > ( ui_ - > combobox_cache_size - > currentData ( index ) . toInt ( ) ) ;
switch ( cache_size_unit ) {
case CacheSizeUnit : : MB :
2021-01-12 20:36:10 +01:00
ui_ - > spinbox_cache_size - > setMaximum ( std : : numeric_limits < int > : : max ( ) / 1024 ) ;
break ;
default :
ui_ - > spinbox_cache_size - > setMaximum ( std : : numeric_limits < int > : : max ( ) ) ;
break ;
}
}
void CollectionSettingsPage : : DiskCacheSizeUnitChanged ( int index ) {
2023-02-18 14:09:27 +01:00
const CacheSizeUnit cache_size_unit = static_cast < CacheSizeUnit > ( ui_ - > combobox_disk_cache_size - > currentData ( index ) . toInt ( ) ) ;
switch ( cache_size_unit ) {
case CacheSizeUnit : : GB :
2021-01-12 20:36:10 +01:00
ui_ - > spinbox_disk_cache_size - > setMaximum ( 4 ) ;
break ;
default :
ui_ - > spinbox_disk_cache_size - > setMaximum ( std : : numeric_limits < int > : : max ( ) ) ;
break ;
}
}
2021-10-24 16:08:17 +02:00
void CollectionSettingsPage : : WriteAllSongsStatisticsToFiles ( ) {
QMessageBox confirmation_dialog ( QMessageBox : : Question , tr ( " Write all playcounts and ratings to files " ) , tr ( " Are you sure you want to write song playcounts and ratings to file for all songs in your collection? " ) , QMessageBox : : Yes | QMessageBox : : Cancel ) ;
if ( confirmation_dialog . exec ( ) ! = QMessageBox : : Yes ) {
return ;
}
dialog ( ) - > app ( ) - > collection ( ) - > SyncPlaycountAndRatingToFilesAsync ( ) ;
}