diff --git a/src/chatviewtheme.cpp b/src/chatviewtheme.cpp index 6042891b3..17f5b47e8 100644 --- a/src/chatviewtheme.cpp +++ b/src/chatviewtheme.cpp @@ -452,6 +452,11 @@ void ChatViewJSLoader::setMetaData(const QVariantMap &map) if (vl.count()) { theme->features = vl; } + + vl = map["stylesList"].toStringList(); + if (vl.count()) { + theme->stylesList = vl; + } } void ChatViewJSLoader::finishThemeLoading() diff --git a/src/options/opt_theme.cpp b/src/options/opt_theme.cpp index 11c604b9b..649b2ff20 100644 --- a/src/options/opt_theme.cpp +++ b/src/options/opt_theme.cpp @@ -92,7 +92,7 @@ QWidget *OptionsTabAppearanceTheme::widget() void OptionsTabAppearanceTheme::themeSelected(const QModelIndex ¤t, const QModelIndex &previous) { - Q_UNUSED(current); + updateStyles(current); if (!previous.isValid()) { return; // Psi won't start if it's impossible to load any theme. So we always have previous. } @@ -108,6 +108,7 @@ void OptionsTabAppearanceTheme::modelRowsInserted(const QModelIndex &parent, int const QModelIndex index = themesModel->index(i, 0); if (themesModel->data(index, PsiThemeModel::IsCurrent).toBool()) { d->themeView->setCurrentIndex(index); + updateStyles(index); } #if 0 const QString id = themesModel->data(index, PsiThemeModel::IdRole).toString(); @@ -187,6 +188,19 @@ QString OptionsTabAppearanceTheme::getThemeId(const QString &objName) const return (index > 0 ? objName.right(objName.length() - index - 1) : QString()); } +void OptionsTabAppearanceTheme::updateStyles(const QModelIndex &index) +{ + auto styles = themesModel->data(index, PsiThemeModel::StylesListRole).toStringList(); + OptAppearanceThemeUI *d = static_cast(w); + d->cmb_style->blockSignals(true); + d->cmb_style->clear(); + for (auto const &s : styles) { + d->cmb_style->addItem(s); + } + d->cmb_style->setCurrentIndex(0); + d->cmb_style->blockSignals(0); +} + void OptionsTabAppearanceTheme::applyOptions() { if (!w) diff --git a/src/options/opt_theme.h b/src/options/opt_theme.h index 8485f8428..15b68ea50 100644 --- a/src/options/opt_theme.h +++ b/src/options/opt_theme.h @@ -59,6 +59,7 @@ private slots: private: QString getThemeId(const QString &objName) const; + void updateStyles(const QModelIndex &index); private: QWidget *w = nullptr; diff --git a/src/options/opt_theme.ui b/src/options/opt_theme.ui index 75f3750ca..fa318d7dd 100644 --- a/src/options/opt_theme.ui +++ b/src/options/opt_theme.ui @@ -19,7 +19,7 @@ - QAbstractItemView::NoEditTriggers + QAbstractItemView::EditTrigger::NoEditTriggers false @@ -42,10 +42,20 @@ + + + + Style + + + + + + - Qt::Horizontal + Qt::Orientation::Horizontal @@ -67,7 +77,7 @@ <a href="thememanager://showmore/">More themes</a> - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + Qt::AlignmentFlag::AlignRight|Qt::AlignmentFlag::AlignTrailing|Qt::AlignmentFlag::AlignVCenter diff --git a/src/psithememodel.cpp b/src/psithememodel.cpp index b056c110e..3735426c3 100644 --- a/src/psithememodel.cpp +++ b/src/psithememodel.cpp @@ -83,6 +83,7 @@ struct PsiThemeModel::Loader { ti.creation = theme.creation(); ti.homeUrl = theme.homeUrl(); ti.features = theme.features(); + ti.stylesList = theme.stylesList(); ti.hasPreview = theme.hasPreview(); ti.isValid = true; @@ -196,6 +197,10 @@ QVariant PsiThemeModel::data(const QModelIndex &index, int role) const } case IsCurrent: return themesInfo[index.row()].isCurrent; + case StylesListRole: { + const ThemeItemInfo &ti = themesInfo[index.row()]; + return ti.stylesList; + } } return QVariant(); } diff --git a/src/psithememodel.h b/src/psithememodel.h index 39048590c..19c824181 100644 --- a/src/psithememodel.h +++ b/src/psithememodel.h @@ -37,6 +37,7 @@ struct ThemeItemInfo { QString creation; QString homeUrl; QStringList features; + QStringList stylesList; bool hasPreview; bool isValid = false; @@ -47,7 +48,7 @@ class PsiThemeModel : public QAbstractListModel { Q_OBJECT public: - enum ThemeRoles { IdRole = Qt::UserRole + 1, HasPreviewRole, TitleRole, IsCurrent }; + enum ThemeRoles { IdRole = Qt::UserRole + 1, HasPreviewRole, TitleRole, IsCurrent, StylesListRole }; PsiThemeModel(PsiThemeProvider *provider, QObject *parent); ~PsiThemeModel(); diff --git a/src/theme.cpp b/src/theme.cpp index 69283476a..10b43f966 100644 --- a/src/theme.cpp +++ b/src/theme.cpp @@ -189,6 +189,8 @@ const QString &Theme::homeUrl() const { return d->homeUrl; } const QStringList &Theme::features() const { return d->features; } +const QStringList &Theme::stylesList() const { return d->stylesList; } + PsiThemeProvider *Theme::themeProvider() const { return d->provider; } /** diff --git a/src/theme.h b/src/theme.h index 58cc63989..d23fea816 100644 --- a/src/theme.h +++ b/src/theme.h @@ -93,6 +93,7 @@ class Theme { const QString &creation() const; const QString &homeUrl() const; const QStringList &features() const; + const QStringList &stylesList() const; PsiThemeProvider *themeProvider() const; const QString &filePath() const; diff --git a/src/theme_p.h b/src/theme_p.h index ea69ed904..d1d487260 100644 --- a/src/theme_p.h +++ b/src/theme_p.h @@ -33,7 +33,7 @@ class ThemePrivate : public QSharedData { // metadata QString id, name, version, description, creation, homeUrl; - QStringList authors, features; + QStringList authors, features, stylesList; QHash info; // runtime info diff --git a/themes/chatview/psi/bubble/index.html b/themes/chatview/psi/bubble/index.html index 2536711b5..04c0d7b24 100644 --- a/themes/chatview/psi/bubble/index.html +++ b/themes/chatview/psi/bubble/index.html @@ -286,11 +286,7 @@ padding: .5rem 0; margin: 0; box-sizing: border-box; - /*background: url(background.jpg); - background-attachment: fixed; - background-size: cover;*/ - background-color: rgb(194, 181, 209); - background: linear-gradient(90deg, rgb(194, 181, 209) 0%, rgb(198, 198, 255) 37%, rgb(174, 241, 255) 100%); + background-color: #ccd; color: black; font-family: sans, times; position: relative; @@ -307,7 +303,7 @@ margin: 0 auto .5rem; border-radius: 1rem; text-align: center; - box-shadow: 0px 0px 0.5rem black; + box-shadow: 0px 0px 0.3rem black; } .sysmsg .usertext { @@ -323,7 +319,7 @@ position: relative; background-color: #f8f8f8; border-radius: 0 .6rem .6rem .6rem; - box-shadow: 0px 0px 0.5rem black; + box-shadow: 0px 0px 0.3rem black; clip-path: inset(-0.5rem -5rem -0.5rem -5rem); word-wrap: break-word !important; display: flex; @@ -538,7 +534,7 @@ margin-top: 1rem; border-radius: 0.2rem; background-color: #fafafa; - box-shadow: 0px 0px 0.5rem black; + box-shadow: 0px 0px 0.3rem black; flex-wrap: wrap; z-index: 2; } @@ -553,7 +549,7 @@ position: absolute; box-sizing: border-box; flex-flow: column; - box-shadow: 0px 0px 0.5rem black; + box-shadow: 0px 0px 0.3rem black; border-radius: .3rem; background-color: white; z-index: 3; diff --git a/themes/chatview/psi/bubble/load.js b/themes/chatview/psi/bubble/load.js index fc6bcb172..279cd82a4 100644 --- a/themes/chatview/psi/bubble/load.js +++ b/themes/chatview/psi/bubble/load.js @@ -4,5 +4,6 @@ srvLoader.setMetaData({ authors: ["Sergei Ilinykh "], description: "Bubble style.", url: "https://psi-im.org", - features: ["reactions", "message-retract"] + features: ["reactions", "message-retract"], + stylesList: ["Light", "Dark"] }); diff --git a/version b/version index 453788d9d..ec75f1067 100644 --- a/version +++ b/version @@ -1 +1 @@ -1.5.2024 (2024-07-05, 5dbcee2e) +1.5.2025 (2024-07-06, 27eb5bc2)