Clicked text on its baseline, live text on the Move tool's double click, SVG import (12.11c)
This commit is contained in:
1 parent
008493b0a3
commit
8fbb104c48
34 files changed
+572
-47
No files matched your search
@@ -105,6 +105,11 @@ void EditorSession::decodeNext()
|
||||
decodeRaw(url.toLocalFile(), remainingPixels());
|
||||
return;
|
||||
}
|
||||
// An SVG goes by its suffix, before Photoshop's bytes.
|
||||
if (url.isLocalFile() && ImageImporter::isSVG(url.toLocalFile())) {
|
||||
decode(url, false);
|
||||
return;
|
||||
}
|
||||
if (url.isLocalFile() && PSDReader::matches(url.toLocalFile())) {
|
||||
beginPSDReading(QStringLiteral("Open “%1”?").arg(url.fileName()), QStringLiteral("Import"));
|
||||
m_photoshopReader.setFuture(QtConcurrent::run([path = url.toLocalFile(), remaining = remainingPixels()]() -> PhotoshopRead {
|
||||
@@ -143,10 +148,13 @@ qint64 EditorSession::remainingPixels() const
|
||||
// `flattened`: a layerless Photoshop file, read as its merged image.
|
||||
void EditorSession::decode(const QUrl &url, bool flattened)
|
||||
{
|
||||
m_decoder.setFuture(QtConcurrent::run([url, flattened, remaining = remainingPixels()]() -> Decoded {
|
||||
const std::optional<QSizeF> fitting = m_document ? std::optional(m_document->size()) : std::nullopt;
|
||||
m_decoder.setFuture(QtConcurrent::run([url, flattened, fitting, remaining = remainingPixels()]() -> Decoded {
|
||||
try {
|
||||
if (!url.isLocalFile())
|
||||
throw ImageImportError(ImageImportError::Kind::unsupported);
|
||||
if (ImageImporter::isSVG(url.toLocalFile()))
|
||||
return {ImageImporter::decodeSVG(url.toLocalFile(), fitting, remaining), QString()};
|
||||
return {ImageImporter::decode(url.toLocalFile(), remaining, flattened), QString()};
|
||||
} catch (const ImageImportError &error) {
|
||||
return {std::nullopt, url.fileName() + ": " + error.what()};
|
||||
|
||||
@@ -97,8 +97,11 @@ void EditorSession::beginText(QPointF point, bool newLayer)
|
||||
style.boxSize = std::nullopt;
|
||||
}
|
||||
m_tool = NavigationTool::type;
|
||||
// A click puts new text's first baseline on the pointer.
|
||||
const double padding = LayerTextStyle::padding;
|
||||
const QPointF origin = target ? target->origin() : point - QPointF(padding, padding + TextLines(style, QSizeF(100'000, 100'000)).baseline(0));
|
||||
setTextDraft(TextDraft{.documentID = m_document->id, .layerID = target ? std::optional(target->id) : std::nullopt,
|
||||
.origin = target ? target->origin() : point,
|
||||
.origin = origin,
|
||||
.transform = target ? std::optional(target->transform) : std::nullopt, .style = style});
|
||||
}
|
||||
|
||||
@@ -202,6 +205,8 @@ void EditorSession::beginText(const QRectF &rect)
|
||||
beginText(rect.topLeft(), true);
|
||||
if (m_textDraft) {
|
||||
TextDraft draft = *m_textDraft;
|
||||
// A dragged box is exactly where it was drawn.
|
||||
draft.origin = rect.topLeft();
|
||||
draft.style.boxSize = style.boxSize;
|
||||
setTextDraft(draft);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user