Commit 0359ff60 authored by Thorbjørn Lindeijer's avatar Thorbjørn Lindeijer
Browse files

Use QActions to fix toolbar extension

Instead of directly adding QToolButtons to the tool bar of the
navigation subwidget, use QActions. This allows the tool bar extension
to show them in a menu when necessary.

The icons are inappropriate for in a menu, however.
parent d5560b4b
...@@ -354,35 +354,30 @@ NavigationSubWidget::NavigationSubWidget(NavigationWidget *parentWidget) ...@@ -354,35 +354,30 @@ NavigationSubWidget::NavigationSubWidget(NavigationWidget *parentWidget)
m_navigationComboBox->setMaximumWidth(130); m_navigationComboBox->setMaximumWidth(130);
#endif #endif
m_toolbar = new QToolBar(this); m_toolBar = new QToolBar(this);
m_toolbar->setContentsMargins(0, 0, 0, 0); m_toolBar->setContentsMargins(0, 0, 0, 0);
m_toolbar->addWidget(m_navigationComboBox); m_toolBar->addWidget(m_navigationComboBox);
QToolButton *split = new QToolButton; m_splitAction = new QAction(QIcon(":/core/images/splitbutton_horizontal.png"), tr("Split"), this);
split->setProperty("type", QLatin1String("dockbutton")); QAction *close = new QAction(QIcon(":/core/images/closebutton.png"), tr("Close"), this);
split->setIcon(QIcon(":/core/images/splitbutton_horizontal.png"));
split->setToolTip(tr("Split"));
connect(split, SIGNAL(clicked(bool)), this, SIGNAL(split()));
QToolButton *close = new QToolButton;
close->setProperty("type", QLatin1String("dockbutton"));
close->setIcon(QIcon(":/core/images/closebutton.png"));
close->setToolTip(tr("Close"));
connect(close, SIGNAL(clicked(bool)), this, SIGNAL(close()));
QWidget *spacerItem = new QWidget(this); QWidget *spacerItem = new QWidget(this);
spacerItem->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum); spacerItem->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum);
m_toolbar->addWidget(spacerItem); m_toolBar->addWidget(spacerItem);
m_splitAction = m_toolbar->addWidget(split); m_toolBar->addAction(m_splitAction);
m_toolbar->addWidget(close); m_toolBar->addAction(close);
m_toolBar->widgetForAction(m_splitAction)->setProperty("type", QLatin1String("dockbutton"));
m_toolBar->widgetForAction(close)->setProperty("type", QLatin1String("dockbutton"));
QVBoxLayout *lay = new QVBoxLayout(); QVBoxLayout *lay = new QVBoxLayout();
lay->setMargin(0); lay->setMargin(0);
lay->setSpacing(0); lay->setSpacing(0);
setLayout(lay); setLayout(lay);
lay->addWidget(m_toolbar); lay->addWidget(m_toolBar);
connect(m_splitAction, SIGNAL(triggered()), this, SIGNAL(split()));
connect(close, SIGNAL(triggered()), this, SIGNAL(close()));
connect(m_navigationComboBox, SIGNAL(currentIndexChanged(int)), connect(m_navigationComboBox, SIGNAL(currentIndexChanged(int)),
this, SLOT(setCurrentIndex(int))); this, SLOT(setCurrentIndex(int)));
...@@ -417,7 +412,7 @@ void NavigationSubWidget::setCurrentIndex(int index) ...@@ -417,7 +412,7 @@ void NavigationSubWidget::setCurrentIndex(int index)
// Add Toolbutton // Add Toolbutton
m_additionalToolBarWidgets = n.doockToolBarWidgets; m_additionalToolBarWidgets = n.doockToolBarWidgets;
foreach (QToolButton *w, m_additionalToolBarWidgets) { foreach (QToolButton *w, m_additionalToolBarWidgets) {
m_toolbar->insertWidget(m_splitAction, w); m_toolBar->insertWidget(m_splitAction, w);
} }
} }
......
...@@ -151,7 +151,7 @@ private: ...@@ -151,7 +151,7 @@ private:
NavigationWidget *m_parentWidget; NavigationWidget *m_parentWidget;
QComboBox *m_navigationComboBox; QComboBox *m_navigationComboBox;
QWidget *m_navigationWidget; QWidget *m_navigationWidget;
QToolBar *m_toolbar; QToolBar *m_toolBar;
QAction *m_splitAction; QAction *m_splitAction;
QList<QToolButton *> m_additionalToolBarWidgets; QList<QToolButton *> m_additionalToolBarWidgets;
}; };
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment