kde-workspace/kmediaplayer/main.cpp
Ivailo Monev c6b591023e generic: enable session management for all GUI applications
to what degree session management is supported is different story, e.g. if
there is no kRestoreMainWindows<T>() call (or other method that actually
restores state) then the application is simply started again on login and
placed where it was in the window state it was by the window manager

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
2024-05-09 09:03:17 +03:00

61 lines
2 KiB
C++

/* This file is part of the KDE libraries
Copyright (C) 2016 Ivailo Monev <xakepa10@gmail.com>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License version 2, as published by the Free Software Foundation.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include <KAboutData>
#include <KCmdLineArgs>
#include <KApplication>
#include <KPluginLoader>
#include <KPluginFactory>
#include <KParts/Part>
#include <KLocale>
#include <KMessageBox>
#include <KDebug>
#include "kmediawindow.h"
int main(int argc, char **argv) {
KAboutData aboutData(
"kmediaplayer", 0, ki18n("KMediaPlayer"),
"1.1.0", ki18n("Simple media player for KDE."),
KAboutData::License_GPL_V2,
ki18n("(c) 2016 Ivailo Monev")
);
aboutData.addAuthor(ki18n("Ivailo Monev"), ki18n("Maintainer"), "xakepa10@gmail.com");
aboutData.setProgramIconName(QLatin1String("applications-multimedia"));
KCmdLineArgs::init(argc, argv, &aboutData);
KCmdLineOptions option;
option.add("+[url]", ki18n("URL to be opened"));
KCmdLineArgs::addCmdLineOptions(option);
KApplication app;
app.enableSessionManagement();
if (app.isSessionRestored()) {
kRestoreMainWindows<KMediaWindow>();
} else {
KMediaWindow *window = new KMediaWindow();
window->show();
KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
for (int pos = 0; pos < args->count(); ++pos) {
window->slotOpenURL(args->url(pos));
}
}
return app.exec();
}