Commit 97ec753e authored by Alexander Lohnau's avatar Alexander Lohnau 💬
Browse files

bookmarksrunner: Add optional parameter to specify browser config dir

parent de9588fc
......@@ -30,7 +30,7 @@
#include <QFile>
#include <QRegularExpression>
Firefox::Firefox(QObject *parent)
Firefox::Firefox(QObject *parent, const QString &firefoxConfigDir)
: QObject(parent)
, m_favicon(new FallbackFavicon(this))
, m_fetchsqlite(nullptr)
......@@ -38,7 +38,7 @@ Firefox::Firefox(QObject *parent)
{
m_dbCacheFile = QStandardPaths::writableLocation(QStandardPaths::CacheLocation) + QStringLiteral("/bookmarkrunnerfirefoxdbfile.sqlite");
m_dbCacheFile_fav = QStandardPaths::writableLocation(QStandardPaths::CacheLocation) + QStringLiteral("/bookmarkrunnerfirefoxfavdbfile.sqlite");
reloadConfiguration();
init(firefoxConfigDir);
}
Firefox::~Firefox()
......@@ -148,7 +148,7 @@ void Firefox::teardown()
m_favicon->teardown();
}
void Firefox::reloadConfiguration()
void Firefox::init(const QString &firefoxConfigDir)
{
if (!QSqlDatabase::isDriverAvailable(QStringLiteral("QSQLITE"))) {
qCWarning(RUNNER_BOOKMARKS) << "SQLITE driver isn't available";
......@@ -159,7 +159,7 @@ void Firefox::reloadConfiguration()
m_dbFile = grp.readEntry("dbfile", QString());
if (m_dbFile.isEmpty() || !QFile::exists(m_dbFile)) {
// Try to get the right database file, the default profile is used
KConfig firefoxProfile(QDir::homePath() + "/.mozilla/firefox/profiles.ini", KConfig::SimpleConfig);
KConfig firefoxProfile(firefoxConfigDir + "profiles.ini", KConfig::SimpleConfig);
QStringList profilesList = firefoxProfile.groupList();
profilesList = profilesList.filter(QRegularExpression(QStringLiteral("^Profile\\d+$")));
......@@ -190,7 +190,7 @@ void Firefox::reloadConfiguration()
qCWarning(RUNNER_BOOKMARKS) << "No default firefox profile found";
return;
}
profilePath.prepend(QStringLiteral("%1/.mozilla/firefox/").arg(QDir::homePath()));
profilePath.prepend(firefoxConfigDir);
m_dbFile = profilePath + "/places.sqlite";
m_dbFile_fav = profilePath + "/favicons.sqlite";
} else {
......
......@@ -22,6 +22,7 @@
#define FIREFOX_H
#include "browser.h"
#include <QDir>
#include <QSqlDatabase>
class Favicon;
......@@ -30,7 +31,7 @@ class Firefox : public QObject, public Browser
{
Q_OBJECT
public:
explicit Firefox(QObject *parent = nullptr);
explicit Firefox(QObject *parent = nullptr, const QString &firefoxConfigDir = QDir::homePath() + QStringLiteral("/.mozilla/firefox/"));
~Firefox() override;
QList<BookmarkMatch> match(const QString &term, bool addEverything) override;
public Q_SLOTS:
......@@ -38,7 +39,7 @@ public Q_SLOTS:
void prepare() override;
private:
virtual void reloadConfiguration();
virtual void init(const QString &firefoxConfigDir);
QString m_dbFile;
QString m_dbFile_fav;
QString m_dbCacheFile;
......
Supports Markdown
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