[Kde-games-devel] Breaking config files for card games
Andreas Pakulat
apaku at gmx.de
Fri Dec 7 16:05:50 CET 2007
On 04.12.07 23:13:05, Andreas Pakulat wrote:
> Hi,
>
> while trying to fix the card-selection related problems I've found that
> KCardDialog already provides means to read from and write to a config
> file (or rather config group). Unfortunately neither kpat nor lskat take
> advantage of that and this means they don't persist all things from the
> dialog (like the checkboxes).
>
> Unfortunately fixing that breaks existing config files, which means this
> should be done before the 4.0.0 release, not afterwards.
>
> The question I have is: Can I just do that? It only affects beta-users
> and it only forces them to open the config dialog for cards one more
> time.
No objections to that so far, thus I've done the change. I didn't commit
yet, wanted to let people have a look at the diff.
BTW: This showed a few more small errors in the dialog.
Andreas
--
So this is it. We're going to die.
-------------- next part --------------
Index: lskat/src/mainwindow.cpp
===================================================================
--- lskat/src/mainwindow.cpp (revision 745798)
+++ lskat/src/mainwindow.cpp (working copy)
@@ -251,8 +251,6 @@
// Program data
KConfigGroup cfg = config->group("ProgramData");
- cfg.writeEntry("cards", mCardDir);
- cfg.writeEntry("deck", mDeckGrafix);
cfg.writeEntry("startplayer", mStartPlayer);
cfg.writeEntry("ThemeIndexNo", mThemeIndexNo);
@@ -279,8 +277,8 @@
QString dd = KCardDialog::defaultDeckName();
// Read card path
- mCardDir = cfg.readEntry("cards", dcd);
- mDeckGrafix = cfg.readEntry("deck", dd);
+ mCardDir = cfg.readEntry("Cardname", dcd);
+ mDeckGrafix = cfg.readEntry("Deckname", dd);
// Check for path existence
QFile file(KCardDialog::deckFilename(mDeckGrafix));
@@ -545,23 +543,27 @@
QString back = mDeckGrafix;
int result;
- result=KCardDialog::getCardDeck(front, back, this, true, true, false, false);
+ KConfigGroup grp = KGlobal::config()->group("ProgramData");
+ KCardDialog dlg(grp);
+ result=dlg.exec();
if (result==QDialog::Accepted)
{
if (global_debug > 0) kDebug() << "NEW CARDDECK:" << front << "and" << back;
bool change = false; // Avoid unnecessary changes
- if (!back.isEmpty() && back != mDeckGrafix)
+ if (!dlg.deckName().isEmpty() && dlg.deckName() != mDeckGrafix)
{
- mDeckGrafix = back;
+ mDeckGrafix = dlg.deckName();
change = true;
}
- if (!front.isEmpty() && front != mCardDir)
+ if (!dlg.cardName().isEmpty() && dlg.cardName() != mCardDir)
{
- mCardDir = front;
+ mCardDir = dlg.cardName();
change = true;
}
if (change)
{
+ dlg.saveSettings(grp);
+ grp.sync();
mTheme->updateCardTheme(KCardDialog::cardDir(mCardDir),
KCardDialog::deckFilename(mDeckGrafix),
KCardDialog::deckSVGFilePath(mDeckGrafix));
Index: kpat/pwidget.cpp
===================================================================
--- kpat/pwidget.cpp (revision 745798)
+++ kpat/pwidget.cpp (working copy)
@@ -240,15 +240,26 @@
KSharedConfig::Ptr config = KGlobal::config();
KConfigGroup cs(config, settings_group);
QString deckName, oldDeckName, dummy;
- deckName = oldDeckName = cs.readEntry("Theme");
+ deckName = oldDeckName = cs.readEntry("Cardname");
- int result = KCardDialog::getCardDeck(deckName, dummy, this, true, false);
+ // This makes sure that the dialog doesn't allow to change to non-svg themes
+ // or change the back. The latter is unsupported in kpat in KDE 4.0 and the
+ // former seems to be not wanted by the author.
+ // This should be removed for KDE4.1, when kpat starts to support changing
+ // the backside
+ // apaku at gmx.de
+ cs.writeEntry("Fixed", false);
+ cs.writeEntry("Scaled", true);
+ cs.writeEntry("Locking", true);
+
+ KCardDialog dlg(cs);
+ int result = dlg.exec();
if (result == QDialog::Accepted)
{
if (deckName != oldDeckName) {
- cs.writeEntry("Theme", deckName);
-
+ dlg.saveSettings(cs);
+ cs.sync();
cardMap::self()->updateTheme(cs);
cardMap::self()->triggerRescale();
}
Index: kpat/cardmaps.cpp
===================================================================
--- kpat/cardmaps.cpp (revision 745798)
+++ kpat/cardmaps.cpp (working copy)
@@ -240,7 +240,7 @@
d->m_thread->finish();
d->m_thread->reset();
- QString theme = cs.readEntry( "Theme", "Oxygen (SVG)" );
+ QString theme = cs.readEntry( "Cardname", "Oxygen (SVG)" );
d->m_cardDeck = KCardDialog::cardDir(theme);
if( d->m_cardDeck.isEmpty() )
More information about the kde-games-devel
mailing list