Commit 944754c8 authored by C. Boemann's avatar C. Boemann
Browse files

Add icon for table of contents, and reorganice the buttons a bit in the review tool

parent ae859756
kde4_install_icons( ${ICON_INSTALL_DIR} )
......@@ -130,7 +130,7 @@ void ReferencesTool::createActions()
addAction("insert_configure_tableofcontents", action);
action->setToolTip(i18n("Insert a custom Table of Contents into the document."));
action = new KAction(i18n("Configure..."), this);
action = new KAction(koIcon("configure"), i18n("Configure..."), this);
addAction("format_tableofcontents", action);
action->setToolTip(i18n("Configure the Table of Contents"));
connect(action, SIGNAL(triggered()), this, SLOT(formatTableOfContents()));
......@@ -236,7 +236,7 @@ QList<QWidget*> ReferencesTool::createOptionWidgets()
connect(m_slw, SIGNAL(doneWithFocus()), this, SLOT(returnFocusToCanvas()));
m_stocw->setWindowTitle(i18n("Table of Contents"));
m_stocw->setWindowTitle(i18nc("as in table of contents, list of pictures, index", "Tables, Lists & Indexes"));
widgets.append(m_stocw);
m_sfenw->setWindowTitle(i18n("Footnotes and Endnotes"));
......@@ -270,34 +270,9 @@ void ReferencesTool::configureBibliography()
void ReferencesTool::formatTableOfContents()
{
const QTextDocument *document = textEditor()->document();
QMenu *tocList = new QMenu(m_stocw);
int i = 0;
QTextBlock firstToCTextBlock;
for (QTextBlock it = document->begin(); it != document->end(); it = it.next())
{
if (it.blockFormat().hasProperty(KoParagraphStyle::TableOfContentsData)) {
KoTableOfContentsGeneratorInfo *info = it.blockFormat().property(KoParagraphStyle::TableOfContentsData).value<KoTableOfContentsGeneratorInfo*>();
if (i == 0) {
firstToCTextBlock = it;
}
QAction *action = new QAction(info->m_indexTitleTemplate.text, tocList);
action->setData(QVariant::fromValue<QTextBlock>(it));
tocList->addAction(action);
i++;
}
}
if (i == 0) {
//no ToCs in the document
return;
} else if (i == 1 && firstToCTextBlock.isValid()) {
m_configure = new TableOfContentsConfigure(textEditor(), firstToCTextBlock, m_stocw);
if (textEditor()->block().blockFormat().hasProperty(KoParagraphStyle::TableOfContentsData)) {
m_configure = new TableOfContentsConfigure(textEditor(), textEditor()->block(), m_stocw);
connect(m_configure, SIGNAL(finished(int)), this, SLOT(hideCofigureDialog()));
} else {
m_stocw->setToCConfigureMenu(tocList);
connect(m_stocw->ToCConfigureMenu(), SIGNAL(triggered(QAction *)), SLOT(showConfigureDialog(QAction*)));
m_stocw->showMenu();
}
}
......@@ -360,6 +335,12 @@ void ReferencesTool::updateButtons()
m_sfenw->widget.addFootnote->setEnabled(true);
m_sfenw->widget.addEndnote->setEnabled(true);
}
if (textEditor()->block().blockFormat().hasProperty(KoParagraphStyle::TableOfContentsData)) {
action("format_tableofcontents")->setEnabled(true);
} else {
action("format_tableofcontents")->setEnabled(false);
}
}
KoTextEditor *ReferencesTool::editor()
......
......@@ -24,6 +24,7 @@
#include "TableOfContentsPreview.h"
#include <KoTableOfContentsGeneratorInfo.h>
#include <KoIcon.h>
#include <kaction.h>
#include <kdebug.h>
......@@ -43,13 +44,11 @@ SimpleTableOfContentsWidget::SimpleTableOfContentsWidget(ReferencesTool *tool, Q
m_templateGenerator = new TableOfContentsTemplate(KoTextDocument(m_referenceTool->editor()->document()).styleManager());
widget.addToC->setDefaultAction(tool->action("insert_tableofcontents"));
widget.configureToC->setDefaultAction(tool->action("format_tableofcontents"));
widget.addToC->setIcon(koIcon("insert-tableofcontents"));
widget.addToC->setNumColumns(1);
connect(widget.addToC, SIGNAL(clicked(bool)), this, SIGNAL(doneWithFocus()));
connect(widget.addToC, SIGNAL(aboutToShowMenu()), this, SLOT(prepareTemplateMenu()));
connect(widget.addToC, SIGNAL(itemTriggered(int)), this, SLOT(applyTemplate(int)));
connect(widget.configureToC, SIGNAL(clicked(bool)), this, SIGNAL(showConfgureOptions()));
}
SimpleTableOfContentsWidget::~SimpleTableOfContentsWidget()
......@@ -62,25 +61,6 @@ void SimpleTableOfContentsWidget::setStyleManager(KoStyleManager *sm)
m_styleManager = sm;
}
void SimpleTableOfContentsWidget::setToCConfigureMenu(QMenu *tocMenu)
{
if (widget.configureToC->menu()) {
widget.configureToC->menu()->disconnect();
}
widget.configureToC->setMenu(tocMenu);
}
QMenu *SimpleTableOfContentsWidget::ToCConfigureMenu()
{
return widget.configureToC->menu();
}
void SimpleTableOfContentsWidget::showMenu()
{
widget.configureToC->showMenu();
}
void SimpleTableOfContentsWidget::prepareTemplateMenu()
{
m_previewGenerator.clear();
......@@ -119,6 +99,7 @@ void SimpleTableOfContentsWidget::prepareTemplateMenu()
widget.addToC->addSeparator();
widget.addToC->addAction(m_referenceTool->action("insert_configure_tableofcontents"));
connect(m_referenceTool->action("insert_configure_tableofcontents"), SIGNAL(triggered()), this, SLOT(insertCustomToC()), Qt::UniqueConnection);
widget.addToC->addAction(m_referenceTool->action("format_tableofcontents"));
}
}
......
......@@ -42,9 +42,6 @@ class SimpleTableOfContentsWidget : public QWidget
public:
explicit SimpleTableOfContentsWidget(ReferencesTool *tool, QWidget *parent = 0);
~SimpleTableOfContentsWidget();
void setToCConfigureMenu(QMenu *tocMenu);
QMenu *ToCConfigureMenu();
void showMenu();
public slots:
void setStyleManager(KoStyleManager *sm);
......@@ -53,7 +50,6 @@ public slots:
signals:
void doneWithFocus();
void showConfgureOptions();
private slots:
void applyTemplate(int templateId);
......
......@@ -30,20 +30,26 @@
</property>
<item row="0" column="0">
<widget class="FormattingButton" name="addToC">
<property name="text">
<string>Contents</string>
</property>
<property name="iconSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
<property name="popupMode">
<enum>QToolButton::InstantPopup</enum>
</property>
<property name="toolButtonStyle">
<enum>Qt::ToolButtonTextOnly</enum>
<enum>Qt::ToolButtonTextUnderIcon</enum>
</property>
<property name="autoRaise">
<bool>false</bool>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QToolButton" name="configureToC"/>
</item>
</layout>
</item>
<item row="0" column="1">
......
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