Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 1c5f94e7 authored by Scott Wheeler's avatar Scott Wheeler

Switch from KConfigGroupSaver to KConfigGroup

svn path=/trunk/kdemultimedia/juk/; revision=318605
parent 41c7ce44
......@@ -240,88 +240,90 @@ void JuK::keyPressEvent(QKeyEvent *e)
void JuK::readSettings()
{
KConfig *config = KGlobal::config();
{ // general settings
KConfigGroupSaver saver(config, "Settings");
m_showSplash = config->readBoolEntry("ShowSplashScreen", true);
m_startDocked = config->readBoolEntry("StartDocked", false);
}
KConfigGroup config(KGlobal::config(), "Settings");
m_showSplash = config.readBoolEntry("ShowSplashScreen", true);
m_startDocked = config.readBoolEntry("StartDocked", false);
}
void JuK::readConfig()
{
// Automagically save and m_restore many window settings.
setAutoSaveSettings();
KConfig *config = KGlobal::config();
{ // player settings
KConfigGroupSaver saver(config, "Player");
if(m_sliderAction->volumeSlider()) {
int maxVolume = m_sliderAction->volumeSlider()->maxValue();
int volume = config->readNumEntry("Volume", maxVolume);
m_sliderAction->volumeSlider()->setVolume(volume);
}
bool randomPlay = config->readBoolEntry("RandomPlay", false);
m_randomPlayAction->setChecked(randomPlay);
bool loopPlaylist = config->readBoolEntry("LoopPlaylist", false);
ActionCollection::action<KToggleAction>("loopPlaylist")->setChecked(loopPlaylist);
}
{ // view settings
KConfigGroupSaver saver(config, "View");
// player settings
// The history list will actually be created by the playlist restoration
// code, but we want to remember the checkbox's setting and hope that
// it's in synch with the code that does the real work.
KConfigGroup playerConfig(KGlobal::config(), "Player");
bool showHistory = config->readBoolEntry("ShowHistory", false);
m_showHistoryAction->setChecked(showHistory);
if(m_sliderAction->volumeSlider()) {
int maxVolume = m_sliderAction->volumeSlider()->maxValue();
int volume = playerConfig.readNumEntry("Volume", maxVolume);
m_sliderAction->volumeSlider()->setVolume(volume);
}
{ // general settings
KConfigGroupSaver saver(config, "Settings");
bool dockInSystemTray = config->readBoolEntry("DockInSystemTray", true);
m_toggleSystemTrayAction->setChecked(dockInSystemTray);
bool randomPlay = playerConfig.readBoolEntry("RandomPlay", false);
m_randomPlayAction->setChecked(randomPlay);
bool dockOnClose = config->readBoolEntry("DockOnClose", true);
m_toggleDockOnCloseAction->setChecked(dockOnClose);
bool loopPlaylist = playerConfig.readBoolEntry("LoopPlaylist", false);
ActionCollection::action<KToggleAction>("loopPlaylist")->setChecked(loopPlaylist);
bool showPopups = config->readBoolEntry("TrackPopup", false);
m_togglePopupsAction->setChecked(showPopups);
// view settings
if(m_outputSelectAction)
m_outputSelectAction->setCurrentItem(config->readNumEntry("MediaSystem", 0));
}
KConfigGroup viewConfig(KGlobal::config(), "View");
// The history list will actually be created by the playlist restoration
// code, but we want to remember the checkbox's setting and hope that
// it's in synch with the code that does the real work.
bool showHistory = viewConfig.readBoolEntry("ShowHistory", false);
m_showHistoryAction->setChecked(showHistory);
// general settings
KConfigGroup settingsConfig(KGlobal::config(), "Settings");
bool dockInSystemTray = settingsConfig.readBoolEntry("DockInSystemTray", true);
m_toggleSystemTrayAction->setChecked(dockInSystemTray);
bool dockOnClose = settingsConfig.readBoolEntry("DockOnClose", true);
m_toggleDockOnCloseAction->setChecked(dockOnClose);
bool showPopups = settingsConfig.readBoolEntry("TrackPopup", false);
m_togglePopupsAction->setChecked(showPopups);
if(m_outputSelectAction)
m_outputSelectAction->setCurrentItem(settingsConfig.readNumEntry("MediaSystem", 0));
m_toggleSplashAction->setChecked(m_showSplash);
}
void JuK::saveConfig()
{
KConfig *config = KGlobal::config();
{ // player settings
KConfigGroupSaver saver(config, "Player");
config->writeEntry("Volume", m_sliderAction->volumeSlider()->volume());
config->writeEntry("RandomPlay", m_randomPlayAction->isChecked());
KToggleAction *a = ActionCollection::action<KToggleAction>("loopPlaylist");
config->writeEntry("LoopPlaylist", a->isChecked());
}
{ // view settings
KConfigGroupSaver saver(config, "View");
config->writeEntry("ShowHistory", m_showHistoryAction->isChecked());
}
{ // general settings
KConfigGroupSaver saver(config, "Settings");
config->writeEntry("ShowSplashScreen", m_toggleSplashAction->isChecked());
config->writeEntry("StartDocked", m_startDocked);
config->writeEntry("DockInSystemTray", m_toggleSystemTrayAction->isChecked());
config->writeEntry("DockOnClose", m_toggleDockOnCloseAction->isChecked());
config->writeEntry("TrackPopup", m_togglePopupsAction->isChecked());
if(m_outputSelectAction)
config->writeEntry("MediaSystem", m_outputSelectAction->currentItem());
}
config->sync();
// player settings
KConfigGroup playerConfig(KGlobal::config(), "Player");
playerConfig.writeEntry("Volume", m_sliderAction->volumeSlider()->volume());
playerConfig.writeEntry("RandomPlay", m_randomPlayAction->isChecked());
KToggleAction *a = ActionCollection::action<KToggleAction>("loopPlaylist");
playerConfig.writeEntry("LoopPlaylist", a->isChecked());
// view settings
KConfigGroup viewConfig(KGlobal::config(), "View");
viewConfig.writeEntry("ShowHistory", m_showHistoryAction->isChecked());
// general settings
KConfigGroup settingsConfig(KGlobal::config(), "Settings");
settingsConfig.writeEntry("ShowSplashScreen", m_toggleSplashAction->isChecked());
settingsConfig.writeEntry("StartDocked", m_startDocked);
settingsConfig.writeEntry("DockInSystemTray", m_toggleSystemTrayAction->isChecked());
settingsConfig.writeEntry("DockOnClose", m_toggleDockOnCloseAction->isChecked());
settingsConfig.writeEntry("TrackPopup", m_togglePopupsAction->isChecked());
if(m_outputSelectAction)
settingsConfig.writeEntry("MediaSystem", m_outputSelectAction->currentItem());
KGlobal::config()->sync();
}
bool JuK::queryExit()
......
......@@ -77,11 +77,9 @@ KeyDialog::KeyDialog(KGlobalAccel *keys, KActionCollection *actionCollection,
// Read key group from configuration
int selectedButton;
KConfig *config = KGlobal::config();
{
KConfigGroupSaver saver(config, "Shortcuts");
selectedButton = config->readNumEntry("GlobalKeys", StandardKeys);
}
KConfigGroup config(KGlobal::config(), "Shortcuts");
selectedButton = config.readNumEntry("GlobalKeys", StandardKeys);
// Create widgets for key chooser - widget stack used to replace key chooser
......@@ -134,12 +132,11 @@ int KeyDialog::configure()
int retcode = exec();
if(retcode == Accepted) {
KConfig *config = KGlobal::config();
{
KConfigGroupSaver saver(config, "Shortcuts");
config->writeEntry("GlobalKeys", m_group->id(m_group->selected()));
config->sync();
}
KConfigGroup config(KGlobal::config(), "Shortcuts");
config.writeEntry("GlobalKeys", m_group->id(m_group->selected()));
KGlobal::config()->sync();
m_pKeyChooser->save();
}
return retcode;
......
......@@ -198,47 +198,44 @@ void Playlist::SharedSettings::apply(Playlist *l) const
Playlist::SharedSettings::SharedSettings()
{
KConfig *config = kapp->config();
{
KConfigGroupSaver saver(config, "PlaylistShared");
KConfigGroup config(KGlobal::config(), "PlaylistShared");
// save column order
m_columnOrder = config->readIntListEntry("ColumnOrder");
// save column order
m_columnOrder = config.readIntListEntry("ColumnOrder");
QValueList<int> l = config->readIntListEntry("VisibleColumns");
QValueList<int> l = config.readIntListEntry("VisibleColumns");
if(l.isEmpty()) {
if(l.isEmpty()) {
// Provide some default values for column visibility if none were
// read from the configuration file.
// Provide some default values for column visibility if none were
// read from the configuration file.
for(int i = 0; i <= PlaylistItem::lastColumn(); i++) {
switch(i) {
case PlaylistItem::BitrateColumn:
case PlaylistItem::CommentColumn:
case PlaylistItem::FileNameColumn:
m_columnsVisible.append(false);
break;
default:
m_columnsVisible.append(true);
}
for(int i = 0; i <= PlaylistItem::lastColumn(); i++) {
switch(i) {
case PlaylistItem::BitrateColumn:
case PlaylistItem::CommentColumn:
case PlaylistItem::FileNameColumn:
m_columnsVisible.append(false);
break;
default:
m_columnsVisible.append(true);
}
}
else {
// Convert the int list into a bool list.
m_columnsVisible.resize(l.size(), true);
uint i = 0;
for(QValueList<int>::Iterator it = l.begin(); it != l.end(); ++it) {
if(! bool(*it))
m_columnsVisible[i] = bool(*it);
i++;
}
}
else {
// Convert the int list into a bool list.
m_columnsVisible.resize(l.size(), true);
uint i = 0;
for(QValueList<int>::Iterator it = l.begin(); it != l.end(); ++it) {
if(! bool(*it))
m_columnsVisible[i] = bool(*it);
i++;
}
m_inlineCompletion = KGlobalSettings::Completion(
config->readNumEntry("InlineCompletionMode", KGlobalSettings::CompletionAuto));
}
m_inlineCompletion = KGlobalSettings::Completion(
config.readNumEntry("InlineCompletionMode", KGlobalSettings::CompletionAuto));
}
////////////////////////////////////////////////////////////////////////////////
......@@ -247,20 +244,17 @@ Playlist::SharedSettings::SharedSettings()
void Playlist::SharedSettings::writeConfig()
{
KConfig *config = kapp->config();
{
KConfigGroupSaver saver(config, "PlaylistShared");
config->writeEntry("ColumnOrder", m_columnOrder);
KConfigGroup config(KGlobal::config(), "PlaylistShared");
config.writeEntry("ColumnOrder", m_columnOrder);
QValueList<int> l;
for(uint i = 0; i < m_columnsVisible.size(); i++)
l.append(int(m_columnsVisible[i]));
QValueList<int> l;
for(uint i = 0; i < m_columnsVisible.size(); i++)
l.append(int(m_columnsVisible[i]));
config->writeEntry("VisibleColumns", l);
config->writeEntry("InlineCompletionMode", m_inlineCompletion);
}
config.writeEntry("VisibleColumns", l);
config.writeEntry("InlineCompletionMode", m_inlineCompletion);
config->sync();
KGlobal::config()->sync();
}
////////////////////////////////////////////////////////////////////////////////
......
......@@ -207,21 +207,16 @@ void PlaylistBox::setupPlaylist(Playlist *playlist, const QString &iconName, Ite
void PlaylistBox::readConfig()
{
KConfig *config = kapp->config();
{
KConfigGroupSaver saver(config, "PlaylistBox");
m_viewModeIndex = config->readNumEntry("ViewMode", 0);
}
KConfigGroup config(KGlobal::config(), "PlaylistBox");
m_viewModeIndex = config.readNumEntry("ViewMode", 0);
}
void PlaylistBox::saveConfig()
{
KConfig *config = kapp->config();
{
KConfigGroupSaver saver(config, "PlaylistBox");
config->writeEntry("ViewMode", m_viewModeAction->currentItem());
config->sync();
}
KConfigGroup config(KGlobal::config(), "PlaylistBox");
config.writeEntry("ViewMode", m_viewModeAction->currentItem());
KGlobal::config()->sync();
}
void PlaylistBox::remove()
......
......@@ -324,20 +324,19 @@ void TagEditor::slotUpdateCollection()
void TagEditor::readConfig()
{
KConfig *config = KGlobal::config();
{ // combo box completion modes
KConfigGroupSaver saver(config, "TagEditor");
if(m_artistNameBox && m_albumNameBox) {
readCompletionMode(config, m_artistNameBox, "ArtistNameBoxMode");
readCompletionMode(config, m_albumNameBox, "AlbumNameBoxMode");
readCompletionMode(config, m_genreBox, "GenreBoxMode");
}
bool show = config->readBoolEntry("Show", false);
action<KToggleAction>("showEditor")->setChecked(show);
setShown(show);
// combo box completion modes
KConfigGroup config(KGlobal::config(), "TagEditor");
if(m_artistNameBox && m_albumNameBox) {
readCompletionMode(&config, m_artistNameBox, "ArtistNameBoxMode");
readCompletionMode(&config, m_albumNameBox, "AlbumNameBoxMode");
readCompletionMode(&config, m_genreBox, "GenreBoxMode");
}
bool show = config.readBoolEntry("Show", false);
action<KToggleAction>("showEditor")->setChecked(show);
setShown(show);
TagLib::StringList genres = TagLib::ID3v1::genreList();
for(TagLib::StringList::ConstIterator it = genres.begin(); it != genres.end(); ++it)
......@@ -350,7 +349,7 @@ void TagEditor::readConfig()
m_genreBox->completionObject()->setItems(m_genreList);
}
void TagEditor::readCompletionMode(KConfig *config, KComboBox *box, const QString &key)
void TagEditor::readCompletionMode(KConfigBase *config, KComboBox *box, const QString &key)
{
KGlobalSettings::Completion mode =
KGlobalSettings::Completion(config->readNumEntry(key, KGlobalSettings::CompletionAuto));
......@@ -360,17 +359,16 @@ void TagEditor::readCompletionMode(KConfig *config, KComboBox *box, const QStrin
void TagEditor::saveConfig()
{
KConfig *config = KGlobal::config();
{ // combo box completion modes
KConfigGroupSaver saver(config, "TagEditor");
if(m_artistNameBox && m_albumNameBox) {
config->writeEntry("ArtistNameBoxMode", m_artistNameBox->completionMode());
config->writeEntry("AlbumNameBoxMode", m_albumNameBox->completionMode());
config->writeEntry("GenreBoxMode", m_genreBox->completionMode());
}
config->writeEntry("Show", action<KToggleAction>("showEditor")->isChecked());
}
// combo box completion modes
KConfigGroup config(KGlobal::config(), "TagEditor");
if(m_artistNameBox && m_albumNameBox) {
config.writeEntry("ArtistNameBoxMode", m_artistNameBox->completionMode());
config.writeEntry("AlbumNameBoxMode", m_albumNameBox->completionMode());
config.writeEntry("GenreBoxMode", m_genreBox->completionMode());
}
config.writeEntry("Show", action<KToggleAction>("showEditor")->isChecked());
}
void TagEditor::setupActions()
......
......@@ -23,7 +23,7 @@ class KLineEdit;
class KIntSpinBox;
class KEdit;
class KPushButton;
class KConfig;
class KConfigBase;
class QCheckBox;
class QBoxLayout;
......@@ -52,7 +52,7 @@ private:
void setupActions();
void setupLayout();
void readConfig();
void readCompletionMode(KConfig *config, KComboBox *box, const QString &key);
void readCompletionMode(KConfigBase *config, KComboBox *box, const QString &key);
void saveConfig();
void save(const PlaylistItemList &list);
void saveChangesPrompt();
......
......@@ -11,9 +11,9 @@
#include <kapplication.h>
#include <kconfig.h>
#include <kdebug.h>
#include <kglobal.h>
#include <kmacroexpander.h>
FileNameScheme::FileNameScheme(const QString &s)
: m_regExp(),
m_titleField(-1),
......@@ -93,16 +93,13 @@ QString FileNameScheme::composeRegExp(const QString &s) const
{
QMap<QChar, QString> substitutions;
KConfig *cfg = kapp->config();
{
KConfigGroupSaver saver(cfg, "TagGuesser");
KConfigGroup config(KGlobal::config(), "TagGuesser");
substitutions[ 't' ] = cfg->readEntry("Title regexp", "([\\w\\s'&_,\\.]+)");
substitutions[ 'a' ] = cfg->readEntry("Artist regexp", "([\\w\\s'&_,\\.]+)");
substitutions[ 'A' ] = cfg->readEntry("Album regexp", "([\\w\\s'&_,\\.]+)");
substitutions[ 'T' ] = cfg->readEntry("Track regexp", "(\\d+)");
substitutions[ 'c' ] = cfg->readEntry("Comment regexp", "([\\w\\s_]+)");
}
substitutions[ 't' ] = config.readEntry("Title regexp", "([\\w\\s'&_,\\.]+)");
substitutions[ 'a' ] = config.readEntry("Artist regexp", "([\\w\\s'&_,\\.]+)");
substitutions[ 'A' ] = config.readEntry("Album regexp", "([\\w\\s'&_,\\.]+)");
substitutions[ 'T' ] = config.readEntry("Track regexp", "(\\d+)");
substitutions[ 'c' ] = config.readEntry("Comment regexp", "([\\w\\s_]+)");
QString regExp = QRegExp::escape(s.simplifyWhiteSpace());
regExp = ".*" + regExp;
......@@ -116,11 +113,9 @@ QStringList TagGuesser::schemeStrings()
{
QStringList schemes;
KConfig *cfg = kapp->config();
{
KConfigGroupSaver saver(cfg, "TagGuesser");
schemes = cfg->readListEntry( "Filename schemes" );
}
KConfigGroup config(KGlobal::config(), "TagGuesser");
schemes = config.readListEntry("Filename schemes");
if ( schemes.isEmpty() ) {
schemes += "%a - (%T) - %t [%c]";
schemes += "%a - (%T) - %t (%c)";
......
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