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

List:       kde-commits
Subject:    KDE/kdewebdev/quanta
From:       Andras Mantia <amantia () kde ! org>
Date:       2008-04-15 15:10:19
Message-ID: 1208272219.566846.13717.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 797345 by amantia:

Put the user toolbars inside a tabwidget on a toolbar.

 M  +1 -1      lib/useraction.cpp  
 M  +70 -42    plugins/usertoolbars/toolbarguibuilder.cpp  
 M  +4 -1      plugins/usertoolbars/toolbarguibuilder.h  
 M  +2 -1      plugins/usertoolbars/toolbartabwidget.cpp  
 M  +4 -9      plugins/usertoolbars/usertoolbarspart.cpp  


--- trunk/KDE/kdewebdev/quanta/lib/useraction.cpp #797344:797345
@@ -74,7 +74,7 @@
   }
   if (plugin)
   {
-    kDebug(24000) << "Load icon: " << s << " from: "<< \
plugin->iconLoader()->iconPath(s, KIconLoader::Small, false); +//     kDebug(24000) \
<< "Load icon: " << s << " from: "<< plugin->iconLoader()->iconPath(s, \
                KIconLoader::Small, false);
     setIcon(KIcon(plugin->iconLoader()->iconPath(s, KIconLoader::Small, false)));
   }
   else
--- trunk/KDE/kdewebdev/quanta/plugins/usertoolbars/toolbarguibuilder.cpp \
#797344:797345 @@ -26,9 +26,36 @@
 #include <kglobalsettings.h>
 #include <ktoolbar.h>
 
-// from kfiledialog.cpp - avoid qt warning in STDERR (~/.xsessionerrors)
-static void silenceQToolBar(QtMsgType, const char *){}
+#include <core.h>
+#include <iuicontroller.h>
 
+#if 0
+//code to create a toolview for each toolbar
+class UTViewFactory: public KDevelop::IToolViewFactory
+{
+  public:
+    UTViewFactory(const QDomElement &element) : m_domElement(element)
+    {}
+    
+    virtual QWidget* create( QWidget *parent = 0 )
+    {
+      UserToolBar *tb = new UserToolBar(parent, \
m_domElement.attribute("name").toUtf8(), true, true); +      \
tb->loadState(m_domElement); +      tb->setSizePolicy(QSizePolicy::Preferred, \
QSizePolicy::Minimum); +      tb->setWindowTitle(i18n(m_domElement.attribute( \
"i18ntabname", "" ).toUtf8())); +      
+      return tb;
+    }
+    virtual Qt::DockWidgetArea defaultPosition(const QString &/*areaName*/)
+    {
+      return Qt::TopDockWidgetArea;
+    }
+    
+  private:
+    QDomElement m_domElement;
+};
+#endif
+
 QWidget *ToolbarGUIBuilder::createContainer(QWidget *parent, int index, const \
QDomElement &element, QAction* &action)  {
 //  kDebug(24000) << "createContainer: this=" << this << " parent=" << parent;
@@ -39,9 +66,13 @@
   ToolbarTabWidget *toolbarTab = ToolbarTabWidget::ref();
   if ( element.tagName().toLower() == "toolbar" && !tabname.isEmpty())
   {
-    //avoid QToolBar warning in the log
-//     QtMsgHandler oldHandler = qInstallMsgHandler(silenceQToolBar);
-
+#if 0
+    //code to create a toolview for each toolbar
+    UTViewFactory *factory = new UTViewFactory(element);
+    KDevelop::Core::self()->uiController()->addToolView(i18n(tabname.toUtf8()), \
factory);         +    return container;
+#endif
+        
     //create the toolbar on the tabwidget
     QWidget *w = new QWidget(toolbarTab);
     w->setObjectName(QString("ToolbarHoldingWidget" + \
element.attribute("name")).toUtf8()); @@ -51,6 +82,7 @@
 
     //set the correct fixed height of the toolbar
   //kDebug(24000) << "tb->iconSize() " << tb->iconSize();
+    
     if (toolbarTab->iconText() == Qt::ToolButtonTextUnderIcon)
     {
       tb->setGeometry(0,0, toolbarTab->width(), tb->iconSize().height() + \
QFontMetrics(KGlobalSettings::toolBarFont()).height() + 10); @@ -60,36 +92,29 @@
       tb->setGeometry(0,0, toolbarTab->width(), tb->iconSize().height() + 10);
       toolbarTab->setFixedHeight(toolbarTab->tabHeight() + tb->height() + 3);
     }
+    /*
    kDebug(24000) << "tb->height() " << tb->height();
    kDebug(24000) << "toolbarTab->height() " << toolbarTab->height();
    kDebug(24000) << "toolbarTab->tabHeight() " << toolbarTab->tabHeight();
+   */
+    
     toolbarTab->insertTab(tb, i18n(tabname.toUtf8()), idStr);
     toolbarTab->setCurrentWidget(w);
-    if (toolbarTab->parentWidget()->parentWidget())
-      toolbarTab->parentWidget()->parentWidget()->show();
-//     qInstallMsgHandler(oldHandler);
-    tb->setSeparate(m_separateToolbars);
-
-    if (m_separateToolbars)
-    {
-      container = KXMLGUIBuilder::createContainer(parent, index, element, action);
-      static_cast<KToolBar*>(container)->setWindowTitle(i18n(tabname.toUtf8()));
-      toolbarTab->parentWidget()->parentWidget()->hide();
-    } else
-    {
-      container = tb;
-    }
+    toolbarTab->show();
+    if (m_userToolbar)
+      m_userToolbar->show();
+     container = tb;
   } else
   {
     container = KXMLGUIBuilder::createContainer(parent, index, element, action);
   }
 
-//  kDebug(24000) << "container " << element.attribute("name") << " created: " << \
                container;
-  //The tabwidget needs to be the child of the user toolbar, so detect when it is \
                created
-  //and make the child of it.
-  if (element.attribute("name") == "userToolbar")
+  //The tabwidget needs to be the inside the user toolbar, so detect when it is \
created +  //and add to it.
+  if (element.attribute("name") == "userToolbar" && \
dynamic_cast<QToolBar*>(container))  {
-    toolbarTab->parentWidget()->setParent(container);
+    m_userToolbar = static_cast<QToolBar*>(container);
+    m_userToolbar->addWidget(toolbarTab);
     if (toolbarTab->count() == 0 || m_separateToolbars)
       container->hide();
   }
@@ -98,34 +123,37 @@
 
 void ToolbarGUIBuilder::removeContainer(QWidget *container, QWidget *parent, \
QDomElement &element, QAction* action)  {
+  /*
   QString s;
   QTextStream str(&s, IO_ReadWrite);
   element.save(str, 2);
   kDebug(24000) << "Remove element:" << s;
-//  kDebug(24000) << "removeContainer: this=" << this << " parent=" << parent << \
"container = " << container; +  kDebug(24000) << "removeContainer: this=" << this << \
" parent=" << parent << "container = " << container; +  */
+  
   //We need to reparent the tabwidget, otherwise it gets deleted when for example \
the  //toolbars are configured and the GUI is rebuilt.
-  ToolbarTabWidget *toolbarTab = ToolbarTabWidget::ref();
-  if (container == toolbarTab->parentWidget()->parent())
-    toolbarTab->parentWidget()->setParent(0);
-
-  QString tabname = element.attribute( "i18ntabname", "" );
-  QString idStr = element.attribute( "id", "" );
-
-  if ( element.tagName().toLower() == "toolbar" && !tabname.isEmpty())
+  if (!m_separateToolbars)
   {
-    UserToolBar *tb = dynamic_cast<UserToolBar*>(toolbarTab->page(idStr));
-    if (tb)
+    ToolbarTabWidget *toolbarTab = ToolbarTabWidget::ref();
+    if (container == m_userToolbar)
+      toolbarTab->setParent(0);
+  
+    QString tabname = element.attribute( "i18ntabname", "" );
+    QString idStr = element.attribute( "id", "" );
+  
+    if ( element.tagName().toLower() == "toolbar" && !tabname.isEmpty())
     {
-      if (tb->separate())
-        KXMLGUIBuilder::removeContainer(container, parent, element, action);
-      toolbarTab->removePage(tb);
-      if (toolbarTab->count() == 0 && toolbarTab->parentWidget()->parentWidget())
-        toolbarTab->parentWidget()->parentWidget()->hide();
-      return;
+      UserToolBar *tb = dynamic_cast<UserToolBar*>(toolbarTab->page(idStr));
+      if (tb)
+      {
+        toolbarTab->removePage(tb);
+        if (toolbarTab->count() == 0 && m_userToolbar)
+          m_userToolbar->hide();
+        return;
+      }
     }
   }
-
   KXMLGUIBuilder::removeContainer(container, parent, element, action);
 }
 
--- trunk/KDE/kdewebdev/quanta/plugins/usertoolbars/toolbarguibuilder.h \
#797344:797345 @@ -15,6 +15,8 @@
 
 #include <kxmlguibuilder.h>
 
+class QToolBar;
+
 /**
  Builder for the toolbar XML gui client objects. It handles putting and removing the \
toolbar  on a tabwidget inside a toolbar.
@@ -62,9 +64,10 @@
    * @param widget passed to the KXMLGUIBuilder constructor
    * @return
    */
-  ToolbarGUIBuilder(QWidget *widget):KXMLGUIBuilder(widget){ m_separateToolbars = \
false; } +  ToolbarGUIBuilder(QWidget *widget):KXMLGUIBuilder(widget){ \
m_separateToolbars = false; m_userToolbar = 0L;}  
   bool m_separateToolbars; ///< True when the toolbars are not on a tab widget
+  QToolBar *m_userToolbar;
 };
 
 #endif
--- trunk/KDE/kdewebdev/quanta/plugins/usertoolbars/toolbartabwidget.cpp \
#797344:797345 @@ -195,7 +195,6 @@
 void ToolbarTabWidget::resizeEvent(QResizeEvent *e)
 {
 //  kDebug(24000) << "ToolbarTabWidget::resizeEvent. width = " << width() << "height \
                = " << height();
-  QWidget::resizeEvent(e);
   //Resize every included toolbar if the tabwidget is resized
   QWidget *tb;
   for (QMap<QString, QWidget*>::Iterator it = m_toolbarList.begin(); it != \
m_toolbarList.end(); ++it) @@ -204,6 +203,7 @@
     tb->setFixedSize(QSize(width(), tb->height()));
 //    kDebug(24000) << it.data() << " resize";
   }
+  
   //force update of the widget and the toolbars contained inside
   int i = currentIndex();
   if (i > 0)
@@ -215,6 +215,7 @@
     setCurrentIndex(i + 1);
   }
   setCurrentIndex(i);
+  QWidget::resizeEvent(e);
 }
 
 int ToolbarTabWidget::tabHeight() const
--- trunk/KDE/kdewebdev/quanta/plugins/usertoolbars/usertoolbarspart.cpp \
#797344:797345 @@ -80,15 +80,10 @@
 K_PLUGIN_FACTORY(UserToolbarsFactory, registerPlugin<UserToolbarsPart>();)
 K_EXPORT_PLUGIN(UserToolbarsFactory("kdevusertoolbars"))
 
-
-
-#define GLOBALDOC_OPTIONS 1
-#define PROJECTDOC_OPTIONS 2
-
-
 const QString resourceDir = "quanta/";
 
 
+
 UserToolbarsPart::UserToolbarsPart(QObject *parent, const QVariantList &/*args*/)
   : KDevelop::IPlugin(UserToolbarsFactory::componentData(), parent)
 {
@@ -489,7 +484,7 @@
     for (int i = 0 ; i < actions.count(); i++)
     {
       QAction *action = actions.value(i);
-      kDebug(24000) << "Add the action " << action->objectName() << " to toolbar: " \
<< name << toolbarId<< toolbarGUI << toolbarGUI->actionCollection(); +//       \
kDebug(24000) << "Add the action " << action->objectName() << " to toolbar: " << name \
                << toolbarId<< toolbarGUI << toolbarGUI->actionCollection();
       toolbarGUI->actionCollection()->addAction(action->objectName(), action);
     }
     m_tempFileList.append(tempFile);
@@ -1183,10 +1178,10 @@
   QAction *action;
   KActionCollection *ac = p_toolbar->guiClient->actionCollection();
   QDomNodeList nodeList = \
                p_toolbar->guiClient->domDocument().elementsByTagName("Action");
-  kDebug(24000) << "Check toolbar " << p_toolbar->name << id << p_toolbar->guiClient \
<< ac; +//   kDebug(24000) << "Check toolbar " << p_toolbar->name << id << \
p_toolbar->guiClient << ac;  for (int i = 0; i < nodeList.count(); i++)
   {
-    kDebug(24000) << "node name=" << \
nodeList.item(i).cloneNode().toElement().attribute("name"); +//     kDebug(24000) << \
                "node name=" << \
                nodeList.item(i).cloneNode().toElement().attribute("name");
     action = ac->action(nodeList.item(i).cloneNode().toElement().attribute("name") \
);  if (action)
     {


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

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