plasma: log bookmarks runner messages to the plasma debug area

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2024-05-12 21:10:05 +03:00
parent 59cea6ff49
commit d30570a6e3
11 changed files with 32 additions and 65 deletions

View file

@ -33,15 +33,13 @@
#include <KDebug>
#include "bookmarkmatch.h"
#include "browserfactory.h"
#include "bookmarksrunner_defs.h"
BookmarksRunner::BookmarksRunner( QObject* parent, const QVariantList &args )
: Plasma::AbstractRunner(parent, args),
m_browser(nullptr),
m_browserFactory(new BrowserFactory(this))
{
Q_UNUSED(args)
kDebug(kdbg_code) << "Creating BookmarksRunner";
kDebug() << "Creating BookmarksRunner";
setObjectName( QLatin1String("Bookmarks" ));
addSyntax(
Plasma::RunnerSyntax(i18nc("list of all web browser bookmarks", "bookmarks"),
@ -90,7 +88,7 @@ QString BookmarksRunner::findBrowserName()
//HACK find the default browser
KConfigGroup config(KSharedConfig::openConfig("kdeglobals"), QLatin1String("General") );
QString exec = config.readPathEntry(QLatin1String("BrowserApplication"), QString());
kDebug(kdbg_code) << "Found exec string: " << exec;
kDebug() << "Found exec string" << exec;
if (exec.isEmpty()) {
KService::Ptr service = KMimeTypeTrader::self()->preferredService("text/html");
if (service) {
@ -98,7 +96,7 @@ QString BookmarksRunner::findBrowserName()
}
}
kDebug(kdbg_code) << "KRunner::Bookmarks: found executable " << exec << " as default browser";
kDebug() << "Found executable" << exec << "as default browser";
return exec;
}

View file

@ -1,26 +0,0 @@
/*
* Copyright 2007 Glenn Ergeerts <glenn.ergeerts@telenet.be>
* Copyright 2012 Glenn Ergeerts <marco.gulino@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef BOOKMARKS_RUNNER_DEFS
#define BOOKMARKS_RUNNER_DEFS
#define kdbg_code 1207
#endif

View file

@ -27,7 +27,6 @@
#include "chrome.h"
#include "browsers/findprofile.h"
#include "bookmarksrunner_defs.h"
#include "favicon.h"
class ProfileBookmarks {
@ -72,7 +71,7 @@ QList<BookmarkMatch> Chrome::match(const QString &term, bool addEveryThing, Prof
foreach(const QVariantMap &bookmark, profileBookmarks->bookmarks()) {
const QString url = bookmark.value("url").toString();
const QString name = bookmark.value("name").toString();
kDebug(kdbg_code) << "Match" << name << url;
kDebug() << "Match" << name << url;
BookmarkMatch bookmarkMatch(profileBookmarks->profile().favicon(), term, name, url);
bookmarkMatch.addTo(results, addEveryThing);
}
@ -90,15 +89,15 @@ void Chrome::prepare()
QJsonDocument jsondoc = QJsonDocument::fromJson(bookmarksFile.readAll());
if (jsondoc.isNull()) {
kDebug(kdbg_code) << "Null profile document" << jsondoc.errorString();
kDebug() << "Null profile document" << jsondoc.errorString();
continue;
}
const QVariantMap root = jsondoc.toVariant().toMap();
if (!root.contains("roots")) {
kDebug(kdbg_code) << "No roots in" << profile.path();
kDebug() << "No roots in" << profile.path();
continue;
}
kDebug(kdbg_code) << "Filling entries from" << profile.path();
kDebug() << "Filling entries from" << profile.path();
const QVariantMap roots = root.value("roots").toMap();
foreach (const QVariant &folder, roots.values()) {
parseFolder(folder.toMap(), profileBookmarks);
@ -122,7 +121,7 @@ void Chrome::parseFolder(const QVariantMap &entry, ProfileBookmarks *profile)
if(entry.value("type").toString() == "folder") {
parseFolder(entry, profile);
} else {
// kDebug(kdbg_code) << "Adding entry" << entry;
// kDebug() << "Adding entry" << entry;
profile->add(entry);
}
}

View file

@ -26,7 +26,6 @@
#include <KDebug>
#include "chromefindprofile.h"
#include "bookmarksrunner_defs.h"
#include "favicon.h"
FindChromeProfile::FindChromeProfile (const QString &applicationName, const QString &homeDirectory, QObject* parent )
@ -48,7 +47,7 @@ QList<Profile> FindChromeProfile::find()
QJsonDocument jsondoc = QJsonDocument::fromJson(localStateFile.readAll());
if (jsondoc.isNull()) {
kDebug(kdbg_code) << "error opening " << QFileInfo(localStateFile).absoluteFilePath();
kWarning() << "error opening " << QFileInfo(localStateFile).absoluteFilePath();
return profiles;
}

View file

@ -53,7 +53,7 @@ QList< BookmarkMatch > KDEBrowser::match(const QString& term, bool addEverything
}
if (bookmark.isGroup()) { // descend
//kDebug (kdbg_code) << "descending into" << bookmark.text();
// kDebug() << "descending into" << bookmark.text();
groups.push(bookmarkGroup);
bookmarkGroup = bookmark.toGroup();
bookmark = bookmarkGroup.first();
@ -82,7 +82,7 @@ QList< BookmarkMatch > KDEBrowser::match(const QString& term, bool addEverything
bookmark = bookmarkGroup;
bookmarkGroup = groups.pop();
//kDebug(kdbg_code) << "ascending from" << bookmark.text() << "to" << bookmarkGroup.text();
//kDebug() << "ascending from" << bookmark.text() << "to" << bookmarkGroup.text();
bookmark = bookmarkGroup.next(bookmark);
}
}

View file

@ -70,15 +70,15 @@ void CalculatorRunner::powSubstitutions(QString& cmd)
int count = 0;
QChar decimalSymbol = KGlobal::locale()->toLocale().decimalPoint();
//avoid out of range on weird commands
// avoid out of range on weird commands
preIndex = qMax(0, preIndex);
postIndex = qMin(postIndex, cmd.length()-1);
//go backwards looking for the beginning of the number or expression
// go backwards looking for the beginning of the number or expression
while (preIndex != 0) {
QChar current = cmd.at(preIndex);
QChar next = cmd.at(preIndex-1);
//kDebug() << "index " << preIndex << " char " << current;
// kDebug() << "index " << preIndex << " char " << current;
if (current == ')') {
count++;
} else if (current == '(') {
@ -90,7 +90,7 @@ void CalculatorRunner::powSubstitutions(QString& cmd)
}
}
if (count == 0) {
//check for functions
// check for functions
if (!((next <= 'z' ) && (next >= 'a'))) {
break;
}
@ -132,7 +132,7 @@ void CalculatorRunner::powSubstitutions(QString& cmd)
cmd.insert(preIndex,"pow(");
// +1 +4 == next position to the last number after we add 4 new characters pow(
cmd.insert(postIndex + 1 + 4, ')');
//kDebug() << "from" << preIndex << " to " << postIndex << " got: " << cmd;
// kDebug() << "from" << preIndex << " to " << postIndex << " got: " << cmd;
}
}
@ -230,7 +230,6 @@ void CalculatorRunner::match(Plasma::RunnerContext &context)
QMimeData* CalculatorRunner::mimeDataForMatch(const Plasma::QueryMatch &match)
{
// kDebug();
QMimeData *result = new QMimeData();
result->setText(match.text());
return result;

View file

@ -88,14 +88,14 @@ void LocationsRunner::match(Plasma::RunnerContext &context)
match.setData(url.url());
if (KProtocolInfo::isHelperProtocol(url.protocol())) {
//kDebug() << "helper protocol" << url.protocol() <<"call external application" ;
// kDebug() << "helper protocol" << url.protocol() <<"call external application" ;
if (url.protocol() == "mailto") {
match.setText(i18n("Send email to %1",url.path()));
} else {
match.setText(i18n("Launch with %1", KProtocolInfo::exec(url.protocol())));
}
} else {
//kDebug() << "protocol managed by browser" << url.protocol();
// kDebug() << "protocol managed by browser" << url.protocol();
match.setText(i18n("Go to %1", url.prettyUrl()));
}

View file

@ -32,8 +32,6 @@
PlacesRunner::PlacesRunner(QObject* parent, const QVariantList &args)
: Plasma::AbstractRunner(parent, args)
{
// qRegisterMetaType
Q_UNUSED(args)
setObjectName( QLatin1String("Places" ));
addSyntax(Plasma::RunnerSyntax(i18n("places"), i18n("Lists all file manager locations")));
addSyntax(Plasma::RunnerSyntax(":q:", i18n("Finds file manager locations that match :q:")));
@ -51,14 +49,14 @@ void PlacesRunner::match(Plasma::RunnerContext &context)
{
if (QThread::currentThread() == QCoreApplication::instance()->thread()) {
// from the main thread
//kDebug() << "calling";
// kDebug() << "calling";
m_helper->match(&context);
} else {
// from the non-gui thread
//kDebug() << "emitting";
// kDebug() << "emitting";
emit doMatch(&context);
}
//m_helper->match(c);
// m_helper->match(c);
}
PlacesRunnerHelper::PlacesRunnerHelper(PlacesRunner *runner)
@ -156,7 +154,7 @@ void PlacesRunner::run(const Plasma::QueryMatch &action)
void PlacesRunner::setupComplete(QModelIndex index, bool success)
{
KFilePlacesModel *places = qobject_cast<KFilePlacesModel*>(sender());
//kDebug() << "setup complete" << places << sender();
// kDebug() << "setup complete" << places << sender();
if (success && places) {
KToolInvocation::self()->startServiceForUrl(places->url(index).url());
places->deleteLater();

View file

@ -56,7 +56,7 @@ RecentDocuments::~RecentDocuments()
void RecentDocuments::loadRecentDocuments()
{
//kDebug() << "Refreshing recent documents.";
// kDebug() << "Refreshing recent documents.";
m_recentdocuments = KRecentDocument::recentDocuments();
}

View file

@ -57,7 +57,7 @@ void ServiceRunner::match(Plasma::RunnerContext &context)
KService::List services = KServiceTypeTrader::self()->query("Application", query);
if (!services.isEmpty()) {
//kDebug() << service->name() << "is an exact match!" << service->storageId() << service->exec();
// kDebug() << service->name() << "is an exact match!" << service->storageId() << service->exec();
foreach (const KService::Ptr &service, services) {
if (!service->noDisplay() && service->property("NotShowIn", QVariant::String) != "KDE") {
Plasma::QueryMatch match(this);
@ -91,7 +91,7 @@ void ServiceRunner::match(Plasma::RunnerContext &context)
KService::List services = KServiceTypeTrader::self()->query("Application", query);
services += KServiceTypeTrader::self()->query("KCModule", query);
//kDebug() << "got " << services.count() << " services from " << query;
// kDebug() << "got " << services.count() << " services from " << query;
foreach (const KService::Ptr &service, services) {
if (!context.isValid()) {
return;
@ -106,11 +106,11 @@ void ServiceRunner::match(Plasma::RunnerContext &context)
const QString exec = service->exec();
if (seen.contains(id) || seen.contains(exec)) {
//kDebug() << "already seen" << id << exec;
// kDebug() << "already seen" << id << exec;
continue;
}
//kDebug() << "haven't seen" << id << "so processing now";
// kDebug() << "haven't seen" << id << "so processing now";
seen.insert(id);
seen.insert(exec);
@ -156,7 +156,7 @@ void ServiceRunner::match(Plasma::RunnerContext &context)
query = QString("exist Exec and (exist Categories and '%1' ~subin Categories)").arg(term);
services = KServiceTypeTrader::self()->query("Application", query);
//kDebug() << service->name() << "is an exact match!" << service->storageId() << service->exec();
// kDebug() << service->name() << "is an exact match!" << service->storageId() << service->exec();
foreach (const KService::Ptr &service, services) {
if (!context.isValid()) {
return;
@ -166,7 +166,7 @@ void ServiceRunner::match(Plasma::RunnerContext &context)
QString id = service->storageId();
QString exec = service->exec();
if (seen.contains(id) || seen.contains(exec)) {
//kDebug() << "already seen" << id << exec;
// kDebug() << "already seen" << id << exec;
continue;
}
Plasma::QueryMatch match(this);

View file

@ -52,12 +52,12 @@ void WebshortcutRunner::readFiltersConfig()
m_delimiter = filterData.searchTermSeparator();
}
//kDebug() << "keyword delimiter:" << m_delimiter;
//kDebug() << "search providers:" << filterData.preferredSearchProviders();
// kDebug() << "keyword delimiter:" << m_delimiter;
// kDebug() << "search providers:" << filterData.preferredSearchProviders();
QList<Plasma::RunnerSyntax> syns;
Q_FOREACH (const QString &provider, filterData.preferredSearchProviders()) {
//kDebug() << "checking out" << provider;
// kDebug() << "checking out" << provider;
Plasma::RunnerSyntax s(filterData.queryForPreferredSearchProvider(provider), /*":q:",*/
i18n("Opens \"%1\" in a web browser with the query :q:.", provider));
syns << s;