[kde-edu]: Should these fixes be backported? [PATCH]

David Capel wot.narg at gmail.com
Tue Mar 3 11:18:00 CET 2009


Here are some fixes for Parley's flashcard mode that I made to trunk
recently and I'm unsure if they should be backported to 4.2. The first
one just fixes a minor bug and shouldn't be an issue, but the second
one changes the UI slightly. My inclination is that the second one
isn't valid for backporting, but I want to make sure.

Any issues?

Thanks,
David

SVN commit 930794 by capel:

After using the flashcard mode pretty extensively, I found out that
the prompts will eat anything between < and >'s that
is put into the entry, causing confusion.

Here is a simple fix -- they are just escaped to &lt; and &gt;



 M  +3 -1      messagebox.cpp
 M  +5 -2      multiple/multipletextualprompt.cpp
 M  +4 -1      prompt/textualprompt.cpp


--- trunk/KDE/kdeedu/parley/src/practice/messagebox.cpp #930793:930794
@@ -39,5 +39,7 @@

    setTextWidth(m_backgroundRect.width()*.8);

-    setHtml("<center>" + text + "</center>");
+       QString escapedText = text;
+       escapedText.replace("<", "&lt;").replace(">", "&gt;");
+    setHtml("<center>" + escapedText + "</center>");
 }
--- trunk/KDE/kdeedu/parley/src/practice/multiple/multipletextualprompt.cpp
#930793:930794
@@ -78,11 +78,14 @@
        return;
    }

+       QString escapedText;
+
    for(int i = 0; i < texts.size(); ++i)
    {
-        m_map[m_elementIds[i]]->setHtml(texts[i]);
+               escapedText = texts[i];
+               escapedText.replace("<", "&lt;").replace(">", "&gt;");
+        m_map[m_elementIds[i]]->setHtml(escapedText);
    }
-
 }

 void MultipleTextualPrompt::slotClear()
--- trunk/KDE/kdeedu/parley/src/practice/prompt/textualprompt.cpp #930793:930794
@@ -46,7 +46,10 @@
        setHtml("");
        return;
    }
-    setHtml( "<center>" + text + "</center>" );
+
+       QString escapedText = text;
+       escapedText.replace("<", "&lt;").replace(">", "&gt;");
+       setHtml("<center>" + escapedText + "</center>");
 }

 void TextualPrompt::slotClear()



SVN commit 931142 by capel:

Various fixes for flashcard UI:
* Key shortcuts now work and are remappable.
* Clicking on the card makes it flip (as per multiple requests)
* Actions that don't make sense in flashcard mode are hidden.

Problems remaining:
* The new actions ('I know it' and 'I don't know it') don't show up in
the navigation menu. This has to do with the new
parleypracticeui.rc file not being parsed for some reason. They do,
however, show up in the shortcuts config menu.

BUG:179196



 M  +6 -0      activearea.cpp
 M  +7 -0      activearea.h
 M  +34 -8     modespecifics.cpp
 M  +5 -3      parleypracticeui.rc


--- trunk/KDE/kdeedu/parley/src/practice/activearea.cpp #931141:931142
@@ -67,6 +67,12 @@
 }


+void ActiveArea::mousePressEvent ( QGraphicsSceneMouseEvent * event )
+{
+  emit signalClicked();
+  QGraphicsItem::mousePressEvent(event);
+}
+
 QString ActiveArea::translateElementId(const QString& originalElementId)
 {
    //static QSet<QString> m_set = QSet();
--- trunk/KDE/kdeedu/parley/src/practice/activearea.h #931141:931142
@@ -40,6 +40,8 @@
 */
 class ActiveArea : public QGraphicsSvgItem
 {
+    Q_OBJECT
+
    public:
        /// It attempts to find an active area that matches @param
modeName, but falls back to @param fallbackModeName if it cannot.
        ActiveArea(KSvgRenderer * renderer, const QString& modeName,
const QString& fallbackModeName = "");
@@ -56,6 +58,11 @@
        void setActive(bool active) { m_active = active; };
        /// Access function for the active flag.
        bool active() const { return m_active; };
+
+        void mousePressEvent ( QGraphicsSceneMouseEvent * event );
+
+    signals:
+        void signalClicked();
    private:
        KSvgRenderer * m_renderer;
        QPointF m_offset;
--- trunk/KDE/kdeedu/parley/src/practice/modespecifics.cpp #931141:931142
@@ -94,20 +94,46 @@
    connect(m_manager, SIGNAL(signalNewText(const QString&)), tprompt,
SLOT(slotSetText(const QString&)));
    connect(this, SIGNAL(signalShowSolution(const QString&)), tprompt,
SLOT(slotSetText(const QString&)));

-    // flip the card on click
-    //connect(this, SIGNAL(clicked()),
actionCollection()->action("show solution"), SIGNAL(triggered()));

-    PracticeActionButton * knownButton = new
PracticeActionButton(i18n("I Know It"), m_renderer, area,
"known_button");
+    KAction *knownAction = actionCollection()->addAction("flashcard known");
+    knownAction->setText(i18n("I &Know It"));
+    knownAction->setShortcut(Qt::Key_K, KAction::DefaultShortcut);
+    knownAction->setShortcutConfigurable(true);
+    connect(knownAction, SIGNAL(triggered()), this, SLOT(slotForceCorrect()));
+
+
+    PracticeActionButton * knownButton = new
PracticeActionButton(i18n("I &Know It"), m_renderer, area,
"known_button");
    scene->addWidget(knownButton);
-    connect(knownButton, SIGNAL(clicked()), this, SLOT(slotForceCorrect()));
+    connect(knownButton, SIGNAL(clicked()), knownAction, SLOT(trigger()));

-    PracticeActionButton * unknownButton = new
PracticeActionButton(i18n("I Don't Know It"), m_renderer, area,
"unknown_button");
-    connect(unknownButton, SIGNAL(clicked()), this,
SLOT(slotForceIncorrect()));
+    KAction *unknownAction = actionCollection()->addAction("flashcard
unknown");
+    unknownAction->setText(i18n("I &Don't Know It"));
+    unknownAction->setShortcut(Qt::Key_D, KAction::DefaultShortcut);
+    unknownAction->setShortcutConfigurable(true);
+    connect(unknownAction, SIGNAL(triggered()), this,
SLOT(slotForceIncorrect()));
+
+    PracticeActionButton * unknownButton = new
PracticeActionButton(i18n("I &Don't Know It"), m_renderer, area,
"unknown_button");
+    connect(unknownButton, SIGNAL(clicked()), unknownAction, SLOT(trigger()));
    scene->addWidget(unknownButton);

-    PracticeActionButton * showSolutionButton = new
PracticeActionButton(i18n("Check"), m_renderer, area,
"show_solution_button");
-    connect(showSolutionButton, SIGNAL(clicked()), this,
SLOT(slotShowSolution()));
+    KAction *showSolutionAction = actionCollection()->addAction("show
solution");
+    showSolutionAction->setText(i18n("&Flip"));
+    showSolutionAction->setShortcut(Qt::Key_F, KAction::DefaultShortcut);
+    showSolutionAction->setShortcutConfigurable(true);
+    connect(showSolutionAction, SIGNAL(triggered()), this,
SLOT(slotShowSolution()));
+
+    PracticeActionButton * showSolutionButton = new
PracticeActionButton(i18n("&Flip"), m_renderer, area,
"show_solution_button");
+    connect(showSolutionButton, SIGNAL(clicked()),
showSolutionAction, SLOT(trigger()));
    scene->addWidget(showSolutionButton);
+
+    //flip the card on click
+    connect(area, SIGNAL(signalClicked()), showSolutionAction,
SLOT(trigger()));
+
+    // these don't make sense for flashcards
+    actionCollection()->action("skip known")->setVisible(false);
+    actionCollection()->action("skip unknown")->setVisible(false);
+    actionCollection()->action("check answer")->setVisible(false);
+    actionCollection()->action("hint")->setVisible(false);
 }


--- trunk/KDE/kdeedu/parley/src/practice/parleypracticeui.rc #931141:931142
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE kpartgui SYSTEM "kpartgui.dtd">
-<gui name="parleypractice" version="1">
+<gui name="parleypractice" version="1.1">
  <MenuBar>
    <Menu name="file">
      <Action name="stop_practice" />
@@ -11,6 +11,8 @@
      <Action name="continue" />
      <Action name="skip known" />
      <Action name="skip unknown" />
+      <Action name="flashcard known" />
+      <Action name="flashcard unknown" />
      <Action name="select option 1" />
      <Action name="select option 2" />
      <Action name="select option 3" />
@@ -21,8 +23,8 @@
      <Action name="select option 8" />
      <Action name="select option 9" />
    </Menu>
-      <Menu name="Hint" >
-      <text>Hint</text>
+      <Menu name="Solution" >
+      <text>Solution</text>
      <Action name="hint" />
      <Action name="show solution" />
    </Menu>


More information about the kde-edu mailing list