Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Show a message bar warning on startup if a wayland session is detected
Even on the latest Qt 6 versions, wayland support is limited. Eg. basic
things like re-docking floating docks, moving toolbars, switching
between menus is broken.

Let's show a warning on startup to advise users to switch to an X11
session for the best user experience, so at least they don't place
the blame on QGIS and rather know where to target their bug reports
correctly!
  • Loading branch information
nyalldawson committed May 3, 2023
1 parent 74636ce commit cca67a8
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions src/app/qgisapp.cpp
Expand Up @@ -1974,6 +1974,43 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, bool skipBadLayers
QgsApplication::fontManager()->enableFontDownloadsForSession();

mDevToolsWidget->setActiveTab( lastDevToolsTab );

if ( QGuiApplication::platformName() == QLatin1String( "wayland" ) )
{
const bool displayWaylandWarning = settings.value( QStringLiteral( "/UI/displayWaylandWarning" ), true ).toBool();
if ( displayWaylandWarning )
{
const QString shortMessage = tr( "Wayland session detected: User experience will be degraded" );
QgsMessageBarItem *messageWidget = QgsMessageBar::createMessage( QString(), shortMessage );

QPushButton *detailsButton = new QPushButton( tr( "More Info" ) );
connect( detailsButton, &QPushButton::clicked, this, [detailsButton]
{
QgsMessageViewer *dialog = new QgsMessageViewer( detailsButton );
dialog->setTitle( tr( "Wayland Session Detected" ) );
// NOTE: black coloring MUST be specified here or the message shows white-on-white on wayland sessions 🙃
const QString warning = QStringLiteral( "<p style=\"color: black\">%1</p><p style=\"color: black\"><b>%2</b></p>" ).arg(
tr( "Running QGIS in a Wayland session will result "
"in a degraded experience due to limitations in the "
"underlying Qt library and current versions of the Wayland protocol." ),
tr( "It is highly recommended that you switch to a traditional X11 session "
"for an optimal user experience." ) );
dialog->setMessageAsHtml( warning );
dialog->showMessage();
} );
messageWidget->layout()->addWidget( detailsButton );

QPushButton *ignoreButton = new QPushButton( tr( "Ignore" ) );
connect( ignoreButton, &QPushButton::clicked, this, [this, messageWidget]
{
QgsSettings().setValue( QStringLiteral( "/UI/displayWaylandWarning" ), false );
messageBar()->popWidget( messageWidget );
} );
messageWidget->layout()->addWidget( ignoreButton );

messageBar()->pushWidget( messageWidget, Qgis::MessageLevel::Critical, 0 );
}
}
}

QgisApp::QgisApp()
Expand Down

0 comments on commit cca67a8

Please sign in to comment.