Hide console on Windows

Show command line help text in dialog, accessible from About menu
Show command line help dialog instead of console output on Windows
p4#: 22130
This commit is contained in:
Magne Sjaastad 2013-08-08 11:09:18 +02:00
parent ffb3d3e235
commit 69f3f98f5a
6 changed files with 91 additions and 59 deletions

View File

@ -837,42 +837,14 @@ bool RiaApplication::parseArguments()
if (showHelp)
{
QString helpText = QString("\n%1 v. %2\n").arg(RI_APPLICATION_NAME).arg(getVersionStringApp(false));
helpText += "Copyright Statoil ASA, Ceetron AS 2011, 2012\n\n";
helpText +=
"\nParameter Description\n"
"-----------------------------------------------------------------\n"
"-last Open last used project\n"
"\n"
"-project <filename> Open project file <filename>\n"
"\n"
"-case <casename> Open Eclipse case <casename>\n"
" (do not include .GRID/.EGRID)\n"
"\n"
"-startdir The default directory for open/save commands\n"
"\n"
"-savesnapshots Save snapshot of all views to 'snapshots' folder in project file folder\n"
" Application closes after snapshots are written to file\n"
"\n"
"-regressiontest <folder> Run a regression test on all sub-folders starting with \"" + RegTestNames::testFolderFilter + "\" of the given folder: \n"
" " + RegTestNames::testProjectName + " files in the sub-folders will be opened and \n"
" snapshots of all the views is written to the sub-sub-folder " + RegTestNames::generatedFolderName + ". \n"
" Then difference images is generated in the sub-sub-folder " + RegTestNames::diffFolderName + " based \n"
" on the images in sub-sub-folder " + RegTestNames::baseFolderName + ".\n"
" The results are presented in " + RegTestNames::reportFileName + " that is\n"
" written in the given folder.\n"
"\n"
"-updateregressiontestbase <folder> For all sub-folders starting with \"" + RegTestNames::testFolderFilter + "\" of the given folder: \n"
" Copy the images in the sub-sub-folder " + RegTestNames::generatedFolderName + " to the sub-sub-folder\n"
" " + RegTestNames::baseFolderName + " after deleting " + RegTestNames::baseFolderName + " completely.\n"
"\n"
"-help, -? Displays help text\n"
"-----------------------------------------------------------------";
QString helpText = commandLineParameterHelp();
#if defined(_MSC_VER) && defined(_WIN32)
showFormattedTextInMessageBox(helpText);
#else
fprintf(stdout, "%s\n", helpText.toAscii().data());
fflush(stdout);
#endif
return false;
}
@ -1578,3 +1550,65 @@ RimProject* RiaApplication::project()
return m_project;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaApplication::showFormattedTextInMessageBox(const QString& text)
{
QString helpText = text;
QMessageBox msgBox;
msgBox.setIcon(QMessageBox::Information);
msgBox.setWindowTitle("ResInsight");
helpText.replace("&", "&amp;");
helpText.replace("<", "&lt;");
helpText.replace(">", "&gt;");
helpText = QString("<pre>%1</pre>").arg(helpText);
msgBox.setText(helpText);
msgBox.exec();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RiaApplication::commandLineParameterHelp() const
{
QString text = QString("\n%1 v. %2\n").arg(RI_APPLICATION_NAME).arg(getVersionStringApp(false));
text += "Copyright Statoil ASA, Ceetron AS 2011, 2012\n\n";
text +=
"\nParameter Description\n"
"-----------------------------------------------------------------\n"
"-last Open last used project\n"
"\n"
"-project <filename> Open project file <filename>\n"
"\n"
"-case <casename> Open Eclipse case <casename>\n"
" (do not include .GRID/.EGRID)\n"
"\n"
"-startdir The default directory for open/save commands\n"
"\n"
"-savesnapshots Save snapshot of all views to 'snapshots' folder in project file folder\n"
" Application closes after snapshots are written to file\n"
"\n"
"-regressiontest <folder> Run a regression test on all sub-folders starting with \"" + RegTestNames::testFolderFilter + "\" of the given folder: \n"
" " + RegTestNames::testProjectName + " files in the sub-folders will be opened and \n"
" snapshots of all the views is written to the sub-sub-folder " + RegTestNames::generatedFolderName + ". \n"
" Then difference images is generated in the sub-sub-folder " + RegTestNames::diffFolderName + " based \n"
" on the images in sub-sub-folder " + RegTestNames::baseFolderName + ".\n"
" The results are presented in " + RegTestNames::reportFileName + " that is\n"
" written in the given folder.\n"
"\n"
"-updateregressiontestbase <folder> For all sub-folders starting with \"" + RegTestNames::testFolderFilter + "\" of the given folder: \n"
" Copy the images in the sub-sub-folder " + RegTestNames::generatedFolderName + " to the sub-sub-folder\n"
" " + RegTestNames::baseFolderName + " after deleting " + RegTestNames::baseFolderName + " completely.\n"
"\n"
"-help, -? Displays help text\n"
"-----------------------------------------------------------------";
return text;
}

View File

@ -125,6 +125,9 @@ public:
cvf::Font* standardFont();
QString commandLineParameterHelp() const;
void showFormattedTextInMessageBox(const QString& text);
private:
void onProjectOpenedOrClosed();
void setWindowCaptionFromAppState();

View File

@ -237,6 +237,12 @@ endif()
target_link_libraries( ResInsight ${LINK_LIBRARIES} ${EXTERNAL_LINK_LIBRARIES})
if(WIN32) # Check if we are on Windows
if(MSVC) # Check if we are using the Visual Studio compiler
set_target_properties(ResInsight PROPERTIES LINK_FLAGS "/SUBSYSTEM:WINDOWS")
endif()
ENDIF()
# Copy Dlls
if (MSVC)

View File

@ -21,32 +21,6 @@
#include "RiuMainWindow.h"
// Cmake is able to control subsystem on Windows using the following method http://www.cmake.org/Wiki/VSConfigSpecificSettings
//
// if(WIN32)
// set_target_properties(WindowApplicationExample PROPERTIES LINK_FLAGS_DEBUG "/SUBSYSTEM:CONSOLE")
// set_target_properties(WindowApplicationExample PROPERTIES COMPILE_DEFINITIONS_DEBUG "_CONSOLE")
// set_target_properties(WindowApplicationExample PROPERTIES LINK_FLAGS_RELWITHDEBINFO "/SUBSYSTEM:CONSOLE")
// set_target_properties(WindowApplicationExample PROPERTIES COMPILE_DEFINITIONS_RELWITHDEBINFO "_CONSOLE")
// set_target_properties(WindowApplicationExample PROPERTIES LINK_FLAGS_RELEASE "/SUBSYSTEM:WINDOWS")
// set_target_properties(WindowApplicationExample PROPERTIES LINK_FLAGS_MINSIZEREL "/SUBSYSTEM:WINDOWS")
// endif(WIN32)
//
//
// Due to a bug in Cmake, use workaround described here http://public.kitware.com/Bug/view.php?id=12566
#if defined(_MSC_VER) && defined(_WIN32)
#ifdef _DEBUG
#pragma comment(linker, "/SUBSYSTEM:CONSOLE")
#else
#pragma comment(linker, "/SUBSYSTEM:WINDOWS")
#endif // _DEBUG
#endif // defined(_MSC_VER) && defined(_WIN32)
int main(int argc, char *argv[])
{
RiaApplication app(argc, argv);

View File

@ -267,6 +267,8 @@ void RiuMainWindow::createActions()
// Help actions
m_aboutAction = new QAction("&About", this);
connect(m_aboutAction, SIGNAL(triggered()), SLOT(slotAbout()));
m_commandLineHelpAction = new QAction("&Command Line Help", this);
connect(m_commandLineHelpAction, SIGNAL(triggered()), SLOT(slotShowCommandLineHelp()));
// Draw style actions
m_dsActionGroup = new QActionGroup(this);
@ -365,6 +367,7 @@ void RiuMainWindow::createMenus()
// Help menu
QMenu* helpMenu = menuBar()->addMenu("&Help");
helpMenu->addAction(m_aboutAction);
helpMenu->addAction(m_commandLineHelpAction);
}
@ -1647,3 +1650,13 @@ void RiuMainWindow::slotImportWellPathsFromSSIHub()
if (app->project()) app->project()->createDisplayModelAndRedrawAllViews();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuMainWindow::slotShowCommandLineHelp()
{
RiaApplication* app = RiaApplication::instance();
QString text = app->commandLineParameterHelp();
app->showFormattedTextInMessageBox(text);
}

View File

@ -156,6 +156,7 @@ private:
// Help actions
QAction* m_aboutAction;
QAction* m_commandLineHelpAction;
// Animation
caf::AnimationToolBar* m_animationToolBar;
@ -231,6 +232,7 @@ private slots:
// Help slots
void slotAbout();
void slotShowCommandLineHelp();
void slotSubWindowActivated(QMdiSubWindow* subWindow);
void slotCurrentChanged(const QModelIndex & current, const QModelIndex & previous);