Console command
Add command for console !
This commit is contained in:
@@ -9,6 +9,8 @@
|
||||
#include <string_view>
|
||||
#include <QtCore/QSettings>
|
||||
#include <QtCore/QDir>
|
||||
#include <qcommandlineparser.h>
|
||||
#include <qcommandlineoption.h>
|
||||
#include <QtWidgets/QApplication>
|
||||
#include <QtWidgets/QFileDialog>
|
||||
#include <QtWidgets/QMessageBox>
|
||||
@@ -17,6 +19,20 @@
|
||||
#include <codecvt>
|
||||
#include <string>
|
||||
|
||||
QCommandLineParser* ProcessCommandLine()
|
||||
{
|
||||
QCommandLineParser* parser = new QCommandLineParser();
|
||||
parser->setApplicationDescription("Help");
|
||||
parser->addHelpOption();
|
||||
parser->addVersionOption();
|
||||
parser->addOptions({
|
||||
{"disable-update", QApplication::translate("main", "Disable the check for update.")},
|
||||
{"force-changelog", QApplication::translate("main", "Force displaying the changelog popup.")}
|
||||
});
|
||||
|
||||
return parser;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
Noggit::RegisterErrorHandlers();
|
||||
@@ -28,8 +44,15 @@ int main(int argc, char *argv[])
|
||||
q_application.setApplicationName ("Noggit");
|
||||
q_application.setOrganizationName ("Noggit");
|
||||
|
||||
auto parser = ProcessCommandLine();
|
||||
parser->process(q_application);
|
||||
|
||||
std::vector<bool> Command;
|
||||
Command.push_back(parser->isSet("disable-update"));
|
||||
Command.push_back(parser->isSet("force-changelog"));
|
||||
|
||||
auto noggit = Noggit::Application::NoggitApplication::instance();
|
||||
noggit->initalize(argc, argv);
|
||||
noggit->initalize(argc, argv, Command);
|
||||
|
||||
auto project_selection = new Noggit::Ui::Windows::NoggitProjectSelectionWindow(noggit);
|
||||
project_selection->show();
|
||||
|
||||
@@ -3,9 +3,10 @@
|
||||
|
||||
namespace Noggit::Application
|
||||
{
|
||||
void NoggitApplication::initalize(int argc, char* argv[])
|
||||
void NoggitApplication::initalize(int argc, char* argv[], std::vector<bool> Parser)
|
||||
{
|
||||
InitLogging();
|
||||
Command = Parser;
|
||||
|
||||
//Locate application relative path
|
||||
Log << "Noggit Studio - " << STRPRODUCTVER << std::endl;
|
||||
@@ -132,4 +133,12 @@ namespace Noggit::Application
|
||||
}
|
||||
LogError << "std::terminate: " << reason << std::endl;
|
||||
}
|
||||
|
||||
bool NoggitApplication::GetCommand(int index)
|
||||
{
|
||||
if (index >= 0 && index < Command.size())
|
||||
return Command[index];
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,9 +48,14 @@ namespace Noggit::Application {
|
||||
BlizzardArchive::ClientData* clientData() { return _client_data.get(); }
|
||||
void setClientData(std::shared_ptr<BlizzardArchive::ClientData> data) { _client_data = data; }
|
||||
|
||||
void initalize(int argc, char* argv[]);
|
||||
void initalize(int argc, char* argv[], std::vector<bool> Parser);
|
||||
std::shared_ptr<Noggit::Application::NoggitApplicationConfiguration> getConfiguration();
|
||||
static void terminationHandler();
|
||||
bool GetCommand(int index);
|
||||
|
||||
protected:
|
||||
std::vector<bool> Command;
|
||||
|
||||
private:
|
||||
NoggitApplication() = default;
|
||||
|
||||
|
||||
@@ -129,13 +129,24 @@ NoggitProjectSelectionWindow::NoggitProjectSelectionWindow(Noggit::Application::
|
||||
}
|
||||
);
|
||||
|
||||
_updater = new Noggit::Ui::CUpdater(this);
|
||||
// disable-update
|
||||
if (!_noggit_application->GetCommand(0))
|
||||
{
|
||||
_updater = new Noggit::Ui::CUpdater(this);
|
||||
|
||||
QObject::connect(_updater, &CUpdater::OpenUpdater, [=]()
|
||||
{
|
||||
_updater->setModal(true);
|
||||
_updater->show();
|
||||
});
|
||||
QObject::connect(_updater, &CUpdater::OpenUpdater, [=]()
|
||||
{
|
||||
_updater->setModal(true);
|
||||
_updater->show();
|
||||
});
|
||||
}
|
||||
|
||||
// force-changelog
|
||||
if (_noggit_application->GetCommand(1))
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void NoggitProjectSelectionWindow::handleContextMenuProjectListItemDelete(std::string const& project_path)
|
||||
|
||||
Reference in New Issue
Block a user