Commit e992d10e authored by C. Boemann's avatar C. Boemann
Browse files

Visualize variables and other inline objects (aka forms)

Can be turned on and off via it's own entry in view menu

FEATURE
BUG: 260182
parent d18a7a2a
......@@ -79,6 +79,7 @@ public:
ShowTextShapeOutlines, ///< Paint of text shape outlines ?
ShowFormattingCharacters, ///< Paint of formatting characters ?
ShowTableBorders, ///< Paint of table borders (when not really there) ?
ShowInlineObjectVisualization, ///< paint a different background for inline objects
ApplicationSpeciality, ///< Special features and limitations of the application
KarbonStart = 1000, ///< Base number for Karbon specific values.
KexiStart = 2000, ///< Base number for Kexi specific values.
......
......@@ -28,6 +28,7 @@ KoShapePaintingContext::KoShapePaintingContext()
, showTableBorders(true)
, showSpellChecking(false)
, showSelections(true)
, showInlineObjectVisualization(false)
{
}
......@@ -40,8 +41,10 @@ KoShapePaintingContext::KoShapePaintingContext(KoCanvasBase *canvas, bool forPri
showTextShapeOutlines = false;
showFormattingCharacters = false;
showTableBorders = false;
showInlineObjectVisualization = false;
} else {
showTextShapeOutlines = rm->boolResource(KoCanvasResourceManager::ShowTextShapeOutlines);
showInlineObjectVisualization = rm->boolResource(KoCanvasResourceManager::ShowInlineObjectVisualization);
if (rm->hasResource(KoCanvasResourceManager::ShowTableBorders)) {
showTableBorders = rm->boolResource(KoCanvasResourceManager::ShowTableBorders);
} else {
......
......@@ -44,6 +44,7 @@ public:
bool showTableBorders;
bool showSpellChecking;
bool showSelections;
bool showInlineObjectVisualization;
};
#endif /* KOSHAPEPAINTINGCONTEXT_H */
......@@ -86,6 +86,7 @@ public:
, changesBlocked(false)
, restartLayout(false)
, wordprocessingMode(false)
, showInlineObjectVisualization(false)
{
}
KoStyleManager *styleManager;
......@@ -127,6 +128,7 @@ public:
bool changesBlocked;
bool restartLayout;
bool wordprocessingMode;
bool showInlineObjectVisualization;
};
......@@ -388,12 +390,20 @@ KoTextLayoutRootArea *KoTextDocumentLayout::rootAreaForPoint(const QPointF &poin
return 0;
}
void KoTextDocumentLayout::showInlineObjectVisualization(bool show)
{
d->showInlineObjectVisualization = show;
}
void KoTextDocumentLayout::drawInlineObject(QPainter *painter, const QRectF &rect, QTextInlineObject object, int position, const QTextFormat &format)
{
Q_ASSERT(format.isCharFormat());
if (d->inlineTextObjectManager == 0)
return;
QTextCharFormat cf = format.toCharFormat();
if (d->showInlineObjectVisualization) {
cf.setBackground(QBrush(Qt::gray));
}
KoInlineObject *obj = d->inlineTextObjectManager->inlineTextObject(cf);
if (obj)
obj->paint(*painter, paintDevice(), document(), rect, object, position, cf);
......
......@@ -138,6 +138,9 @@ public:
/// are the tabs relative to indent or not
bool relativeTabs(QTextBlock block) const;
/// visualize inline objects during paint
void showInlineObjectVisualization(bool show);
/// Calc a bounding box rect of the selection
QRectF selectionBoundingBox(QTextCursor &cursor) const;
......
......@@ -116,6 +116,7 @@ void TextShape::paintComponent(QPainter &painter, const KoViewConverter &convert
Q_ASSERT(doc);
KoTextDocumentLayout *lay = qobject_cast<KoTextDocumentLayout*>(doc->documentLayout());
Q_ASSERT(lay);
lay->showInlineObjectVisualization(paintContext.showInlineObjectVisualization);
applyConversion(painter, converter);
......
......@@ -37,6 +37,7 @@ KWApplicationConfig::KWApplicationConfig()
m_statusBarShowModified(true),
m_statusBarShowMouse(false),
m_statusBarShowZoom(true),
m_showInlineObjectVisualization(true),
m_zoom(100),
m_zoomMode(KoZoomMode::ZOOM_WIDTH),
m_autoSaveSeconds(KoDocument::defaultAutoSave()),
......@@ -61,6 +62,7 @@ void KWApplicationConfig::load(KWDocument *document)
// m_maxRecentFiles = interface.readEntry("NbRecentFile", 10);
m_showFormattingChars = interface.readEntry("ViewFormattingChars", m_showFormattingChars);
m_showInlineObjectVisualization = interface.readEntry("ViewFieldShadings", m_showInlineObjectVisualization);
m_showTableBorders = interface.readEntry("ViewTableBorders", m_showTableBorders);
m_viewFrameBorders = interface.readEntry("ViewFrameBorders", m_viewFrameBorders);
......@@ -128,6 +130,7 @@ void KWApplicationConfig::save()
KSharedConfigPtr config = KGlobal::config();
KConfigGroup interface = config->group("Interface");
interface.writeEntry("ViewFormattingChars", m_showFormattingChars);
interface.writeEntry("ViewFieldShadings", m_showInlineObjectVisualization);
interface.writeEntry("ViewTableBorders", m_showTableBorders);
interface.writeEntry("ViewFrameBorders", m_viewFrameBorders);
interface.writeEntry("Zoom", m_zoom);
......
......@@ -52,6 +52,13 @@ public:
return m_showFormattingChars;
}
void setShowInlineObjectVisualization(bool on) {
m_showInlineObjectVisualization = on;
}
bool showInlineObjectVisualization() const {
return m_showInlineObjectVisualization;
}
void setShowTableBorders(bool on) {
m_showTableBorders = on;
}
......@@ -171,6 +178,7 @@ private:
bool m_statusBarShowPage, m_statusBarShowPageStyle, m_statusBarShowPageSize;
bool m_statusBarShowLineNumber, m_statusBarShowModified;
bool m_statusBarShowMouse, m_statusBarShowZoom;
bool m_showInlineObjectVisualization;
int m_zoom; /// < zoom level in percent
KoZoomMode::Mode m_zoomMode;
......
......@@ -298,6 +298,15 @@ void KWView::setupActions()
action->setToolTip(i18n("Toggle the display of non-printing characters"));
action->setWhatsThis(i18n("Toggle the display of non-printing characters.<br/><br/>When this is enabled, Words shows you tabs, spaces, carriage returns and other non-printing characters."));
action = new KAction(i18n("Show Field Shadings"), this);
action->setCheckable(true);
actionCollection()->addAction("view_fieldshadings", action);
connect(action, SIGNAL(toggled(bool)), this, SLOT(setShowInlineObjectVisualization(bool)));
m_canvas->resourceManager()->setResource(KoCanvasResourceManager::ShowInlineObjectVisualization, QVariant(false));
action->setChecked(m_document->config().showInlineObjectVisualization()); // will change resource if true
action->setToolTip(i18n("Toggle the shaded background of fields"));
action->setWhatsThis(i18n("Toggle the visualizaion of fields (variables etc) by drawing their background in a contrasting color."));
action = new KAction(i18n("Show Text Shape Borders"), this);
action->setToolTip(i18n("Turns the border display on and off"));
action->setCheckable(true);
......@@ -632,6 +641,13 @@ void KWView::toggleViewFrameBorders(bool on)
m_document->config().setViewFrameBorders(on);
}
void KWView::setShowInlineObjectVisualization(bool on)
{
m_canvas->resourceManager()->setResource(KoCanvasResourceManager::ShowInlineObjectVisualization, QVariant(on));
m_canvas->update();
m_document->config().setShowInlineObjectVisualization(on);
}
void KWView::setShowFormattingChars(bool on)
{
m_canvas->resourceManager()->setResource(KoCanvasResourceManager::ShowFormattingCharacters, QVariant(on));
......
......@@ -125,6 +125,8 @@ public slots:
void toggleViewFrameBorders(bool on);
/// toggle the display of non-printing characters
void setShowFormattingChars(bool on);
/// toggle the display of field shadings
void setShowInlineObjectVisualization(bool on);
/// toggle the display of table borders
void setShowTableBorders(bool on);
/// go to previous page
......
<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd" ><kpartgui name="Calligra Words" version="137">
<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd" ><kpartgui name="Calligra Words" version="138">
<MenuBar>
<Menu name="file"><text>&amp;File</text>
<Action name="extra_template"/>
......@@ -35,6 +35,7 @@
<Action name="view_formattingchars"/>
<Action name="view_frameborders"/>
<Action name="view_tableborders"/>
<Action name="view_fieldshadings"/>
<Separator/>
<Action name="view_toggledockers"/>
<Action name="show_docstruct"/>
......
Supports Markdown
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