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 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113
|
/*
KMix -- KDE's full featured mini mixer
Copyright (C) 2012 Christian Esken <esken@kde.org>
This program 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 2 of the License, or
(at your option) any later version.
This program 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 this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "GlobalConfig.h"
// instanceObj must be created "late", so we can refer to the correct application config file kmixrc instead of kderc.
GlobalConfig* GlobalConfig::instanceObj;
GlobalConfig::GlobalConfig() :
KConfigSkeleton("kmixrc")
{
setCurrentGroup("Global");
// General
addItemBool("Tickmarks", data.showTicks, true);
addItemBool("Labels", data.showLabels, true);
addItemBool("VolumeOverdrive", data.volumeOverdrive, false);
addItemBool("VolumeFeedback", data.beepOnVolumeChange, true);
addItemString("VolumePercentageStep", data.VolumePercentageStep, "5");
// ItemString* is =
addItemString("Orientation", data.orientationMainGUIString, "Vertical");
// qCDebug(KMIX_LOG) << is->name() << is->value();
addItemString("Orientation.TrayPopup", data.orientationTrayPopupString, QLatin1String("Vertical"));
// Sound Menu
addItemBool("showOSD", data.showOSD, true);
addItemBool("AllowDocking", data.showDockWidget, true);
// addItemBool("TrayVolumeControl", data.trayVolumePopupEnabled, true); // removed support in KDE4.13. Always active!
// Startup
addItemBool("AutoStart", data.allowAutostart, true);
addItemBool("VolumeFeedback", data.volumeFeedback, true);
addItemBool("startkdeRestore", data.startkdeRestore, true);
// Debug options: Not in dialog
addItemBool("Debug.ControlManager", data.debugControlManager, false);
addItemBool("Debug.GUI", data.debugGUI, false);
addItemBool("Debug.Volume", data.debugVolume, false);
addItemBool("Debug.Config", data.debugConfig, false);
load();
}
// --- Special READ/WRITE ----------------------------------------------------------------------------------------
void GlobalConfig::usrReadConfig()
{
// qCDebug(KMIX_LOG) << "or=" << data.orientationMainGUIString;
// Convert orientation strings to Qt::Orientation
data.convertOrientation();
}
//void GlobalConfig::usrWriteConfig()
//{
// // TODO: Is this any good? When is usrWriteConfig() called? Hopefully BEFORE actually writing. Otherwise
// // I must move this code to #setToplevelOrientation() and #setTraypopupOrientation().
//}
Qt::Orientation GlobalConfigData::getToplevelOrientation()
{
return toplevelOrientation;
}
Qt::Orientation GlobalConfigData::getTraypopupOrientation()
{
return traypopupOrientation;
}
/**
* Converts the orientation strings to Qt::Orientation
*/
void GlobalConfigData::convertOrientation()
{
toplevelOrientation = stringToOrientation(orientationMainGUIString);
traypopupOrientation = stringToOrientation(orientationTrayPopupString);
}
void GlobalConfigData::setToplevelOrientation(Qt::Orientation orientation)
{
toplevelOrientation = orientation;
orientationMainGUIString = orientationToString(toplevelOrientation);
}
void GlobalConfigData::setTraypopupOrientation(Qt::Orientation orientation)
{
traypopupOrientation = orientation;
orientationTrayPopupString = orientationToString(traypopupOrientation);
}
Qt::Orientation GlobalConfigData::stringToOrientation(QString& orientationString)
{
return orientationString == "Horizontal" ? Qt::Horizontal : Qt::Vertical;
}
QString GlobalConfigData::orientationToString(Qt::Orientation orientation)
{
return orientation == Qt::Horizontal ? "Horizontal" : "Vertical";
}
|