Commit b4978ee5 authored by Hugo Beauzee-Luyssen's avatar Hugo Beauzee-Luyssen

Getting verbosity level from command line.

parent 3146ed2e
......@@ -74,7 +74,7 @@ MainWindow::MainWindow( QWidget *parent ) :
VLMCSettingsDefault::load( "VLMC" );
VLMCSettingsDefault::loadKeyboardShortcutDefaults();
//We only install message handler here cause it uses configuration.
qInstallMsgHandler( VlmcDebug::vlmcMessageHandler );
VlmcDebug::getInstance()->setup();
// GUI
DockWidgetManager::instance( this )->setMainWindow( this );
......
......@@ -27,6 +27,19 @@
VlmcDebug::VlmcDebug() : m_logFile( NULL )
{
//setup log level :
QStringList args = qApp->arguments();
if ( args.contains( "-vv" ) == true )
SettingsManager::getInstance()->setValue( "private", "LogLevel", QtDebugMsg );
else if ( args.contains( "-v" ) == true )
SettingsManager::getInstance()->setValue( "private", "LogLevel", QtWarningMsg );
else
SettingsManager::getInstance()->setValue( "private", "LogLevel", QtCriticalMsg );
//Yeah I just changed preferences, but I have to commit. Though I don't feel like a widget...
SettingsManager::getInstance()->commit();
fprintf( stderr, "%d\n", SettingsManager::getInstance()->getValue( "private", "LogLevel" )->get().toInt() );
const SettingValue* setVal = SettingsManager::getInstance()->getValue( "private", "LogFile" );
connect( setVal, SIGNAL( changed( QVariant ) ), this, SLOT( logFileChanged( const QVariant& ) ) );
QObject::connect( qApp,
......@@ -46,6 +59,11 @@ VlmcDebug::~VlmcDebug()
delete m_logFile;
}
void VlmcDebug::setup()
{
qInstallMsgHandler( VlmcDebug::vlmcMessageHandler );
}
void VlmcDebug::logFileChanged( const QVariant& logFileV )
{
QString logFile = logFileV.toString();
......
......@@ -39,6 +39,7 @@ class VlmcDebug : public QObject, public Singleton<VlmcDebug>
public:
static void vlmcMessageHandler( QtMsgType type, const char* msg );
void setup();
private:
VlmcDebug();
virtual ~VlmcDebug();
......
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