[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: koffice/shapes/text
From: Thomas Zander <zander () kde ! org>
Date: 2007-01-29 20:11:35
Message-ID: 1170101495.006273.28006.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 628340 by zander:
Show the current paragraph style
M +26 -1 StylesWidget.cpp
M +7 -0 StylesWidget.h
M +40 -11 TextTool.cpp
M +8 -0 TextTool.h
--- trunk/koffice/shapes/text/StylesWidget.cpp #628339:628340
@@ -27,7 +27,8 @@
StylesWidget::StylesWidget(Type type, QWidget *parent)
: QWidget(parent),
m_type(type),
- m_styleManager(0)
+ m_styleManager(0),
+ m_blockSignals(false)
{
widget.setupUi(this);
connect(widget.styleList, SIGNAL(itemPressed(QListWidgetItem *)), this, \
SLOT(itemSelected())); @@ -53,6 +54,8 @@
}
void StylesWidget::itemSelected() {
+ if(m_blockSignals)
+ return;
int styleId = m_items[widget.styleList->currentRow()].second;
if(m_type == CharacterStyle)
@@ -61,4 +64,26 @@
emit paragraphStyleSelected(m_styleManager->paragraphStyle(styleId));
}
+void StylesWidget::setCurrentFormat(const QTextBlockFormat &format) {
+ if(m_type == CharacterStyle || format == m_currentBlockFormat)
+ return;
+ m_currentBlockFormat = format;
+ int id = m_currentBlockFormat.intProperty(KoCharacterStyle::StyleId);
+ int index = 0;
+ foreach(Entry entry, m_items) {
+ if(entry.second == id)
+ break;
+ index++;
+ }
+ if(index >= m_items.count()) // not here, so default to the first one.
+ index = 0;
+ m_blockSignals = true;
+ widget.styleList->setCurrentItem(widget.styleList->item(index));
+ m_blockSignals = false;
+}
+
+void StylesWidget::setCurrentFormat(const QTextCharFormat &format) {
+
+}
+
#include <StylesWidget.moc>
--- trunk/koffice/shapes/text/StylesWidget.h #628339:628340
@@ -21,6 +21,8 @@
#include <QWidget>
#include <QList>
+#include <QTextBlockFormat>
+#include <QTextCharFormat>
#include <ui_StylesWidget.h>
@@ -38,6 +40,8 @@
public slots:
void setStyleManager(KoStyleManager *sm);
void itemSelected();
+ void setCurrentFormat(const QTextBlockFormat &format);
+ void setCurrentFormat(const QTextCharFormat &format);
signals:
void paragraphStyleSelected(KoParagraphStyle *style);
@@ -50,6 +54,9 @@
typedef QPair<QString, int> Entry;
QList<Entry> m_items;
+ QTextBlockFormat m_currentBlockFormat;
+ QTextCharFormat m_currentCharFormat;
+ bool m_blockSignals;
};
#endif
--- trunk/koffice/shapes/text/TextTool.cpp #628339:628340
@@ -53,24 +53,24 @@
addAction("format_bold", m_actionFormatBold );
m_actionFormatBold->setShortcut(Qt::CTRL + Qt::Key_B);
m_actionFormatBold->setCheckable(true);
- connect( m_actionFormatBold, SIGNAL(toggled(bool)), &m_selectionHandler, \
SLOT(textBold(bool)) ); + connect( m_actionFormatBold, SIGNAL(toggled(bool)), \
&m_selectionHandler, SLOT(bold(bool)) );
m_actionFormatItalic = new QAction(KIcon("text_italic"), i18n("Italic"), this);
addAction("format_italic", m_actionFormatItalic );
m_actionFormatItalic->setShortcut( Qt::CTRL + Qt::Key_I);
m_actionFormatItalic->setCheckable(true);
- connect( m_actionFormatItalic, SIGNAL(toggled(bool)), &m_selectionHandler, \
SLOT(textItalic(bool)) ); + connect( m_actionFormatItalic, SIGNAL(toggled(bool)), \
&m_selectionHandler, SLOT(italic(bool)) );
m_actionFormatUnderline = new QAction(KIcon("text_under"), i18n("Underline"), \
this); addAction("format_underline", m_actionFormatUnderline );
m_actionFormatUnderline->setShortcut(Qt::CTRL + Qt::Key_U);
m_actionFormatUnderline->setCheckable(true);
- connect( m_actionFormatUnderline, SIGNAL(toggled(bool)), &m_selectionHandler, \
SLOT(textUnderline(bool)) ); + connect( m_actionFormatUnderline, \
SIGNAL(toggled(bool)), &m_selectionHandler, SLOT(underline(bool)) );
m_actionFormatStrikeOut = new QAction(KIcon("text_strike"), i18n("Strike Out"), \
this); addAction("format_strike", m_actionFormatStrikeOut );
m_actionFormatStrikeOut->setCheckable(true);
- connect( m_actionFormatStrikeOut, SIGNAL(toggled(bool)), &m_selectionHandler, \
SLOT(textStrikeOut(bool)) ); + connect( m_actionFormatStrikeOut, \
SIGNAL(toggled(bool)), &m_selectionHandler, SLOT(strikeOut(bool)) );
QActionGroup *alignmentGroup = new QActionGroup(this);
m_actionAlignLeft = new QAction(KIcon("text_left"), i18n("Align Left"), this);
@@ -122,29 +122,29 @@
QAction *action = new QAction(i18n("Insert Non-Breaking Space"), this);
addAction("nonbreaking_space", action );
action->setShortcut( Qt::CTRL+Qt::Key_Space);
- connect(action, SIGNAL(triggered()), &m_selectionHandler, SLOT( \
nonbreakingSpace() )); + connect(action, SIGNAL(triggered()), this, SLOT( \
nonbreakingSpace() ));
action = new QAction(i18n("Insert Non-Breaking Hyphen"), this);
addAction("nonbreaking_hyphen", action );
action->setShortcut( Qt::CTRL+Qt::SHIFT+Qt::Key_Minus);
- connect(action, SIGNAL(triggered()), &m_selectionHandler, SLOT( \
nonbreakingHyphen() )); + connect(action, SIGNAL(triggered()), this, SLOT( \
nonbreakingHyphen() ));
action = new QAction(i18n("Insert Soft Hyphen"), this);
addAction("soft_hyphen", action );
//action->setShortcut( Qt::CTRL+Qt::Key_Minus); // TODO this one is also used \
for the kde-global zoom-out :(
- connect(action, SIGNAL(triggered()), &m_selectionHandler, SLOT( softHyphen() ));
+ connect(action, SIGNAL(triggered()), this, SLOT( softHyphen() ));
action = new QAction(i18n("Line Break"), this);
addAction("line_break", action );
action->setShortcut( Qt::SHIFT+Qt::Key_Return);
- connect(action, SIGNAL(triggered()), &m_selectionHandler, SLOT( lineBreak() ));
+ connect(action, SIGNAL(triggered()), this, SLOT( lineBreak() ));
action = new QAction(i18n("Font..."), this);
addAction("format_font", action );
action->setShortcut( Qt::ALT + Qt::CTRL + Qt::Key_F);
action->setToolTip( i18n( "Change character size, font, boldface, italics etc." \
) );
action->setWhatsThis( i18n( "Change the attributes of the currently selected \
characters." ) );
- connect(action, SIGNAL(triggered()), &m_selectionHandler, SLOT( formatFont() ));
+ connect(action, SIGNAL(triggered()), &m_selectionHandler, SLOT( selectFont() ));
}
TextTool::~TextTool() {
@@ -214,6 +214,7 @@
updateSelectionHandler();
updateStyleManager();
+ updateActions();
}
void TextTool::updateSelectionHandler() {
@@ -349,6 +350,9 @@
case Qt::AlignJustify: m_actionAlignBlock->setChecked(true); break;
}
blockSignals(sigs);
+
+ emit charFormatChanged(cf);
+ emit blockFormatChanged(bf);
}
void TextTool::updateStyleManager() {
@@ -430,12 +434,37 @@
connect(this, SIGNAL(styleManagerChanged(KoStyleManager *)), paragTab, \
SLOT(setStyleManager(KoStyleManager *)));
connect(this, SIGNAL(styleManagerChanged(KoStyleManager *)), charTab, \
SLOT(setStyleManager(KoStyleManager *))); + connect(this, \
SIGNAL(charFormatChanged(const QTextCharFormat &)), + paragTab, \
SLOT(setCurrentFormat(const QTextCharFormat &))); + connect(this, \
SIGNAL(blockFormatChanged(const QTextBlockFormat &)), + paragTab, \
SLOT(setCurrentFormat(const QTextBlockFormat &))); + connect(this, \
SIGNAL(charFormatChanged(const QTextCharFormat &)), + charTab, \
SLOT(setCurrentFormat(const QTextCharFormat &)));
- connect(paragTab, SIGNAL(paragraphStyleSelected(KoParagraphStyle *)), \
&m_selectionHandler, SLOT(setStyle(KoParagraphStyle*)));
- connect(charTab, SIGNAL(characterStyleSelected(KoCharacterStyle *)), \
&m_selectionHandler, SLOT(setStyle(KoCharacterStyle*))); + connect(paragTab, \
SIGNAL(paragraphStyleSelected(KoParagraphStyle *)), + &m_selectionHandler, \
SLOT(setStyle(KoParagraphStyle*))); + connect(charTab, \
SIGNAL(characterStyleSelected(KoCharacterStyle *)), + &m_selectionHandler, \
SLOT(setStyle(KoCharacterStyle*)));
updateStyleManager();
return widget;
}
+void TextTool::nonbreakingSpace() {
+ m_selectionHandler.insert(QString(QChar(0xa0)));
+}
+
+void TextTool::nonbreakingHyphen() {
+ m_selectionHandler.insert(QString(QChar(0x2013)));
+}
+
+void TextTool::softHyphen() {
+ m_selectionHandler.insert(QString(QChar(0xad)));
+}
+
+void TextTool::lineBreak() {
+ m_selectionHandler.insert(QString(QChar('\n')));
+}
+
+
#include "TextTool.moc"
--- trunk/koffice/shapes/text/TextTool.h #628339:628340
@@ -56,7 +56,15 @@
signals:
void styleManagerChanged(KoStyleManager *manager);
+ void charFormatChanged(const QTextCharFormat &format);
+ void blockFormatChanged(const QTextBlockFormat &format);
+private slots:
+ void nonbreakingSpace();
+ void nonbreakingHyphen();
+ void softHyphen();
+ void lineBreak();
+
private:
void repaint();
int pointToPosition(const QPointF & point) const;
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic