Commit c21ae6be authored by heretik's avatar heretik

Update arguments.hpp, main.cpp, and 5 more files...

parent 1b3bc234
#ifndef ARGUMENTS_HPP
#define ARGUMENTS_HPP
namespace prototypator {
struct Arguments {
bool no_restore = false;
};
}
#endif
#include "arguments.hpp"
#include "mainwindow.hpp"
#include "utils/qt/translator.hpp"
#include <QApplication>
#include <QCommandLineParser>
#include <QLibraryInfo>
int main( int argc, char **argv ) {
// global settings
QCoreApplication::setOrganizationName( "gamasoft" );
QCoreApplication::setOrganizationDomain( "gamasoft.fr" );
QCoreApplication::setApplicationName( "prototypator" );
// start application
// Start application
auto app = QApplication{ argc, argv };
QApplication::setOrganizationName( "gamasoft" );
QApplication::setOrganizationDomain( "gamasoft.fr" );
QApplication::setApplicationName( "prototypator" );
auto qt_translator = qt::Translator{ app, "qt_", QLibraryInfo::location( QLibraryInfo::TranslationsPath ) };
auto app_translator = qt::Translator{ app, "prototypator_" };
auto mainWin = MainWindow{};
// parse arguments
auto parser = QCommandLineParser{};
parser.addOptions( {
{ "no-restore", QCoreApplication::translate( "main", "Don't restore settings" ) }
} );
parser.process( app );
auto arguments = ::prototypator::Arguments{};
arguments.no_restore = parser.isSet( "no-restore" );
// start application
auto mainWin = MainWindow{ arguments };
mainWin.show();
return QApplication::exec();
}
......@@ -12,15 +12,11 @@
namespace fs = std::filesystem;
MainWindow::MainWindow( QWidget *parent )
MainWindow::MainWindow( ::prototypator::Arguments arguments, QWidget *parent )
: QMainWindow( parent )
, arguments_{ std::move( arguments ) }
, ui_ptr_{ new Ui::MainWindow }
, directory_{}
, process_{ parent }
, plain_text_{ nullptr }
, commands_{}
, line_and_messages_{}
, syntax_highlighter_ptr_{}
{
// prepare qt things
ui_ptr_->setupUi( this );
......@@ -45,7 +41,9 @@ MainWindow::MainWindow( QWidget *parent )
syntax_highlighter_ptr_ = std::make_unique<SyntaxHighlighter>( ui_ptr_->textEdit_code->document() );
// restore settings
restore_settings();
if( not arguments_.no_restore ) {
restore_settings();
}
// prepare context
prepare_directory();
......
#ifndef MAINWINDOW_HPP
#define MAINWINDOW_HPP
#include "arguments.hpp"
#include "syntax_highlighter.hpp"
#include <QMainWindow>
#include <QProcess>
......@@ -25,7 +26,7 @@ class MainWindow
Q_OBJECT
public:
explicit MainWindow( QWidget *parent = nullptr );
explicit MainWindow( ::prototypator::Arguments arguments, QWidget *parent = nullptr );
~MainWindow() override;
public slots:
......@@ -54,15 +55,16 @@ private:
};
private:
::prototypator::Arguments arguments_;
std::unique_ptr<Ui::MainWindow> ui_ptr_;
bool is_prepared_ = false;
std::filesystem::path directory_;
std::filesystem::path directory_ = {};
QProcess process_;
std::experimental::observer_ptr<QPlainTextEdit> plain_text_;
std::vector<Command> commands_;
std::experimental::observer_ptr<QPlainTextEdit> plain_text_ = nullptr;
std::vector<Command> commands_ = {};
unsigned current_command_index_ = 0;
std::map<int, Messages> line_and_messages_;
std::unique_ptr<SyntaxHighlighter> syntax_highlighter_ptr_;
std::map<int, Messages> line_and_messages_ = {};
std::unique_ptr<SyntaxHighlighter> syntax_highlighter_ptr_ = {};
};
#endif // MAINWINDOW_HPP
......@@ -276,6 +276,19 @@
</layout>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</widget>
......
......@@ -6,113 +6,127 @@
<message>
<location filename="../src/prototypator/mainwindow.ui" line="14"/>
<source>Prototypator</source>
<translation></translation>
<translation>Prototypator</translation>
</message>
<message>
<location filename="../src/prototypator/mainwindow.ui" line="27"/>
<source>C++ code:</source>
<translation></translation>
<translation>C++ code:</translation>
</message>
<message>
<location filename="../src/prototypator/mainwindow.ui" line="50"/>
<source>&amp;Run</source>
<translation></translation>
<translation>&amp;Run</translation>
</message>
<message>
<location filename="../src/prototypator/mainwindow.ui" line="53"/>
<source>Ctrl+R</source>
<translation></translation>
<translation>Ctrl+R</translation>
</message>
<message>
<location filename="../src/prototypator/mainwindow.ui" line="88"/>
<source>Compilation</source>
<translation></translation>
<translation>Compilation</translation>
</message>
<message>
<location filename="../src/prototypator/mainwindow.ui" line="153"/>
<source>Input/output</source>
<translation></translation>
<translation>Input/output</translation>
</message>
<message>
<location filename="../src/prototypator/mainwindow.ui" line="215"/>
<source>Options</source>
<translation type="unfinished"></translation>
<translation>Options</translation>
</message>
<message>
<location filename="../src/prototypator/mainwindow.ui" line="225"/>
<source>Version</source>
<translation type="unfinished"></translation>
<translation>Version</translation>
</message>
<message>
<location filename="../src/prototypator/mainwindow.ui" line="231"/>
<source>C++98</source>
<translation type="unfinished"></translation>
<translation>C++98</translation>
</message>
<message>
<location filename="../src/prototypator/mainwindow.ui" line="238"/>
<source>C++11</source>
<translation type="unfinished"></translation>
<translation>C++11</translation>
</message>
<message>
<location filename="../src/prototypator/mainwindow.ui" line="245"/>
<source>C++14</source>
<translation type="unfinished"></translation>
<translation>C++14</translation>
</message>
<message>
<location filename="../src/prototypator/mainwindow.ui" line="252"/>
<source>C++17</source>
<translation type="unfinished"></translation>
<translation>C++17</translation>
</message>
<message>
<location filename="../src/prototypator/mainwindow.ui" line="259"/>
<source>C++20</source>
<translation type="unfinished"></translation>
<translation>C++20</translation>
</message>
<message>
<location filename="../src/prototypator/mainwindow.cpp" line="58"/>
<location filename="../src/prototypator/mainwindow.cpp" line="56"/>
<source>testing presence of cmake...
</source>
<translation></translation>
<translation>testing presence of cmake...
</translation>
</message>
<message>
<location filename="../src/prototypator/mainwindow.cpp" line="62"/>
<location filename="../src/prototypator/mainwindow.cpp" line="60"/>
<source>running &apos;cmake&apos;...
</source>
<translation></translation>
<translation>running &apos;cmake&apos;...
</translation>
</message>
<message>
<location filename="../src/prototypator/mainwindow.cpp" line="66"/>
<location filename="../src/prototypator/mainwindow.cpp" line="64"/>
<source>running &apos;make&apos;...
</source>
<translation></translation>
<translation>running &apos;make&apos;...
</translation>
</message>
<message>
<location filename="../src/prototypator/mainwindow.cpp" line="70"/>
<location filename="../src/prototypator/mainwindow.cpp" line="68"/>
<source>running application...
</source>
<translation></translation>
<translation>running application...
</translation>
</message>
<message>
<location filename="../src/prototypator/mainwindow.cpp" line="122"/>
<location filename="../src/prototypator/mainwindow.cpp" line="120"/>
<source> exited with code </source>
<translation></translation>
<translation> exited with code </translation>
</message>
<message>
<location filename="../src/prototypator/mainwindow.cpp" line="208"/>
<location filename="../src/prototypator/mainwindow.cpp" line="206"/>
<source>error(s):
</source>
<translation></translation>
<translation>error(s):
</translation>
</message>
<message>
<location filename="../src/prototypator/mainwindow.cpp" line="213"/>
<location filename="../src/prototypator/mainwindow.cpp" line="211"/>
<source>warning(s):
</source>
<translation></translation>
<translation>warning(s):
</translation>
</message>
<message>
<location filename="../src/prototypator/mainwindow.cpp" line="232"/>
<location filename="../src/prototypator/mainwindow.cpp" line="230"/>
<source>failed to start &apos;</source>
<translation></translation>
<translation>failed to start &apos;</translation>
</message>
</context>
<context>
<name>main</name>
<message>
<location filename="../src/prototypator/main.cpp" line="21"/>
<source>Don&apos;t restore settings</source>
<translation>Don&apos;t restore settings</translation>
</message>
</context>
</TS>
......@@ -11,7 +11,7 @@
<message>
<location filename="../src/prototypator/mainwindow.ui" line="27"/>
<source>C++ code:</source>
<translation>Code c++ :</translation>
<translation>Code C++ :</translation>
</message>
<message>
<location filename="../src/prototypator/mainwindow.ui" line="50"/>
......@@ -21,7 +21,7 @@
<message>
<location filename="../src/prototypator/mainwindow.ui" line="53"/>
<source>Ctrl+R</source>
<translation>Ctrl+D</translation>
<translation>Ctr+D</translation>
</message>
<message>
<location filename="../src/prototypator/mainwindow.ui" line="88"/>
......@@ -36,89 +36,97 @@
<message>
<location filename="../src/prototypator/mainwindow.ui" line="215"/>
<source>Options</source>
<translation type="unfinished"></translation>
<translation>Options</translation>
</message>
<message>
<location filename="../src/prototypator/mainwindow.ui" line="225"/>
<source>Version</source>
<translation type="unfinished"></translation>
<translation>Version</translation>
</message>
<message>
<location filename="../src/prototypator/mainwindow.ui" line="231"/>
<source>C++98</source>
<translation type="unfinished"></translation>
<translation>C++98</translation>
</message>
<message>
<location filename="../src/prototypator/mainwindow.ui" line="238"/>
<source>C++11</source>
<translation type="unfinished"></translation>
<translation>C++11</translation>
</message>
<message>
<location filename="../src/prototypator/mainwindow.ui" line="245"/>
<source>C++14</source>
<translation type="unfinished"></translation>
<translation>C++14</translation>
</message>
<message>
<location filename="../src/prototypator/mainwindow.ui" line="252"/>
<source>C++17</source>
<translation type="unfinished"></translation>
<translation>C++17</translation>
</message>
<message>
<location filename="../src/prototypator/mainwindow.ui" line="259"/>
<source>C++20</source>
<translation type="unfinished"></translation>
<translation>C++20</translation>
</message>
<message>
<location filename="../src/prototypator/mainwindow.cpp" line="58"/>
<location filename="../src/prototypator/mainwindow.cpp" line="56"/>
<source>testing presence of cmake...
</source>
<translation>test de la présence de cmake...
</translation>
</message>
<message>
<location filename="../src/prototypator/mainwindow.cpp" line="62"/>
<location filename="../src/prototypator/mainwindow.cpp" line="60"/>
<source>running &apos;cmake&apos;...
</source>
<translation>démarrage de &apos;cmake&apos;...
</translation>
</message>
<message>
<location filename="../src/prototypator/mainwindow.cpp" line="66"/>
<location filename="../src/prototypator/mainwindow.cpp" line="64"/>
<source>running &apos;make&apos;...
</source>
<translation>démarrage de &apos;make&apos;...
</translation>
</message>
<message>
<location filename="../src/prototypator/mainwindow.cpp" line="70"/>
<location filename="../src/prototypator/mainwindow.cpp" line="68"/>
<source>running application...
</source>
<translation>démarrage de l&apos;application...
</translation>
</message>
<message>
<location filename="../src/prototypator/mainwindow.cpp" line="122"/>
<location filename="../src/prototypator/mainwindow.cpp" line="120"/>
<source> exited with code </source>
<translation> s&apos;est terminé avec le code </translation>
<translation> terminé avec le code </translation>
</message>
<message>
<location filename="../src/prototypator/mainwindow.cpp" line="208"/>
<location filename="../src/prototypator/mainwindow.cpp" line="206"/>
<source>error(s):
</source>
<translation>erreur(s) :
</translation>
</message>
<message>
<location filename="../src/prototypator/mainwindow.cpp" line="213"/>
<location filename="../src/prototypator/mainwindow.cpp" line="211"/>
<source>warning(s):
</source>
<translation>avertissement(s) :
<translation>averrtissement(s):
</translation>
</message>
<message>
<location filename="../src/prototypator/mainwindow.cpp" line="232"/>
<location filename="../src/prototypator/mainwindow.cpp" line="230"/>
<source>failed to start &apos;</source>
<translation>impossible de démarrer &apos;</translation>
</message>
</context>
<context>
<name>main</name>
<message>
<location filename="../src/prototypator/main.cpp" line="21"/>
<source>Don&apos;t restore settings</source>
<translation>Ne recharge pas les réglages</translation>
</message>
</context>
</TS>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment