Commit 4c146e44 authored by Alexander Semke's avatar Alexander Semke
Browse files

Fixes:

* when removing the current placeholder entry during a drag move event, don't ask for confirmation
* more icons in the worksheet context menu
* made Worksheet::showCompletion() public since it's called from another object and we want to use the new signal-slot syntax
* simplified the setting of the short cut for "show completion" in CantorPart
* more forward declarations in Worksheet
parent 157c5f32
Pipeline #116388 failed with stage
in 2 minutes and 43 seconds
......@@ -357,10 +357,8 @@ CantorPart::CantorPart( QWidget *parentWidget, QObject *parent, const QVariantLi
QAction* showCompletion = new QAction(i18n("Show Completion"), collection);
collection->addAction(QLatin1String("show_completion"), showCompletion);
QList<QKeySequence> showCompletionShortcuts;
showCompletionShortcuts << Qt::CTRL + Qt::Key_Space; // No Tab, because the tab handeled by entries itself
collection->setDefaultShortcuts(showCompletion, showCompletionShortcuts);
connect(showCompletion, SIGNAL(triggered()), m_worksheet, SLOT(showCompletion()));
collection->setDefaultShortcut(showCompletion, Qt::CTRL + Qt::Key_Space);
connect(showCompletion, &QAction::triggered, m_worksheet, &Worksheet::showCompletion);
m_editActions.push_back(showCompletion);
// set our XML-UI resource file
......
......@@ -21,6 +21,7 @@
#include <QGuiApplication>
#include <QDebug>
#include <QDesktopWidget>
#include <QFontDatabase>
#include <QFontDialog>
#include <QScreen>
#include <QTimer>
......@@ -28,6 +29,7 @@
#include <QPropertyAnimation>
#include <QJsonArray>
#include <QJsonObject>
#include <QTextBlock>
#include <QTextDocumentFragment>
#include <QPainter>
......
......@@ -26,6 +26,7 @@
#include <QClipboard>
#include <QMimeData>
#include <QGraphicsSceneDragDropEvent>
#include <QTextBlock>
#include <KLocalizedString>
#include <KZip>
......
......@@ -124,6 +124,7 @@ void Worksheet::print(QPrinter* printer)
m_epsRenderer.useHighResolution(true);
m_mathRenderer.useHighResolution(true);
m_isPrinting = true;
QRect pageRect = printer->pageRect();
qreal scale = 1; // todo: find good scale for page size
// todo: use epsRenderer()->scale() for printing ?
......@@ -134,6 +135,7 @@ void Worksheet::print(QPrinter* printer)
QPainter painter(printer);
painter.scale(scale, scale);
painter.setRenderHint(QPainter::Antialiasing);
WorksheetEntry* entry = firstEntry();
qreal y = TopMargin;
......@@ -1848,10 +1850,10 @@ void Worksheet::populateMenu(QMenu *menu, QPointF pos)
convertTo->addAction(QIcon::fromTheme(QLatin1String("insert-page-break")), i18n("Page Break"), entry, &WorksheetEntry::converToPageBreakEntry);
if (entry->type() != HorizontalRuleEntry::Type)
convertTo->addAction(QIcon(), i18n("Horizontal Line"), entry, &WorksheetEntry::convertToHorizontalRuleEntry);
convertTo->addAction(QIcon::fromTheme(QLatin1String("newline")), i18n("Horizontal Line"), entry, &WorksheetEntry::convertToHorizontalRuleEntry);
if (entry->type() != HierarchyEntry::Type)
convertTo->addAction(QIcon(), i18n("Hierarchy Entry"), entry, &WorksheetEntry::convertToHierarchyEntry);
convertTo->addAction(QIcon::fromTheme(QLatin1String("view-list-tree")), i18n("Hierarchy Entry"), entry, &WorksheetEntry::convertToHierarchyEntry);
//"Insert After" menu
QMenu* insert = new QMenu(i18n("Insert After"), menu);
......@@ -1868,9 +1870,11 @@ void Worksheet::populateMenu(QMenu *menu, QPointF pos)
insert->addAction(QIcon::fromTheme(QLatin1String("text-x-tex")), i18n("LaTeX"), entry, SLOT(insertLatexEntry()));
#endif
insert->addAction(QIcon::fromTheme(QLatin1String("image-x-generic")), i18n("Image"), entry, SLOT(insertImageEntry()));
insert->addSeparator();
insert->addAction(QIcon::fromTheme(QLatin1String("newline")), i18n("Horizontal Line"), entry, SLOT(insertHorizontalRuleEntry()));
insert->addAction(QIcon::fromTheme(QLatin1String("insert-page-break")), i18n("Page Break"), entry, SLOT(insertPageBreakEntry()));
insert->addAction(QIcon(), i18n("Horizontal Line"), entry, SLOT(insertHorizontalRuleEntry()));
insert->addAction(QIcon(), i18n("Hierarchy Entry"), entry, SLOT(insertHierarchyEntry()));
insert->addSeparator();
insert->addAction(QIcon::fromTheme(QLatin1String("view-list-tree")), i18n("Hierarchy Entry"), entry, SLOT(insertHierarchyEntry()));
//"Insert Before" menu
QMenu* insertBefore = new QMenu(i18n("Insert Before"), menu);
......@@ -1886,9 +1890,11 @@ void Worksheet::populateMenu(QMenu *menu, QPointF pos)
insertBefore->addAction(QIcon::fromTheme(QLatin1String("text-x-tex")), i18n("LaTeX"), entry, SLOT(insertLatexEntryBefore()));
#endif
insertBefore->addAction(QIcon::fromTheme(QLatin1String("image-x-generic")), i18n("Image"), entry, SLOT(insertImageEntryBefore()));
insertBefore->addSeparator();
insertBefore->addAction(QIcon::fromTheme(QLatin1String("newline")), i18n("Horizontal Line"), entry, SLOT(insertHorizontalRuleEntryBefore()));
insertBefore->addAction(QIcon::fromTheme(QLatin1String("insert-page-break")), i18n("Page Break"), entry, SLOT(insertPageBreakEntryBefore()));
insertBefore->addAction(QIcon(), i18n("Horizontal Line"), entry, SLOT(insertHorizontalRuleEntryBefore()));
insertBefore->addAction(QIcon(), i18n("Hierarchy Entry"), entry, SLOT(insertHierarchyEntryBefore()));
insertBefore->addSeparator();
insertBefore->addAction(QIcon::fromTheme(QLatin1String("view-list-tree")), i18n("Hierarchy Entry"), entry, SLOT(insertHierarchyEntryBefore()));
} else {
QMenu* insertMenu = new QMenu(i18n("Insert"));
insertMenu->setIcon(QIcon::fromTheme(QLatin1String("insert-table-row")));
......@@ -1902,9 +1908,11 @@ void Worksheet::populateMenu(QMenu *menu, QPointF pos)
insertMenu->addAction(QIcon::fromTheme(QLatin1String("text-x-tex")), i18n("LaTeX"), this, &Worksheet::appendLatexEntry);
#endif
insertMenu->addAction(QIcon::fromTheme(QLatin1String("image-x-generic")), i18n("Image"), this, &Worksheet::appendImageEntry);
insertMenu->addSeparator();
insertMenu->addAction(QIcon::fromTheme(QLatin1String("newline")), i18n("Horizontal Line"), this, &Worksheet::appendHorizontalRuleEntry);
insertMenu->addAction(QIcon::fromTheme(QLatin1String("insert-page-break")), i18n("Page Break"), this, &Worksheet::appendPageBreakEntry);
insertMenu->addAction(QIcon(), i18n("Horizontal Line"), this, &Worksheet::appendHorizontalRuleEntry);
insertMenu->addAction(QIcon(), i18n("Hierarchy Entry"), this, &Worksheet::appendHierarchyEntry);
insertMenu->addSeparator();
insertMenu->addAction(QIcon::fromTheme(QLatin1String("view-list-tree")), i18n("Hierarchy Entry"), this, &Worksheet::appendHierarchyEntry);
menu->addMenu(insertMenu);
}
......
......@@ -8,10 +8,8 @@
#ifndef WORKSHEET_H
#define WORKSHEET_H
#include <QDomDocument>
#include <QGraphicsScene>
#include <QDomElement>
#include <QGraphicsObject>
#include <QSyntaxHighlighter>
#include <QQueue>
#include "lib/renderer.h"
......@@ -32,8 +30,10 @@ class WorksheetTextItem;
class QAction;
class QDrag;
class QGraphicsObject;
class QMenu;
class QPrinter;
class QSyntaxHighlighter;
class KActionCollection;
class KToggleAction;
class KFontAction;
......@@ -180,7 +180,7 @@ class Worksheet : public QGraphicsScene
void interruptCurrentEntryEvaluation();
bool completionEnabled();
//void showCompletion();
void showCompletion();
void highlightItem(WorksheetTextItem*);
void rehighlight();
......@@ -283,7 +283,6 @@ class Worksheet : public QGraphicsScene
bool isValidEntry(WorksheetEntry*);
private Q_SLOTS:
void showCompletion();
//void checkEntriesForSanity();
WorksheetEntry* appendEntry(int type, bool focus = true);
......
......@@ -710,6 +710,9 @@ bool WorksheetEntry::aboutToBeRemoved()
void WorksheetEntry::startRemoving()
{
if (type() ==PlaceHolderEntry::Type) //don't do anything if a PlaceholderEntry is being removed in Worksheet::drageMoveEvent()
return;
int rc = KMessageBox::warningYesNo(nullptr, i18n("Do you really want to remove this entry?"), i18n("Remove Entry"));
if (rc == KMessageBox::No)
return;
......
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