[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdegames/lskat/src
From:       Martin Heni <martin () heni-online ! de>
Date:       2007-06-08 7:49:11
Message-ID: 1181288951.291386.31337.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 672807 by heni:

Fixed installation paths.


 M  +7 -7      deck.cpp  
 M  +35 -10    mainwindow.cpp  
 M  +12 -2     thememanager.cpp  
 M  +5 -0      thememanager.h  


--- trunk/KDE/kdegames/lskat/src/deck.cpp #672806:672807
@@ -67,7 +67,7 @@
   if (type == Jack) return Grand;
 
   // TODO: Hardcoded test
-  //return Grand;
+  return Diamond;
   return suite;
 }
 
@@ -92,15 +92,15 @@
 
 
    // TODO: Hardcoded deck
-   return;
+  // return;
    static int c[] = {
-   Ten, Spade, Seven, Diamond, Ten, Diamond, Ten, Club,  
-   Eight, Club, Nine, Club, Nine, Heart, Jack, Heart,
-   Eight, Spade, Seven, Heart, Nine, Spade, Jack, Spade,
+   Ten, Spade, Seven, Diamond, Ten, Diamond, Jack, Club, 
+   Eight, Club, Nine, Club, Nine, Heart, Jack, Diamond,
+   Eight, Spade, Seven, Heart, Nine, Spade, Ten, Club,
    Ace, Diamond, Eight, Heart, Queen, Spade, Ten, Heart,
 
-   Ace, Club, Ace, Heart, Queen, Club, Jack, Diamond,
-   King, Heart, Ace, Spade, Queen, Diamond, Jack, Club,
+   Ace, Club, Ace, Heart, Queen, Club, Jack, Heart,
+   King, Heart, Ace, Spade, Queen, Diamond, Jack, Spade,
    King, Club, Nine, Diamond, Seven, Spade, Queen, Heart,
    Eight, Diamond, Seven, Club, King, Spade, King, Diamond
    };
--- trunk/KDE/kdegames/lskat/src/mainwindow.cpp #672806:672807
@@ -44,6 +44,7 @@
 #include <kglobal.h>
 #include <ktoolbar.h>
 #include <kselectaction.h>
+#include <kapplication.h>
 
 // Application specific includes
 #include "lskatglobal.h"
@@ -63,11 +64,14 @@
 #include <config-src.h>
 
 // Forward declarations
-#define ADVANCE_PERDIOD 20
+const int ADVANCE_PERDIOD =  20;
 
 // Shortcut to access the actions
 #define ACTION(x)   (actionCollection()->action(x))
 
+// Name of the theme
+const QString THEMENAME = "default.rc";
+
 using namespace InputDevice;
 
 
@@ -76,22 +80,37 @@
           : KXmlGuiWindow(parent)
 {
   // Reset stuff
-  mDeck    = 0;
-  mEngine  = 0;
-  mDisplay = 0;
-  mView    = 0;
+  mDeck        = 0;
+  mEngine      = 0;
+  mDisplay     = 0;
+  mView        = 0;
+  mLSkatConfig = 0;
+  mCanvas      = 0;
+  mTheme       = 0;
 
+  // Add resource type to grafix
+  KGlobal::dirs()->addResourceType("lskattheme", "appdata", "grafix/");
+
   #ifdef SRC_DIR
   kDebug() << "Found SRC_DIR =" << SRC_DIR << endl;
-  KGlobal::dirs()->addResourceDir("data",QString(SRC_DIR)+QString("/grafix/"));
-  QString theme = KStandardDirs::locate("data", "default.rc");
-  kDebug() << "theme =" << theme << endl;
+  KGlobal::dirs()->addResourceDir("lskattheme",QString(SRC_DIR)+QString("/grafix/"));
   #endif
 
   // Theme file
-  mThemeDirName = KGlobal::dirs()->findResourceDir("data","default.rc");
+  mThemeDirName = KGlobal::dirs()->findResourceDir("lskattheme",THEMENAME);
   kDebug() << "THEME DIR IS " << mThemeDirName << endl;
 
+  // Check theme file
+  QString theme = KStandardDirs::locate("lskattheme", THEMENAME);
+  kDebug() << "theme file =" << theme << endl;
+  if (theme.isEmpty())
+  {
+    KMessageBox::error(this, i18n("Installation error: No theme file found."));
+    QTimer::singleShot(0, this,SLOT(close()));
+    return;
+  }
+
+
   // Create menus etc
   initGUI();
 
@@ -112,7 +131,13 @@
 
   // Theme manager
   mTheme  = new ThemeManager(mCardDir, mDeckGrafix, KCardDialog::deckSVGFilePath(mDeckGrafix), 
-                             "default.rc", this, this->width());
+                             THEMENAME, this, this->width());
+  if (mTheme->checkTheme() != 0)
+  {
+    KMessageBox::error(this, i18n("Installation error: Theme file error."));
+    QTimer::singleShot(0, this,SLOT(close()));
+    return;
+  }
 
   // Overall view
   mCanvas        = new QGraphicsScene(this);
--- trunk/KDE/kdegames/lskat/src/thememanager.cpp #672806:672807
@@ -76,6 +76,15 @@
 }
 
 
+// Check whether the theme is alright
+int ThemeManager::checkTheme()
+{
+  // Check theme
+  if (mRenderer == 0) return 1;
+  return 0; // Ok
+}
+
+
 // Force an refresh of the theme object given
 void ThemeManager::updateTheme(Themable* ob)
 {
@@ -151,13 +160,13 @@
   mThemeFile = themefile;
 
   // Process dirs
-  QString rcfile = KStandardDirs::locate("data", themefile);
+  QString rcfile = KStandardDirs::locate("lskattheme", themefile);
   kDebug() << "ThemeManager LOAD with theme "<<rcfile << endl;
 
   // Read config and SVG file for theme
   mConfig = new KConfig(rcfile, KConfig::NoGlobals);
   QString svgfile = config("general").readEntry("svgfile");
-  svgfile = KStandardDirs::locate("data", svgfile);
+  svgfile = KStandardDirs::locate("lskattheme", svgfile);
   kDebug() << "Reading SVG master file  = " << svgfile << endl;
 
   mAspectRatio     =  config("general").readEntry("aspect-ratio", 1.0);
@@ -170,6 +179,7 @@
   bool result = mRenderer->load(svgfile);
   if (!result) 
   {
+    mRenderer = 0;
     kFatal() << "Cannot open file " << svgfile << endl;
   }
 
--- trunk/KDE/kdegames/lskat/src/thememanager.h #672806:672807
@@ -214,6 +214,11 @@
       * @return The aspect ratio (x/y).
       */
     double aspectRatio() {return mAspectRatio;}
+
+    /** Check whether the theme is properly initialized.
+      * @return 0 if everything is alright
+      */
+    int checkTheme();
     
    protected:
     /** Load a pixmap from the SVG theme file. Its filename is given in the
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic