Qt: add separate settings for max list/grid entries

This commit is contained in:
Brad Parker 2018-07-25 15:24:26 -04:00
parent 065318eb39
commit 665628e6c0
6 changed files with 47 additions and 21 deletions

View File

@ -3632,7 +3632,9 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_MPV_SUPPORT,
"mpv対応") "mpv対応")
MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_PROGRESS, MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_PROGRESS,
"進行状況:") "進行状況:")
MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_ALL_PLAYLISTS_MAX_COUNT, MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_ALL_PLAYLISTS_LIST_MAX_COUNT,
"「すべてのプレイリスト」の最大個数:") "「すべてのプレイリスト」一覧の最大個数:")
MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_ALL_PLAYLISTS_GRID_MAX_COUNT,
"「すべてのプレイリスト」アイコンの最大個数:")
MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_SHOW_HIDDEN_FILES, MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_SHOW_HIDDEN_FILES,
"隠しファイルとフォルダを表示:") "隠しファイルとフォルダを表示:")

View File

@ -3790,7 +3790,9 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_MPV_SUPPORT,
"mpv support") "mpv support")
MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_PROGRESS, MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_PROGRESS,
"Progress:") "Progress:")
MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_ALL_PLAYLISTS_MAX_COUNT, MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_ALL_PLAYLISTS_LIST_MAX_COUNT,
"\"All Playlists\" max entries:") "\"All Playlists\" max list entries:")
MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_ALL_PLAYLISTS_GRID_MAX_COUNT,
"\"All Playlists\" max grid entries:")
MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_SHOW_HIDDEN_FILES, MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_SHOW_HIDDEN_FILES,
"Show hidden files and folders:") "Show hidden files and folders:")

View File

@ -1836,7 +1836,8 @@ enum msg_hash_enums
MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_HIGHLIGHT_COLOR, MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_HIGHLIGHT_COLOR,
MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_SUGGEST_LOADED_CORE_FIRST, MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_SUGGEST_LOADED_CORE_FIRST,
MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_SHOW_HIDDEN_FILES, MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_SHOW_HIDDEN_FILES,
MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_ALL_PLAYLISTS_MAX_COUNT, MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_ALL_PLAYLISTS_LIST_MAX_COUNT,
MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_ALL_PLAYLISTS_GRID_MAX_COUNT,
MENU_ENUM_LABEL_VALUE_QT_MENU_DOCK_CONTENT_BROWSER, MENU_ENUM_LABEL_VALUE_QT_MENU_DOCK_CONTENT_BROWSER,
MENU_ENUM_LABEL_VALUE_QT_THUMBNAIL_BOXART, MENU_ENUM_LABEL_VALUE_QT_THUMBNAIL_BOXART,
MENU_ENUM_LABEL_VALUE_QT_THUMBNAIL_SCREENSHOT, MENU_ENUM_LABEL_VALUE_QT_THUMBNAIL_SCREENSHOT,

View File

@ -280,7 +280,8 @@ ViewOptionsDialog::ViewOptionsDialog(MainWindow *mainwindow, QWidget *parent) :
,m_highlightColorLabel(new QLabel(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_HIGHLIGHT_COLOR), this)) ,m_highlightColorLabel(new QLabel(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_HIGHLIGHT_COLOR), this))
,m_customThemePath() ,m_customThemePath()
,m_suggestLoadedCoreFirstCheckBox(new QCheckBox(this)) ,m_suggestLoadedCoreFirstCheckBox(new QCheckBox(this))
,m_allPlaylistsMaxCountSpinBox(new QSpinBox(this)) ,m_allPlaylistsListMaxCountSpinBox(new QSpinBox(this))
,m_allPlaylistsGridMaxCountSpinBox(new QSpinBox(this))
{ {
QFormLayout *form = new QFormLayout(); QFormLayout *form = new QFormLayout();
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
@ -291,7 +292,8 @@ ViewOptionsDialog::ViewOptionsDialog(MainWindow *mainwindow, QWidget *parent) :
m_themeComboBox->addItem(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_THEME_DARK), MainWindow::THEME_DARK); m_themeComboBox->addItem(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_THEME_DARK), MainWindow::THEME_DARK);
m_themeComboBox->addItem(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_THEME_CUSTOM), MainWindow::THEME_CUSTOM); m_themeComboBox->addItem(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_THEME_CUSTOM), MainWindow::THEME_CUSTOM);
m_allPlaylistsMaxCountSpinBox->setRange(0, 99999); m_allPlaylistsListMaxCountSpinBox->setRange(0, 99999);
m_allPlaylistsGridMaxCountSpinBox->setRange(0, 99999);
form->setFormAlignment(Qt::AlignCenter); form->setFormAlignment(Qt::AlignCenter);
form->setLabelAlignment(Qt::AlignCenter); form->setLabelAlignment(Qt::AlignCenter);
@ -309,7 +311,8 @@ ViewOptionsDialog::ViewOptionsDialog(MainWindow *mainwindow, QWidget *parent) :
form->addRow(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_SAVE_LAST_TAB), m_saveLastTabCheckBox); form->addRow(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_SAVE_LAST_TAB), m_saveLastTabCheckBox);
form->addRow(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_SHOW_HIDDEN_FILES), m_showHiddenFilesCheckBox); form->addRow(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_SHOW_HIDDEN_FILES), m_showHiddenFilesCheckBox);
form->addRow(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_SUGGEST_LOADED_CORE_FIRST), m_suggestLoadedCoreFirstCheckBox); form->addRow(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_SUGGEST_LOADED_CORE_FIRST), m_suggestLoadedCoreFirstCheckBox);
form->addRow(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_ALL_PLAYLISTS_MAX_COUNT), m_allPlaylistsMaxCountSpinBox); form->addRow(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_ALL_PLAYLISTS_LIST_MAX_COUNT), m_allPlaylistsListMaxCountSpinBox);
form->addRow(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_ALL_PLAYLISTS_GRID_MAX_COUNT), m_allPlaylistsGridMaxCountSpinBox);
form->addRow(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_THEME), m_themeComboBox); form->addRow(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_THEME), m_themeComboBox);
form->addRow(m_highlightColorLabel, m_highlightColorPushButton); form->addRow(m_highlightColorLabel, m_highlightColorPushButton);
@ -385,7 +388,8 @@ void ViewOptionsDialog::loadViewOptions()
m_saveLastTabCheckBox->setChecked(m_settings->value("save_last_tab", false).toBool()); m_saveLastTabCheckBox->setChecked(m_settings->value("save_last_tab", false).toBool());
m_showHiddenFilesCheckBox->setChecked(m_settings->value("show_hidden_files", true).toBool()); m_showHiddenFilesCheckBox->setChecked(m_settings->value("show_hidden_files", true).toBool());
m_suggestLoadedCoreFirstCheckBox->setChecked(m_settings->value("suggest_loaded_core_first", false).toBool()); m_suggestLoadedCoreFirstCheckBox->setChecked(m_settings->value("suggest_loaded_core_first", false).toBool());
m_allPlaylistsMaxCountSpinBox->setValue(m_settings->value("all_playlists_max_count", 5000).toInt()); m_allPlaylistsListMaxCountSpinBox->setValue(m_settings->value("all_playlists_list_max_count", 0).toInt());
m_allPlaylistsGridMaxCountSpinBox->setValue(m_settings->value("all_playlists_grid_max_count", 5000).toInt());
themeIndex = m_themeComboBox->findData(m_mainwindow->getThemeFromString(m_settings->value("theme", "default").toString())); themeIndex = m_themeComboBox->findData(m_mainwindow->getThemeFromString(m_settings->value("theme", "default").toString()));
@ -425,12 +429,14 @@ void ViewOptionsDialog::saveViewOptions()
m_settings->setValue("show_hidden_files", m_showHiddenFilesCheckBox->isChecked()); m_settings->setValue("show_hidden_files", m_showHiddenFilesCheckBox->isChecked());
m_settings->setValue("highlight_color", m_highlightColor); m_settings->setValue("highlight_color", m_highlightColor);
m_settings->setValue("suggest_loaded_core_first", m_suggestLoadedCoreFirstCheckBox->isChecked()); m_settings->setValue("suggest_loaded_core_first", m_suggestLoadedCoreFirstCheckBox->isChecked());
m_settings->setValue("all_playlists_max_count", m_allPlaylistsMaxCountSpinBox->value()); m_settings->setValue("all_playlists_list_max_count", m_allPlaylistsListMaxCountSpinBox->value());
m_settings->setValue("all_playlists_grid_max_count", m_allPlaylistsGridMaxCountSpinBox->value());
if (!m_mainwindow->customThemeString().isEmpty()) if (!m_mainwindow->customThemeString().isEmpty())
m_settings->setValue("custom_theme", m_customThemePath); m_settings->setValue("custom_theme", m_customThemePath);
m_mainwindow->setAllPlaylistsMaxCount(m_allPlaylistsMaxCountSpinBox->value()); m_mainwindow->setAllPlaylistsListMaxCount(m_allPlaylistsListMaxCountSpinBox->value());
m_mainwindow->setAllPlaylistsGridMaxCount(m_allPlaylistsGridMaxCountSpinBox->value());
} }
void ViewOptionsDialog::onAccepted() void ViewOptionsDialog::onAccepted()
@ -550,7 +556,8 @@ MainWindow::MainWindow(QWidget *parent) :
,m_currentGridHash() ,m_currentGridHash()
,m_lastViewType(m_viewType) ,m_lastViewType(m_viewType)
,m_currentGridWidget(NULL) ,m_currentGridWidget(NULL)
,m_allPlaylistsMaxCount(0) ,m_allPlaylistsListMaxCount(0)
,m_allPlaylistsGridMaxCount(0)
{ {
settings_t *settings = config_get_ptr(); settings_t *settings = config_get_ptr();
QDir playlistDir(settings->paths.directory_playlist); QDir playlistDir(settings->paths.directory_playlist);
@ -3190,7 +3197,7 @@ void MainWindow::addPlaylistItemsToGrid(const QStringList &paths, bool add)
/* QVector::append() wasn't added until 5.5, so just do it the old fashioned way */ /* QVector::append() wasn't added until 5.5, so just do it the old fashioned way */
for (j = 0; j < vec.size(); j++) for (j = 0; j < vec.size(); j++)
{ {
if (add && items.size() >= m_allPlaylistsMaxCount) if (add && m_allPlaylistsGridMaxCount > 0 && items.size() >= m_allPlaylistsGridMaxCount)
goto finish; goto finish;
items.append(vec.at(j)); items.append(vec.at(j));
@ -3527,7 +3534,7 @@ void MainWindow::addPlaylistItemsToTable(const QStringList &paths, bool add)
/* QVector::append() wasn't added until 5.5, so just do it the old fashioned way */ /* QVector::append() wasn't added until 5.5, so just do it the old fashioned way */
for (j = 0; j < vec.size(); j++) for (j = 0; j < vec.size(); j++)
{ {
if (add && items.size() >= m_allPlaylistsMaxCount) if (add && m_allPlaylistsListMaxCount > 0 && items.size() >= m_allPlaylistsListMaxCount)
goto finish; goto finish;
items.append(vec.at(j)); items.append(vec.at(j));
@ -3608,12 +3615,20 @@ void MainWindow::closeEvent(QCloseEvent *event)
QMainWindow::closeEvent(event); QMainWindow::closeEvent(event);
} }
void MainWindow::setAllPlaylistsMaxCount(int count) void MainWindow::setAllPlaylistsListMaxCount(int count)
{ {
if (count < 1) if (count < 1)
count = 0; count = 0;
m_allPlaylistsMaxCount = count; m_allPlaylistsListMaxCount = count;
}
void MainWindow::setAllPlaylistsGridMaxCount(int count)
{
if (count < 1)
count = 0;
m_allPlaylistsGridMaxCount = count;
} }
static void* ui_window_qt_init(void) static void* ui_window_qt_init(void)

View File

@ -476,8 +476,11 @@ static void* ui_companion_qt_init(void)
/* this should come last */ /* this should come last */
mainwindow->resizeThumbnails(true, true, true); mainwindow->resizeThumbnails(true, true, true);
if (qsettings->contains("all_playlists_max_count")) if (qsettings->contains("all_playlists_list_max_count"))
mainwindow->setAllPlaylistsMaxCount(qsettings->value("all_playlists_max_count", 5000).toInt()); mainwindow->setAllPlaylistsListMaxCount(qsettings->value("all_playlists_list_max_count", 0).toInt());
if (qsettings->contains("all_playlists_grid_max_count"))
mainwindow->setAllPlaylistsGridMaxCount(qsettings->value("all_playlists_grid_max_count", 5000).toInt());
if (qsettings->contains("geometry")) if (qsettings->contains("geometry"))
if (qsettings->contains("save_geometry")) if (qsettings->contains("save_geometry"))

View File

@ -192,7 +192,8 @@ private:
QLabel *m_highlightColorLabel; QLabel *m_highlightColorLabel;
QString m_customThemePath; QString m_customThemePath;
QCheckBox *m_suggestLoadedCoreFirstCheckBox; QCheckBox *m_suggestLoadedCoreFirstCheckBox;
QSpinBox *m_allPlaylistsMaxCountSpinBox; QSpinBox *m_allPlaylistsListMaxCountSpinBox;
QSpinBox *m_allPlaylistsGridMaxCountSpinBox;
}; };
class CoreInfoLabel : public QLabel class CoreInfoLabel : public QLabel
@ -294,7 +295,8 @@ public:
void setCurrentViewType(ViewType viewType); void setCurrentViewType(ViewType viewType);
QString getCurrentViewTypeString(); QString getCurrentViewTypeString();
ViewType getCurrentViewType(); ViewType getCurrentViewType();
void setAllPlaylistsMaxCount(int count); void setAllPlaylistsListMaxCount(int count);
void setAllPlaylistsGridMaxCount(int count);
signals: signals:
void thumbnailChanged(const QPixmap &pixmap); void thumbnailChanged(const QPixmap &pixmap);
@ -427,7 +429,8 @@ private:
QHash<QString, QString> m_currentGridHash; QHash<QString, QString> m_currentGridHash;
ViewType m_lastViewType; ViewType m_lastViewType;
QPointer<ThumbnailWidget> m_currentGridWidget; QPointer<ThumbnailWidget> m_currentGridWidget;
int m_allPlaylistsMaxCount; int m_allPlaylistsListMaxCount;
int m_allPlaylistsGridMaxCount;
protected: protected:
void closeEvent(QCloseEvent *event); void closeEvent(QCloseEvent *event);