2017-01-03 01:05:30 +03:00
/*
* Copyright 2016 Smith AR < audoban @ openmailbox . org >
* Michail Vourlakos < mvourlakos @ gmail . com >
*
* This file is part of Latte - Dock
*
* Latte - Dock 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 .
*
* Latte - Dock 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 , see < http : //www.gnu.org/licenses/>.
*/
2018-12-02 03:05:52 +03:00
// local
2017-02-16 06:14:37 +03:00
# include "config-latte.h"
2020-04-24 12:31:03 +03:00
# include "apptypes.h"
2018-12-06 15:35:34 +03:00
# include "lattecorona.h"
2019-05-09 17:57:12 +03:00
# include "layouts/importer.h"
2016-12-25 10:25:27 +03:00
2018-12-02 03:05:52 +03:00
// C++
2016-12-25 10:25:27 +03:00
# include <memory>
2017-02-26 20:37:46 +03:00
# include <csignal>
2016-12-25 10:25:27 +03:00
2018-12-02 03:05:52 +03:00
// Qt
2016-12-25 10:25:27 +03:00
# include <QApplication>
2017-01-28 20:45:49 +03:00
# include <QDebug>
2016-12-25 10:25:27 +03:00
# include <QQuickWindow>
2016-12-31 00:25:27 +03:00
# include <QCommandLineParser>
# include <QCommandLineOption>
2017-02-18 15:34:30 +03:00
# include <QDir>
# include <QLockFile>
2017-02-18 10:44:04 +03:00
# include <QSharedMemory>
2016-12-25 10:25:27 +03:00
2018-12-02 03:05:52 +03:00
// KDE
2017-08-03 12:53:16 +03:00
# include <KCrash>
2016-12-25 10:25:27 +03:00
# include <KLocalizedString>
2017-01-29 08:16:28 +03:00
# include <KAboutData>
2017-03-11 11:06:10 +03:00
# include <KDBusService>
2017-05-26 15:36:50 +03:00
# include <KQuickAddons/QtQuickSettings>
2016-12-25 10:25:27 +03:00
//! COLORS
# define CNORMAL "\e[0m"
# define CIGREEN "\e[1;32m"
# define CGREEN "\e[0;32m"
# define CICYAN "\e[1;36m"
# define CCYAN "\e[0;36m"
# define CIRED "\e[1;31m"
# define CRED "\e[0;31m"
2017-01-29 08:16:28 +03:00
inline void configureAboutData ( ) ;
2018-04-02 14:37:19 +03:00
inline void detectPlatform ( int argc , char * * argv ) ;
2020-05-09 11:22:49 +03:00
inline void filterDebugMessageOutput ( QtMsgType type , const QMessageLogContext & context , const QString & msg ) ;
QString filterDebugMessageText ;
2017-01-28 20:45:49 +03:00
2016-12-25 10:25:27 +03:00
int main ( int argc , char * * argv )
2017-03-11 11:06:10 +03:00
{
2018-03-07 19:11:40 +03:00
//Plasma scales itself to font DPI
//on X, where we don't have compositor scaling, this generally works fine.
//also there are bugs on older Qt, especially when it comes to fractional scaling
//there's advantages to disabling, and (other than small context menu icons) few advantages in enabling
//On wayland, it's different. Everything is simpler as all co-ordinates are in the same co-ordinate system
//we don't have fractional scaling on the client so don't hit most the remaining bugs and
//even if we don't use Qt scaling the compositor will try to scale us anyway so we have no choice
if ( ! qEnvironmentVariableIsSet ( " PLASMA_USE_QT_SCALING " ) ) {
qunsetenv ( " QT_DEVICE_PIXEL_RATIO " ) ;
QCoreApplication : : setAttribute ( Qt : : AA_DisableHighDpiScaling ) ;
} else {
QCoreApplication : : setAttribute ( Qt : : AA_UseHighDpiPixmaps ) ;
}
2017-02-17 22:14:31 +03:00
2016-12-25 10:25:27 +03:00
QQuickWindow : : setDefaultAlphaBuffer ( true ) ;
2018-04-02 14:37:19 +03:00
const bool qpaVariable = qEnvironmentVariableIsSet ( " QT_QPA_PLATFORM " ) ;
detectPlatform ( argc , argv ) ;
2016-12-25 10:25:27 +03:00
QApplication app ( argc , argv ) ;
2018-04-02 14:37:19 +03:00
if ( ! qpaVariable ) {
// don't leak the env variable to processes we start
qunsetenv ( " QT_QPA_PLATFORM " ) ;
}
2017-05-26 15:36:50 +03:00
KQuickAddons : : QtQuickSettings : : init ( ) ;
2017-01-22 02:27:51 +03:00
KLocalizedString : : setApplicationDomain ( " latte-dock " ) ;
2017-01-09 01:40:05 +03:00
app . setWindowIcon ( QIcon : : fromTheme ( QStringLiteral ( " latte-dock " ) ) ) ;
2017-05-26 15:07:06 +03:00
//protect from closing app when changing to "alternative session" and back
app . setQuitOnLastWindowClosed ( false ) ;
2017-02-26 20:37:46 +03:00
2017-01-29 08:16:28 +03:00
configureAboutData ( ) ;
2017-02-26 20:37:46 +03:00
QCommandLineParser parser ;
2020-03-08 11:27:16 +03:00
parser . addHelpOption ( ) ;
2020-08-30 21:35:56 +03:00
parser . addVersionOption ( ) ;
2017-02-26 20:37:46 +03:00
parser . addOptions ( {
2020-05-09 11:22:49 +03:00
{ { " r " , " replace " } , i18nc ( " command line " , " Replace the current Latte instance. " ) }
, { { " d " , " debug " } , i18nc ( " command line " , " Show the debugging messages on stdout. " ) }
, { { " cc " , " clear-cache " } , i18nc ( " command line " , " Clear qml cache. It can be useful after system upgrades. " ) }
, { " default-layout " , i18nc ( " command line " , " Import and load default layout on startup. " ) }
, { " available-layouts " , i18nc ( " command line " , " Print available layouts " ) }
, { " layout " , i18nc ( " command line " , " Load specific layout on startup. " ) , i18nc ( " command line: load " , " layout_name " ) }
, { " import-layout " , i18nc ( " command line " , " Import and load a layout. " ) , i18nc ( " command line: import " , " file_name " ) }
, { " import-full " , i18nc ( " command line " , " Import full configuration. " ) , i18nc ( " command line: import " , " file_name " ) }
, { " single " , i18nc ( " command line " , " Single layout memory mode. Only one layout is active at any case. " ) }
, { " multiple " , i18nc ( " command line " , " Multiple layouts memory mode. Multiple layouts can be active at any time based on Activities running. " ) }
} ) ;
2017-02-26 20:37:46 +03:00
2018-01-31 16:05:57 +03:00
//! START: Hidden options for Developer and Debugging usage
QCommandLineOption graphicsOption ( QStringList ( ) < < QStringLiteral ( " graphics " ) ) ;
graphicsOption . setDescription ( QStringLiteral ( " Draw boxes around of the applets. " ) ) ;
2019-08-18 14:02:25 +03:00
graphicsOption . setFlags ( QCommandLineOption : : HiddenFromHelp ) ;
2018-01-31 16:05:57 +03:00
parser . addOption ( graphicsOption ) ;
QCommandLineOption withWindowOption ( QStringList ( ) < < QStringLiteral ( " with-window " ) ) ;
withWindowOption . setDescription ( QStringLiteral ( " Open a window with much debug information " ) ) ;
2019-08-18 14:02:25 +03:00
withWindowOption . setFlags ( QCommandLineOption : : HiddenFromHelp ) ;
2018-01-31 16:05:57 +03:00
parser . addOption ( withWindowOption ) ;
QCommandLineOption maskOption ( QStringList ( ) < < QStringLiteral ( " mask " ) ) ;
maskOption . setDescription ( QStringLiteral ( " Show messages of debugging for the mask (Only useful to devs). " ) ) ;
2019-08-18 14:02:25 +03:00
maskOption . setFlags ( QCommandLineOption : : HiddenFromHelp ) ;
2018-01-31 16:05:57 +03:00
parser . addOption ( maskOption ) ;
QCommandLineOption timersOption ( QStringList ( ) < < QStringLiteral ( " timers " ) ) ;
timersOption . setDescription ( QStringLiteral ( " Show messages for debugging the timers (Only useful to devs). " ) ) ;
2019-08-18 14:02:25 +03:00
timersOption . setFlags ( QCommandLineOption : : HiddenFromHelp ) ;
2018-01-31 16:05:57 +03:00
parser . addOption ( timersOption ) ;
QCommandLineOption spacersOption ( QStringList ( ) < < QStringLiteral ( " spacers " ) ) ;
spacersOption . setDescription ( QStringLiteral ( " Show visual indicators for debugging spacers (Only useful to devs). " ) ) ;
2019-08-18 14:02:25 +03:00
spacersOption . setFlags ( QCommandLineOption : : HiddenFromHelp ) ;
2018-01-31 16:05:57 +03:00
parser . addOption ( spacersOption ) ;
2018-07-08 20:51:30 +03:00
QCommandLineOption overloadedIconsOption ( QStringList ( ) < < QStringLiteral ( " overloaded-icons " ) ) ;
overloadedIconsOption . setDescription ( QStringLiteral ( " Show visual indicators for debugging overloaded applets icons (Only useful to devs). " ) ) ;
2019-08-18 14:02:25 +03:00
overloadedIconsOption . setFlags ( QCommandLineOption : : HiddenFromHelp ) ;
2018-07-08 20:51:30 +03:00
parser . addOption ( overloadedIconsOption ) ;
2020-01-01 20:40:54 +03:00
QCommandLineOption edgesOption ( QStringList ( ) < < QStringLiteral ( " kwinedges " ) ) ;
2020-03-08 11:27:16 +03:00
edgesOption . setDescription ( QStringLiteral ( " Show visual window indicators for hidden screen edge windows. " ) ) ;
edgesOption . setFlags ( QCommandLineOption : : HiddenFromHelp ) ;
2020-01-01 20:40:54 +03:00
parser . addOption ( edgesOption ) ;
2020-03-08 11:27:16 +03:00
QCommandLineOption localGeometryOption ( QStringList ( ) < < QStringLiteral ( " localgeometry " ) ) ;
localGeometryOption . setDescription ( QStringLiteral ( " Show visual window indicators for calculated local geometry. " ) ) ;
localGeometryOption . setFlags ( QCommandLineOption : : HiddenFromHelp ) ;
parser . addOption ( localGeometryOption ) ;
2020-05-09 11:22:49 +03:00
2020-05-12 17:08:09 +03:00
QCommandLineOption layouterOption ( QStringList ( ) < < QStringLiteral ( " layouter " ) ) ;
layouterOption . setDescription ( QStringLiteral ( " Show visual debug tags for items sizes. " ) ) ;
layouterOption . setFlags ( QCommandLineOption : : HiddenFromHelp ) ;
parser . addOption ( layouterOption ) ;
2020-05-09 11:22:49 +03:00
QCommandLineOption filterDebugTextOption ( QStringList ( ) < < QStringLiteral ( " debug-text " ) ) ;
filterDebugTextOption . setDescription ( QStringLiteral ( " Show only debug messages that contain specific text. " ) ) ;
filterDebugTextOption . setFlags ( QCommandLineOption : : HiddenFromHelp ) ;
filterDebugTextOption . setValueName ( i18nc ( " command line: debug-text " , " filter_debug_text " ) ) ;
parser . addOption ( filterDebugTextOption ) ;
2020-07-19 15:04:46 +03:00
QCommandLineOption filterDebugInputMask ( QStringList ( ) < < QStringLiteral ( " input " ) ) ;
filterDebugInputMask . setDescription ( QStringLiteral ( " Show visual window indicators for calculated input mask. " ) ) ;
filterDebugInputMask . setFlags ( QCommandLineOption : : HiddenFromHelp ) ;
parser . addOption ( filterDebugInputMask ) ;
2020-12-29 22:18:21 +03:00
QCommandLineOption filterDebugEventSinkMask ( QStringList ( ) < < QStringLiteral ( " events-sink " ) ) ;
filterDebugEventSinkMask . setDescription ( QStringLiteral ( " Show visual indicators for areas of EventsSink. " ) ) ;
filterDebugEventSinkMask . setFlags ( QCommandLineOption : : HiddenFromHelp ) ;
parser . addOption ( filterDebugEventSinkMask ) ;
2018-01-31 16:05:57 +03:00
//! END: Hidden options
2017-02-26 20:37:46 +03:00
parser . process ( app ) ;
2019-03-11 11:08:03 +03:00
//! print available-layouts
2017-12-17 19:34:50 +03:00
if ( parser . isSet ( QStringLiteral ( " available-layouts " ) ) ) {
2019-05-09 17:57:12 +03:00
QStringList layouts = Latte : : Layouts : : Importer : : availableLayouts ( ) ;
2017-12-17 19:13:26 +03:00
if ( layouts . count ( ) > 0 ) {
qInfo ( ) < < i18n ( " Available layouts that can be used to start Latte: " ) ;
2019-04-04 23:55:44 +03:00
for ( const auto & layout : layouts ) {
2017-12-17 19:13:26 +03:00
qInfo ( ) < < " " < < layout ;
}
} else {
qInfo ( ) < < i18n ( " There are no available layouts, during startup Default will be used. " ) ;
}
qGuiApp - > exit ( ) ;
return 0 ;
}
2017-12-17 19:34:50 +03:00
bool defaultLayoutOnStartup = false ;
2018-01-31 16:27:58 +03:00
int memoryUsage = - 1 ;
2017-12-17 19:34:50 +03:00
QString layoutNameOnStartup = " " ;
2019-03-11 11:08:03 +03:00
//! --default-layout option
2017-12-17 19:34:50 +03:00
if ( parser . isSet ( QStringLiteral ( " default-layout " ) ) ) {
defaultLayoutOnStartup = true ;
} else if ( parser . isSet ( QStringLiteral ( " layout " ) ) ) {
layoutNameOnStartup = parser . value ( QStringLiteral ( " layout " ) ) ;
2019-05-09 17:57:12 +03:00
if ( ! Latte : : Layouts : : Importer : : layoutExists ( layoutNameOnStartup ) ) {
2018-08-02 18:39:32 +03:00
qInfo ( ) < < i18nc ( " layout missing " , " This layout doesn't exist in the system. " ) ;
2017-12-17 19:34:50 +03:00
qGuiApp - > exit ( ) ;
return 0 ;
}
}
2019-03-11 11:08:03 +03:00
//! --replace option
2017-12-25 22:07:07 +03:00
QString username = qgetenv ( " USER " ) ;
if ( username . isEmpty ( ) )
username = qgetenv ( " USERNAME " ) ;
QLockFile lockFile { QDir : : tempPath ( ) + " /latte-dock. " + username + " .lock " } ;
2017-02-26 20:37:46 +03:00
int timeout { 100 } ;
2017-05-26 15:07:06 +03:00
2017-12-17 20:08:35 +03:00
if ( parser . isSet ( QStringLiteral ( " replace " ) ) | | parser . isSet ( QStringLiteral ( " import-full " ) ) ) {
2017-05-26 15:07:06 +03:00
qint64 pid { - 1 } ;
2017-02-26 20:37:46 +03:00
if ( lockFile . getLockInfo ( & pid , nullptr , nullptr ) ) {
2017-03-20 20:20:37 +03:00
kill ( static_cast < pid_t > ( pid ) , SIGINT ) ;
2019-01-15 22:16:05 +03:00
timeout = - 1 ;
2017-02-26 20:37:46 +03:00
}
}
if ( ! lockFile . tryLock ( timeout ) ) {
qInfo ( ) < < i18n ( " An instance is already running!, use --replace to restart Latte " ) ;
qGuiApp - > exit ( ) ;
2017-12-17 19:15:04 +03:00
return 0 ;
2017-02-26 20:37:46 +03:00
}
2019-03-11 11:08:03 +03:00
//! clear-cache option
if ( parser . isSet ( QStringLiteral ( " clear-cache " ) ) ) {
QDir cacheDir ( QDir : : homePath ( ) + " /.cache/lattedock/qmlcache " ) ;
if ( cacheDir . exists ( ) ) {
cacheDir . removeRecursively ( ) ;
qDebug ( ) < < " Cache directory found and cleared... " ;
}
}
//! import-full option
2017-12-17 20:08:35 +03:00
if ( parser . isSet ( QStringLiteral ( " import-full " ) ) ) {
2019-05-09 17:57:12 +03:00
bool imported = Latte : : Layouts : : Importer : : importHelper ( parser . value ( QStringLiteral ( " import-full " ) ) ) ;
2017-03-20 20:20:37 +03:00
if ( ! imported ) {
qInfo ( ) < < i18n ( " The configuration cannot be imported " ) ;
2017-12-17 19:15:04 +03:00
qGuiApp - > exit ( ) ;
return 0 ;
2017-03-20 20:20:37 +03:00
}
}
2019-03-11 11:08:03 +03:00
//! import-layout option
2017-12-17 20:08:35 +03:00
if ( parser . isSet ( QStringLiteral ( " import-layout " ) ) ) {
2019-05-09 17:57:12 +03:00
QString importedLayout = Latte : : Layouts : : Importer : : importLayoutHelper ( parser . value ( QStringLiteral ( " import-layout " ) ) ) ;
2017-12-17 20:08:35 +03:00
if ( importedLayout . isEmpty ( ) ) {
qInfo ( ) < < i18n ( " The layout cannot be imported " ) ;
qGuiApp - > exit ( ) ;
return 0 ;
} else {
layoutNameOnStartup = importedLayout ;
}
}
2019-03-11 11:08:03 +03:00
//! memory usage option
2018-01-31 16:27:58 +03:00
if ( parser . isSet ( QStringLiteral ( " multiple " ) ) ) {
2020-04-24 12:31:03 +03:00
memoryUsage = ( int ) ( Latte : : MemoryUsage : : MultipleLayouts ) ;
2018-01-31 16:27:58 +03:00
} else if ( parser . isSet ( QStringLiteral ( " single " ) ) ) {
2020-04-24 12:31:03 +03:00
memoryUsage = ( int ) ( Latte : : MemoryUsage : : SingleLayout ) ;
2018-01-31 16:27:58 +03:00
}
2020-05-09 11:22:49 +03:00
//! text filter for debug messages
if ( parser . isSet ( QStringLiteral ( " debug-text " ) ) ) {
filterDebugMessageText = parser . value ( QStringLiteral ( " debug-text " ) ) ;
}
2019-03-11 11:08:03 +03:00
//! debug/mask options
2020-05-09 11:22:49 +03:00
if ( parser . isSet ( QStringLiteral ( " debug " ) ) | | parser . isSet ( QStringLiteral ( " mask " ) ) | | parser . isSet ( QStringLiteral ( " debug-text " ) ) ) {
qInstallMessageHandler ( filterDebugMessageOutput ) ;
2017-02-01 22:19:50 +03:00
} else {
2017-03-11 11:06:10 +03:00
const auto noMessageOutput = [ ] ( QtMsgType , const QMessageLogContext & , const QString & ) { } ;
2017-02-26 20:37:46 +03:00
qInstallMessageHandler ( noMessageOutput ) ;
}
2017-02-01 22:19:50 +03:00
2017-02-26 20:37:46 +03:00
auto signal_handler = [ ] ( int ) {
qGuiApp - > exit ( ) ;
} ;
std : : signal ( SIGKILL , signal_handler ) ;
std : : signal ( SIGINT , signal_handler ) ;
2017-01-29 08:16:28 +03:00
2017-08-03 12:53:16 +03:00
KCrash : : setDrKonqiEnabled ( true ) ;
2018-01-15 16:02:58 +03:00
KCrash : : setFlags ( KCrash : : AutoRestart | KCrash : : AlwaysDirectly ) ;
2017-08-03 12:53:16 +03:00
2018-12-06 15:35:34 +03:00
Latte : : Corona corona ( defaultLayoutOnStartup , layoutNameOnStartup , memoryUsage ) ;
2017-03-11 11:06:10 +03:00
KDBusService service ( KDBusService : : Unique ) ;
2016-12-25 10:25:27 +03:00
return app . exec ( ) ;
}
2017-01-29 08:16:28 +03:00
2020-05-09 11:22:49 +03:00
inline void filterDebugMessageOutput ( QtMsgType type , const QMessageLogContext & context , const QString & msg )
{
2020-06-12 21:01:03 +03:00
if ( msg . endsWith ( " QML Binding: Not restoring previous value because restoreMode has not been set.This behavior is deprecated.In Qt < 6.0 the default is Binding.RestoreBinding.In Qt >= 6.0 the default is Binding.RestoreBindingOrValue. " )
| | msg . endsWith ( " QML Binding: Not restoring previous value because restoreMode has not been set. \n This behavior is deprecated. \n You have to import QtQml 2.15 after any QtQuick imports and set \n the restoreMode of the binding to fix this warning. \n In Qt < 6.0 the default is Binding.RestoreBinding. \n In Qt >= 6.0 the default is Binding.RestoreBindingOrValue. \n " )
| | msg . endsWith ( " QML Binding: Not restoring previous value because restoreMode has not been set. \n This behavior is deprecated. \n You have to import QtQml 2.15 after any QtQuick imports and set \n the restoreMode of the binding to fix this warning. \n In Qt < 6.0 the default is Binding.RestoreBinding. \n In Qt >= 6.0 the default is Binding.RestoreBindingOrValue. " )
| | msg . endsWith ( " QML Connections: Implicitly defined onFoo properties in Connections are deprecated. Use this syntax instead: function onFoo(<arguments>) { ... } " ) ) {
//! block warnings because they will be needed only after qt6.0 support. Currently Binding.restoreMode can not be supported because
2020-05-09 11:22:49 +03:00
//! qt5.9 is the minimum supported version.
return ;
}
if ( ! filterDebugMessageText . isEmpty ( ) & & ! msg . contains ( filterDebugMessageText ) ) {
return ;
}
const char * function = context . function ? context . function : " " ;
QString typeStr ;
switch ( type ) {
case QtDebugMsg :
typeStr = " Debug " ;
break ;
case QtInfoMsg :
typeStr = " Info " ;
break ;
case QtWarningMsg :
typeStr = " Warning " ;
break ;
case QtCriticalMsg :
typeStr = " Critical " ;
break ;
case QtFatalMsg :
typeStr = " Fatal " ;
break ;
} ;
const char * TypeColor ;
if ( type = = QtInfoMsg | | type = = QtWarningMsg ) {
2020-05-09 11:36:48 +03:00
TypeColor = CGREEN ;
2020-05-09 11:22:49 +03:00
} else if ( type = = QtCriticalMsg | | type = = QtFatalMsg ) {
TypeColor = CRED ;
} else {
TypeColor = CIGREEN ;
}
qDebug ( ) . nospace ( ) < < TypeColor < < " [ " < < typeStr . toStdString ( ) . c_str ( ) < < " : " < < CGREEN < < QTime : : currentTime ( ) . toString ( " h:mm:ss.zz " ) . toStdString ( ) . c_str ( ) < < TypeColor < < " ] " < < CNORMAL
# ifndef QT_NO_DEBUG
< < CIRED < < " [ " < < CCYAN < < function < < CIRED < < " : " < < CCYAN < < context . line < < CIRED < < " ] "
# endif
< < CICYAN < < " - " < < CNORMAL < < msg ;
}
2017-01-29 08:16:28 +03:00
inline void configureAboutData ( )
{
KAboutData about ( QStringLiteral ( " lattedock " )
, QStringLiteral ( " Latte Dock " )
2017-02-16 06:14:37 +03:00
, QStringLiteral ( VERSION )
2017-01-30 01:17:28 +03:00
, i18n ( " Latte is a dock based on plasma frameworks that provides an elegant and "
" intuitive experience for your tasks and plasmoids. It animates its contents "
2017-09-08 21:29:33 +03:00
" by using parabolic zoom effect and tries to be there only when it is needed. "
2017-01-30 01:17:28 +03:00
" \n \n \" Art in Coffee \" " )
2017-01-29 08:16:28 +03:00
, KAboutLicense : : GPL_V2
, QStringLiteral ( " \251 2016-2017 Michail Vourlakos, Smith AR " ) ) ;
2017-02-03 08:21:51 +03:00
about . setHomepage ( WEBSITE ) ;
2017-01-29 08:16:28 +03:00
about . setProgramLogo ( QIcon : : fromTheme ( QStringLiteral ( " latte-dock " ) ) ) ;
about . setDesktopFileName ( QStringLiteral ( " latte-dock " ) ) ;
// Authors
about . addAuthor ( QStringLiteral ( " Michail Vourlakos " ) , QString ( ) , QStringLiteral ( " mvourlakos@gmail.com " ) ) ;
about . addAuthor ( QStringLiteral ( " Smith AR " ) , QString ( ) , QStringLiteral ( " audoban@openmailbox.org " ) ) ;
KAboutData : : setApplicationData ( about ) ;
}
2018-04-02 14:37:19 +03:00
//! used the version provided by PW:KWorkspace
inline void detectPlatform ( int argc , char * * argv )
{
if ( qEnvironmentVariableIsSet ( " QT_QPA_PLATFORM " ) ) {
return ;
}
for ( int i = 0 ; i < argc ; i + + ) {
if ( qstrcmp ( argv [ i ] , " -platform " ) = = 0 | |
2020-05-09 11:22:49 +03:00
qstrcmp ( argv [ i ] , " --platform " ) = = 0 | |
QByteArray ( argv [ i ] ) . startsWith ( " -platform= " ) | |
QByteArray ( argv [ i ] ) . startsWith ( " --platform= " ) ) {
2018-04-02 14:37:19 +03:00
return ;
}
}
const QByteArray sessionType = qgetenv ( " XDG_SESSION_TYPE " ) ;
if ( sessionType . isEmpty ( ) ) {
return ;
}
if ( qstrcmp ( sessionType , " wayland " ) = = 0 ) {
qputenv ( " QT_QPA_PLATFORM " , " wayland " ) ;
} else if ( qstrcmp ( sessionType , " x11 " ) = = 0 ) {
qputenv ( " QT_QPA_PLATFORM " , " xcb " ) ;
}
}