Skip to content
Snippets Groups Projects
Commit 6c5e3f5b authored by Ludwig Jaeck's avatar Ludwig Jaeck
Browse files

Added command line argument for project file

parent cfaa9ce7
No related branches found
No related tags found
1 merge request!1241Added command line argument for project file
Pipeline #85020 passed
...@@ -65,7 +65,8 @@ ApplicationOptions::ApplicationOptions(int argc, char** argv) ...@@ -65,7 +65,8 @@ ApplicationOptions::ApplicationOptions(int argc, char** argv)
m_options.add_options()(geometry, bpo::value<std::string>(), m_options.add_options()(geometry, bpo::value<std::string>(),
"Main window geometry, e.g. 1600x1000"); "Main window geometry, e.g. 1600x1000");
m_options.add_options()(nohighdpi, "Run without high-dpi support"); m_options.add_options()(nohighdpi, "Run without high-dpi support");
m_options.add_options()("project-file", bpo::value<std::string>(), "project file");
m_positional_options.add("project-file", -1);
parseCommandLine(argc, argv); parseCommandLine(argc, argv);
processOptions(); processOptions();
...@@ -152,3 +153,10 @@ bool ApplicationOptions::disableHighDPISupport() const ...@@ -152,3 +153,10 @@ bool ApplicationOptions::disableHighDPISupport() const
{ {
return find(nohighdpi); return find(nohighdpi);
} }
QString ApplicationOptions::projectFile() const
{
if (find("project-file"))
return QString::fromStdString(m_variables_map["project-file"].as<std::string>());
return QString();
}
\ No newline at end of file
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include <string> #include <string>
class QSize; class QSize;
class QString;
namespace bpo = boost::program_options; namespace bpo = boost::program_options;
...@@ -39,6 +40,8 @@ public: ...@@ -39,6 +40,8 @@ public:
bool disableHighDPISupport() const; bool disableHighDPISupport() const;
QString projectFile() const;
//! Returns true if option with given name has been set //! Returns true if option with given name has been set
bool find(std::string name) const; bool find(std::string name) const;
......
...@@ -64,7 +64,8 @@ int main(int argc, char* argv[]) ...@@ -64,7 +64,8 @@ int main(int argc, char* argv[])
GUI::Global::mainWindow = &win; GUI::Global::mainWindow = &win;
if (options.find("geometry")) if (options.find("geometry"))
win.resize(options.mainWindowSize()); win.resize(options.mainWindowSize());
if (options.find("project-file"))
win.loadProject(options.projectFile());
win.show(); win.show();
int result = QApplication::exec(); int result = QApplication::exec();
......
...@@ -102,9 +102,9 @@ MainWindow::MainWindow() ...@@ -102,9 +102,9 @@ MainWindow::MainWindow()
m_viewSelectionButtons->button(ViewId::WELCOME)->setChecked(true); m_viewSelectionButtons->button(ViewId::WELCOME)->setChecked(true);
updateTitle(); updateTitle();
if (appSettings)
if (appSettings->createNewProjectOnStartup()) if (appSettings->createNewProjectOnStartup())
m_projectManager->newProject(); m_projectManager->newProject();
} }
MainWindow::~MainWindow() = default; MainWindow::~MainWindow() = default;
...@@ -402,3 +402,8 @@ QToolButton* MainWindow::createViewSelectionButton() const ...@@ -402,3 +402,8 @@ QToolButton* MainWindow::createViewSelectionButton() const
btn->setToolButtonStyle(Qt::ToolButtonTextUnderIcon); btn->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
return btn; return btn;
} }
void MainWindow::loadProject(QString projectPath)
{
m_projectManager->openProject(projectPath);
}
...@@ -54,6 +54,7 @@ public: ...@@ -54,6 +54,7 @@ public:
void setCurrentView(int viewId); void setCurrentView(int viewId);
void updateTitle(); void updateTitle();
void loadProject(QString projectPath);
public slots: public slots:
void onFocusRequest(int index); void onFocusRequest(int index);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment