Make use of the proposed new KColorScheme API
Make use of new API proposed in frameworks/kcolorscheme!12
This commit is contained in:
@@ -14,7 +14,7 @@ set(RELEASE_SERVICE_VERSION "${RELEASE_SERVICE_VERSION_MAJOR}.${RELEASE_SERVICE_
|
|||||||
|
|
||||||
project(NeoChat VERSION ${RELEASE_SERVICE_VERSION})
|
project(NeoChat VERSION ${RELEASE_SERVICE_VERSION})
|
||||||
|
|
||||||
set(KF_MIN_VERSION "6.4")
|
set(KF_MIN_VERSION "6.6")
|
||||||
set(QT_MIN_VERSION "6.5")
|
set(QT_MIN_VERSION "6.5")
|
||||||
|
|
||||||
find_package(ECM ${KF_MIN_VERSION} REQUIRED NO_MODULE)
|
find_package(ECM ${KF_MIN_VERSION} REQUIRED NO_MODULE)
|
||||||
|
|||||||
@@ -26,23 +26,9 @@ void ColorSchemer::apply(int idx)
|
|||||||
c->activateScheme(c->model()->index(idx, 0));
|
c->activateScheme(c->model()->index(idx, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ColorSchemer::apply(const QString &name)
|
int ColorSchemer::indexForCurrentScheme()
|
||||||
{
|
{
|
||||||
c->activateScheme(c->indexForScheme(name));
|
return c->indexForSchemeId(c->activeSchemeId()).row();
|
||||||
}
|
|
||||||
|
|
||||||
int ColorSchemer::indexForScheme(const QString &name) const
|
|
||||||
{
|
|
||||||
auto index = c->indexForScheme(name).row();
|
|
||||||
if (index == -1) {
|
|
||||||
index = 0;
|
|
||||||
}
|
|
||||||
return index;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString ColorSchemer::nameForIndex(int index) const
|
|
||||||
{
|
|
||||||
return c->model()->data(c->model()->index(index, 0), Qt::DisplayRole).toString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "moc_colorschemer.cpp"
|
#include "moc_colorschemer.cpp"
|
||||||
|
|||||||
@@ -44,21 +44,11 @@ public:
|
|||||||
Q_INVOKABLE void apply(int idx);
|
Q_INVOKABLE void apply(int idx);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Activates the KColorScheme with the given name.
|
* @brief Get the row for the current color scheme.
|
||||||
*
|
*
|
||||||
* @sa KColorScheme
|
* @sa KColorScheme
|
||||||
*/
|
*/
|
||||||
Q_INVOKABLE void apply(const QString &name);
|
Q_INVOKABLE int indexForCurrentScheme();
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Returns the index for the scheme with the given name.
|
|
||||||
*/
|
|
||||||
Q_INVOKABLE int indexForScheme(const QString &name) const;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Returns the name for the scheme with the given index.
|
|
||||||
*/
|
|
||||||
Q_INVOKABLE QString nameForIndex(int index) const;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
KColorSchemeManager *c;
|
KColorSchemeManager *c;
|
||||||
|
|||||||
@@ -185,9 +185,6 @@ int main(int argc, char *argv[])
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
ColorSchemer colorScheme;
|
ColorSchemer colorScheme;
|
||||||
if (!NeoChatConfig::self()->colorScheme().isEmpty()) {
|
|
||||||
colorScheme.apply(NeoChatConfig::self()->colorScheme());
|
|
||||||
}
|
|
||||||
|
|
||||||
QCommandLineParser parser;
|
QCommandLineParser parser;
|
||||||
parser.setApplicationDescription(i18n("Client for the matrix communication protocol"));
|
parser.setApplicationDescription(i18n("Client for the matrix communication protocol"));
|
||||||
|
|||||||
@@ -15,9 +15,6 @@
|
|||||||
<entry name="OpenRoom" type="String">
|
<entry name="OpenRoom" type="String">
|
||||||
<label>Latest opened room</label>
|
<label>Latest opened room</label>
|
||||||
</entry>
|
</entry>
|
||||||
<entry name="ColorScheme" type="String">
|
|
||||||
<label>Color scheme</label>
|
|
||||||
</entry>
|
|
||||||
<entry name="Blur" type="bool">
|
<entry name="Blur" type="bool">
|
||||||
<label>Make NeoChat blurry</label>
|
<label>Make NeoChat blurry</label>
|
||||||
<default>false</default>
|
<default>false</default>
|
||||||
|
|||||||
@@ -15,10 +15,6 @@ FormCard.FormComboBoxDelegate {
|
|||||||
textRole: "display"
|
textRole: "display"
|
||||||
valueRole: "display"
|
valueRole: "display"
|
||||||
model: ColorSchemer.model
|
model: ColorSchemer.model
|
||||||
Component.onCompleted: currentIndex = ColorSchemer.indexForScheme(NeoChatConfig.colorScheme)
|
Component.onCompleted: currentIndex = ColorSchemer.indexForCurrentScheme()
|
||||||
onCurrentValueChanged: {
|
onCurrentValueChanged: ColorSchemer.apply(currentIndex);
|
||||||
ColorSchemer.apply(currentIndex);
|
|
||||||
NeoChatConfig.colorScheme = ColorSchemer.nameForIndex(currentIndex);
|
|
||||||
NeoChatConfig.save();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user