Commit b8ed382c authored by Laurent Montel's avatar Laurent Montel 😁

USe nullptr/override/ Fix compile with strict compile flags

parent 5952adcd
......@@ -32,6 +32,13 @@ find_package(KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS
Activities
)
add_definitions(-DQT_NO_CAST_FROM_ASCII)
add_definitions(-DQT_NO_CAST_TO_ASCII)
add_definitions(-DQT_NO_NARROWING_CONVERSIONS_IN_CONNECT)
add_definitions(-DQT_NO_URL_CAST_FROM_STRING)
add_definitions(-DQT_USE_QSTRINGBUILDER)
#add_definitions(-DQT_DISABLE_DEPRECATED_BEFORE=0x060000)
# Options
option(INSTALL_CHROME_MANIFEST "Whether to install a configuration file that makes Chrome automatically download the extension from the store" FALSE)
add_feature_info(INSTALL_CHROME_MANIFEST ${INSTALL_CHROME_MANIFEST} "Install extension from Chrome store automatically")
......
......@@ -29,7 +29,7 @@ AbstractBrowserPlugin::AbstractBrowserPlugin::AbstractBrowserPlugin(const QStrin
QObject(parent),
m_subsystem(subsystemId)
{
sendData(QStringLiteral("created"), {{"version", protocolVersion}});
sendData(QStringLiteral("created"), {{QStringLiteral("version"), protocolVersion}});
}
void AbstractBrowserPlugin::handleData(const QString& event, const QJsonObject& data)
......@@ -41,10 +41,10 @@ void AbstractBrowserPlugin::handleData(const QString& event, const QJsonObject&
void AbstractBrowserPlugin::sendData(const QString &action, const QJsonObject &payload)
{
QJsonObject data;
data["subsystem"] = m_subsystem;
data["action"] = action;
data[QStringLiteral("subsystem")] = m_subsystem;
data[QStringLiteral("action")] = action;
if (!payload.isEmpty()) {
data["payload"] = payload;
data[QStringLiteral("payload")] = payload;
}
Connection::self()->sendData(data);
}
......
......@@ -53,7 +53,7 @@ void Connection::sendData(const QJsonObject &data)
Connection* Connection::self()
{
static Connection *s = 0;
static Connection *s = nullptr;
if (!s) {
s = new Connection();
}
......
......@@ -32,9 +32,9 @@ class DownloadPlugin : public AbstractBrowserPlugin
{
Q_OBJECT
public:
DownloadPlugin(QObject *parent);
explicit DownloadPlugin(QObject *parent);
bool onUnload() override;
void handleData(const QString &event, const QJsonObject &data);
void handleData(const QString &event, const QJsonObject &data) override;
private:
QHash<int, DownloadJob *> m_jobs;
};
......@@ -36,10 +36,10 @@ KDEConnectPlugin::KDEConnectPlugin(QObject* parent) :
bool KDEConnectPlugin::onLoad()
{
QDBusMessage msg = QDBusMessage::createMethodCall("org.kde.kdeconnect",
"/modules/kdeconnect",
"org.kde.kdeconnect.daemon",
"devices");
QDBusMessage msg = QDBusMessage::createMethodCall(QStringLiteral("org.kde.kdeconnect"),
QStringLiteral("/modules/kdeconnect"),
QStringLiteral("org.kde.kdeconnect.daemon"),
QStringLiteral("devices"));
msg.setArguments({true /* only reachable */, true /* only paired */});
QDBusPendingReply<QStringList> reply = QDBusConnection::sessionBus().asyncCall(msg);
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(reply, this);
......@@ -51,11 +51,11 @@ bool KDEConnectPlugin::onLoad()
const QStringList &devices = reply.value();
foreach (const QString &deviceId, devices) {
QDBusMessage msg = QDBusMessage::createMethodCall("org.kde.kdeconnect",
"/modules/kdeconnect/devices/" + deviceId,
"org.freedesktop.DBus.Properties",
"GetAll");
msg.setArguments({"org.kde.kdeconnect.device"});
QDBusMessage msg = QDBusMessage::createMethodCall(QStringLiteral("org.kde.kdeconnect"),
QStringLiteral("/modules/kdeconnect/devices/") + deviceId,
QStringLiteral("org.freedesktop.DBus.Properties"),
QStringLiteral("GetAll"));
msg.setArguments({QStringLiteral("org.kde.kdeconnect.device")});
QDBusPendingReply<QVariantMap> reply = QDBusConnection::sessionBus().asyncCall(msg);
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(reply, this);
......@@ -66,9 +66,9 @@ bool KDEConnectPlugin::onLoad()
debug() << "getting device properties" << reply.error().message();
} else {
auto props = reply.value();
props["id"] = deviceId;
props[QStringLiteral("id")] = deviceId;
m_devices.append(deviceId);
sendData("deviceAdded", QJsonObject::fromVariantMap(props));
sendData(QStringLiteral("deviceAdded"), QJsonObject::fromVariantMap(props));
}
});
}
......@@ -81,7 +81,7 @@ bool KDEConnectPlugin::onLoad()
bool KDEConnectPlugin::onUnload()
{
foreach(const QString &deviceId, m_devices) {
sendData("deviceRemoved", {{"id", deviceId}});
sendData(QStringLiteral("deviceRemoved"), {{QStringLiteral("id"), deviceId}});
}
return true;
}
......@@ -89,15 +89,15 @@ bool KDEConnectPlugin::onUnload()
void KDEConnectPlugin::handleData(const QString& event, const QJsonObject& json)
{
if (event == QLatin1String("shareUrl")) {
const QString deviceId = json.value("deviceId").toString();
const QString url = json.value("url").toString();
const QString deviceId = json.value(QStringLiteral("deviceId")).toString();
const QString url = json.value(QStringLiteral("url")).toString();
debug() << "sending kde connect url" << url << "to device" << deviceId;
QDBusMessage msg = QDBusMessage::createMethodCall("org.kde.kdeconnect",
"/modules/kdeconnect/devices/" + deviceId + "/share",
"org.kde.kdeconnect.device.share",
"shareUrl");
QDBusMessage msg = QDBusMessage::createMethodCall(QStringLiteral("org.kde.kdeconnect"),
QStringLiteral("/modules/kdeconnect/devices/") + deviceId + QStringLiteral("/share"),
QStringLiteral("org.kde.kdeconnect.device.share"),
QStringLiteral("shareUrl"));
msg.setArguments({url});
QDBusPendingReply<QStringList> reply = QDBusConnection::sessionBus().asyncCall(msg);
......
......@@ -28,7 +28,7 @@ class KDEConnectPlugin : public AbstractBrowserPlugin
{
Q_OBJECT
public:
KDEConnectPlugin(QObject *parent);
explicit KDEConnectPlugin(QObject *parent);
bool onLoad() override;
bool onUnload() override;
void handleData(const QString &event, const QJsonObject &data) override;
......
......@@ -40,16 +40,16 @@ void msgHandler(QtMsgType type, const QMessageLogContext &context, const QString
Q_UNUSED(context);
QJsonObject data;
data["subsystem"] = QStringLiteral("debug");
data[QStringLiteral("subsystem")] = QStringLiteral("debug");
switch(type) {
case QtDebugMsg:
case QtInfoMsg:
data["action"] = "debug";
data[QStringLiteral("action")] = QStringLiteral("debug");
break;
default:
data["action"] = "warning";
data[QStringLiteral("action")] = QStringLiteral("warning");
}
data["payload"] = QJsonObject({{"message", msg}});
data[QStringLiteral("payload")] = QJsonObject({{QStringLiteral("message"), msg}});
Connection::self()->sendData(data);
}
......
......@@ -57,7 +57,7 @@ class MPrisPlugin : public AbstractBrowserPlugin
Q_PROPERTY(QVariantMap Metadata READ metadata NOTIFY metadataChanged)
public:
MPrisPlugin(QObject *parent);
explicit MPrisPlugin(QObject *parent);
bool onUnload() override;
......
......@@ -58,7 +58,7 @@ public:
};
Q_ENUM(Environment)
void handleData(const QString &event, const QJsonObject &data);
void handleData(const QString &event, const QJsonObject &data) override;
Environment environment() const;
QString environmentString() const; // dbus
......
......@@ -33,7 +33,7 @@ class TabsRunnerPlugin : public AbstractBrowserPlugin, protected QDBusContext
Q_OBJECT
public:
TabsRunnerPlugin(QObject *parent);
explicit TabsRunnerPlugin(QObject *parent);
bool onLoad() override;
bool onUnload() override;
void handleData(const QString &event, const QJsonObject &data) override;
......
......@@ -63,15 +63,15 @@ BrowserIntegrationReminder::BrowserIntegrationReminder(QObject *parent, const QL
return;
}
QUrl firefox("https://addons.mozilla.org/en-US/firefox/addon/plasma-integration/");
m_browsers["firefox.desktop"] = firefox;
m_browsers["nightly.desktop"] = firefox;
QUrl firefox(QStringLiteral("https://addons.mozilla.org/en-US/firefox/addon/plasma-integration/"));
m_browsers[QStringLiteral("firefox.desktop")] = firefox;
m_browsers[QStringLiteral("nightly.desktop")] = firefox;
QUrl chrome("https://chrome.google.com/webstore/detail/plasma-integration/cimiefiiaegbelhefglklhhakcgmhkai");
m_browsers["google-chrome.desktop"] = chrome;
m_browsers["google-chrome-beta.desktop"] = chrome;
m_browsers["google-chrome-unstable.desktop"] = chrome;
m_browsers["chromium-browser.desktop"] = chrome;
QUrl chrome(QStringLiteral("https://chrome.google.com/webstore/detail/plasma-integration/cimiefiiaegbelhefglklhhakcgmhkai"));
m_browsers[QStringLiteral("google-chrome.desktop")] = chrome;
m_browsers[QStringLiteral("google-chrome-beta.desktop")] = chrome;
m_browsers[QStringLiteral("google-chrome-unstable.desktop")] = chrome;
m_browsers[QStringLiteral("chromium-browser.desktop")] = chrome;
setModuleName(QStringLiteral("BrowserIntegrationReminder"));
QDBusConnection dbus = QDBusConnection::sessionBus();
......@@ -95,7 +95,7 @@ void BrowserIntegrationReminder::onResourceScoresChanged(const QString &activity
Q_UNUSED(firstUpdate);
Q_UNUSED(client)
if (!resource.startsWith("applications:")) {
if (!resource.startsWith(QStringLiteral("applications:"))) {
return;
}
const QString desktopFile = resource.mid(strlen("applications:"));
......@@ -143,7 +143,7 @@ void BrowserIntegrationReminder::onBrowserStarted(const QString &browser)
config.writeEntry("shownCount", m_shownCount);
m_sni->setTitle(i18n("Get Plasma Browser Integration"));
m_sni->setIconByName("plasma-browser-integration");
m_sni->setIconByName(QStringLiteral("plasma-browser-integration"));
m_sni->setStandardActionsEnabled(false);
m_sni->setStatus(KStatusNotifierItem::Active);
......@@ -156,7 +156,7 @@ void BrowserIntegrationReminder::onBrowserStarted(const QString &browser)
}
KRun::runApplication(*service, QList<QUrl>() << m_browsers[browser], nullptr, KRun::RunFlags(),
QString(), 0);
QString(), nullptr);
KActivities::ResourceInstance::notifyAccessed(QUrl(QStringLiteral("applications:") + browser),
QStringLiteral("org.kde.plasma.browserintegrationreminder"));
......
......@@ -186,7 +186,7 @@ void TabsRunner::match(Plasma::RunnerContext &context)
QIcon icon;
const QString favIconData = tab.value(QStringLiteral("favIconData")).toString();
const int b64start = favIconData.indexOf(',');
const int b64start = favIconData.indexOf(QLatin1Char(','));
if (b64start != -1) {
QByteArray b64 = favIconData.rightRef(favIconData.size() - b64start - 1).toLatin1();
QByteArray data = QByteArray::fromBase64(b64);
......
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