Commit 444696fe authored by David Edmundson's avatar David Edmundson
Browse files

Show SNI when software renderer is in use

Summary: This then invokes the relevant KCM when clicked

Test Plan:
Forced software rendering, saw SNI
restarted, saw SNI
set "never show again". It hid itself
Restarted. It remained hidden

Reviewers: #plasma, broulik

Reviewed By: #plasma, broulik

Subscribers: alexeymin, broulik, plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D12679
parent 743e2bc9
......@@ -41,6 +41,7 @@ set (plasma_shell_SRCS
coronatesthelper.cpp
debug.cpp
screenpool.cpp
softwarerendernotifier.cpp
${scripting_SRC}
)
......@@ -74,6 +75,7 @@ target_link_libraries(plasmashell
KF5::Package
KF5::WaylandClient
KF5::WindowSystem
KF5::Notifications
PW::KWorkspace
)
target_include_directories(plasmashell PRIVATE "${CMAKE_BINARY_DIR}")
......
......@@ -40,6 +40,7 @@
#include "standaloneappcorona.h"
#include "shellmanager.h"
#include "coronatesthelper.h"
#include "softwarerendernotifier.h"
#include <QDir>
......@@ -183,7 +184,6 @@ int main(int argc, char *argv[])
KDBusService service(KDBusService::Unique);
QObject::connect(ShellManager::instance(), &ShellManager::glInitialisationFailed, &app, [&app]() {
//scene graphs errors come from a thread
//even though we process them in the main thread, app.exit could still process these events
......@@ -206,6 +206,7 @@ int main(int argc, char *argv[])
}
app.exit(-1);
});
SoftwareRendererNotifier::notifyIfRelevant();
QObject::connect(QCoreApplication::instance(), &QCoreApplication::aboutToQuit, ShellManager::instance(), &QObject::deleteLater);
return app.exec();
......
#include "softwarerendernotifier.h"
#include <QMenu>
#include <QIcon>
#include <QProcess>
#include <QGuiApplication>
#include <KLocalizedString>
#include <KSharedConfig>
#include <KConfigGroup>
#include <QQuickWindow>
void SoftwareRendererNotifier::notifyIfRelevant()
{
if (QQuickWindow::sceneGraphBackend() == QLatin1String("software")) {
auto group = KSharedConfig::openConfig()->group(QStringLiteral("softwarerenderer"));
bool neverShow = group.readEntry("neverShow", false);
if (neverShow) {
return;
}
new SoftwareRendererNotifier(qApp);
}
}
SoftwareRendererNotifier::SoftwareRendererNotifier(QObject *parent)
: KStatusNotifierItem(parent)
{
setTitle(i18n("Software Renderer In Use"));
setToolTipTitle(i18nc("Tooltip telling user their GL drivers are broken", "Software Renderer In Use"));
setToolTipSubTitle(i18nc("Tooltip telling user their GL drivers are broken", "Rendering may be degraded"));
setIconByName(QStringLiteral("video-card-inactive"));
setStatus(KStatusNotifierItem::Active);
setStandardActionsEnabled(false);
connect(this, &KStatusNotifierItem::activateRequested, this, []() {
QProcess::startDetached("kcmshell5 qtquicksettings");
});
auto menu = new QMenu; //ownership is transferred in setContextMenu
auto action = new QAction(i18n("Never show again"));
connect(action, &QAction::triggered, this, [this]() {
auto group = KSharedConfig::openConfig()->group(QStringLiteral("softwarerenderer"));
group.writeEntry("neverShow", true);
deleteLater();
});
menu->addAction(action);
setContextMenu(menu);
}
SoftwareRendererNotifier::~SoftwareRendererNotifier() = default;
/*
* Copyright 2018 David Edmundson <davidedmundson@kde.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, 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 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.
*/
#include <KStatusNotifierItem>
/**
* Responsible for showing an SNI if the software renderer is used
* to allow the a user to open the KCM
*/
class SoftwareRendererNotifier: public KStatusNotifierItem
{
Q_OBJECT
public:
//only exposed as void static constructor as internally it is self memory managing
static void notifyIfRelevant();
private:
SoftwareRendererNotifier(QObject *parent=nullptr);
~SoftwareRendererNotifier();
};
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