qsrun/main.cpp

80 lines
2.1 KiB
C++
Raw Normal View History

2018-01-05 15:52:11 +01:00
/*
* Copyright (c) 2018 Albert S. <mail at quitesimple dot org>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
2018-01-03 09:52:05 +01:00
#include <QApplication>
#include <QFuture>
#include <QFutureWatcher>
#include <QtConcurrent/QtConcurrentRun>
#include <QSettings>
#include "window.h"
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QString configDirectoryPath;
if(argc >= 2)
{
configDirectoryPath = QCoreApplication::arguments().at(1);
}
else
{
configDirectoryPath = QDir::homePath() + "/.config/qsRun/";
}
qRegisterMetaType<QVector<QString> >("QVector<QString>");
2019-05-30 10:57:33 +02:00
QDir dir;
2018-01-03 09:52:05 +01:00
if(!dir.exists(configDirectoryPath))
{
QMessageBox::warning(nullptr, "Directory not found", configDirectoryPath + " was not found!");
return 1;
}
QSettings settings(configDirectoryPath + "qsrun.config", QSettings::NativeFormat);
QVector<EntryConfig> configs;
try
{
2019-05-30 10:57:33 +02:00
ConfigReader reader({configDirectoryPath});
2018-01-03 09:52:05 +01:00
configs = reader.readConfig();
}
catch(std::exception &e)
{
std::cerr << e.what() << std::endl;
}
Window w(configs);
2018-01-03 09:52:05 +01:00
try
{
2019-05-30 10:57:33 +02:00
QStringList systemApplicationsPaths = settings.value("sysAppsPaths", "/usr/share/applications/").toStringList();
ConfigReader systemConfigReader(systemApplicationsPaths);
2018-01-03 09:52:05 +01:00
QVector<EntryConfig> systemconfigs = systemConfigReader.readConfig();
if(systemconfigs.count() > 0)
{
w.setSystemConfig(systemconfigs);
}
}
catch(std::exception &e)
{
std::cerr << e.what() << std::endl;
}
w.showMaximized();
return app.exec();
}