1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
|
/*
* Copyright (C) 2009, 2010 Nicolas Bonnefon and other contributors
*
* This file is part of glogg.
*
* glogg is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* glogg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with glogg. If not, see <http://www.gnu.org/licenses/>.
*/
#include <QFontInfo>
#include "log.h"
#include "configuration.h"
Configuration::Configuration()
{
// Should have some sensible default values.
mainFont_ = QFont("mono", 10);
mainFont_.setStyleHint( QFont::Courier, QFont::PreferOutline );
mainRegexpType_ = ExtendedRegexp;
quickfindRegexpType_ = ExtendedRegexp;
overviewVisible_ = true;
QFontInfo fi(mainFont_);
LOG(logDEBUG) << "Default font is " << fi.family().toStdString();
}
// Accessor functions
QFont Configuration::mainFont() const
{
return mainFont_;
}
void Configuration::setMainFont( QFont newFont )
{
LOG(logDEBUG) << "Configuration::setMainFont";
mainFont_ = newFont;
}
void Configuration::retrieveFromStorage( QSettings& settings )
{
LOG(logDEBUG) << "Configuration::retrieveFromStorage";
// Fonts
QString family = settings.value( "mainFont.family" ).toString();
int size = settings.value( "mainFont.size" ).toInt();
// If no config read, keep the default
if ( !family.isNull() )
mainFont_ = QFont( family, size );
// Regexp types
mainRegexpType_ = static_cast<SearchRegexpType>(
settings.value( "regexpType.main", mainRegexpType_ ).toInt() );
quickfindRegexpType_ = static_cast<SearchRegexpType>(
settings.value( "regexpType.quickfind", quickfindRegexpType_ ).toInt() );
// View settings
if ( settings.contains( "view.overviewVisible" ) )
overviewVisible_ = settings.value( "view.overviewVisible" ).toBool();
}
void Configuration::saveToStorage( QSettings& settings ) const
{
LOG(logDEBUG) << "Configuration::saveToStorage";
QFontInfo fi(mainFont_);
settings.setValue( "mainFont.family", fi.family() );
settings.setValue( "mainFont.size", fi.pointSize() );
settings.setValue( "regexpType.main", static_cast<int>( mainRegexpType_ ) );
settings.setValue( "regexpType.quickfind", static_cast<int>( quickfindRegexpType_ ) );
settings.setValue( "view.overviewVisible", overviewVisible_ );
}
|