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

List:       kde-commits
Subject:    branches/work/soc-parley/parley/practice
From:       David Capel <wot.narg () gmail ! com>
Date:       2008-06-10 20:46:42
Message-ID: 1213130802.719835.18277.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 819269 by capel:

Now uses KGameTheme and desktop files to load themes. Loading themes works.
A few other changes to improve themeing support.

Current task:
make it use the loaded svg correct ;)



 M  +13 -6     CMakeLists.txt  
 D             defaulttheme (directory)  
 M  +1 -1      kgametheme/kgametheme.cpp  
 M  +2 -2      kgametheme/kgamethemeselector.cpp  
 M  +4 -0      parleypractice.kcfg  
 M  +25 -3     parleypracticemainwindow.cpp  
 M  +1 -1      parleypracticemainwindow.h  
 M  +3 -0      practiceprefs.cpp  
 M  +20 -0     practiceprefs.h  
 M  +1 -2      practiceprefs.kcfgc  
 M  +12 -9     statistics.cpp  
 M  +1 -1      statistics.h  
 A             themes (directory)  
 A             themes/default.desktop  
 AM            themes/default_theme.svgz  


--- branches/work/soc-parley/parley/practice/CMakeLists.txt #819268:819269
@@ -13,8 +13,16 @@
 #    defaulttheme/vocabularycard.cpp
 #)
 
+set(kgametheme_SRCS
+	kgametheme/kgametheme.cpp
+    kgametheme/kgamethemeselector.cpp)
+
+
+kde4_add_ui_files(kgametheme_SRCS kgametheme/kgamethemeselector.ui )
+
 set(parleypractice_SRCS
  #   ${defaulttheme_SRCS}
+    ${kgametheme_SRCS}
     main.cpp
     parleypracticemainwindow.cpp
     input.cpp
@@ -27,9 +35,8 @@
     practiceprefs.cpp
     entryfilter.cpp
 )
+kde4_add_ui_files(parleypractice_SRCS entryfilter.ui)
 
-kde4_add_ui_files(parleypractice_SRCS entryfilter.ui )
-
 kde4_add_kcfg_files(parleypractice_SRCS practiceprefs.kcfgc)
 
 kde4_add_executable(parleypractice ${parleypractice_SRCS})
@@ -37,7 +44,7 @@
 target_link_libraries(
     parleypractice
     keduvocdocument
-#     ${KDE4_KNEWSTUFF2_LIBS}
+    ${KDE4_KNEWSTUFF2_LIBS}
     ${KDE4_PHONON_LIBS}
     ${KDE4_KDEUI_LIBS}
 )
@@ -45,7 +52,7 @@
 install(TARGETS parleypractice  DESTINATION ${BIN_INSTALL_DIR} )
 install(FILES parleypracticeui.rc
         DESTINATION  ${DATA_INSTALL_DIR}/parleypractice/)
-install( FILES defaulttheme/layout.svgz
-	       defaulttheme/widgets.svgz	
-    DESTINATION  ${DATA_INSTALL_DIR}/parley/defaulttheme/ )
+install( FILES themes/default_theme.svgz
+                themes/default.desktop
+    DESTINATION  ${DATA_INSTALL_DIR}/parley/themes/ )
 
--- branches/work/soc-parley/parley/practice/kgametheme/kgametheme.cpp #819268:819269
@@ -68,7 +68,7 @@
         kDebug(11000) << "Refusing to load theme with no name";
         return false;
     }
-    QString filePath = KStandardDirs::locate("appdata", fileName);
+    QString filePath = KStandardDirs::locate("data", fileName); // TODO change this \
back to appdata  kDebug(11000) << "Attempting to load .desktop at" << filePath;
     if (filePath.isEmpty()) {
         return false;
--- branches/work/soc-parley/parley/practice/kgametheme/kgamethemeselector.cpp \
#819268:819269 @@ -25,7 +25,7 @@
 #include <knewstuff2/engine.h>
 #include <KComponentData>
 
-#include "ui_kgamethemeselector.h"
+#include "../ui_kgamethemeselector.h"
 #include "kgametheme.h"
 
 class KGameThemeSelector::KGameThemeSelectorPrivate
@@ -159,4 +159,4 @@
     qDeleteAll(entries);
 }
 
-#include "kgamethemeselector.moc"
+#include "../kgamethemeselector.moc"
--- branches/work/soc-parley/parley/practice/parleypractice.kcfg #819268:819269
@@ -7,6 +7,10 @@
   <kcfgfile name="parleypracticerc"/>
 
   <group name="PracticeOptions">
+    <entry name="Theme" type="String">
+      <label>Practice theme to use</label>
+      <default>default</default>
+    </entry>
     <entry name="Block" type="Bool">
       <label>In Blocking Query Tab Dialog, if checked then the Query is \
blocked</label>  <default>false</default>
--- branches/work/soc-parley/parley/practice/parleypracticemainwindow.cpp \
#819268:819269 @@ -34,6 +34,7 @@
 #include <KActionCollection>
 #include <KActionMenu>
 #include <KLocalizedString>
+#include <KConfigDialog>
 
 #include "input.h"
 #include "prompt.h"
@@ -42,7 +43,13 @@
 #include "hint.h"
 #include "testentrymanager.h"
 #include "answervalidator.h"
+#include "practiceprefs.h"
 
+#include "kgametheme/kgamethemeselector.h"
+#include "kgametheme/kgametheme.h"
+
+
+
 #include "../../libkdeedu/keduvocdocument/keduvocexpression.h"
 #include "../../libkdeedu/keduvocdocument/keduvoctranslation.h"
 #include "../../libkdeedu/keduvocdocument/keduvocdocument.h"
@@ -62,10 +69,14 @@
     m_view->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
     m_view->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
 
+    //KGameThemeSelector
 
+    
      QGraphicsSvgItem * backgroundsvg = new QGraphicsSvgItem();
      KSvgRenderer * krenderer = new KSvgRenderer();
-     krenderer->load(KStandardDirs::locate("data", \
"parley/defaulttheme/layout.svgz")); +     KGameTheme kgtheme;
+     kgtheme.load("parley/themes/default.desktop");
+     krenderer->load(kgtheme.graphics());
      backgroundsvg->setSharedRenderer(krenderer);
      scene->addItem(backgroundsvg);
      m_backgroundRect = backgroundsvg->boundingRect();
@@ -86,7 +97,7 @@
     // take the last file, but there are File1..n and Name1..n entries..
     QString sourceFile = \
recentFilesGroup.readEntry(recentFilesGroup.keyList().value(recentFilesGroup.keyList().count() \
/ 2 - 1), QString());  
-    int code = doc->open(sourceFile);
+    int code = doc->open(sourceFile); 
     kDebug() << code;
 
     // this is the only object/widget the window directly keeps track of (outside of \
the canvas, etc). @@ -107,7 +118,7 @@
     QGraphicsProxyWidget * ginput = scene->addWidget(input);
 
     Statistics * stats = new Statistics(this);
-    SvgBarStatistics * barstats = new \
SvgBarStatistics(backgroundsvg->renderer()->boundsOnElement("progress_bar_background"));
 +    SvgBarStatistics * barstats = new SvgBarStatistics(backgroundsvg->renderer());
     scene->addItem(barstats);
     connect(stats, SIGNAL(signalUpdateDisplay(Statistics*)), barstats, \
                SLOT(slotUpdateDisplay(Statistics*)));
     connect(m_manager, SIGNAL(signalExpressionChanged(KEduVocExpression*)), stats, \
SLOT(slotSetExpression(KEduVocExpression*))); @@ -190,6 +201,9 @@
     connect(continueAction, SIGNAL(triggered()), input, SLOT(slotClear()));
     continueAction->setVisible(false);
 
+    KAction *prefsAct = KStandardAction::preferences(this, \
SLOT(slotCreatePreferencesDialog()), +                                       \
actionCollection()); +
     //// Final Graphics Setup ////
 
     gpromptAndInput->setPos(m_backgroundRect.width() / 2.0, \
m_backgroundRect.height() / 2.0); @@ -216,6 +230,14 @@
     emit signalShowSolution(m_manager->currentSolution());
 }
 
+void ParleyPracticeMainWindow::slotCreatePreferencesDialog()
+{
+    KConfigDialog *dialog = new KConfigDialog(this, "settings", \
PracticePrefs::self()); +    dialog->addPage(new KGameThemeSelector(dialog, \
PracticePrefs::self()), i18n("Theme"), "game_theme"); +    kDebug() << "hit";
+    dialog->show();
+}
+
 // this one is a mouthful...
 void ParleyPracticeMainWindow::slotToggleShowSolutionContinueActions()
 {
--- branches/work/soc-parley/parley/practice/parleypracticemainwindow.h \
#819268:819269 @@ -50,7 +50,7 @@
         void slotGetInput(const QString& input);
         void slotShowSolution();
         void slotToggleShowSolutionContinueActions();
-        
+        void slotCreatePreferencesDialog();        
     signals:
         void signalCheckInput(const QString&, const QString&);
         void signalShowSolution(const QString&);
--- branches/work/soc-parley/parley/practice/practiceprefs.cpp #819268:819269
@@ -31,6 +31,9 @@
   s_globalPracticePrefs->q = this;
   setCurrentGroup( QLatin1String( "PracticeOptions" ) );
 
+  KConfigSkeleton::ItemString  *itemTheme;
+  itemTheme = new KConfigSkeleton::ItemString( currentGroup(), QLatin1String( \
"Theme" ), mTheme, QLatin1String( "default" ) ); +  addItem( itemTheme, \
QLatin1String( "Theme" ) );  KConfigSkeleton::ItemBool  *itemBlock;
   itemBlock = new KConfigSkeleton::ItemBool( currentGroup(), QLatin1String( "Block" \
), mBlock, false );  addItem( itemBlock, QLatin1String( "Block" ) );
--- branches/work/soc-parley/parley/practice/practiceprefs.h #819268:819269
@@ -30,6 +30,25 @@
     ~PracticePrefs();
 
     /**
+      Set Practice theme to use
+    */
+    static
+    void setTheme( const QString & v )
+    {
+      if (!self()->isImmutable( QString::fromLatin1 ( "Theme" ) ))
+        self()->mTheme = v;
+    }
+
+    /**
+      Get Practice theme to use
+    */
+    static
+    QString theme()
+    {
+      return self()->mTheme;
+    }
+
+    /**
       Set In Blocking Query Tab Dialog, if checked then the Query is blocked
     */
     static
@@ -1023,6 +1042,7 @@
 
 
     // PracticeOptions
+    QString mTheme;
     bool mBlock;
     bool mExpire;
     bool mAltLearn;
--- branches/work/soc-parley/parley/practice/practiceprefs.kcfgc #819268:819269
@@ -1,5 +1,4 @@
-# Code generation options for kconfig_compiler
 File=parleypractice.kcfg
-ClassName=PracticePrefs
 Singleton=true
 Mutators=true
+ClassName=PracticePrefs
\ No newline at end of file
--- branches/work/soc-parley/parley/practice/statistics.cpp #819268:819269
@@ -47,14 +47,12 @@
     display(0.0);
 }
 
-SvgBarStatistics::SvgBarStatistics(const QRectF& background, QGraphicsItem * parent)
-    : QGraphicsSvgItem(parent),
-      m_backgroundRect(background)
+SvgBarStatistics::SvgBarStatistics(QSvgRenderer* renderer, QGraphicsItem * parent)
+    : QGraphicsSvgItem(parent)
 {
-    KSvgRenderer * krenderer = new KSvgRenderer();
-    krenderer->load(KStandardDirs::locate("data", \
                "parley/defaulttheme/widgets.svgz"));
-    setSharedRenderer(krenderer);
-    setElementId("progress_bar");
+    setSharedRenderer(renderer);
+    setElementId("percent_correct_bar");
+    m_backgroundRect = renderer->boundsOnElement("percent_correct_background");
     setPos(m_backgroundRect.x(), m_backgroundRect.y());
     scale((m_backgroundRect.width())/boundingRect().width(), 1.0);
     kDebug() << boundingRect() << scenePos();
@@ -219,8 +217,13 @@
 
 void SvgBarStatistics::slotUpdateDisplay(Statistics*stats)
 {
-    kDebug() << boundingRect();
-    kDebug() << stats->percentCorrect() << "*" << m_backgroundRect.width() << "/" << \
mapToScene(boundingRect()).boundingRect().width() << "="; +    if \
(stats->percentCorrect() == 0.0) +    {
+        setVisible(false);
+        return;
+    }
+    else if (isVisible() && stats->percentCorrect() != 0.0)
+        setVisible(true);
     scale((m_backgroundRect.width() * \
stats->percentCorrect())/mapToScene(boundingRect()).boundingRect().width(), 1.0);  }
 
--- branches/work/soc-parley/parley/practice/statistics.h #819268:819269
@@ -190,7 +190,7 @@
     Q_OBJECT
 
     public:
-        SvgBarStatistics(const QRectF& background, QGraphicsItem * parent = 0);
+        SvgBarStatistics(QSvgRenderer * renderer, QGraphicsItem * parent = 0);
         ~SvgBarStatistics();
         
     public slots:
** branches/work/soc-parley/parley/practice/themes/default_theme.svgz #property \
svn:mime-type  + application/octet-stream


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

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