Commit 4e637613 authored by Jan Möbius's avatar Jan Möbius

Use QSettings for logfile states

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@8094 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 7737c2f5
...@@ -128,7 +128,6 @@ Core() : ...@@ -128,7 +128,6 @@ Core() :
//init logFile //init logFile
logStream_ = 0; logStream_ = 0;
logFile_ = 0; logFile_ = 0;
OpenFlipper::Options::logFileEnabled(true);
//init nodes //init nodes
root_node_scenegraph_ = new ACG::SceneGraph::SeparatorNode(0, "SceneGraph Root Node"); root_node_scenegraph_ = new ACG::SceneGraph::SeparatorNode(0, "SceneGraph Root Node");
...@@ -966,22 +965,24 @@ void Core::slotExit() { ...@@ -966,22 +965,24 @@ void Core::slotExit() {
/// log to file /// log to file
void Core::slotLogToFile(Logtype _type, QString _message){ void Core::slotLogToFile(Logtype _type, QString _message){
if (!OpenFlipper::Options::logFileEnabled()) if (!OpenFlipperSettings().value("Core/Log/logFileEnabled",true).toBool() )
return; return;
if (logStream_ == 0){ if (logStream_ == 0){
//check if a logfile has been specified and if the path is valid //check if a logfile has been specified and if the path is valid
QFileInfo fi( OpenFlipper::Options::logFile() ); QString fileName = OpenFlipperSettings().value("Core/Log/logFile","").toString();
QFileInfo fi( fileName );
if (OpenFlipper::Options::logFile() == "" || !fi.dir().exists() ) if ( fileName == "" || !fi.dir().exists() ) {
OpenFlipper::Options::logFile(QDir::home().absolutePath() + OpenFlipper::Options::dirSeparator() + ".OpenFlipper" + OpenFlipperSettings().setValue("Core/Log/logFile", QDir::home().absolutePath() + OpenFlipper::Options::dirSeparator() + ".OpenFlipper" +
OpenFlipper::Options::dirSeparator() + "OpenFlipper.log"); OpenFlipper::Options::dirSeparator() + "OpenFlipper.log");
}
logFile_ = new QFile( OpenFlipper::Options::logFile() ); logFile_ = new QFile( OpenFlipperSettings().value("Core/Log/logFile").toString() );
if ( logFile_->open(QFile::WriteOnly) ) { if ( logFile_->open(QFile::WriteOnly) ) {
logStream_ = new QTextStream (logFile_); logStream_ = new QTextStream (logFile_);
}else{ } else {
emit log(LOGERR, tr("Unable to open logfile!")); emit log(LOGERR, tr("Unable to open logfile!"));
return; return;
} }
......
...@@ -296,20 +296,6 @@ void Core::readApplicationOptions(INIFile& _ini) { ...@@ -296,20 +296,6 @@ void Core::readApplicationOptions(INIFile& _ini) {
OpenFlipper::Options::defaultViewingDirection( mode, i ); OpenFlipper::Options::defaultViewingDirection( mode, i );
} }
//============================================================================
// Load logFile status
//============================================================================
bool logFileEnabled = true;
if( _ini.get_entry(logFileEnabled, "Options", "LogFileEnabled") )
OpenFlipper::Options::logFileEnabled(logFileEnabled);
//============================================================================
// Load logFile location
//============================================================================
QString logFile = "";
if( _ini.get_entry(logFile, "Options", "LogFileLocation") )
OpenFlipper::Options::logFile(logFile);
//============================================================================ //============================================================================
// Load restrictFrameRate // Load restrictFrameRate
//============================================================================ //============================================================================
...@@ -509,14 +495,6 @@ void Core::writeApplicationOptions(INIFile& _ini) { ...@@ -509,14 +495,6 @@ void Core::writeApplicationOptions(INIFile& _ini) {
//write default ToolboxMode //write default ToolboxMode
_ini.add_entry("Options","DefaultToolboxMode",OpenFlipper::Options::defaultToolboxMode() ); _ini.add_entry("Options","DefaultToolboxMode",OpenFlipper::Options::defaultToolboxMode() );
//============================================================================
// logfile
//============================================================================
//write logfile status
_ini.add_entry("Options","LogFileEnabled",OpenFlipper::Options::logFileEnabled() );
//write logfile location
_ini.add_entry("Options","LogFileLocation",OpenFlipper::Options::logFile() );
//============================================================================ //============================================================================
// other // other
//============================================================================ //============================================================================
......
...@@ -151,7 +151,7 @@ void Core::applyOptions(){ ...@@ -151,7 +151,7 @@ void Core::applyOptions(){
//setup logFile //setup logFile
if (logFile_ != 0){ if (logFile_ != 0){
if (OpenFlipper::Options::logFile() != logFile_->fileName() ){ if ( OpenFlipperSettings().value("Core/Log/logFile").toString() != logFile_->fileName() ){
logFile_->close(); logFile_->close();
delete logFile_; delete logFile_;
logFile_ = 0; logFile_ = 0;
......
...@@ -51,10 +51,10 @@ ...@@ -51,10 +51,10 @@
//== INCLUDES ================================================================= //== INCLUDES =================================================================
// -------------------- mview
#include "Logging.hh" #include "Logging.hh"
// -------------------- ACG
#include "OpenFlipper/common/GlobalOptions.hh" #include <QStringList>
//== IMPLEMENTATION ========================================================== //== IMPLEMENTATION ==========================================================
......
...@@ -214,12 +214,6 @@ static QString updateUsername_ = ""; ...@@ -214,12 +214,6 @@ static QString updateUsername_ = "";
/// Password for updates /// Password for updates
static QString updatePassword_ = ""; static QString updatePassword_ = "";
/// enable logging to file
static bool logFileEnabled_;
/// logfile location (path + filename)
static QString logFile_;
/// last used DataType /// last used DataType
static QString lastDataType_ = "Triangle Mesh"; static QString lastDataType_ = "Triangle Mesh";
...@@ -714,22 +708,6 @@ void debug(bool _debug ) { ...@@ -714,22 +708,6 @@ void debug(bool _debug ) {
debug_ = _debug; debug_ = _debug;
} }
void logFileEnabled(bool _enable ){
logFileEnabled_ = _enable;
}
bool logFileEnabled(){
return logFileEnabled_;
}
void logFile(QString _filename){
logFile_ = _filename;
}
QString logFile(){
return logFile_;
}
bool backupEnabled( ) { bool backupEnabled( ) {
return enableBackup_; return enableBackup_;
} }
......
...@@ -89,6 +89,10 @@ ...@@ -89,6 +89,10 @@
* * Core/Gui/glViewer/showControlWheels This setting controls if the control wheels should be visible in the glViewer (bool) * * Core/Gui/glViewer/showControlWheels This setting controls if the control wheels should be visible in the glViewer (bool)
* * Core/Gui/splash This setting controls if the splash screen is shown at startup(bool) * * Core/Gui/splash This setting controls if the splash screen is shown at startup(bool)
* *
* <b>Log Settings</b>
* * Core/Log/Logfile This is the location of the log file
* * Core/Log/logFileEnabled This controls, if logging to file is enabled
*
* <b>Mouse Controls<b>\n * <b>Mouse Controls<b>\n
* * Core/Mouse/Wheel/ZoomFactor Zoom factor used when turning the mouse wheel (double)\n * * Core/Mouse/Wheel/ZoomFactor Zoom factor used when turning the mouse wheel (double)\n
* * Core/Mouse/Wheel/ZoomFactorShift Zoom factor used when turning the mouse wheel while shift is pressed (makes zoom slower while shift is pressed) (double)\n * * Core/Mouse/Wheel/ZoomFactorShift Zoom factor used when turning the mouse wheel while shift is pressed (makes zoom slower while shift is pressed) (double)\n
...@@ -651,22 +655,6 @@ QString helpDirStr(); ...@@ -651,22 +655,6 @@ QString helpDirStr();
DLLEXPORT DLLEXPORT
void debug(bool _debug ); void debug(bool _debug );
/// enable logging to file
DLLEXPORT
void logFileEnabled(bool _enable );
/// is logging to file enabled?
DLLEXPORT
bool logFileEnabled();
/// logfile location (path + filename)
DLLEXPORT
void logFile(QString _filename);
/// logfile location (path + filename)
DLLEXPORT
QString logFile();
/** @} */ /** @} */
//=========================================================================== //===========================================================================
......
...@@ -239,10 +239,10 @@ void OptionsWidget::showEvent ( QShowEvent * /*event*/ ) { ...@@ -239,10 +239,10 @@ void OptionsWidget::showEvent ( QShowEvent * /*event*/ ) {
loggerHidden->setChecked( OpenFlipper::Options::loggerState() == OpenFlipper::Options::Hidden); loggerHidden->setChecked( OpenFlipper::Options::loggerState() == OpenFlipper::Options::Hidden);
loggerNormal->setChecked( OpenFlipper::Options::loggerState() == OpenFlipper::Options::Normal); loggerNormal->setChecked( OpenFlipper::Options::loggerState() == OpenFlipper::Options::Normal);
loggerInScene->setChecked( OpenFlipper::Options::loggerState() == OpenFlipper::Options::InScene); loggerInScene->setChecked( OpenFlipper::Options::loggerState() == OpenFlipper::Options::InScene);
enableLogFile->setChecked( OpenFlipper::Options::logFileEnabled() ); enableLogFile->setChecked( OpenFlipperSettings().value("Core/Log/logFileEnabled",true).toBool() );
//paths //paths
logFile->setText( OpenFlipper::Options::logFile() ); logFile->setText( OpenFlipperSettings().value("Core/Log/logFile").toString() );
//stereo //stereo
...@@ -552,10 +552,9 @@ void OptionsWidget::slotApply() { ...@@ -552,10 +552,9 @@ void OptionsWidget::slotApply() {
OpenFlipper::Options::loggerState( OpenFlipper::Options::InScene ); OpenFlipper::Options::loggerState( OpenFlipper::Options::InScene );
else else
OpenFlipper::Options::loggerState( OpenFlipper::Options::Normal ); OpenFlipper::Options::loggerState( OpenFlipper::Options::Normal );
OpenFlipper::Options::logFileEnabled( enableLogFile->isChecked() );
OpenFlipperSettings().setValue("Core/Log/logFileEnabled",enableLogFile->isChecked());
//paths OpenFlipperSettings().setValue("Core/Log/logFile",logFile->text());
OpenFlipper::Options::logFile( logFile->text() );
//viewer //viewer
OpenFlipperSettings().setValue("Core/Mouse/Wheel/ZoomFactor", wZoomFactor->text().toDouble()); OpenFlipperSettings().setValue("Core/Mouse/Wheel/ZoomFactor", wZoomFactor->text().toDouble());
......
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