Qt: better border drawing across styles, add option for max entries in "all playlists"

This commit is contained in:
Brad Parker 2018-07-25 01:43:57 -04:00
parent f0b0be898a
commit 5ff77d1833
7 changed files with 81 additions and 24 deletions

View File

@ -3479,7 +3479,7 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_SAVE_GEOMETRY,
MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_SAVE_LAST_TAB,
"最後のコンテンツブラウザーのタブを記憶:")
MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_THEME,
"テーマ")
"テーマ:")
MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_THEME_SYSTEM_DEFAULT,
"<システムデフォルト>")
MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_THEME_DARK,
@ -3543,7 +3543,7 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_HIDDEN_PLAYLISTS,
MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_HIDE,
"隠す")
MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_HIGHLIGHT_COLOR,
"ハイライトカラー")
"ハイライトカラー:")
MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_CHOOSE,
"選択(&C)...")
MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_SELECT_COLOR,
@ -3561,7 +3561,7 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_FILE_READ_OPEN_FAILED,
MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_FILE_DOES_NOT_EXIST,
"ファイルは存在しません。")
MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_SUGGEST_LOADED_CORE_FIRST,
"ロードしたコアを最初に優先する")
"ロードしたコアを最初に優先する:")
MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_ZOOM,
"ズーム")
MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_VIEW,
@ -3632,3 +3632,7 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_MPV_SUPPORT,
"mpv対応")
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_SHOW_HIDDEN_FILES,
"隠しファイルとフォルダを表示:")

View File

@ -3619,7 +3619,7 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_SAVE_GEOMETRY,
MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_SAVE_LAST_TAB,
"Remember last content browser tab:")
MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_THEME,
"Theme")
"Theme:")
MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_THEME_SYSTEM_DEFAULT,
"<System Default>")
MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_THEME_DARK,
@ -3691,7 +3691,7 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_HIDDEN_PLAYLISTS,
MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_HIDE,
"Hide")
MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_HIGHLIGHT_COLOR,
"Highlight Color")
"Highlight color:")
MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_CHOOSE,
"&Choose...")
MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_SELECT_COLOR,
@ -3709,7 +3709,7 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_FILE_READ_OPEN_FAILED,
MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_FILE_DOES_NOT_EXIST,
"File does not exist.")
MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_SUGGEST_LOADED_CORE_FIRST,
"Suggest loaded core first")
"Suggest loaded core first:")
MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_ZOOM,
"Zoom")
MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_VIEW,
@ -3790,3 +3790,7 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_MPV_SUPPORT,
"mpv support")
MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_PROGRESS,
"Progress:")
MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_ALL_PLAYLISTS_MAX_COUNT,
"\"All Playlists\" max entries:")
MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_SHOW_HIDDEN_FILES,
"Show hidden files and folders:")

View File

@ -1835,6 +1835,8 @@ enum msg_hash_enums
MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_TITLE,
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_SHOW_HIDDEN_FILES,
MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_ALL_PLAYLISTS_MAX_COUNT,
MENU_ENUM_LABEL_VALUE_QT_MENU_DOCK_CONTENT_BROWSER,
MENU_ENUM_LABEL_VALUE_QT_THUMBNAIL_BOXART,
MENU_ENUM_LABEL_VALUE_QT_THUMBNAIL_SCREENSHOT,

View File

@ -9,9 +9,13 @@ static const QString qt_theme_default_stylesheet = QStringLiteral(""
" background-color: transparent;\n"
" border: 1px solid #ddd;\n"
"}\n"
"ThumbnailWidget, ThumbnailLabel, QLabel#thumbnailQLabel {\n"
"ThumbnailWidget#thumbnailWidget, ThumbnailLabel#thumbnailGridLabel, QLabel#thumbnailQLabel {\n"
" background-color:#555555;\n"
"}\n"
"ThumbnailWidget#thumbnailWidgetSelected {\n"
" background-color:#555555;\n"
" border:3px solid %1;\n"
"}\n"
);
static const QString qt_theme_dark_stylesheet = QStringLiteral(""
@ -389,7 +393,11 @@ static const QString qt_theme_dark_stylesheet = QStringLiteral(""
"QSizeGrip {\n"
" background-color:solid;\n"
"}\n"
"ThumbnailWidget, ThumbnailLabel, QLabel#thumbnailQLabel {\n"
"ThumbnailWidget#thumbnailWidget, ThumbnailLabel#thumbnailGridLabel, QLabel#thumbnailQLabel {\n"
" background-color:#555555;\n"
"}\n"
"ThumbnailWidget#thumbnailWidgetSelected {\n"
" background-color:#555555;\n"
" border:3px solid %1;\n"
"}\n"
);

View File

@ -280,6 +280,7 @@ 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_customThemePath()
,m_suggestLoadedCoreFirstCheckBox(new QCheckBox(this))
,m_allPlaylistsMaxCountSpinBox(new QSpinBox(this))
{
QFormLayout *form = new QFormLayout();
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
@ -290,6 +291,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_CUSTOM), MainWindow::THEME_CUSTOM);
m_allPlaylistsMaxCountSpinBox->setRange(0, 99999);
form->setFormAlignment(Qt::AlignCenter);
form->setLabelAlignment(Qt::AlignCenter);
@ -304,8 +307,9 @@ ViewOptionsDialog::ViewOptionsDialog(MainWindow *mainwindow, QWidget *parent) :
form->addRow(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_SAVE_GEOMETRY), m_saveGeometryCheckBox);
form->addRow(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_SAVE_DOCK_POSITIONS), m_saveDockPositionsCheckBox);
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_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_ALL_PLAYLISTS_MAX_COUNT), m_allPlaylistsMaxCountSpinBox);
form->addRow(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_THEME), m_themeComboBox);
form->addRow(m_highlightColorLabel, m_highlightColorPushButton);
@ -381,6 +385,7 @@ void ViewOptionsDialog::loadViewOptions()
m_saveLastTabCheckBox->setChecked(m_settings->value("save_last_tab", false).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_allPlaylistsMaxCountSpinBox->setValue(m_settings->value("all_playlists_max_count", 0).toInt());
themeIndex = m_themeComboBox->findData(m_mainwindow->getThemeFromString(m_settings->value("theme", "default").toString()));
@ -420,9 +425,12 @@ void ViewOptionsDialog::saveViewOptions()
m_settings->setValue("show_hidden_files", m_showHiddenFilesCheckBox->isChecked());
m_settings->setValue("highlight_color", m_highlightColor);
m_settings->setValue("suggest_loaded_core_first", m_suggestLoadedCoreFirstCheckBox->isChecked());
m_settings->setValue("all_playlists_max_count", m_allPlaylistsMaxCountSpinBox->value());
if (!m_mainwindow->customThemeString().isEmpty())
m_settings->setValue("custom_theme", m_customThemePath);
m_mainwindow->setAllPlaylistsMaxCount(m_allPlaylistsMaxCountSpinBox->value());
}
void ViewOptionsDialog::onAccepted()
@ -455,7 +463,7 @@ CoreInfoWidget::CoreInfoWidget(CoreInfoLabel *label, QWidget *parent) :
,m_label(label)
,m_scrollArea(new QScrollArea(this))
{
m_scrollArea->setFrameShape(QFrame::NoFrame);
//m_scrollArea->setFrameShape(QFrame::NoFrame);
m_scrollArea->setWidgetResizable(true);
m_scrollArea->setWidget(m_label);
}
@ -542,6 +550,7 @@ MainWindow::MainWindow(QWidget *parent) :
,m_currentGridHash()
,m_lastViewType(m_viewType)
,m_currentGridWidget(NULL)
,m_allPlaylistsMaxCount(0)
{
settings_t *settings = config_get_ptr();
QDir playlistDir(settings->paths.directory_playlist);
@ -795,12 +804,16 @@ void MainWindow::onGridItemClicked()
if (m_currentGridWidget)
{
m_currentGridWidget->setObjectName("thumbnailWidget");
m_currentGridWidget->setFrameStyle(QFrame::Plain);
//m_currentGridWidget->setFrameStyle(QFrame::Plain);
m_currentGridWidget->style()->unpolish(m_currentGridWidget);
m_currentGridWidget->style()->polish(m_currentGridWidget);
}
hash = w->property("hash").value<QHash<QString, QString> >();
w->setObjectName("thumbnailWidgetSelected");
w->setFrameStyle(QFrame::Box | QFrame::Plain);
w->style()->unpolish(w);
w->style()->polish(w);
//w->setFrameStyle(QFrame::Box | QFrame::Plain);
w->setLineWidth(2);
m_currentGridWidget = w;
@ -1517,7 +1530,7 @@ void MainWindow::setTheme(Theme theme)
{
case THEME_SYSTEM_DEFAULT:
{
qApp->setStyleSheet(qt_theme_default_stylesheet);
qApp->setStyleSheet(qt_theme_default_stylesheet.arg(m_settings->value("highlight_color", "palette(highlight)").toString()));
break;
}
@ -3162,7 +3175,7 @@ GridItem* MainWindow::doDeferredImageLoad(GridItem *item, QString path)
return item;
}
void MainWindow::addPlaylistItemsToGrid(const QStringList &paths)
void MainWindow::addPlaylistItemsToGrid(const QStringList &paths, bool add)
{
QVector<QHash<QString, QString> > items;
int i;
@ -3177,10 +3190,13 @@ void MainWindow::addPlaylistItemsToGrid(const QStringList &paths)
/* QVector::append() wasn't added until 5.5, so just do it the old fashioned way */
for (j = 0; j < vec.size(); j++)
{
if (add && items.size() >= m_allPlaylistsMaxCount)
goto finish;
items.append(vec.at(j));
}
}
finish:
std::sort(items.begin(), items.end(), comp_hash_label_key);
addPlaylistHashToGrid(items);
@ -3252,13 +3268,14 @@ void MainWindow::addPlaylistHashToGrid(const QVector<QHash<QString, QString> > &
item->widget->setLayout(new QVBoxLayout());
item->widget->setObjectName("thumbnailWidget");
item->widget->setProperty("hash", QVariant::fromValue<QHash<QString, QString> >(hash));
item->widget->setFrameStyle(QFrame::Plain);
//item->widget->setFrameStyle(QFrame::Plain);
item->widget->setLineWidth(0);
connect(item->widget, SIGNAL(mouseDoubleClicked()), this, SLOT(onGridItemDoubleClicked()));
connect(item->widget, SIGNAL(mousePressed()), this, SLOT(onGridItemClicked()));
label = new ThumbnailLabel(item->widget);
label->setObjectName("thumbnailGridLabel");
item->label = label;
@ -3309,8 +3326,10 @@ void MainWindow::initContentGridLayout()
if (m_currentGridWidget)
{
m_currentGridWidget->setObjectName("thumbnailWidget");
m_currentGridWidget->setFrameStyle(QFrame::Plain);
//m_currentGridWidget->setFrameStyle(QFrame::Plain);
m_currentGridWidget->setLineWidth(0);
m_currentGridWidget->style()->unpolish(m_currentGridWidget);
m_currentGridWidget->style()->polish(m_currentGridWidget);
}
m_currentGridWidget = NULL;
@ -3330,7 +3349,7 @@ void MainWindow::initContentGridLayout()
playlists.append(playlistDir.absoluteFilePath(playlist));
}
addPlaylistItemsToGrid(playlists);
addPlaylistItemsToGrid(playlists, true);
}
else
addPlaylistItemsToGrid(QStringList() << path);
@ -3362,8 +3381,10 @@ void MainWindow::initContentTableWidget()
if (m_currentGridWidget)
{
m_currentGridWidget->setObjectName("thumbnailWidget");
m_currentGridWidget->setFrameStyle(QFrame::Plain);
//m_currentGridWidget->setFrameStyle(QFrame::Plain);
m_currentGridWidget->setLineWidth(0);
m_currentGridWidget->style()->unpolish(m_currentGridWidget);
m_currentGridWidget->style()->polish(m_currentGridWidget);
}
m_currentGridWidget = NULL;
@ -3397,7 +3418,7 @@ void MainWindow::initContentTableWidget()
playlists.append(playlistDir.absoluteFilePath(playlist));
}
addPlaylistItemsToTable(playlists);
addPlaylistItemsToTable(playlists, true);
}
else
addPlaylistItemsToTable(QStringList() << path);
@ -3491,7 +3512,7 @@ QVector<QHash<QString, QString> > MainWindow::getPlaylistItems(QString pathStrin
return items;
}
void MainWindow::addPlaylistItemsToTable(const QStringList &paths)
void MainWindow::addPlaylistItemsToTable(const QStringList &paths, bool add)
{
QVector<QHash<QString, QString> > items;
int i;
@ -3506,10 +3527,13 @@ void MainWindow::addPlaylistItemsToTable(const QStringList &paths)
/* QVector::append() wasn't added until 5.5, so just do it the old fashioned way */
for (j = 0; j < vec.size(); j++)
{
if (add && items.size() >= m_allPlaylistsMaxCount)
goto finish;
items.append(vec.at(j));
}
}
finish:
addPlaylistHashToTable(items);
}
@ -3584,6 +3608,14 @@ void MainWindow::closeEvent(QCloseEvent *event)
QMainWindow::closeEvent(event);
}
void MainWindow::setAllPlaylistsMaxCount(int count)
{
if (count < 1)
count = 0;
m_allPlaylistsMaxCount = count;
}
static void* ui_window_qt_init(void)
{
ui_window.qtWindow = new MainWindow();

View File

@ -476,6 +476,9 @@ static void* ui_companion_qt_init(void)
/* this should come last */
mainwindow->resizeThumbnails(true, true, true);
if (qsettings->contains("all_playlists_max_count"))
mainwindow->setAllPlaylistsMaxCount(qsettings->value("all_playlists_max_count", 0).toInt());
if (qsettings->contains("geometry"))
if (qsettings->contains("save_geometry"))
mainwindow->restoreGeometry(qsettings->value("geometry").toByteArray());

View File

@ -58,6 +58,7 @@ class QPixmap;
class QPaintEvent;
class QSettings;
class QCheckBox;
class QSpinBox;
class QFormLayout;
class QStyle;
class QScrollArea;
@ -190,6 +191,7 @@ private:
QLabel *m_highlightColorLabel;
QString m_customThemePath;
QCheckBox *m_suggestLoadedCoreFirstCheckBox;
QSpinBox *m_allPlaylistsMaxCountSpinBox;
};
class CoreInfoLabel : public QLabel
@ -291,6 +293,7 @@ public:
void setCurrentViewType(ViewType viewType);
QString getCurrentViewTypeString();
ViewType getCurrentViewType();
void setAllPlaylistsMaxCount(int count);
signals:
void thumbnailChanged(const QPixmap &pixmap);
@ -339,9 +342,9 @@ private slots:
void currentItemChanged(const QHash<QString, QString> &hash);
void onSearchEnterPressed();
void onSearchLineEditEdited(const QString &text);
void addPlaylistItemsToTable(const QStringList &paths);
void addPlaylistItemsToTable(const QStringList &paths, bool all = false);
void addPlaylistHashToTable(const QVector<QHash<QString, QString> > &items);
void addPlaylistItemsToGrid(const QStringList &paths);
void addPlaylistItemsToGrid(const QStringList &paths, bool all = false);
void addPlaylistHashToGrid(const QVector<QHash<QString, QString> > &items);
void onContentItemDoubleClicked(QTableWidgetItem *item);
void onCoreLoadWindowClosed();
@ -423,6 +426,7 @@ private:
QHash<QString, QString> m_currentGridHash;
ViewType m_lastViewType;
QPointer<ThumbnailWidget> m_currentGridWidget;
int m_allPlaylistsMaxCount;
protected:
void closeEvent(QCloseEvent *event);