diff --git a/words/part/KWCanvas.cpp b/words/part/KWCanvas.cpp index 146adfdb451..a427c16d4a4 100644 --- a/words/part/KWCanvas.cpp +++ b/words/part/KWCanvas.cpp @@ -1,199 +1,199 @@ /* This file is part of the KDE project * Copyright (C) 2002-2006 David Faure * Copyright (C) 2005-2006 Thomas Zander * Copyright (C) 2009 Inge Wallin * Copyright (C) 2010 Boudewijn Rempt * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public License * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ // Own #include "KWCanvas.h" // words includes #include "KWGui.h" #include "KWView.h" #include "KWViewMode.h" #include "KWPage.h" // calligra libs includes #include #include #include #include #include // Qt includes #include #include #include KWCanvas::KWCanvas(const QString &viewMode, KWDocument *document, KWView *view, KWGui *parent) : QWidget(parent), KWCanvasBase(document, this), m_view(view) { setAttribute(Qt::WA_OpaquePaintEvent, true); setAttribute(Qt::WA_InputMethodEnabled, true); setFocusPolicy(Qt::StrongFocus); connect(document, SIGNAL(pageSetupChanged()), this, SLOT(pageSetupChanged())); m_viewConverter = m_view->viewConverter(); m_viewMode = KWViewMode::create(viewMode, document); } KWCanvas::~KWCanvas() { } void KWCanvas::pageSetupChanged() { m_viewMode->pageSetupChanged(); updateSize(); } void KWCanvas::updateSize() { resourceManager()->setResource(Words::CurrentPageCount, m_document->pageCount()); QSizeF canvasSize = m_viewMode->contentsSize(); if (showAnnotations()) { canvasSize += QSize(AnnotationAreaWidth, 0.0); } emit documentSize(canvasSize); } void KWCanvas::setDocumentOffset(const QPoint &offset) { m_documentOffset = offset; } bool KWCanvas::snapToGrid() const { return m_view->snapToGrid(); } QPointF KWCanvas::viewToDocument(const QPointF &viewPoint) const { return m_viewMode->viewToDocument(viewPoint, m_viewConverter); } void KWCanvas::contextMenuEvent(QContextMenuEvent *e) { m_view->popupContextMenu(e->globalPos(), m_toolProxy->popupActionList()); e->setAccepted(true); } void KWCanvas::mouseMoveEvent(QMouseEvent *e) { m_view->viewMouseMoveEvent(e); m_toolProxy->mouseMoveEvent(e, m_viewMode->viewToDocument(e->pos() + m_documentOffset, m_viewConverter)); } void KWCanvas::mousePressEvent(QMouseEvent *e) { m_toolProxy->mousePressEvent(e, m_viewMode->viewToDocument(e->pos() + m_documentOffset, m_viewConverter)); } void KWCanvas::mouseReleaseEvent(QMouseEvent *e) { m_toolProxy->mouseReleaseEvent(e, m_viewMode->viewToDocument(e->pos() + m_documentOffset, m_viewConverter)); } void KWCanvas::mouseDoubleClickEvent(QMouseEvent *e) { m_toolProxy->mouseDoubleClickEvent(e, m_viewMode->viewToDocument(e->pos() + m_documentOffset, m_viewConverter)); } bool KWCanvas::event(QEvent *e) { if(toolProxy()) { toolProxy()->processEvent(e); } return QWidget::event(e); } void KWCanvas::keyPressEvent(QKeyEvent *e) { m_toolProxy->keyPressEvent(e); if (! e->isAccepted()) { if (e->key() == Qt::Key_Backtab || (e->key() == Qt::Key_Tab && (e->modifiers() & Qt::ShiftModifier))) focusNextPrevChild(false); else if (e->key() == Qt::Key_Tab) focusNextPrevChild(true); else if (e->key() == Qt::Key_PageUp) m_view->goToPreviousPage(e->modifiers()); else if (e->key() == Qt::Key_PageDown) m_view->goToNextPage(e->modifiers()); } if(e->key() == Qt::Key_Escape) - m_view->exitDistractioFreeMode(); + m_view->exitFullscreenMode(); } QVariant KWCanvas::inputMethodQuery(Qt::InputMethodQuery query) const { if (query == Qt::ImMicroFocus) { QRectF rect = (m_toolProxy->inputMethodQuery(query, *(viewConverter())).toRectF()).toRect(); rect = m_viewMode->documentToView(viewConverter()->viewToDocument(rect), viewConverter()); QPointF scroll(canvasController()->scrollBarValue()); if (canvasWidget()->layoutDirection() == Qt::RightToLeft) { scroll.setX(-scroll.x()); } rect.translate(documentOrigin() - scroll); return rect.toRect(); } return m_toolProxy->inputMethodQuery(query, *(viewConverter())); } void KWCanvas::keyReleaseEvent(QKeyEvent *e) { m_toolProxy->keyReleaseEvent(e); } void KWCanvas::tabletEvent(QTabletEvent *e) { m_toolProxy->tabletEvent(e, m_viewMode->viewToDocument(e->pos() + m_documentOffset, m_viewConverter)); } void KWCanvas::wheelEvent(QWheelEvent *e) { m_toolProxy->wheelEvent(e, m_viewMode->viewToDocument(e->pos() + m_documentOffset, m_viewConverter)); } void KWCanvas::inputMethodEvent(QInputMethodEvent *event) { m_toolProxy->inputMethodEvent(event); } void KWCanvas::paintEvent(QPaintEvent *ev) { QPainter painter(this); painter.eraseRect(ev->rect()); paint(painter, ev->rect()); // In KWCanvasBase painter.end(); } void KWCanvas::setCursor(const QCursor &cursor) { QWidget::setCursor(cursor); } void KWCanvas::updateInputMethodInfo() { updateMicroFocus(); } diff --git a/words/part/KWView.cpp b/words/part/KWView.cpp index 6e7f5cb167f..0164586dd5e 100644 --- a/words/part/KWView.cpp +++ b/words/part/KWView.cpp @@ -1,1134 +1,1134 @@ /* This file is part of the KDE project * Copyright (C) 2001 David Faure * Copyright (C) 2005-2007, 2009, 2010 Thomas Zander * Copyright (C) 2010-2011 Boudewijn Rempt * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public License * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA */ // words includes #define SHOW_ANNOTATIONS 1 #include "KWView.h" #include "KWGui.h" #include "KWDocument.h" #include "KWCanvas.h" #include "KWFactory.h" #include "KWStatusBar.h" #include "KWPageManager.h" #include "frames/KWFrame.h" #include "frames/KWCopyShape.h" #include "frames/KWTextFrameSet.h" #include "dialogs/KWFrameDialog.h" #include "dialogs/KWPageSettingsDialog.h" #include "dialogs/KWPrintingDialog.h" #include "dialogs/KWCreateBookmarkDialog.h" #include "dialogs/KWSelectBookmarkDialog.h" #include "dialogs/KWConfigureDialog.h" #include "commands/KWShapeCreateCommand.h" #include "widgets/KoFindToolbar.h" #include "ui_KWInsertImage.h" #include "gemini/ViewModeSwitchEvent.h" #include "WordsDebug.h" // calligra libs includes #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include // for KoPathShapeId #include #include #include #include #include #include #include #ifdef SHOULD_BUILD_RDF #include #include #endif #include #include #include #include // KF5 #include #include #include #include #include #include // Qt #include #include #include #include #include #include #include KWView::KWView(KoPart *part, KWDocument *document, QWidget *parent) : KoView(part, document, parent) , m_canvas(0) , m_textMinX(1) , m_textMaxX(600) , m_minPageNum(1) , m_maxPageNum(1) - , m_isDistractionFreeMode(false) + , m_isFullscreenMode(false) { setAcceptDrops(true); m_document = document; m_snapToGrid = m_document->gridData().snapToGrid(); m_gui = new KWGui(QString(), this); m_canvas = m_gui->canvas(); setFocusProxy(m_canvas); QVBoxLayout *layout = new QVBoxLayout(this); layout->setMargin(0); layout->addWidget(m_gui); setComponentName(KWFactory::componentData().componentName(), KWFactory::componentData().componentDisplayName()); setXMLFile("calligrawords.rc"); m_currentPage = m_document->pageManager()->begin(); m_document->annotationLayoutManager()->setShapeManager(m_canvas->shapeManager()); m_document->annotationLayoutManager()->setCanvasBase(m_canvas); m_document->annotationLayoutManager()->setViewContentWidth(m_canvas->viewMode()->contentsSize().width()); connect(m_document->annotationLayoutManager(), SIGNAL(hasAnnotationsChanged(bool)), this, SLOT(hasNotes(bool))); //We need to create associate widget before connect them in actions //Perhaps there is a better place for the WordCount widget creates here //If you know where to move it in a better place, just do it buildAssociatedWidget(); setupActions(); connect(m_canvas->shapeManager()->selection(), SIGNAL(selectionChanged()), this, SLOT(selectionChanged())); m_find = new KoFindText(this); KoFindToolbar *toolbar = new KoFindToolbar(m_find, actionCollection(), this); toolbar->setVisible(false); connect(m_find, SIGNAL(matchFound(KoFindMatch)), this, SLOT(findMatchFound(KoFindMatch))); connect(m_find, SIGNAL(updateCanvas()), m_canvas, SLOT(update())); // The text documents to search in will potentially change when we add/remove shapes and after load connect(m_document, SIGNAL(shapeAdded(KoShape*,KoShapeManager::Repaint)), this, SLOT(refreshFindTexts())); connect(m_document, SIGNAL(shapeRemoved(KoShape*)), this, SLOT(refreshFindTexts())); refreshFindTexts(); layout->addWidget(toolbar); m_zoomController = new KoZoomController(m_gui->canvasController(), &m_zoomHandler, actionCollection(), 0, this); if (statusBar()) KWStatusBar::addViewControls(statusBar(), this); // the zoom controller needs to be initialized after the status bar gets initialized as // that resulted in bug 180759 QSizeF pageSize = m_currentPage.rect().size(); if (m_canvas->showAnnotations()) { pageSize += QSize(KWCanvasBase::AnnotationAreaWidth, 0.0); } m_zoomController->setPageSize(pageSize); m_zoomController->setTextMinMax(m_currentPage.contentRect().left(), m_currentPage.contentRect().right()); KoZoomMode::Modes modes = KoZoomMode::ZOOM_WIDTH | KoZoomMode::ZOOM_TEXT; if (m_canvas->viewMode()->hasPages()) modes |= KoZoomMode::ZOOM_PAGE; m_zoomController->zoomAction()->setZoomModes(modes); connect(m_canvas, SIGNAL(documentSize(QSizeF)), m_zoomController, SLOT(setDocumentSize(QSizeF))); m_canvas->updateSize(); // to emit the doc size at least once m_zoomController->setZoom(m_document->config().zoomMode(), m_document->config().zoom() / 100.); connect(m_zoomController, SIGNAL(zoomChanged(KoZoomMode::Mode,qreal)), this, SLOT(zoomChanged(KoZoomMode::Mode,qreal))); - //Timer start in Distraction-Free mode view. + //Timer start in Fullscreen mode view. m_hideCursorTimer = new QTimer(this); connect(m_hideCursorTimer, SIGNAL(timeout()), this, SLOT(hideCursor())); - m_dfmExitButton = new QPushButton(i18n("Exit Distraction-Free Mode")); + m_dfmExitButton = new QPushButton(i18n("Exit Fullscreen Mode")); addStatusBarItem(m_dfmExitButton, 0); m_dfmExitButton->setVisible(false); - connect(m_dfmExitButton, SIGNAL(clicked()), this, SLOT(exitDistractioFreeMode())); + connect(m_dfmExitButton, SIGNAL(clicked()), this, SLOT(exitFullscreenMode())); #ifdef SHOULD_BUILD_RDF if (KoDocumentRdf *rdf = dynamic_cast(m_document->documentRdf())) { connect(rdf, SIGNAL(semanticObjectViewSiteUpdated(hKoRdfBasicSemanticItem,QString)), this, SLOT(semanticObjectViewSiteUpdated(hKoRdfBasicSemanticItem,QString))); } #endif } KWView::~KWView() { KoToolManager::instance()->removeCanvasController(m_gui->canvasController()); m_canvas = 0; } KoCanvasBase *KWView::canvasBase() const { return m_canvas; } const KWPage KWView::currentPage() const { return m_currentPage; } QWidget *KWView::canvas() const { return m_canvas; } void KWView::updateReadWrite(bool readWrite) { m_actionFormatFrameSet->setEnabled(readWrite); m_actionViewHeader->setEnabled(readWrite); m_actionViewFooter->setEnabled(readWrite); m_actionViewSnapToGrid->setEnabled(readWrite); QAction *action = actionCollection()->action("insert_framebreak"); if (action) action->setEnabled(readWrite); action = actionCollection()->action("insert_variable"); if (action) action->setEnabled(readWrite); action = actionCollection()->action("format_page"); if (action) action->setEnabled(readWrite); action = actionCollection()->action("anchor"); if (action) action->setEnabled(readWrite); action = actionCollection()->action("edit_cut"); if (action) action->setEnabled(readWrite); action = actionCollection()->action("edit_copy"); if (action) action->setEnabled(readWrite); action = actionCollection()->action("edit_paste"); if (action) action->setEnabled(readWrite); action = actionCollection()->action("edit_paste_text"); if (action) action->setEnabled(readWrite); action = actionCollection()->action("delete_page"); if (action) action->setEnabled(readWrite); action = actionCollection()->action("edit_delete"); if (action) action->setEnabled(readWrite); action = actionCollection()->action("create_linked_frame"); if (action) action->setEnabled(readWrite); action = actionCollection()->action("create_custom_outline"); if (action) action->setEnabled(readWrite); } void KWView::buildAssociatedWidget() { wordCount = new KWStatisticsWidget(this,true); wordCount->setLayoutDirection(KWStatisticsWidget::LayoutHorizontal); wordCount->setCanvas(dynamic_cast(this->canvas())); statusBar()->insertWidget(0,wordCount); } void KWView::setupActions() { m_actionFormatFrameSet = new QAction(i18n("Shape Properties..."), this); actionCollection()->addAction("format_frameset", m_actionFormatFrameSet); m_actionFormatFrameSet->setToolTip(i18n("Change how the shape behave")); m_actionFormatFrameSet->setEnabled(false); connect(m_actionFormatFrameSet, SIGNAL(triggered()), this, SLOT(editFrameProperties())); QAction *action = actionCollection()->addAction(KStandardAction::Prior, "page_previous", this, SLOT(goToPreviousPage())); action = actionCollection()->addAction(KStandardAction::Next, "page_next", this, SLOT(goToNextPage())); // -------------- File menu m_actionCreateTemplate = new QAction(i18n("Create Template From Document..."), this); m_actionCreateTemplate->setToolTip(i18n("Save this document and use it later as a template")); m_actionCreateTemplate->setWhatsThis(i18n("You can save this document as a template.

You can use this new template as a starting point for another document.")); actionCollection()->addAction("extra_template", m_actionCreateTemplate); connect(m_actionCreateTemplate, SIGNAL(triggered()), this, SLOT(createTemplate())); // -------------- Edit actions action = actionCollection()->addAction(KStandardAction::Cut, "edit_cut", 0, 0); new KoCutController(canvasBase(), action); action = actionCollection()->addAction(KStandardAction::Copy, "edit_copy", 0, 0); new KoCopyController(canvasBase(), action); action = actionCollection()->addAction(KStandardAction::Paste, "edit_paste", 0, 0); new KoPasteController(canvasBase(), action); action = new QAction(koIcon("edit-delete"), i18n("Delete"), this); action->setShortcut(QKeySequence("Del")); connect(action, SIGNAL(triggered()), this, SLOT(editDeleteSelection())); connect(canvasBase()->toolProxy(), SIGNAL(selectionChanged(bool)), action, SLOT(setEnabled(bool))); actionCollection()->addAction("edit_delete", action); // -------------- View menu action = new QAction(i18n("Show Formatting Characters"), this); action->setCheckable(true); actionCollection()->addAction("view_formattingchars", action); connect(action, SIGNAL(toggled(bool)), this, SLOT(setShowFormattingChars(bool))); m_canvas->resourceManager()->setResource(KoCanvasResourceManager::ShowFormattingCharacters, QVariant(false)); action->setChecked(m_document->config().showFormattingChars()); // will change resource if true action->setToolTip(i18n("Toggle the display of non-printing characters")); action->setWhatsThis(i18n("Toggle the display of non-printing characters.

When this is enabled, Words shows you tabs, spaces, carriage returns and other non-printing characters.")); action = new QAction(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 visualization of fields (variables etc.) by drawing their background in a contrasting color.")); action = new QAction(i18n("Show Text Shape Borders"), this); action->setToolTip(i18n("Turns the border display on and off")); action->setCheckable(true); actionCollection()->addAction("view_frameborders", action); connect(action, SIGNAL(toggled(bool)), this, SLOT(toggleViewFrameBorders(bool))); m_canvas->resourceManager()->setResource(KoCanvasResourceManager::ShowTextShapeOutlines, QVariant(false)); action->setChecked(m_document->config().viewFrameBorders()); // will change resource if true action->setWhatsThis(i18n("Turns the border display on and off.

The borders are never printed. This option is useful to see how the document will appear on the printed page.")); action = new QAction(i18n("Show Table Borders"), this); action->setCheckable(true); actionCollection()->addAction("view_tableborders", action); connect(action, SIGNAL(toggled(bool)), this, SLOT(setShowTableBorders(bool))); m_canvas->resourceManager()->setResource(KoCanvasResourceManager::ShowTableBorders, QVariant(false)); action->setChecked(m_document->config().showTableBorders()); // will change resource if true action->setToolTip(i18n("Toggle the display of table borders")); action->setWhatsThis(i18n("Toggle the display of table borders.

When this is enabled, Words shows you any invisible table borders with a thin gray line.")); action = new QAction(i18n("Show Section Bounds"), this); action->setCheckable(true); actionCollection()->addAction("view_sectionbounds", action); connect(action, SIGNAL(toggled(bool)), this, SLOT(setShowSectionBounds(bool))); m_canvas->resourceManager()->setResource(KoCanvasResourceManager::ShowSectionBounds, QVariant(false)); action->setChecked(m_document->config().showSectionBounds()); // will change resource if true action->setToolTip(i18n("Toggle the display of section bounds")); action->setWhatsThis(i18n("Toggle the display of section bounds.

When this is enabled, any section bounds will be indicated with a thin gray horizontal brackets.")); action = new QAction(i18n("Show Rulers"), this); action->setCheckable(true); action->setToolTip(i18n("Shows or hides rulers")); action->setWhatsThis(i18n("The rulers are the white measuring spaces top and left of the " "document. The rulers show the position and width of pages and of frames and can " "be used to position tabulators among others.

Uncheck this to disable " "the rulers from being displayed.

")); action->setChecked(m_document->config().viewRulers()); actionCollection()->addAction("show_ruler", action); connect(action, SIGNAL(toggled(bool)), this, SLOT(showRulers(bool))); action = m_document->gridData().gridToggleAction(m_canvas); actionCollection()->addAction("view_grid", action); m_actionViewSnapToGrid = new KToggleAction(i18n("Snap to Grid"), this); actionCollection()->addAction("view_snaptogrid", m_actionViewSnapToGrid); m_actionViewSnapToGrid->setChecked(m_snapToGrid); connect(m_actionViewSnapToGrid, SIGNAL(triggered()), this, SLOT(toggleSnapToGrid())); KToggleAction *guides = KoStandardAction::showGuides(this, SLOT(setGuideVisibility(bool)), actionCollection()); guides->setChecked(m_document->guidesData().showGuideLines()); KToggleAction *tAction = new KToggleAction(i18n("Show Status Bar"), this); tAction->setToolTip(i18n("Shows or hides the status bar")); actionCollection()->addAction("showStatusBar", tAction); connect(tAction, SIGNAL(toggled(bool)), this, SLOT(showStatusBar(bool))); mainWindow()->actionCollection()->action("view_fullscreen")->setEnabled(false); - tAction = new KToggleAction(i18n("Distraction Free Mode"), this); - tAction->setToolTip(i18n("Set view in distraction free mode")); + tAction = new KToggleAction(i18n("Fullscreen Mode"), this); + tAction->setToolTip(i18n("Set view in fullscreen mode")); tAction->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_F)); - actionCollection()->addAction("view_distractionfreemode", tAction); - connect(tAction, SIGNAL(toggled(bool)), this, SLOT(setDistractionFreeMode(bool))); + actionCollection()->addAction("view_fullscreen", tAction); + connect(tAction, SIGNAL(toggled(bool)), this, SLOT(setFullscreenMode(bool))); #ifdef SHOULD_BUILD_RDF action = new QAction(i18n("Semantic Stylesheets..."), this); actionCollection()->addAction("edit_semantic_stylesheets", action); action->setToolTip(i18n("Modify and add semantic stylesheets")); action->setWhatsThis(i18n("Stylesheets are used to format the display of information which is stored in RDF.")); connect(action, SIGNAL(triggered()), this, SLOT(editSemanticStylesheets())); if (KoDocumentRdf* rdf = dynamic_cast(m_document->documentRdf())) { QAction* createRef = rdf->createInsertSemanticObjectReferenceAction(canvasBase()); actionCollection()->addAction("insert_semanticobject_ref", createRef); KActionMenu *subMenu = new KActionMenu(i18n("Create"), this); actionCollection()->addAction("insert_semanticobject_new", subMenu); foreach(QAction *action, rdf->createInsertSemanticObjectNewActions(canvasBase())) { subMenu->addAction(action); } } #endif // -------------- Settings menu action = new QAction(koIcon("configure"), i18n("Configure..."), this); actionCollection()->addAction("configure", action); connect(action, SIGNAL(triggered()), this, SLOT(configure())); // not sure why this isn't done through KStandardAction, but since it isn't // we ought to set the MenuRole manually so the item ends up in the appropriate // menu on OS X: action->setMenuRole(QAction::PreferencesRole); // -------------- Page tool action = new QAction(i18n("Page Layout..."), this); actionCollection()->addAction("format_page", action); action->setToolTip(i18n("Change properties of entire page")); action->setWhatsThis(i18n("Change properties of the entire page.

Currently you can change paper size, paper orientation, header and footer sizes, and column settings.

")); connect(action, SIGNAL(triggered()), this, SLOT(formatPage())); m_actionViewHeader = new QAction(i18n("Create Header"), this); actionCollection()->addAction("insert_header", m_actionViewHeader); if (m_currentPage.isValid()) m_actionViewHeader->setEnabled(m_currentPage.pageStyle().headerPolicy() == Words::HFTypeNone); connect(m_actionViewHeader, SIGNAL(triggered()), this, SLOT(enableHeader())); m_actionViewFooter = new QAction(i18n("Create Footer"), this); actionCollection()->addAction("insert_footer", m_actionViewFooter); if (m_currentPage.isValid()) m_actionViewFooter->setEnabled(m_currentPage.pageStyle().footerPolicy() == Words::HFTypeNone); connect(m_actionViewFooter, SIGNAL(triggered()), this, SLOT(enableFooter())); // -------- Show annotations (called Comments in the UI) tAction = new KToggleAction(i18n("Show Comments"), this); tAction->setToolTip(i18n("Shows comments in the document")); tAction->setChecked(m_canvas && m_canvas->showAnnotations()); actionCollection()->addAction("view_notes", tAction); connect(tAction, SIGNAL(toggled(bool)), this, SLOT(showNotes(bool))); // -------- Statistics in the status bar KToggleAction *tActionBis = new KToggleAction(i18n("Word Count"), this); tActionBis->setToolTip(i18n("Shows or hides word counting in status bar")); tActionBis->setChecked(kwdocument()->config().statusBarShowWordCount()); actionCollection()->addAction("view_wordCount", tActionBis); connect(tActionBis, SIGNAL(toggled(bool)), this, SLOT(showWordCountInStatusBar(bool))); wordCount->setVisible(kwdocument()->config().statusBarShowWordCount()); /* ********** From old kwview **** We probably want to have each of these again, so just move them when you want to implement it This saves problems with finding out which we missed near the end. m_actionEditCustomVarsEdit = new QAction(i18n("Custom Variables..."), 0, this, SLOT(editCustomVars()), // TODO: new dialog w add etc. actionCollection(), "custom_vars"); m_actionEditCustomVars = new QAction(i18n("Edit Variable..."), 0, this, SLOT(editCustomVariable()), actionCollection(), "edit_customvars"); m_actionImportStyle= new QAction(i18n("Import Styles..."), 0, this, SLOT(importStyle()), actionCollection(), "import_style"); m_actionConfigureCompletion = new QAction(i18n("Configure Completion..."), 0, this, SLOT(configureCompletion()), actionCollection(), "configure_completion"); m_actionConfigureCompletion->setToolTip(i18n("Change the words and options for autocompletion")); m_actionConfigureCompletion->setWhatsThis(i18n("Add words or change the options for autocompletion.")); new QAction(i18n("Completion"), KStdAccel::shortcut(KStdAccel::TextCompletion), this, SLOT(slotCompletion()), actionCollection(), "completion"); */ } QList KWView::selectedShapes() const { return canvasBase()->shapeManager()->selection()->selectedShapes(KoFlake::TopLevelSelection); } KoShape* KWView::selectedShape() const { KoSelection *selection = canvasBase()->shapeManager()->selection(); foreach (KoShape *s, selection->selectedShapes(KoFlake::TopLevelSelection)) { if (s->isGeometryProtected()) continue; return s; } return 0; } // -------------------- Actions ----------------------- void KWView::pasteRequested() { QImage img = QApplication::clipboard()->image(); if (!img.isNull()) { QVector images; images.append(img); addImages(images, canvas()->mapFromGlobal(QCursor::pos())); } } void KWView::showNotes(bool show) { m_canvas->setShowAnnotations(show); m_canvas->updateSize(); } void KWView::hasNotes(bool has) { m_canvas->setShowAnnotations(has); m_canvas->updateSize(); KToggleAction *action = (KToggleAction*) actionCollection()->action("view_notes"); action->setEnabled(has); action->setChecked(has); } void KWView::showWordCountInStatusBar(bool doShow) { kwdocument()->config().setStatusBarShowWordCount(doShow); wordCount->setVisible(doShow); } void KWView::editFrameProperties() { const QList &shapes = selectedShapes(); if (!shapes.isEmpty()) { QPointer frameDialog = new KWFrameDialog(shapes, m_document, m_canvas); frameDialog->exec(); delete frameDialog; } } KoPrintJob *KWView::createPrintJob() { KWPrintingDialog *dia = new KWPrintingDialog(m_document, m_canvas->shapeManager(), this); dia->printer().setResolution(600); dia->printer().setCreator(QString::fromLatin1("Calligra Words %1").arg(CalligraVersionWrapper::versionString())); dia->printer().setFullPage(true); // ignore printer margins return dia; } void KWView::createTemplate() { KoTemplateCreateDia::createTemplate(koDocument()->documentPart()->templatesResourcePath(), ".ott", m_document, this); } void KWView::enableHeader() { if (!m_currentPage.isValid()) return; Q_ASSERT(m_currentPage.pageStyle().isValid()); m_currentPage.pageStyle().setHeaderPolicy(Words::HFTypeUniform); m_actionViewHeader->setEnabled(false); m_document->relayout(); } void KWView::enableFooter() { if (!m_currentPage.isValid()) return; Q_ASSERT(m_currentPage.pageStyle().isValid()); m_currentPage.pageStyle().setFooterPolicy(Words::HFTypeUniform); m_actionViewFooter->setEnabled(false); m_document->relayout(); } void KWView::toggleSnapToGrid() { m_snapToGrid = !m_snapToGrid; m_document->gridData().setSnapToGrid(m_snapToGrid); // for persistency } void KWView::toggleViewFrameBorders(bool on) { m_canvas->resourceManager()->setResource(KoCanvasResourceManager::ShowTextShapeOutlines, on); m_canvas->update(); 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)); m_canvas->update(); m_document->config().setShowFormattingChars(on); } void KWView::setShowTableBorders(bool on) { m_canvas->resourceManager()->setResource(KoCanvasResourceManager::ShowTableBorders, QVariant(on)); m_canvas->update(); m_document->config().setShowTableBorders(on); } void KWView::setShowSectionBounds(bool on) { m_canvas->resourceManager()->setResource(KoCanvasResourceManager::ShowSectionBounds, QVariant(on)); m_canvas->update(); // m_document->config().setShowSectionBounds(on); } void KWView::formatPage() { if (! m_currentPage.isValid()) return; KWPageSettingsDialog *dia = new KWPageSettingsDialog(this, m_document, m_currentPage); if (!m_lastPageSettingsTab.isEmpty()) { KPageWidgetItem *item = dia->pageItem(m_lastPageSettingsTab); if (item) dia->setCurrentPage(item); } connect(dia, SIGNAL(finished(int)), this, SLOT(pageSettingsDialogFinished())); dia->show(); } void KWView::pageSettingsDialogFinished() { KWPageSettingsDialog *dia = qobject_cast(QObject::sender()); m_lastPageSettingsTab = dia && dia->currentPage() ? dia->currentPage()->name() : QString(); } void KWView::editSemanticStylesheets() { #ifdef SHOULD_BUILD_RDF if (KoDocumentRdf *rdf = dynamic_cast(m_document->documentRdf())) { KoSemanticStylesheetsEditor *dia = new KoSemanticStylesheetsEditor(this, rdf); dia->show(); // TODO this leaks memory } #endif } void KWView::showRulers(bool visible) { m_document->config().setViewRulers(visible); m_gui->updateRulers(); } void KWView::showStatusBar(bool toggled) { if (statusBar()) statusBar()->setVisible(toggled); } -void KWView::setDistractionFreeMode(bool status) +void KWView::setFullscreenMode(bool status) { - m_isDistractionFreeMode = status; + m_isFullscreenMode = status; mainWindow()->toggleDockersVisibility(!status); mainWindow()->menuBar()->setVisible(!status); mainWindow()->viewFullscreen(status); foreach(KToolBar* toolbar, mainWindow()->toolBars()) { if (toolbar->isVisible() == status) { toolbar->setVisible(!status); } } if (status) { QTimer::singleShot(2000, this, SLOT(hideUI())); } else { mainWindow()->statusBar()->setVisible(true); static_cast(m_gui->canvasController())->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); static_cast(m_gui->canvasController())->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded); } - // Exit Distraction-Free mode button. + // Exit Fullscreen mode button. m_dfmExitButton->setVisible(status); //Hide cursor. if (status) { m_hideCursorTimer->start(4000); } else { // FIXME: Return back cursor to canvas if cursor is blank cursor. m_hideCursorTimer->stop(); } // From time to time you can end up in a situation where the shape manager suddenly // looses track of the current shape selection. So, we trick it here. Logically, // it also makes sense to just make sure the text tool is active anyway when - // switching to/from distraction free (since that's explicitly for typing things + // switching to/from fullscreen (since that's explicitly for typing things // out, not layouting) const QList selection = m_canvas->shapeManager()->selection()->selectedShapes(); m_canvas->shapeManager()->selection()->deselectAll(); if (selection.count() > 0) m_canvas->shapeManager()->selection()->select(selection.at(0)); KoToolManager::instance()->switchToolRequested("TextToolFactory_ID"); } void KWView::hideUI() { - if (m_isDistractionFreeMode) { + if (m_isFullscreenMode) { mainWindow()->statusBar()->setVisible(false); // Hide vertical and horizontal scroll bar. static_cast(m_gui->canvasController())->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); static_cast(m_gui->canvasController())->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); } } void KWView::hideCursor(){ m_canvas->setCursor(Qt::BlankCursor); m_gui->setCursor(Qt::BlankCursor); } -void KWView::exitDistractioFreeMode() +void KWView::exitFullscreenMode() { - if (m_isDistractionFreeMode) { - QAction *action = actionCollection()->action("view_distractionfreemode"); + if (m_isFullscreenMode) { + QAction *action = actionCollection()->action("view_fullscreen"); action->setChecked(false); m_gui->setCursor(Qt::ArrowCursor); - setDistractionFreeMode(false); + setFullscreenMode(false); } } void KWView::viewMouseMoveEvent(QMouseEvent *e) { - if (!m_isDistractionFreeMode) + if (!m_isFullscreenMode) return; m_gui->setCursor(Qt::ArrowCursor); // Handle status bar and horizontal scroll bar. if (e->y() >= (m_gui->size().height() - statusBar()->size().height())) { mainWindow()->statusBar()->setVisible(true); static_cast(m_gui->canvasController())->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded); } else { mainWindow()->statusBar()->setVisible(false); static_cast(m_gui->canvasController())->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); } // Handle vertical scroll bar. QScrollBar *vsb = static_cast(m_gui->canvasController())->verticalScrollBar(); if (e->x() >= (m_gui->size().width() - vsb->size().width() - 10)) { static_cast(m_gui->canvasController())->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); } else { static_cast(m_gui->canvasController())->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); } } void KWView::editDeleteSelection() { canvasBase()->toolProxy()->deleteSelection(); } void KWView::setGuideVisibility(bool on) { m_document->guidesData().setShowGuideLines(on); m_canvas->update(); } void KWView::configure() { QPointer dialog(new KWConfigureDialog(this)); dialog->exec(); delete dialog; // TODO update canvas } // end of actions void KWView::popupContextMenu(const QPoint &globalPosition, const QList &actions) { unplugActionList("frameset_type_action"); plugActionList("frameset_type_action", actions); if (factory() == 0) // we are a kpart, the factory is only set on the active component. return; QMenu *menu = dynamic_cast(factory()->container("frame_popup", this)); if (menu) menu->exec(globalPosition); } void KWView::zoomChanged(KoZoomMode::Mode mode, qreal zoom) { m_document->config().setZoom(qRound(zoom * 100.0)); m_document->config().setZoomMode(mode); m_canvas->update(); } void KWView::selectionChanged() { KoShape *shape = canvasBase()->shapeManager()->selection()-> firstSelectedShape(); if (shape) { // Disallow shape properties action for auto-generated frames. const KWFrame *frame = kwdocument()->frameOfShape(shape); const bool enableAction = !frame || !Words::isAutoGenerated(KWFrameSet::from(frame->shape())); m_actionFormatFrameSet->setEnabled(enableAction); m_actionFormatFrameSet->setVisible(enableAction); } // actions that need at least one shape selected QAction *action = actionCollection()->action("anchor"); if (action) action->setEnabled(shape && kwdocument()->mainFrameSet()); } void KWView::setCurrentPage(const KWPage ¤tPage) { Q_ASSERT(currentPage.isValid()); if (currentPage != m_currentPage) { m_currentPage = currentPage; m_canvas->resourceManager()->setResource(KoCanvasResourceManager::CurrentPage, m_currentPage.pageNumber()); m_actionViewHeader->setEnabled(m_currentPage.pageStyle().headerPolicy() == Words::HFTypeNone); m_actionViewFooter->setEnabled(m_currentPage.pageStyle().footerPolicy() == Words::HFTypeNone); } } void KWView::goToPreviousPage(Qt::KeyboardModifiers modifiers) { // Scroll display qreal moveDistance = m_canvas->canvasController()->visibleHeight() * 0.8; m_canvas->canvasController()->pan(QPoint(0, -moveDistance)); // Find current frameset, FIXME for now assume main KWTextFrameSet *currentFrameSet = kwdocument()->mainFrameSet(); // Since we move _up_ calculate the position where a frame would _start_ if // we were scrolled to the _first_ page QPointF pos = currentFrameSet->shapes().first()->absoluteTransformation(0).map(QPointF(0, 5)); pos += m_canvas->viewMode()->viewToDocument(m_canvas->documentOffset(), viewConverter()); // Find textshape under that position and from current frameset QList possibleTextShapes = m_canvas->shapeManager()->shapesAt(QRectF(pos.x() - 20, pos.y() -20, 40, 40)); KoTextShapeData *textShapeData = 0; foreach (KoShape* shape, possibleTextShapes) { KoShapeUserData *userData = shape->userData(); if ((textShapeData = dynamic_cast(userData))) { foreach (KoShape *s, currentFrameSet->shapes()) { if (s == shape) { pos = shape->absoluteTransformation(0).inverted().map(pos); pos += QPointF(0.0, textShapeData->documentOffset()); KoTextLayoutArea *area = textShapeData->rootArea(); if (area) { int cursorPos = area->hitTest(pos, Qt::FuzzyHit).position; KoTextDocument(textShapeData->document()).textEditor()->setPosition(cursorPos, (modifiers & Qt::ShiftModifier) ? QTextCursor::KeepAnchor : QTextCursor::MoveAnchor); } return; } } } } } void KWView::goToNextPage(Qt::KeyboardModifiers modifiers) { // Scroll display qreal moveDistance = m_canvas->canvasController()->visibleHeight() * 0.8; m_canvas->canvasController()->pan(QPoint(0, moveDistance)); // Find current frameset, FIXME for now assume main KWTextFrameSet *currentFrameSet = kwdocument()->mainFrameSet(); // Since we move _down_ calculate the position where a frame would _end_ if // we were scrolled to the _lasst_ page KoShape *shape = currentFrameSet->shapes().last(); QPointF pos = shape->absoluteTransformation(0).map(QPointF(0, shape->size().height() - 5)); pos.setY(pos.y() - m_document->pageManager()->page(qreal(pos.y())).rect().bottom()); pos += m_canvas->viewMode()->viewToDocument(m_canvas->documentOffset() + QPointF(0, m_canvas->canvasController()->visibleHeight()), viewConverter()); // Find textshape under that position and from current frameset QList possibleTextShapes = m_canvas->shapeManager()->shapesAt(QRectF(pos.x() - 20, pos.y() -20, 40, 40)); KoTextShapeData *textShapeData = 0; foreach (KoShape* shape, possibleTextShapes) { KoShapeUserData *userData = shape->userData(); if ((textShapeData = dynamic_cast(userData))) { foreach (KoShape *s, currentFrameSet->shapes()) { if (s == shape) { pos = shape->absoluteTransformation(0).inverted().map(pos); pos += QPointF(0.0, textShapeData->documentOffset()); KoTextLayoutArea *area = textShapeData->rootArea(); if (area) { int cursorPos = area->hitTest(pos, Qt::FuzzyHit).position; KoTextDocument(textShapeData->document()).textEditor()->setPosition(cursorPos, (modifiers & Qt::ShiftModifier) ? QTextCursor::KeepAnchor : QTextCursor::MoveAnchor); } return; } } } } } void KWView::goToPage(const KWPage &page) { KoCanvasController *controller = m_gui->canvasController(); QPoint origPos = controller->scrollBarValue(); QPointF pos = m_canvas->viewMode()->documentToView(QPointF(0, page.offsetInDocument()), m_canvas->viewConverter()); origPos.setY((int)pos.y()); controller->setScrollBarValue(origPos); } void KWView::showEvent(QShowEvent *e) { KoView::showEvent(e); QTimer::singleShot(0, this, SLOT(updateStatusBarAction())); } bool KWView::event(QEvent* event) { switch(static_cast(event->type())) { case ViewModeSwitchEvent::AboutToSwitchViewModeEvent: { ViewModeSynchronisationObject* syncObject = static_cast(event)->synchronisationObject(); if (m_canvas) { syncObject->scrollBarValue = m_canvas->canvasController()->scrollBarValue(); syncObject->zoomLevel = zoomController()->zoomAction()->effectiveZoom(); syncObject->activeToolId = KoToolManager::instance()->activeToolId(); syncObject->shapes = m_canvas->shapeManager()->shapes(); syncObject->initialized = true; } return true; } case ViewModeSwitchEvent::SwitchedToDesktopModeEvent: { ViewModeSynchronisationObject* syncObject = static_cast(event)->synchronisationObject(); if (m_canvas && syncObject->initialized) { m_canvas->canvasWidget()->setFocus(); qApp->processEvents(); m_canvas->shapeManager()->setShapes(syncObject->shapes); zoomController()->setZoom(KoZoomMode::ZOOM_CONSTANT, syncObject->zoomLevel); qApp->processEvents(); m_canvas->canvasController()->setScrollBarValue(syncObject->scrollBarValue); qApp->processEvents(); foreach(KoShape *shape, m_canvas->shapeManager()->shapesAt(currentPage().rect())) { if (qobject_cast(shape->userData())) { m_canvas->shapeManager()->selection()->select(shape); break; } } KoToolManager::instance()->switchToolRequested("TextToolFactory_ID"); } return true; } } return QWidget::event(event); } void KWView::updateStatusBarAction() { KToggleAction *action = (KToggleAction*) actionCollection()->action("showStatusBar"); if (action && statusBar()) action->setChecked(! statusBar()->isHidden()); } void KWView::offsetInDocumentMoved(int yOffset) { const qreal offset = -m_zoomHandler.viewToDocumentY(yOffset); const qreal height = m_zoomHandler.viewToDocumentY(m_gui->viewportSize().height()); /* if (m_currentPage.isValid()) { // most of the time the current will not change. const qreal pageTop = m_currentPage.offsetInDocument(); const qreal pageBottom = pageTop + m_currentPage.height(); const qreal visibleArea = qMin(offset + height, pageBottom) - qMax(pageTop, offset); if (visibleArea / height >= 0.45) // current page is just fine if > 45% is shown return; // using 'next'/'prev' is much cheaper than using a documentOffset, so try that first. if (pageTop > offset && pageTop < offset + height) { // check if the page above is a candidate. KWPage page = m_currentPage.previous(); if (page.isValid() && pageTop - offset > visibleArea) { firstDrawnPage = page; return; } } if (pageBottom > offset && pageBottom < offset + height) { // check if the page above is a candidate. KWPage page = m_currentPage.next(); if (page.isValid() && m_currentPage.height() - height > visibleArea) { firstDrawnPage = page; return; } } } */ KWPage page = m_document->pageManager()->page(qreal(offset)); qreal pageTop = page.offsetInDocument(); QSizeF maxPageSize; qreal minTextX = std::numeric_limits::max(); qreal maxTextX = std::numeric_limits::min(); int minPageNum = page.pageNumber(); int maxPageNum = page.pageNumber(); while (page.isValid() && pageTop < qreal(offset + height)) { pageTop += page.height(); QSizeF pageSize = page.rect().size(); maxPageSize = QSize(qMax(maxPageSize.width(), pageSize.width()), qMax(maxPageSize.height(), pageSize.height())); minTextX = qMin(minTextX, page.contentRect().left()); maxTextX = qMax(maxTextX, page.contentRect().right()); maxPageNum = page.pageNumber(); page = page.next(); } if (maxPageSize != m_pageSize) { m_pageSize = maxPageSize; QSizeF pageSize = m_pageSize; if (m_canvas->showAnnotations()) { pageSize += QSize(KWCanvasBase::AnnotationAreaWidth, 0.0); } m_zoomController->setPageSize(pageSize); } if (minTextX != m_textMinX || maxTextX != m_textMaxX) { m_textMinX = minTextX; m_textMaxX = maxTextX; m_zoomController->setTextMinMax(minTextX, maxTextX); } if (minPageNum != m_minPageNum || maxPageNum != m_maxPageNum) { m_minPageNum = minPageNum; m_maxPageNum = maxPageNum; emit shownPagesChanged(); } } #ifdef SHOULD_BUILD_RDF void KWView::semanticObjectViewSiteUpdated(hKoRdfBasicSemanticItem basicitem, const QString &xmlid) { hKoRdfSemanticItem item(static_cast(basicitem.data())); kDebug(30015) << "xmlid:" << xmlid << " reflow item:" << item->name(); KoTextEditor *editor = KoTextEditor::getTextEditorFromCanvas(canvasBase()); if (!editor) { kDebug(30015) << "no editor, not reflowing rdf semantic item."; return; } kDebug(30015) << "reflowing rdf semantic item."; KoRdfSemanticItemViewSite vs(item, xmlid); vs.reflowUsingCurrentStylesheet(editor); } #endif void KWView::findMatchFound(KoFindMatch match) { if(!match.isValid() || !match.location().canConvert() || !match.container().canConvert()) { return; } QTextCursor cursor = match.location().value(); m_canvas->resourceManager()->setResource(KoText::CurrentTextAnchor, cursor.anchor()); m_canvas->resourceManager()->setResource(KoText::CurrentTextPosition, cursor.position()); } void KWView::refreshFindTexts() { QList texts; foreach (KWFrameSet *fSet, m_document->frameSets()) { KWTextFrameSet *tFSet = dynamic_cast(fSet); if (tFSet) { texts.append(tFSet->document()); } } m_find->setDocuments(texts); } void KWView::addImages(const QVector &imageList, const QPoint &insertAt) { if (!m_canvas) { // no canvas because we're not on the desktop? return; } QPointF pos = viewConverter()->viewToDocument(m_canvas->documentOffset() + insertAt - canvas()->pos()); pos.setX(qMax(qreal(0), pos.x())); pos.setY(qMax(qreal(0), pos.y())); // create a factory KoShapeFactoryBase *factory = KoShapeRegistry::instance()->value("PictureShape"); if (!factory) { warnWords << "No picture shape found, cannot drop images."; return; } foreach(const QImage &image, imageList) { KoProperties params; params.setProperty("qimage", image); KoShape *shape = factory->createShape(¶ms, kwdocument()->resourceManager()); // resize the shape so it will fit in the document, with some nice // hard-coded constants. qreal pageWidth = currentPage().width(); qreal pageHeight = currentPage().height(); if (shape->size().width() > (pageWidth * 0.8) || shape->size().height() > pageHeight) { QSizeF sz = shape->size(); sz.scale(QSizeF(pageWidth * 0.6, pageHeight *.6), Qt::KeepAspectRatio); shape->setSize(sz); } if (!shape) { warnWords << "Could not create a shape from the image"; return; } shape->setTextRunAroundSide(KoShape::BothRunAroundSide); KoShapeAnchor *anchor = new KoShapeAnchor(shape); anchor->setAnchorType(KoShapeAnchor::AnchorPage); anchor->setHorizontalPos(KoShapeAnchor::HFromLeft); anchor->setVerticalPos(KoShapeAnchor::VFromTop); anchor->setHorizontalRel(KoShapeAnchor::HPage); anchor->setVerticalRel(KoShapeAnchor::VPage); shape->setAnchor(anchor); shape->setPosition(pos); pos += QPointF(25,25); // increase the position for each shape we insert so the // user can see them all. // create the undo step. KWShapeCreateCommand *cmd = new KWShapeCreateCommand(kwdocument(), shape); KoSelection *selection = m_canvas->shapeManager()->selection(); selection->deselectAll(); selection->select(shape); m_canvas->addCommand(cmd); } } const qreal KWView::AnnotationAreaWidth = 200.0; // only static const integral data members can be initialized within a class diff --git a/words/part/KWView.h b/words/part/KWView.h index 120826709b8..fcb3f700a92 100644 --- a/words/part/KWView.h +++ b/words/part/KWView.h @@ -1,266 +1,266 @@ /* This file is part of the KDE project * Copyright (C) 2005-2007, 2009, 2010 Thomas Zander * Copyright (C) 2010 Boudewijn Rempt * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public License * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA */ #ifndef KWVIEW_H #define KWVIEW_H #include "words_export.h" #include "KWPage.h" #include "./dockers/KWStatisticsWidget.h" #include "./dockers/KWStatisticsDocker.h" #include #include #include #include #include class KWDocument; class KWCanvas; class KWFrame; class KWGui; class KoPart; class KoCanvasBase; class KoZoomController; class KoFindText; class QPushButton; #ifdef SHOULD_BUILD_RDF class KoRdfBasicSemanticItem; typedef QExplicitlySharedDataPointer hKoRdfBasicSemanticItem; #endif class KToggleAction; /** * Words' view class. Following the broad model-view-controller idea this class * shows you one view on the document. There can be multiple views of the same document each * in with independent settings for viewMode and zoom etc. */ class WORDS_EXPORT KWView : public KoView { Q_OBJECT public: static const qreal AnnotationAreaWidth; /** * Construct a new view on the words document. * The view will have a canvas as a member which does all the actual painting, the view will * be responsible for handling the actions. The View is technically speaking the controller * class in the MVC design. * @param part a KoPart * @param document the document we show. * @param parent a parent widget we show ourselves in. */ KWView(KoPart *part, KWDocument *document, QWidget *parent); virtual ~KWView(); /** * return the KWDocument that owns this view. * @see KoView::document() */ KWDocument *kwdocument() const { return m_document; } /// reimplemented from superclass void addImages(const QVector &imageList, const QPoint &insertAt); // interface KoView /// reimplemented method from superclass virtual void updateReadWrite(bool readWrite); /// reimplemented method from superclass virtual QWidget *canvas() const; /// returns true if this view has the snap-to-grid enabled. bool snapToGrid() const { return m_snapToGrid; } /** * Return the current canvas; much like canvas(), but this one does not downcast. */ KoCanvasBase *canvasBase() const; /// Return the view converter for this view. KoViewConverter *viewConverter() { return &m_zoomHandler; } /// show a popup on the view, adding to it a list of actions void popupContextMenu(const QPoint &globalPosition, const QList &actions); const KWPage currentPage() const; void setCurrentPage(const KWPage &page); /// go to page void goToPage(const KWPage &page); virtual KoZoomController *zoomController() const { return m_zoomController; } int minPageNumber() const { return m_minPageNum; } int maxPageNumber() const { return m_maxPageNum; } void viewMouseMoveEvent(QMouseEvent *e); Q_SIGNALS: void shownPagesChanged(); public Q_SLOTS: void offsetInDocumentMoved(int yOffset); /// displays the KWPageSettingsDialog that allows to change properties of the entire page void formatPage(); /// turns the border display on/off 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); /// toggle the display of section bounds void setShowSectionBounds(bool on); /// go to previous page void goToPreviousPage(Qt::KeyboardModifiers modifiers = Qt::NoModifier); /// go to next page void goToNextPage(Qt::KeyboardModifiers modifiers = Qt::NoModifier); - /// Call when "Exit Distraction-Free Mode" in status bar clicked. - void exitDistractioFreeMode(); + /// Call when "Exit Fullscreen Mode" in status bar clicked. + void exitFullscreenMode(); protected: /// reimplemented method from superclass virtual void showEvent(QShowEvent *event); virtual bool event(QEvent* event); private: void setupActions(); virtual KoPrintJob *createPrintJob(); /// loops over the selected shapes and returns the top level shapes. QList selectedShapes() const; KoShape *selectedShape() const; private Q_SLOTS: /// create a template from document void createTemplate(); /// displays the KWFrameDialog that allows to alter the frameset properties void editFrameProperties(); /// called if another shape got selected void selectionChanged(); /// enable document headers void enableHeader(); /// enable document footers void enableFooter(); /// snap to grid void toggleSnapToGrid(); /// displays libs/main/rdf/SemanticStylesheetsEditor to edit Rdf stylesheets void editSemanticStylesheets(); /// called if the zoom changed void zoomChanged(KoZoomMode::Mode mode, qreal zoom); /// shows or hides the rulers void showRulers(bool visible); /// shows or hides the status bar void showStatusBar(bool); /// calls delete on the active tool void editDeleteSelection(); /** decide if we enable or disable the action "delete_page" uppon m_document->page_count() */ void updateStatusBarAction(); /// show guides menu option uses this void setGuideVisibility(bool on); /// open the configure dialog. void configure(); #ifdef SHOULD_BUILD_RDF /// A semantic item was updated and should have it's text refreshed. void semanticObjectViewSiteUpdated(hKoRdfBasicSemanticItem item, const QString &xmlid); #endif /// A match was found when searching. void findMatchFound(KoFindMatch match); /// This is used to update the text that can be searched. void refreshFindTexts(); /// The KWPageSettingsDialog was closed. void pageSettingsDialogFinished(); /// user wants to past data from the clipboard void pasteRequested(); /// Call when the user want to show/hide the WordsCount in the statusbar void showWordCountInStatusBar(bool doShow); /// Show annotations ("notes" in the UI) on the canvas - this is the user view menu visibility change void showNotes(bool show); /// "hasAnnotations" has changed ("notes" in the UI) - will cause showNotes above to change too void hasNotes(bool has); /** - * Set view into distraction free mode, hide menu bar, status bar, tool bar, dockers + * Set view into fullscreen mode, hide menu bar, status bar, tool bar, dockers * and set view into full screen mode. */ - void setDistractionFreeMode(bool); /// Call after 4 seconds, user doesn't move cursor. + void setFullscreenMode(bool); /// Call after 4 seconds, user doesn't move cursor. void hideCursor(); - /// Hide status bar and scroll bars after seconds in Distraction-Free mode. + /// Hide status bar and scroll bars after seconds in fullscreen mode. void hideUI(); private: KWGui *m_gui; KWCanvas *m_canvas; KWDocument *m_document; KoZoomHandler m_zoomHandler; KoZoomController *m_zoomController; KWPage m_currentPage; KoFindText *m_find; QAction *m_actionCreateTemplate; QAction *m_actionFormatFrameSet; QAction *m_actionInsertFrameBreak; QAction *m_actionFormatFont; QAction *m_actionEditDelFrame; QAction *m_actionRaiseFrame; QAction *m_actionLowerFrame; QAction *m_actionBringToFront; QAction *m_actionSendBackward; KToggleAction *m_actionFormatBold; KToggleAction *m_actionFormatItalic; KToggleAction *m_actionFormatUnderline; KToggleAction *m_actionFormatStrikeOut; QAction *m_actionViewHeader; QAction *m_actionViewFooter; KToggleAction *m_actionViewSnapToGrid; bool m_snapToGrid; QString m_lastPageSettingsTab; QSizeF m_pageSize; // The max size of the pages we currently show. Prevents endless loop qreal m_textMinX; // The min x value where text can appear we currently show. Prevents endless loop qreal m_textMaxX; // The max x value where text can appear we currently show. Prevents endless loop int m_minPageNum; int m_maxPageNum; //Word count stuff for display in status bar void buildAssociatedWidget(); KWStatisticsWidget *wordCount; - bool m_isDistractionFreeMode; + bool m_isFullscreenMode; QTimer *m_hideCursorTimer; - // The button will add to status bar in distraction-free mode to let user come + // The button will add to status bar in fullscreen mode to let user come // back to standard view. QPushButton *m_dfmExitButton; }; #endif diff --git a/words/part/calligrawords.rc b/words/part/calligrawords.rc index a50eb57b860..fe93dbf554e 100644 --- a/words/part/calligrawords.rc +++ b/words/part/calligrawords.rc @@ -1,254 +1,253 @@ &File &Edit &View - S&tyles &Settings Spellcheck Edit Spell Check Result Change Variable To