diff --git a/src/kedittoolbar.h b/src/kedittoolbar.h
--- a/src/kedittoolbar.h
+++ b/src/kedittoolbar.h
@@ -36,6 +36,9 @@
* framework for creating menus and toolbars. It depends on the XML
* files to describe the toolbar layouts and it requires the actions
* to determine which buttons are active.
+ * KEditToolBar creates the XML file describing the toolbar layouts
+ * based on this data. The actual building of the customized toolbars
+ * is done by the KXMLGUIFactory.
*
* Typically you do not need to use it directly as KXmlGuiWindow::setupGUI
* takes care of it.
diff --git a/src/kedittoolbar.cpp b/src/kedittoolbar.cpp
--- a/src/kedittoolbar.cpp
+++ b/src/kedittoolbar.cpp
@@ -53,8 +53,10 @@
#include "../kxmlgui_version.h"
static const char separatorstring[] = I18N_NOOP("--- separator ---");
+static const char spacerstring[] = I18N_NOOP("--- spacer ---");
#define SEPARATORSTRING i18n(separatorstring)
+#define SPACERSTRING i18n(spacerstring)
//static const char *const s_XmlTypeToString[] = { "Shell", "Part", "Local", "Merged" };
@@ -186,6 +188,7 @@
m_internalName(name),
m_statusText(statusText),
m_isSeparator(false),
+ m_isSpacer(false),
m_isTextAlongsideIconHidden(false)
{
// Drop between items, not onto items
@@ -208,6 +211,10 @@
{
m_isSeparator = sep;
}
+ void setSpacer(bool spacer)
+ {
+ m_isSpacer = spacer;
+ }
void setTextAlongsideIconHidden(bool hidden)
{
m_isTextAlongsideIconHidden = hidden;
@@ -228,6 +235,10 @@
{
return m_isSeparator;
}
+ bool isSpacer() const
+ {
+ return m_isSpacer;
+ }
bool isTextAlongsideIconHidden() const
{
return m_isTextAlongsideIconHidden;
@@ -243,6 +254,7 @@
QString m_internalName;
QString m_statusText;
bool m_isSeparator;
+ bool m_isSpacer;
bool m_isTextAlongsideIconHidden;
};
@@ -252,6 +264,7 @@
s << item.internalName();
s << item.statusText();
s << item.isSeparator();
+ s << item.isSpacer();
s << item.isTextAlongsideIconHidden();
return s;
}
@@ -269,6 +282,9 @@
bool sep;
s >> sep;
item.setSeparator(sep);
+ bool spacer;
+ s >> spacer;
+ item.setSpacer(spacer);
bool hidden;
s >> hidden;
item.setTextAlongsideIconHidden(hidden);
@@ -436,6 +452,9 @@
void slotDropped(ToolBarListWidget *list, int index, ToolBarItem *item, bool sourceIsActiveList);
+ /**
+ * Sets up the layout and contents of the "Configure Toolbars" window
+ */
void setupLayout();
void initOldStyle(const QString &file, bool global, const QString &defaultToolbar);
@@ -1141,7 +1160,7 @@
for (; xit != m_xmlFiles.constEnd(); ++xit) {
// skip the merged one in favor of the local one,
// so that we can change icons
- // This also makes the app-defined named for "mainToolBar" appear rather than the ui_standards-defined name.
+ // This also makes the app-defined name for "mainToolBar" appear rather than the ui_standards-defined name.
if ((*xit).type() == XmlData::Merged) {
continue;
}
@@ -1173,13 +1192,16 @@
void KEditToolBarWidgetPrivate::loadActions(const QDomElement &elem)
{
const QLatin1String tagSeparator("Separator");
+ const QLatin1String tagSpacer("Spacer");
const QLatin1String tagMerge("Merge");
const QLatin1String tagActionList("ActionList");
const QLatin1String tagAction("Action");
const QLatin1String attrName("name");
int sep_num = 0;
QString sep_name(QStringLiteral("separator_%1"));
+ int spacer_num = 0;
+ QString spacer_name(QStringLiteral("spacer_%1"));
// clear our lists
m_inactiveList->clear();
@@ -1212,6 +1234,13 @@
it.setAttribute(attrName, act->internalName());
continue;
}
+ if (it.tagName() == tagSpacer) {
+ ToolBarItem *act = new ToolBarItem(m_activeList, tagSpacer, spacer_name.arg(spacer_num++), QString());
+ act->setSpacer(true);
+ act->setText(SPACERSTRING);
+ it.setAttribute(attrName, act->internalName());
+ continue;
+ }
if (it.tagName() == tagMerge) {
// Merge can be named or not - use the name if there is one
@@ -1263,11 +1292,16 @@
m_inactiveList->sortItems(Qt::AscendingOrder);
- // finally, add default separators to the inactive list
- ToolBarItem *act = new ToolBarItem(nullptr, tagSeparator, sep_name.arg(sep_num++), QString());
- act->setSeparator(true);
- act->setText(SEPARATORSTRING);
- m_inactiveList->insertItem(0, act);
+ // finally, add default separators and spacers to the inactive list
+ ToolBarItem *sep = new ToolBarItem(nullptr, tagSeparator, sep_name.arg(sep_num++), QString());
+ sep->setSeparator(true);
+ sep->setText(SEPARATORSTRING);
+ m_inactiveList->insertItem(0, sep);
+
+ ToolBarItem *spacer = new ToolBarItem(nullptr, tagSpacer, spacer_name.arg(spacer_num++), QString());
+ spacer->setSpacer(true);
+ spacer->setText(SPACERSTRING);
+ m_inactiveList->insertItem(1, spacer);
}
KActionCollection *KEditToolBarWidget::actionCollection() const
@@ -1400,9 +1434,11 @@
}
QDomElement new_item;
- // let's handle the separator specially
+ // let's handle the separator and spacer specially
if (item->isSeparator()) {
new_item = m_widget->domDocument().createElement(QStringLiteral("Separator"));
+ } else if (item->isSpacer()) {
+ new_item = m_widget->domDocument().createElement(QStringLiteral("Spacer"));
} else {
new_item = m_widget->domDocument().createElement(QStringLiteral("Action"));
}
diff --git a/src/kxmlgui.xsd b/src/kxmlgui.xsd
--- a/src/kxmlgui.xsd
+++ b/src/kxmlgui.xsd
@@ -80,6 +80,20 @@
+
+
+
+
+ Inserts a spacer item into a toolbar.
+
+
+
+
+
+
+
+
+
@@ -335,6 +349,7 @@
+
diff --git a/src/kxmlguibuilder.cpp b/src/kxmlguibuilder.cpp
--- a/src/kxmlguibuilder.cpp
+++ b/src/kxmlguibuilder.cpp
@@ -55,6 +55,7 @@
QString tagStatusBar;
QString tagSeparator;
+ QString tagSpacer;
QString tagTearOffHandle;
QString tagMenuTitle;
@@ -85,6 +86,7 @@
d->tagStatusBar = QStringLiteral("statusbar");
d->tagSeparator = QStringLiteral("separator");
+ d->tagSpacer = QStringLiteral("spacer");
d->tagTearOffHandle = QStringLiteral("tearoffhandle");
d->tagMenuTitle = QStringLiteral("title");
@@ -297,7 +299,7 @@
QStringList KXMLGUIBuilder::customTags() const
{
QStringList res;
- res << d->tagSeparator << d->tagTearOffHandle << d->tagMenuTitle;
+ res << d->tagSeparator << d->tagSpacer << d->tagTearOffHandle << d->tagMenuTitle;
return res;
}
@@ -343,6 +345,13 @@
return bar->insertSeparator(before);
}
+ } else if (tagName == d->tagSpacer) {
+ if (KToolBar *bar = qobject_cast(parent)) {
+ // Create the simple spacer widget
+ QWidget *spacer = new QWidget(parent);
+ spacer->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
+ return bar->insertWidget(before, spacer);
+ }
} else if (tagName == d->tagTearOffHandle) {
static_cast(parent)->setTearOffEnabled(true);
} else if (tagName == d->tagMenuTitle) {