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

List:       kde-commits
Subject:    KDE/kdeedu/parley/src
From:       Daniel Laidig <d.laidig () gmx ! de>
Date:       2010-04-15 17:58:06
Message-ID: 20100415175806.6F76EAC898 () svn ! kde ! org
[Download RAW message or body]

SVN commit 1115234 by laidig:

make adding actions from the main window (such as file_close) to the toolbars possibe

to do so, these actions must be added in parleyui.rc which means that all toolbars \
are visible in all components. to work around this, i introduced code to manually \
hide all toolbars except for the current component

 M  +1 -1      editor/editorui.rc  
 M  +48 -1     parleymainwindow.cpp  
 M  +5 -0      parleymainwindow.h  
 M  +20 -0     parleyui.rc  
 M  +3 -2      practice/practicesummarycomponent.cpp  
 M  +2 -3      practice/practicesummaryui.rc  
 M  +2 -2      practice/practiceui.rc  
 M  +1 -1      statistics/statisticsui.rc  


--- trunk/KDE/kdeedu/parley/src/editor/editorui.rc #1115233:1115234
@@ -69,7 +69,7 @@
   </Menu>
  </MenuBar> 
 
- <ToolBar noMerge="1" name="editorToolBar" >
+ <ToolBar name="editorToolBar" >
   <text>Editor Toolbar</text>
   <Action name="file_open" />
   <Action name="file_save" />
--- trunk/KDE/kdeedu/parley/src/parleymainwindow.cpp #1115233:1115234
@@ -292,6 +292,7 @@
             WelcomeScreen *welcome = new WelcomeScreen(this);
             m_currentComponentWindow = welcome;
             showDocumentActions(true, false);
+//            setVisibleToolbar(QString());
             welcome->updateRecentFilesModel();
             break;
         }
@@ -299,6 +300,7 @@
             StatisticsMainWindow *statisticsWidget = new \
StatisticsMainWindow(m_document->document(), this);  m_currentComponentWindow = \
statisticsWidget;  showDocumentActions(true, true);
+//            setVisibleToolbar("statisticsToolBar");
             break;
         }
         case EditorComponent: {
@@ -306,6 +308,7 @@
             m_currentComponentWindow = editor;
             showDocumentActions(true, true);
             editor->updateDocument(m_document->document());
+//            setVisibleToolbar("editorToolBar");
             break;
         }
         case PracticeComponent: {
@@ -314,13 +317,15 @@
             connect(practiceWindow, SIGNAL(stopPractice()), this, \
SLOT(showPracticeSummary()));  m_currentComponentWindow = practiceWindow;
             showDocumentActions(false, false);
+//            setVisibleToolbar("practiceToolBar");
             practiceWindow->startPractice();
             break;
         }
         case PracticeSummary: {
             Practice::PracticeSummaryComponent* summary = new \
Practice::PracticeSummaryComponent(&m_testEntryManager, this);  \
                m_currentComponentWindow = summary;
-            showDocumentActions(true, true);            
+            showDocumentActions(true, true);
+//            setVisibleToolbar("practiceSummaryToolBar");
             break;
         }
         default:
@@ -331,6 +336,31 @@
     guiFactory()->addClient(m_currentComponentWindow);
     centralWidget()->layout()->addWidget(m_currentComponentWindow);
     m_currentComponentWindow->show();
+        setupToolbarMenuActions();
+    switch (component) {
+        case WelcomeComponent: {
+            setVisibleToolbar(QString());
+            break;
+        }
+        case StatisticsComponent: {
+            setVisibleToolbar("statisticsToolBar");
+            break;
+        }
+        case EditorComponent: {
+            setVisibleToolbar("editorToolBar");
+            break;
+        }
+        case PracticeComponent: {
+            setVisibleToolbar("practiceToolBar");
+            break;
+        }
+        case PracticeSummary: {
+            setVisibleToolbar("practiceSummaryToolBar");
+            break;
+        }
+        default:
+            break;
+    }
     setupToolbarMenuActions();
 }
 
@@ -350,6 +380,23 @@
     actionCollection()->action("file_close")->setVisible(edit);
 }
 
+void ParleyMainWindow::setVisibleToolbar(const QString& name)
+{
+    Q_FOREACH(KToolBar *toolbar, m_hiddenToolbars) {
+        if (toolbar) {
+            toolbar->show();
+        }
+    }
+    m_hiddenToolbars.clear();
+    Q_FOREACH(KToolBar *toolbar, toolBars()) {
+        if (toolbar->objectName() != name) {
+            toolbar->hide();
+            setupToolbarMenuActions();
+            m_hiddenToolbars.append(toolbar);
+        }
+    }
+}
+
 ParleyDocument* ParleyMainWindow::parleyDocument()
 {
     return m_document;
--- trunk/KDE/kdeedu/parley/src/parleymainwindow.h #1115233:1115234
@@ -31,6 +31,8 @@
 #include <KXmlGuiWindow>
 #include "practice/testentrymanager.h"
 
+#include <QPointer>
+
 namespace Practice {
     class GuiFrontend;
     class DefaultBackend;
@@ -151,6 +153,8 @@
      */
     void showDocumentActions(bool open, bool edit);
 
+    void setVisibleToolbar(const QString& name);
+
 signals:
     void recentFilesChanged();
     void preferencesChanged();
@@ -180,6 +184,7 @@
     QString m_appName;
     Component m_componentBeforePractice;
     Practice::TestEntryManager m_testEntryManager;
+    QList<QPointer<KToolBar> > m_hiddenToolbars;
 
     friend int main(int argc, char* argv[]);
 };
--- trunk/KDE/kdeedu/parley/src/parleyui.rc #1115233:1115234
@@ -23,4 +23,24 @@
  <ToolBar noMerge="true" noEdit="true" deleted="true" name="mainToolBar">
   <text>Main Toolbar</text>
  </ToolBar>
+ <ToolBar name="editorToolBar">
+  <text>Statistics Toolbar</text>
+  <Merge/>
+  <Action name="file_close"/>
+ </ToolBar>
+ <ToolBar name="practiceToolBar">
+  <text>Practice Toolbar</text>
+  <Merge/>
+  <Action name="file_close"/>
+ </ToolBar>
+ <ToolBar name="statisticsToolBar">
+  <text>Statistics Toolbar</text>
+  <Merge/>
+  <Action name="file_close"/>
+ </ToolBar>
+ <ToolBar name="practiceSummaryToolBar">
+  <text>Practice Summary Toolbar</text>
+  <Merge/>
+  <Action name="file_close"/>
+ </ToolBar>
 </gui>
--- trunk/KDE/kdeedu/parley/src/practice/practicesummarycomponent.cpp \
#1115233:1115234 @@ -21,6 +21,7 @@
 #include <KConfigGroup>
 #include <KActionCollection>
 #include <KColorScheme>
+#include <KToolBar>
 
 using namespace Practice; 
 
@@ -29,7 +30,7 @@
     ,m_testEntryManager(testEntryManager)
 {
     // KXmlGui
-    setXMLFile("statisticsui.rc");
+    setXMLFile("practicesummaryui.rc");
     setObjectName("Statistics");
     
     QWidget *mainWidget = new QWidget(this);
@@ -42,7 +43,7 @@
     summaryBar->setStatistics(m_testEntryManager->statisticTotalCorrectFirstAttempt(), \
m_testEntryManager->statisticTotalWrong(), \
m_testEntryManager->statisticTotalUnanswered());  
     KConfigGroup cfg(KSharedConfig::openConfig("parleyrc"), objectName());
-    applyMainWindowSettings(cfg); 
+    applyMainWindowSettings(cfg);
 }
 
 PracticeSummaryComponent::~PracticeSummaryComponent()
--- trunk/KDE/kdeedu/parley/src/practice/practicesummaryui.rc #1115233:1115234
@@ -14,10 +14,9 @@
   </Menu>
 </MenuBar>
 
- <ToolBar noMerge="1" name="practiceSummaryToolbar" >
-  <text>Statistics Toolbar</text>
+ <ToolBar name="practiceSummaryToolBar">
+  <text>Practice Summary Toolbar</text>
   <Action name="document_edit" />
-  <Action name="practice_configure" />
   <Action name="practice_start" />
  </ToolBar>
 </gui>
--- trunk/KDE/kdeedu/parley/src/practice/practiceui.rc #1115233:1115234
@@ -9,8 +9,8 @@
   </Menu>
  </MenuBar>
 
- <ToolBar noMerge="1" name="statisticsToolBar" >
-  <text>Statistics Toolbar</text>
+ <ToolBar noMerge="1" name="practiceToolBar" >
+  <text>Practice Toolbar</text>
   <Action name="practice_stop" />
  </ToolBar>
 </gui>
--- trunk/KDE/kdeedu/parley/src/statistics/statisticsui.rc #1115233:1115234
@@ -14,7 +14,7 @@
   </Menu>
 </MenuBar>
 
- <ToolBar noMerge="1" name="statisticsToolBar" >
+ <ToolBar name="statisticsToolBar" >
   <text>Statistics Toolbar</text>
   <Action name="document_edit" />
   <Action name="practice_configure" />


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

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