]>
cloud.milkyroute.net Git - dolphin.git/blob - src/settings/viewmodes/viewmodesettings.cpp
1 /***************************************************************************
2 * Copyright (C) 2011 by Peter Penz <peter.penz19@gmail.com> *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
18 ***************************************************************************/
20 #include "viewmodesettings.h"
22 #include "dolphin_iconsmodesettings.h"
23 #include "dolphin_detailsmodesettings.h"
24 #include "dolphin_compactmodesettings.h"
26 #define VIEWMODESETTINGS_SET_VALUE(mode, setValue, value) \
28 case ViewModeSettings::IconsMode: IconsModeSettings::setValue(value); break; \
29 case ViewModeSettings::CompactMode: CompactModeSettings::setValue(value); break; \
30 case ViewModeSettings::DetailsMode: DetailsModeSettings::setValue(value); break; \
31 default: Q_ASSERT(false); break; \
34 #define VIEWMODESETTINGS_RETURN_VALUE(mode, getValue, type) \
37 case IconsMode: value = IconsModeSettings::getValue(); break; \
38 case CompactMode: value = CompactModeSettings::getValue(); break; \
39 case DetailsMode: value = DetailsModeSettings::getValue(); break; \
40 default: value = IconsModeSettings::getValue(); \
46 ViewModeSettings::ViewModeSettings(ViewMode mode
) :
51 ViewModeSettings::~ViewModeSettings()
55 void ViewModeSettings::setIconSize(int size
) const
57 VIEWMODESETTINGS_SET_VALUE(m_mode
, setIconSize
, size
);
60 int ViewModeSettings::iconSize() const
62 VIEWMODESETTINGS_RETURN_VALUE(m_mode
, iconSize
, int);
65 void ViewModeSettings::setPreviewSize(int size
) const
67 VIEWMODESETTINGS_SET_VALUE(m_mode
, setPreviewSize
, size
);
70 int ViewModeSettings::previewSize() const
72 VIEWMODESETTINGS_RETURN_VALUE(m_mode
, previewSize
, int);
75 void ViewModeSettings::setUseSystemFont(bool flag
)
77 VIEWMODESETTINGS_SET_VALUE(m_mode
, setUseSystemFont
, flag
);
80 bool ViewModeSettings::useSystemFont() const
82 VIEWMODESETTINGS_RETURN_VALUE(m_mode
, useSystemFont
, bool);
85 void ViewModeSettings::setFontFamily(const QString
& fontFamily
)
87 VIEWMODESETTINGS_SET_VALUE(m_mode
, setFontFamily
, fontFamily
);
90 QString
ViewModeSettings::fontFamily() const
92 VIEWMODESETTINGS_RETURN_VALUE(m_mode
, fontFamily
, QString
);
95 void ViewModeSettings::setFontSize(qreal fontSize
)
97 VIEWMODESETTINGS_SET_VALUE(m_mode
, setFontSize
, fontSize
);
100 qreal
ViewModeSettings::fontSize() const
102 VIEWMODESETTINGS_RETURN_VALUE(m_mode
, fontSize
, qreal
);
105 void ViewModeSettings::setItalicFont(bool italic
)
107 VIEWMODESETTINGS_SET_VALUE(m_mode
, setItalicFont
, italic
);
110 bool ViewModeSettings::italicFont() const
112 VIEWMODESETTINGS_RETURN_VALUE(m_mode
, italicFont
, bool);
115 void ViewModeSettings::setFontWeight(int fontWeight
)
117 VIEWMODESETTINGS_SET_VALUE(m_mode
, setFontWeight
, fontWeight
);
120 int ViewModeSettings::fontWeight() const
122 VIEWMODESETTINGS_RETURN_VALUE(m_mode
, fontWeight
, int);
125 void ViewModeSettings::readConfig()
128 case ViewModeSettings::IconsMode
: IconsModeSettings::self()->load(); break;
129 case ViewModeSettings::CompactMode
: CompactModeSettings::self()->load(); break;
130 case ViewModeSettings::DetailsMode
: DetailsModeSettings::self()->load(); break;
131 default: Q_ASSERT(false); break;
135 void ViewModeSettings::save()
138 case ViewModeSettings::IconsMode
: IconsModeSettings::self()->save(); break;
139 case ViewModeSettings::CompactMode
: CompactModeSettings::self()->save(); break;
140 case ViewModeSettings::DetailsMode
: DetailsModeSettings::self()->save(); break;
141 default: Q_ASSERT(false); break;