Commit 5e58ba8f authored by Alexander Semke's avatar Alexander Semke
Browse files

* Enable the copy action in the context menu of the text result item also if...

* Enable the copy action in the context menu of the text result item also if no text is selected, copy everything in this case which is the most frequent and the expected behavior (right click and copy to copy the whole result).
* don't try to save the text result if now the file dialog was canceled, i.e. no file name was provided.
parent 4a9ca0ec
Pipeline #119145 passed with stage
in 18 minutes and 41 seconds
......@@ -56,7 +56,7 @@ ResultItem* ResultItem::create(WorksheetEntry* parent, Cantor::Result* result)
void ResultItem::addCommonActions(QObject* self, QMenu* menu)
{
menu->addAction(i18n("Save result"), self, SLOT(saveResult()));
menu->addAction(QIcon::fromTheme(QLatin1String("document-export")), i18n("Save result"), self, SLOT(saveResult()));
menu->addAction(QIcon::fromTheme(QLatin1String("edit-delete")), i18n("Remove result"), self, [this](){
this->needRemove();
});
......
......@@ -51,9 +51,8 @@ double TextResultItem::setGeometry(double x, double y, double w)
void TextResultItem::populateMenu(QMenu* menu, QPointF pos)
{
QAction * copy = KStandardAction::copy(this, SLOT(copy()), menu);
if (!textCursor().hasSelection())
copy->setEnabled(false);
auto* copy = KStandardAction::copy(this, SLOT(copy()), menu);
copy->setText(i18n("Copy result"));
menu->addAction(copy);
ResultItem::addCommonActions(this, menu);
......@@ -207,10 +206,13 @@ void TextResultItem::showPlain()
void TextResultItem::saveResult()
{
Cantor::Result* res = result();
auto* res = result();
const QString& filename = QFileDialog::getSaveFileName(worksheet()->worksheetView(), i18n("Save result"), QString(), res->mimeType());
qDebug() << "saving result to " << filename;
res->save(filename);
if (!filename.isEmpty())
{
qDebug() << "saving result to " << filename;
res->save(filename);
}
}
void TextResultItem::deleteLater()
......
......@@ -191,9 +191,10 @@ void WorksheetTextItem::copy()
QApplication::sendEvent(worksheet(), event);
delete event;
} else {
if (!textCursor().hasSelection())
return;
QString text = resolveImages(textCursor());
auto cursor = textCursor();
if (!cursor.hasSelection())
cursor.select(QTextCursor::Document);
QString text = resolveImages(cursor);
text.replace(QChar::ParagraphSeparator, QLatin1Char('\n'));
text.replace(QChar::LineSeparator, QLatin1Char('\n'));
QApplication::clipboard()->setText(text);
......
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