Add support for downloading nick icon themes from store.kde.org

parent 5f7ce13c
......@@ -35,6 +35,7 @@ find_package(KF5 ${KF5_MIN_VERSION} REQUIRED
WidgetsAddons
GlobalAccel
DBusAddons
NewStuff
Notifications
WindowSystem
ItemViews
......
......@@ -21,3 +21,4 @@ install(PROGRAMS updaters/konversation-0.19-colors.pl
updaters/konversation-0.20-customfonts.pl
DESTINATION ${DATA_INSTALL_DIR}/kconf_update)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/org.kde.konversation.appdata.xml DESTINATION ${KDE_INSTALL_METAINFODIR})
install(FILES konversation_nicklist_theme.knsrc DESTINATION ${KDE_INSTALL_KNSRCDIR})
[KNewStuff3]
ProvidersUrl=https://autoconfig.kde.org/ocs/providers.xml
Categories=Konversation Nicklist Themes
TargetDir=konversation/themes
Uncompress=always
......@@ -249,6 +249,7 @@ target_link_libraries(konversation
KF5::Notifications
KF5::WindowSystem
KF5::ItemViews
KF5::NewStuff
Phonon::phonon4qt5)
if (Qca-qt5_FOUND)
......
......@@ -27,6 +27,7 @@
#include <KIO/DeleteJob>
#include <KIO/CopyJob>
#include <KSharedConfig>
#include <KNSCore/DownloadManager>
#include <QStringList>
#include <QUrl>
......@@ -48,9 +49,12 @@ Theme_Config::Theme_Config(QWidget* parent, const char* name)
// load the current settings
loadSettings();
getButton->setConfigFile(QStringLiteral("konversation_nicklist_theme.knsrc"));
connect(iconThemeIndex, &QListWidget::currentRowChanged, this, &Theme_Config::updatePreview);
connect(iconThemeIndex, &QListWidget::itemSelectionChanged, this, &Theme_Config::updateButtons);
connect(iconThemeIndex, &QListWidget::itemSelectionChanged, this, &Theme_Config::modified);
connect(getButton, &KNS3::Button::dialogFinished, this, &Theme_Config::gotNewSchemes);
connect(installButton, &QPushButton::clicked, this, &Theme_Config::installTheme);
connect(removeButton, &QPushButton::clicked, this, &Theme_Config::removeTheme);
}
......@@ -172,6 +176,11 @@ void Theme_Config::restorePageToDefaults()
iconThemeIndex->setCurrentRow(m_defaultThemeIndex);
}
void Theme_Config::gotNewSchemes()
{
loadSettings();
}
void Theme_Config::installTheme()
{
QUrl themeURL = QFileDialog::getOpenFileUrl(this,
......@@ -293,11 +302,45 @@ void Theme_Config::removeTheme()
QStringLiteral("warningRemoveTheme")
);
if(remove == KMessageBox::Continue)
{
KIO::DeleteJob* job = KIO::del(QUrl::fromLocalFile(dir.remove(QStringLiteral("index.desktop"))));
connect(job, &KIO::DeleteJob::result, this, &Theme_Config::postRemoveTheme);
if (remove != KMessageBox::Continue) {
return;
}
dir.chop(QLatin1Literal("index.desktop").size());
// Check if theme was installed by KNS, if so uninstall via KNS, otherwise manually
auto *manager = new KNSCore::DownloadManager(QStringLiteral("konversation_nicklist_theme.knsrc"), this);
connect(manager, &KNSCore::DownloadManager::searchResult,
this, [=](const KNSCore::EntryInternal::List &entries) {
bool isUninstalledByKNS = false;
for (auto &entry : entries) {
for (const auto &file : entry.installedFiles()) {
// file strings are of pattern "[...]/konversation/themes/simpleminded/*"
if (file.startsWith(dir)) {
// uninstall via KNS and be done
manager->uninstallEntry(entry);
isUninstalledByKNS = true;
break;
}
}
if (isUninstalledByKNS) {
break;
}
}
if (isUninstalledByKNS) {
loadSettings();
} else {
// manually installed, so delete manually
KIO::DeleteJob* job = KIO::del(QUrl::fromLocalFile(dir));
connect(job, &KIO::DeleteJob::result, this, &Theme_Config::postRemoveTheme);
}
manager->deleteLater();
});
manager->checkForInstalled();
}
void Theme_Config::postRemoveTheme(KJob* /* delete_job */)
......
......@@ -43,6 +43,7 @@ class Theme_Config : public QWidget, public KonviSettingsPage, private Ui::Theme
void updateButtons();
void installTheme();
void removeTheme();
void gotNewSchemes();
void postRemoveTheme(KJob* delete_job);
private:
......
......@@ -22,10 +22,17 @@
</item>
<item row="2" column="0" colspan="3">
<layout class="QHBoxLayout">
<item>
<widget class="KNS3::Button" name="getButton">
<property name="text">
<string>G&amp;et New Themes...</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="installButton">
<property name="text">
<string>I&amp;nstall Theme...</string>
<string>I&amp;nstall from File...</string>
</property>
</widget>
</item>
......@@ -208,6 +215,13 @@
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>KNS3::Button</class>
<extends>QPushButton</extends>
<header>KNS3/Button</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment