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() :
//init logFile
logStream_ = 0;
logFile_ = 0;
OpenFlipper::Options::logFileEnabled(true);
//init nodes
root_node_scenegraph_ = new ACG::SceneGraph::SeparatorNode(0, "SceneGraph Root Node");
......@@ -966,22 +965,24 @@ void Core::slotExit() {
/// log to file
void Core::slotLogToFile(Logtype _type, QString _message){
if (!OpenFlipper::Options::logFileEnabled())
if (!OpenFlipperSettings().value("Core/Log/logFileEnabled",true).toBool() )
return;
if (logStream_ == 0){
//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() )
OpenFlipper::Options::logFile(QDir::home().absolutePath() + OpenFlipper::Options::dirSeparator() + ".OpenFlipper" +
OpenFlipper::Options::dirSeparator() + "OpenFlipper.log");
if ( fileName == "" || !fi.dir().exists() ) {
OpenFlipperSettings().setValue("Core/Log/logFile", QDir::home().absolutePath() + OpenFlipper::Options::dirSeparator() + ".OpenFlipper" +
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) ) {
logStream_ = new QTextStream (logFile_);
}else{
} else {
emit log(LOGERR, tr("Unable to open logfile!"));
return;
}
......
......@@ -296,20 +296,6 @@ void Core::readApplicationOptions(INIFile& _ini) {
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
//============================================================================
......@@ -509,14 +495,6 @@ void Core::writeApplicationOptions(INIFile& _ini) {
//write default ToolboxMode
_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
//============================================================================
......
......@@ -151,7 +151,7 @@ void Core::applyOptions(){
//setup logFile
if (logFile_ != 0){
if (OpenFlipper::Options::logFile() != logFile_->fileName() ){
if ( OpenFlipperSettings().value("Core/Log/logFile").toString() != logFile_->fileName() ){
logFile_->close();
delete logFile_;
logFile_ = 0;
......
......@@ -51,10 +51,10 @@
//== INCLUDES =================================================================
// -------------------- mview
#include "Logging.hh"
// -------------------- ACG
#include "OpenFlipper/common/GlobalOptions.hh"
#include <QStringList>
//== IMPLEMENTATION ==========================================================
......
......@@ -214,12 +214,6 @@ static QString updateUsername_ = "";
/// Password for updates
static QString updatePassword_ = "";
/// enable logging to file
static bool logFileEnabled_;
/// logfile location (path + filename)
static QString logFile_;
/// last used DataType
static QString lastDataType_ = "Triangle Mesh";
......@@ -714,22 +708,6 @@ void debug(bool _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( ) {
return enableBackup_;
}
......
......@@ -89,6 +89,10 @@
* * 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)
*
* <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
* * 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
......@@ -651,22 +655,6 @@ QString helpDirStr();
DLLEXPORT
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*/ ) {
loggerHidden->setChecked( OpenFlipper::Options::loggerState() == OpenFlipper::Options::Hidden);
loggerNormal->setChecked( OpenFlipper::Options::loggerState() == OpenFlipper::Options::Normal);
loggerInScene->setChecked( OpenFlipper::Options::loggerState() == OpenFlipper::Options::InScene);
enableLogFile->setChecked( OpenFlipper::Options::logFileEnabled() );
enableLogFile->setChecked( OpenFlipperSettings().value("Core/Log/logFileEnabled",true).toBool() );
//paths
logFile->setText( OpenFlipper::Options::logFile() );
logFile->setText( OpenFlipperSettings().value("Core/Log/logFile").toString() );
//stereo
......@@ -552,10 +552,9 @@ void OptionsWidget::slotApply() {
OpenFlipper::Options::loggerState( OpenFlipper::Options::InScene );
else
OpenFlipper::Options::loggerState( OpenFlipper::Options::Normal );
OpenFlipper::Options::logFileEnabled( enableLogFile->isChecked() );
//paths
OpenFlipper::Options::logFile( logFile->text() );
OpenFlipperSettings().setValue("Core/Log/logFileEnabled",enableLogFile->isChecked());
OpenFlipperSettings().setValue("Core/Log/logFile",logFile->text());
//viewer
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