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

List:       kde-commits
Subject:    KDE/kdelibs/kdeui
From:       David Faure <faure () kde ! org>
Date:       2010-11-19 1:30:32
Message-ID: 20101119013032.A75E6AC8A0 () svn ! kde ! org
[Download RAW message or body]

SVN commit 1198579 by dfaure:

* Fix toolbar editing when using setLocalXMLFile: the setXMLFile(ui_standards.rc) \
would find the localxmlfile instead, and one would end up with "No text!" menus, \
ouch. Or something else went wrong and one would end up with tons of empty menus. I \
added a new method loadStandardsXmlFile() which loads ui_standards.rc without \
unwanted side effects, much cleaner.

* slotDefault: reload the XML before reloading the action list widgets, otherwise \
                they are still outdated
BUG: 234571
FIXED-IN: 4.6


 M  +12 -12    dialogs/kedittoolbar.cpp  
 M  +16 -3     xmlgui/kxmlguiclient.cpp  
 M  +9 -0      xmlgui/kxmlguiclient.h  
 M  +1 -1      xmlgui/kxmlguiwindow.cpp  


--- trunk/KDE/kdelibs/kdeui/dialogs/kedittoolbar.cpp #1198578:1198579
@@ -342,9 +342,9 @@
 public:
     /**
      *
-     * @param collection In a non-KParts application, this is the collection passed
+     * @param collection In the old-style constructor, this is the collection passed
      * to the KEditToolBar constructor.
-     * In a KParts application we let create a KXMLGUIClient create a dummy one,
+     * In the xmlguifactory-based constructor, we let KXMLGUIClient create a dummy \
                one,
      * but it probably isn't used.
      */
     KEditToolBarWidgetPrivate(KEditToolBarWidget* widget,
@@ -608,7 +608,6 @@
 
     if ( m_factory )
     {
-        kDebug() << m_factory->clients();
         foreach (KXMLGUIClient* client, m_factory->clients())
         {
             const QString file = client->localXMLFile();
@@ -621,9 +620,11 @@
                     kWarning() << "Could not delete" << file;
         }
 
+        // Reload the xml files in all clients, now that the local files are gone
+        oldWidget->rebuildKXMLGUIClients();
+
         m_widget = new KEditToolBarWidget( q );
         m_widget->load( m_factory, m_defaultToolBar );
-        m_widget->rebuildKXMLGUIClients();
     }
     else
     {
@@ -649,6 +650,7 @@
     q->connect(m_widget, SIGNAL(enableOk(bool)), SLOT(enableButtonApply(bool)));
 
     q->enableButtonApply(false);
+
     emit q->newToolBarConfig();
     emit q->newToolbarConfig(); // compat
 }
@@ -729,7 +731,7 @@
 
     // handle the merging
     if (global)
-        m_widget->setXMLFile(KStandardDirs::locate("config", "ui/ui_standards.rc"));
+        m_widget->loadStandardsXmlFile(); // ui_standards.rc
     const QString localXML = loadXMLFile( resourceFile );
     m_widget->setXML(localXML, global ? true /*merge*/ : false);
 
@@ -852,7 +854,7 @@
         d->m_factory->removeClient(client);
     }
 
-//  KXMLGUIClient *firstClient = clients.first();
+  KXMLGUIClient *firstClient = clients.first();
 
   // now, rebuild the gui from the first to the last
   //kDebug(240) << "rebuilding the gui";
@@ -865,16 +867,14 @@
         // passing an empty stream forces the clients to reread the XML
         client->setXMLGUIBuildDocument( QDomDocument() );
 
-#if 0 // This would be only for old-style construction, but then m_factory is NULL \
!?!?  // for the shell, merge in ui_standards.rc
         if ( client == firstClient ) // same assumption as in the ctor: first==shell
-            client->setXMLFile(KStandardDirs::locate("config", \
"ui/ui_standards.rc")); +            client->loadStandardsXmlFile();
 
         // and this forces it to use the *new* XML file
         client->setXMLFile( file, client == firstClient /* merge if shell */ );
-#else
-        client->reloadXML();
-#endif
+
+        // [we can't use reloadXML, it doesn't load ui_standards.rc]
     }
   }
 
@@ -1665,7 +1665,7 @@
     if (!event->spontaneous()) {
         // The dialog has been shown, enable toolbar editing
         if ( d->m_factory ) {
-            // call the kpart version
+            // call the xmlgui-factory version
             d->m_widget->load( d->m_factory, d->m_defaultToolBar );
         } else {
             // call the action collection version
--- trunk/KDE/kdelibs/kdeui/xmlgui/kxmlguiclient.cpp #1198578:1198579
@@ -173,6 +173,9 @@
 
 void KXMLGUIClient::reloadXML()
 {
+    // TODO: this method can't be used for the KXmlGuiWindow, since it doesn't merge \
in ui_standards.rc! +    //   -> KDE5: load ui_standards_rc in setXMLFile using a \
flag, and remember that flag? +    //            and then KEditToolBar can use \
reloadXML.  QString file( xmlFile() );
     if ( !file.isEmpty() )
         setXMLFile( file );
@@ -186,6 +189,17 @@
     d->m_builder->setBuilderClient( this );
 }
 
+void KXMLGUIClient::loadStandardsXmlFile()
+{
+    const QString file = KStandardDirs::locate("config", "ui/ui_standards.rc", \
componentData()); +    if (file.isEmpty()) {
+        kWarning() << "ui/ui_standards.rc not found in" << \
componentData().dirs()->resourceDirs("config"); +    } else {
+        const QString doc = KXMLGUIFactory::readConfigFile( file );
+        setXML( doc );
+    }
+}
+
 void KXMLGUIClient::setXMLFile( const QString& _file, bool merge, bool setXMLDoc )
 {
   // store our xml file name
@@ -210,9 +224,8 @@
     kWarning() << "cannot find .rc file" << _file << "for component" << \
componentData().componentName();  }
 
-  // make sure to merge the settings from any file specified by
-  // setLocalXMLFile()
-  if ( !d->m_localXMLFile.isEmpty() ) {
+  // make sure to merge the settings from any file specified by setLocalXMLFile()
+  if ( !d->m_localXMLFile.isEmpty() && !file.endsWith("ui_standards.rc") ) {
     const bool exists = QDir::isRelativePath(d->m_localXMLFile) || \
QFile::exists(d->m_localXMLFile);  if (exists && \
!allFiles.contains(d->m_localXMLFile))  allFiles.prepend( d->m_localXMLFile );
--- trunk/KDE/kdelibs/kdeui/xmlgui/kxmlguiclient.h #1198578:1198579
@@ -193,6 +193,9 @@
    * intended to be used when you know that the resource file has
    * changed and you will soon be rebuilding the GUI. This will only have
    * an effect if the client is then removed and re-added to the factory.
+   *
+   * This method is only for child clients, do not call it for a mainwindow!
+   * For a mainwindow, use loadStandardsXmlFile + setXmlFile(xmlFile()) instead.
    */
   void reloadXML();
 
@@ -328,6 +331,12 @@
   virtual void setXMLFile( const QString& file, bool merge = false, bool setXMLDoc = \
true );  
   /**
+     * Load the ui_standards.rc file. Usually followed by setXMLFile(xmlFile, true), \
for merging. +     * @since 4.6
+     */
+    void loadStandardsXmlFile();
+
+  /**
    * Set the full path to the "local" xml file, the one used for saving
    * toolbar and shortcut changes. You normally don't need to call this,
    * if you pass a simple filename to setXMLFile.
--- trunk/KDE/kdelibs/kdeui/xmlgui/kxmlguiwindow.cpp #1198578:1198579
@@ -262,7 +262,7 @@
     }
 
     // we always want to load in our global standards file
-    setXMLFile(KStandardDirs::locate("config", "ui/ui_standards.rc", \
componentData())); +    loadStandardsXmlFile();
 
     // now, merge in our local xml file.
     setXMLFile(windowXmlFile, true);


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

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