7#include "openurlwithmanager.h"
8#include "messageviewer_debug.h"
10#include <KSharedConfig>
13#include <QStandardPaths>
16using namespace MessageViewer;
19static const char myOpenUrlWithGroupName[] =
"OpenUrlWith";
21OpenUrlWithManager::OpenUrlWithManager(
QObject *parent)
27OpenUrlWithManager::~OpenUrlWithManager() =
default;
29OpenUrlWithManager *OpenUrlWithManager::self()
31 static OpenUrlWithManager
s_self;
35void OpenUrlWithManager::clear()
37 mOpenWithUrlInfo.clear();
40void OpenUrlWithManager::loadUserSettings()
52 info.setCommand(commands.
at(
i));
60 mOpenWithUrlInfo.append(std::move(info));
64QStringList OpenUrlWithManager::openUrlWithListPath()
const
69void OpenUrlWithManager::loadGlobalSettings()
71 for (
const QString &path : openUrlWithListPath()) {
73 const QStringList entries =
dir.entryList({QStringLiteral(
"*.openurl")});
74 for (
const QString &entry : entries) {
78 info.setIsLocalOpenWithInfo(
false);
79 info.setCommand(settings.value(
"Command").toString());
80 info.setCommandLine(settings.value(
"CommandLine").toString());
81 info.setUrl(settings.value(
"Url").toString());
83 mOpenWithUrlInfo.append(std::move(info));
89void OpenUrlWithManager::loadSettings()
91 mOpenWithUrlInfo.clear();
96void OpenUrlWithManager::saveRules()
104 const auto nbElement{mOpenWithUrlInfo.count()};
108 const auto &openWith(mOpenWithUrlInfo.at(
i));
109 if (openWith.isLocalOpenWithInfo()) {
110 commands.
append(openWith.command());
117 group.writeEntry(
"Commands", commands);
123bool OpenUrlWithManager::alwaysRuleForHost(
const QUrl &url)
127 if (info.enabled()) {
140 if (info.enabled()) {
160 return mOpenWithUrlInfo;
168#include "moc_openurlwithmanager.cpp"
static KSharedConfig::Ptr openConfig(const QString &fileName=QString(), OpenFlags mode=FullConfig, QStandardPaths::StandardLocation type=QStandardPaths::GenericConfigLocation)
The OpenWithUrlInfo class.
KIOCORE_EXPORT QString dir(const QString &fileClass)
void append(QList< T > &&value)
const_reference at(qsizetype i) const const
void reserve(qsizetype size)
T qobject_cast(QObject *object)
QStringList locateAll(StandardLocation type, const QString &fileName, LocateOptions options)
QString host(ComponentFormattingOptions options) const const