diff options
Diffstat (limited to 'src/main.cpp')
-rw-r--r--[-rwxr-xr-x] | src/main.cpp | 241 |
1 files changed, 125 insertions, 116 deletions
diff --git a/src/main.cpp b/src/main.cpp index 1b6285a..60e9a7a 100755..100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -18,7 +18,7 @@ ***************************************************************************/ // -- #include "MainWindow.h" -// -- +// -- // -- #include "UiGuiIndentServer.h" // -- #include "debugging/TSLogger.h" // -- #include "UiGuiIniFileParser.h" @@ -27,7 +27,7 @@ // -- #include "UiGuiSystemInfo.h" // -- #include "IndentHandler.h" // -- #include "SettingsPaths.h" -// -- +// -- // -- #include <tntqapplication.h> // -- #include <tntqtextcodec.h> // -- #include <tqdebug.h> @@ -54,118 +54,127 @@ int main(int argc, char *argv[]) { return 0; -// -- TQString file2OpenOnStart = ""; -// -- int verboseLevel = 1; -// -- bool startAsPlugin = false; -// -- bool startAsServer = false; -// -- bool tclapExitExceptionThrown = false; -// -- int returnValue = 0; -// -- -// -- // Wrap everything in a try block. Do this every time, -// -- // because exceptions will be thrown for problems. -// -- try { -// -- // Define the command line object. -// -- TCLAP::CmdLine cmd("If -p and -s are set, -p will be used.\nGiving no parameters starts full gui without server.", ' ', "UiGUI version " PROGRAM_VERSION_STRING " " PROGRAM_REVISION); -// -- cmd.setExceptionHandling(false); -// -- -// -- // Define a value argument and add it to the command line. -// -- TCLAP::UnlabeledValueArg<std::string> filenameArg("file", "Opens the by filename defined file on start" , false, "", "filename"); -// -- cmd.add( filenameArg ); -// -- -// -- // Define a switch and add it to the command line. -// -- TCLAP::SwitchArg pluginSwitch("p", "plugin", "Run as plugin. Server will be started with a simplified gui", false); -// -- cmd.add( pluginSwitch ); -// -- -// -- // Define a switch and add it to the command line. -// -- TCLAP::SwitchArg serverSwitch("s", "server", "Run as server only without gui", false); -// -- cmd.add( serverSwitch ); -// -- -// -- // Define a value argument and add it to the command line. -// -- TCLAP::ValueArg<int> verboselevelArg("v", "verbose", "Sets how many info is written to the log. 0 means with debug info, 3 means critical messages only" , false, 1, "int"); -// -- cmd.add( verboselevelArg ); -// -- -// -- // Parse the args. -// -- cmd.parse( argc, argv ); -// -- -// -- // Get the value parsed by each arg. -// -- file2OpenOnStart = filenameArg.getValue().c_str(); -// -- startAsPlugin = pluginSwitch.getValue(); -// -- startAsServer = serverSwitch.getValue(); -// -- verboseLevel = verboselevelArg.getValue(); -// -- } -// -- catch (TCLAP::ArgException &e) { // catch arg exceptions -// -- std::cerr << std::endl << "error: " << e.error() << ". " << e.argId() << std::endl; -// -- returnValue = 1; -// -- } -// -- catch (TCLAP::ExitException &e) { // catch exit exceptions -// -- tclapExitExceptionThrown = true; -// -- returnValue = e.getExitStatus(); -// -- } -// -- catch (...) { // catch any exceptions -// -- std::cerr << std::endl << "There was an error! Maybe faulty command line arguments set. See --help." << std::endl; -// -- returnValue = 1; -// -- } -// -- -// -- if ( returnValue != 0 || tclapExitExceptionThrown ) { -// -- return returnValue; -// -- } -// -- -// -- TQApplication app(argc, argv); -// -- UiGuiIndentServer server; -// -- MainWindow *mainWindow = NULL; -// -- IndentHandler *indentHandler = NULL; -// -- -// -- // Init and install the logger function. -// -- // Setting UTF-8 as default 8-Bit encoding to ensure that tqDebug does no false string conversion. -// -- TQTextCodec::setCodecForCStrings( TQTextCodec::codecForName("UTF-8") ); -// -- TQTextCodec::setCodecForLocale( TQTextCodec::codecForName("UTF-8") ); -// -- // Force creation of an TSLogger instance here, to avoid recursion with SettingsPaths init function. -// -- #ifdef _DEBUG -// -- TSLogger::getInstance(0); -// -- #else -// -- TSLogger::getInstance(verboseLevel); -// -- #endif -// -- qInstallMsgHandler( TSLogger::messageHandler ); -// -- TSLogger::messageHandler( TSLoggerInfoMsg, TQString("Starting UiGUI Version %1 %2").arg(PROGRAM_VERSION_STRING).arg(PROGRAM_REVISION).toAscii() ); -// -- TSLogger::messageHandler( TSLoggerInfoMsg, TQString("Running on %1").arg(UiGuiSystemInfo::getOperatingSystem()).toAscii() ); -// -- -// -- // Set default values for all by UniversalIndentGUI used settings objects. -// -- TQCoreApplication::setOrganizationName("UniversalIndentGUI"); -// -- TQCoreApplication::setOrganizationDomain("universalindent.sf.net"); -// -- TQCoreApplication::setApplicationName("UniversalIndentGUI"); -// -- -// -- // Start normal with full gui and without server. -// -- if ( !startAsPlugin && !startAsServer ) { -// -- mainWindow = new MainWindow(file2OpenOnStart); -// -- mainWindow->show(); -// -- } -// -- // Start as plugin with server. -// -- else if ( startAsPlugin ) { -// -- server.startServer(); -// -- indentHandler = new IndentHandler(0); -// -- indentHandler->show(); -// -- } -// -- // Start as server only without any gui. -// -- else if ( startAsServer ) { -// -- server.startServer(); -// -- } -// -- -// -- try { -// -- returnValue = app.exec(); -// -- } -// -- catch (std::exception &ex) { -// -- qCritical() << __LINE__ << " " << __FUNCTION__ << ": Something went terribly wrong:" << ex.what(); -// -- } -// -- -// -- if ( startAsPlugin || startAsServer ) -// -- server.stopServer(); -// -- -// -- delete indentHandler; -// -- delete mainWindow; -// -- -// -- SettingsPaths::cleanAndRemoveTempDir(); -// -- TSLogger::deleteInstance(); -// -- -// -- return returnValue; - + // -- TQString file2OpenOnStart = ""; + // -- int verboseLevel = 1; + // -- bool startAsPlugin = false; + // -- bool startAsServer = false; + // -- bool tclapExitExceptionThrown = false; + // -- int returnValue = 0; + // -- + // -- // Wrap everything in a try block. Do this every time, + // -- // because exceptions will be thrown for problems. + // -- try { + // -- // Define the command line object. + // -- TCLAP::CmdLine cmd("If -p and -s are set, -p will be used.\nGiving no parameters starts + // full gui without server.", ' ', "UiGUI version " PROGRAM_VERSION_STRING " " PROGRAM_REVISION); + // -- cmd.setExceptionHandling(false); + // -- + // -- // Define a value argument and add it to the command line. + // -- TCLAP::UnlabeledValueArg<std::string> filenameArg("file", "Opens the by + // filename defined file on start" , false, "", "filename"); + // -- cmd.add( filenameArg ); + // -- + // -- // Define a switch and add it to the command line. + // -- TCLAP::SwitchArg pluginSwitch("p", "plugin", "Run as plugin. Server will be started with + // a simplified gui", false); + // -- cmd.add( pluginSwitch ); + // -- + // -- // Define a switch and add it to the command line. + // -- TCLAP::SwitchArg serverSwitch("s", "server", "Run as server only without gui", false); + // -- cmd.add( serverSwitch ); + // -- + // -- // Define a value argument and add it to the command line. + // -- TCLAP::ValueArg<int> verboselevelArg("v", "verbose", "Sets how many info is written to + // the log. 0 means with debug info, 3 means critical messages only" , false, 1, "int"); + // -- cmd.add( verboselevelArg ); + // -- + // -- // Parse the args. + // -- cmd.parse( argc, argv ); + // -- + // -- // Get the value parsed by each arg. + // -- file2OpenOnStart = filenameArg.getValue().c_str(); + // -- startAsPlugin = pluginSwitch.getValue(); + // -- startAsServer = serverSwitch.getValue(); + // -- verboseLevel = verboselevelArg.getValue(); + // -- } + // -- catch (TCLAP::ArgException &e) { // catch arg exceptions + // -- std::cerr << std::endl << "error: " << e.error() << ". " << e.argId() << std::endl; + // -- returnValue = 1; + // -- } + // -- catch (TCLAP::ExitException &e) { // catch exit exceptions + // -- tclapExitExceptionThrown = true; + // -- returnValue = e.getExitStatus(); + // -- } + // -- catch (...) { // catch any exceptions + // -- std::cerr << std::endl << "There was an error! Maybe faulty command line arguments set. + // See --help." << std::endl; + // -- returnValue = 1; + // -- } + // -- + // -- if ( returnValue != 0 || tclapExitExceptionThrown ) { + // -- return returnValue; + // -- } + // -- + // -- TQApplication app(argc, argv); + // -- UiGuiIndentServer server; + // -- MainWindow *mainWindow = NULL; + // -- IndentHandler *indentHandler = NULL; + // -- + // -- // Init and install the logger function. + // -- // Setting UTF-8 as default 8-Bit encoding to ensure that tqDebug does no false string + // conversion. + // -- TQTextCodec::setCodecForCStrings( TQTextCodec::codecForName("UTF-8") ); + // -- TQTextCodec::setCodecForLocale( TQTextCodec::codecForName("UTF-8") ); + // -- // Force creation of an TSLogger instance here, to avoid recursion with SettingsPaths + // init function. + // -- #ifdef _DEBUG + // -- TSLogger::getInstance(0); + // -- #else + // -- TSLogger::getInstance(verboseLevel); + // -- #endif + // -- qInstallMsgHandler( TSLogger::messageHandler ); + // -- TSLogger::messageHandler( TSLoggerInfoMsg, TQString("Starting UiGUI Version %1 + // %2").arg(PROGRAM_VERSION_STRING).arg(PROGRAM_REVISION).toAscii() ); + // -- TSLogger::messageHandler( TSLoggerInfoMsg, TQString("Running on + // %1").arg(UiGuiSystemInfo::getOperatingSystem()).toAscii() ); + // -- + // -- // Set default values for all by UniversalIndentGUI used settings objects. + // -- TQCoreApplication::setOrganizationName("UniversalIndentGUI"); + // -- TQCoreApplication::setOrganizationDomain("universalindent.sf.net"); + // -- TQCoreApplication::setApplicationName("UniversalIndentGUI"); + // -- + // -- // Start normal with full gui and without server. + // -- if ( !startAsPlugin && !startAsServer ) { + // -- mainWindow = new MainWindow(file2OpenOnStart); + // -- mainWindow->show(); + // -- } + // -- // Start as plugin with server. + // -- else if ( startAsPlugin ) { + // -- server.startServer(); + // -- indentHandler = new IndentHandler(0); + // -- indentHandler->show(); + // -- } + // -- // Start as server only without any gui. + // -- else if ( startAsServer ) { + // -- server.startServer(); + // -- } + // -- + // -- try { + // -- returnValue = app.exec(); + // -- } + // -- catch (std::exception &ex) { + // -- qCritical() << __LINE__ << " " << __FUNCTION__ << ": Something went terribly wrong:" + // << ex.what(); + // -- } + // -- + // -- if ( startAsPlugin || startAsServer ) + // -- server.stopServer(); + // -- + // -- delete indentHandler; + // -- delete mainWindow; + // -- + // -- SettingsPaths::cleanAndRemoveTempDir(); + // -- TSLogger::deleteInstance(); + // -- + // -- return returnValue; } |