18 #include <boost/program_options/config.hpp>
19 #include <boost/program_options/parsers.hpp>
24 const char* geometry =
"geometry";
25 const char* nohighdpi =
"nohighdpi";
28 QSize windowSize(
const QString& size_string)
30 auto list = size_string.split(
"x");
35 return QSize(list[0].toInt(), list[1].toInt());
39 bool isValid(
const QSize& win_size)
41 if (win_size.width() > 640 && win_size.height() > 480)
51 m_options.add_options()(
"help,h",
"print help message");
52 m_options.add_options()(
"with-debug",
"run application with debug printout");
53 m_options.add_options()(
"no-splash",
"do not show splash screen");
54 m_options.add_options()(geometry, bpo::value<std::string>(),
55 "Main window geometry, e.g. 1600x1000");
56 m_options.add_options()(nohighdpi,
"Run without high-dpi support");
90 bpo::store(bpo::command_line_parser(argc, argv)
101 }
catch (std::exception& e) {
103 std::cout <<
"main() -> " << e.what() << std::endl;
133 std::cout <<
"Wrong window size, try --geometry=1600x900\n";
141 std::cout <<
"BornAgain Graphical User Interface" << std::endl;
147 QString size_str = QString::fromStdString(
m_variables_map[geometry].as<std::string>());
148 return windowSize(size_str);
153 return find(nohighdpi);
Defines class GUIHelpers functions.
Collection of utilities to parse command line options.
bool find(std::string name) const
Returns true if option with given name has been set.
bpo::variables_map & getVariables()
Returns reference to the variables container.
void parseCommandLine(int argc, char **argv)
Parses command line arguments.
bpo::options_description & getOptions()
Returns reference to the options description.
bool m_options_is_consistent
true if options are consistent (no conflicts, no –help request)
bpo::options_description m_options
options description, to be filled with add() from different program modules
ApplicationOptions(int argc=0, char **argv=0)
bool disableHighDPISupport()
bpo::variables_map m_variables_map
bool isConsistent() const
Returns true if options are consistent (no conflicts, no –help request)
QSize mainWindowSize() const
void printHelpMessage() const
bpo::positional_options_description m_positional_options
positional options description, to be filled with addPositional() from main module
const bpo::variable_value & operator[](const std::string &s) const
access to variable with given name defined in variables container
QString getBornAgainVersionString()
QString const & name(EShape k)