2016-02-17 17:24:00 +11:00
|
|
|
#include "mainwindow.h"
|
2016-03-17 19:46:40 +11:00
|
|
|
#include "background.h"
|
2016-03-29 17:42:24 +11:00
|
|
|
#include "loginsplash.h"
|
2016-02-17 17:24:00 +11:00
|
|
|
#include <QApplication>
|
2016-03-17 19:46:40 +11:00
|
|
|
#include <QDesktopWidget>
|
|
|
|
#include <QProcess>
|
|
|
|
#include <QThread>
|
|
|
|
#include <QAbstractNativeEventFilter>
|
2016-03-29 17:42:24 +11:00
|
|
|
#include <QUrl>
|
|
|
|
#include <QMediaPlayer>
|
|
|
|
#include <QDebug>
|
|
|
|
#include <QSettings>
|
2016-04-01 21:05:25 +11:00
|
|
|
#include <QInputDialog>
|
2016-02-17 17:24:00 +11:00
|
|
|
|
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
|
|
|
QApplication a(argc, argv);
|
2016-03-17 19:46:40 +11:00
|
|
|
|
2016-03-29 17:42:24 +11:00
|
|
|
bool showSplash = true;
|
|
|
|
|
|
|
|
QStringList args = a.arguments();
|
|
|
|
args.removeFirst();
|
|
|
|
for (QString arg : a.arguments()) {
|
|
|
|
if (arg == "--help" || arg == "-h") {
|
|
|
|
qDebug() << "theShell";
|
|
|
|
qDebug() << "Usage: theshell [OPTIONS]";
|
|
|
|
qDebug() << " -s, --no-splash-screen Don't show the splash screen";
|
|
|
|
qDebug() << " -h, --help Show this help output";
|
|
|
|
return 0;
|
|
|
|
} else if (arg == "-s" || arg == "--no-splash-screen") {
|
|
|
|
showSplash = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
a.setOrganizationName("theSuite");
|
|
|
|
a.setOrganizationDomain("");
|
|
|
|
a.setApplicationName("theShell");
|
|
|
|
|
2016-04-01 21:05:25 +11:00
|
|
|
QFile lockfile(QDir::home().absolutePath() + "/.theshell.lck");
|
|
|
|
if (lockfile.exists()) {
|
|
|
|
if (QMessageBox::warning(0, "theShell already running", "theShell seems to already be running. "
|
|
|
|
"Do you wish to start theShell anyway?",
|
|
|
|
QMessageBox::Yes | QMessageBox::No) == QMessageBox::No) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
lockfile.open(QFile::WriteOnly);
|
|
|
|
lockfile.write(QByteArray());
|
|
|
|
lockfile.close();
|
|
|
|
|
2016-03-29 17:42:24 +11:00
|
|
|
QSettings settings;
|
|
|
|
|
|
|
|
QString windowManager = settings.value("startup/WindowManagerCommand", "").toString();
|
|
|
|
if (windowManager == "") {
|
|
|
|
windowManager = "kwin_x11";
|
|
|
|
settings.setValue("startup/WindowManagerCommand", windowManager);
|
|
|
|
}
|
|
|
|
|
2016-04-01 21:05:25 +11:00
|
|
|
while (!QProcess::startDetached(windowManager)) {
|
|
|
|
windowManager = QInputDialog::getText(0, "Window Manager couldn't start",
|
|
|
|
"The window manager \"" + windowManager + "\" could not start. \n\n"
|
|
|
|
"Enter the name or path of a window manager to attempt to start a different window"
|
|
|
|
"manager, or hit 'Cancel' to start theShell without a window manager.");
|
|
|
|
if (windowManager == "") {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-03-29 17:42:24 +11:00
|
|
|
|
|
|
|
if (showSplash) {
|
|
|
|
LoginSplash* splash = new LoginSplash();
|
|
|
|
splash->setWindowFlags(Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint);
|
|
|
|
splash->showFullScreen();
|
|
|
|
}
|
|
|
|
|
|
|
|
QProcess* ksuperkey = new QProcess();
|
|
|
|
ksuperkey->start("ksuperkey -d -e \"Super_L=Alt_L|F5;Alt_R|F5\"");
|
2016-03-17 19:46:40 +11:00
|
|
|
|
|
|
|
Background b;
|
|
|
|
b.setWindowFlags(Qt::FramelessWindowHint | Qt::WindowStaysOnBottomHint);
|
2016-03-29 17:42:24 +11:00
|
|
|
b.showFullScreen();
|
2016-03-17 19:46:40 +11:00
|
|
|
|
2016-02-17 17:24:00 +11:00
|
|
|
MainWindow w;
|
2016-03-17 19:46:40 +11:00
|
|
|
w.setWindowFlags(Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint);
|
|
|
|
QRect screenGeometry = QApplication::desktop()->screenGeometry();
|
|
|
|
w.setGeometry(screenGeometry.x() - 1, screenGeometry.y(), screenGeometry.width() + 1, w.height());
|
2016-02-17 17:24:00 +11:00
|
|
|
w.show();
|
|
|
|
|
2016-03-17 19:46:40 +11:00
|
|
|
QThread::sleep(1);
|
|
|
|
|
2016-02-17 17:24:00 +11:00
|
|
|
return a.exec();
|
|
|
|
}
|
2016-03-29 17:42:24 +11:00
|
|
|
|
|
|
|
void playSound(QUrl location, bool uncompressed = false) {
|
|
|
|
if (uncompressed) {
|
|
|
|
QSoundEffect* sound = new QSoundEffect();
|
|
|
|
sound->setSource(location);
|
|
|
|
sound->play();
|
|
|
|
} else {
|
|
|
|
QMediaPlayer* sound = new QMediaPlayer();
|
|
|
|
sound->setMedia(location);
|
|
|
|
sound->play();
|
|
|
|
}
|
|
|
|
}
|