New package: drawy-1.0.1

This commit is contained in:
Nafis
2026-06-24 02:05:40 +02:00
committed by Duncan Overbruck
parent e15b2ac821
commit 7b798ab449
2 changed files with 165 additions and 0 deletions
@@ -0,0 +1,146 @@
From cd5433133464671beea1607ed7d79f43cb4cf1b8 Mon Sep 17 00:00:00 2001
From: Pino Toscano <pino@kde.org>
Date: Sun, 24 May 2026 06:36:07 +0200
Subject: [PATCH 1/2] refactor: rename getLineRange(int) to
getLineRangeForLine()
To help distinguish the two getLineRange() functions, rename the "int"
variant to getLineRangeForLine(), to indicate its input is a line
number.
---
src/gui/autotests/textitemtest.cpp | 4 ++--
src/gui/item/text.cpp | 4 ++--
src/gui/item/text.hpp | 2 +-
3 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/src/gui/autotests/textitemtest.cpp b/src/gui/autotests/textitemtest.cpp
index 143496e3..350e7016 100644
--- a/src/gui/autotests/textitemtest.cpp
+++ b/src/gui/autotests/textitemtest.cpp
@@ -145,11 +145,11 @@ void TextItemTest::shouldTestLineRange()
TextItem i;
i.insertText(u"Line 1\nLine 2\nLine 3"_s);
- auto range1 = i.getLineRange(1);
+ auto range1 = i.getLineRangeForLine(1);
QCOMPARE(range1.first, 0);
QCOMPARE(range1.second, 6);
- auto range2 = i.getLineRange(2);
+ auto range2 = i.getLineRangeForLine(2);
QCOMPARE(range2.first, 7);
QCOMPARE(range2.second, 13);
}
diff --git a/src/gui/item/text.cpp b/src/gui/item/text.cpp
index 1a894b1b..441e1968 100644
--- a/src/gui/item/text.cpp
+++ b/src/gui/item/text.cpp
@@ -205,7 +205,7 @@ qsizetype TextItem::getIndexFromX(double xPos, int lineNumber) const
{
const QFontMetricsF metrics{getFont()};
- auto [start, end] = getLineRange(lineNumber);
+ auto [start, end] = getLineRangeForLine(lineNumber);
const QString line{m_text.mid(start, end - start + 1)};
const double distanceFromLeft{std::max(xPos - m_boundingBox.x(), 0.0)};
@@ -390,7 +390,7 @@ QPen TextItem::getPen() const
return pen;
}
-std::pair<qsizetype, qsizetype> TextItem::getLineRange(int lineNumber) const
+std::pair<qsizetype, qsizetype> TextItem::getLineRangeForLine(int lineNumber) const
{
const qsizetype len{m_text.length()};
diff --git a/src/gui/item/text.hpp b/src/gui/item/text.hpp
index 813a2cdf..34234c8c 100644
--- a/src/gui/item/text.hpp
+++ b/src/gui/item/text.hpp
@@ -55,7 +55,7 @@ public:
[[nodiscard]] bool hasSelection() const;
- [[nodiscard]] std::pair<qsizetype, qsizetype> getLineRange(int lineNumber) const;
+ [[nodiscard]] std::pair<qsizetype, qsizetype> getLineRangeForLine(int lineNumber) const;
[[nodiscard]] std::pair<qsizetype, qsizetype> getLineRange(qsizetype position) const;
[[nodiscard]] qsizetype getPrevBreak(qsizetype pos) const;
--
GitLab
From d400876774a4c2481bebf425a830e0a4642fd3ee Mon Sep 17 00:00:00 2001
From: Pino Toscano <pino@kde.org>
Date: Sun, 24 May 2026 06:38:02 +0200
Subject: [PATCH 2/2] refactor: rename getLineRange(qsizetype) to
getLineRangeForPosition()
To help distinguish the two getLineRange() functions, rename the
"qsizetype" variant to getLineRangeForPosition(), to indicate its input
is a position in the text stream.
---
src/gui/item/text.cpp | 4 ++--
src/gui/item/text.hpp | 2 +-
src/widgets/tools/texttool.cpp | 4 ++--
3 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/src/gui/item/text.cpp b/src/gui/item/text.cpp
index 441e1968..5b06112c 100644
--- a/src/gui/item/text.cpp
+++ b/src/gui/item/text.cpp
@@ -62,7 +62,7 @@ void TextItem::draw(QPainter &painter, const QPointF &offset)
// Drawing the caret
// PERF: There is no need to scan the entire text just to place the caret
// This can be a lot more efficient, so feel free to open a PR
- auto [start, end] = getLineRange(cur);
+ auto [start, end] = getLineRangeForPosition(cur);
const QString &curLine{m_text.mid(start, cur - start)};
int lineCount{0};
@@ -414,7 +414,7 @@ std::pair<qsizetype, qsizetype> TextItem::getLineRangeForLine(int lineNumber) co
return std::make_pair(startIndex, endIndex);
}
-std::pair<qsizetype, qsizetype> TextItem::getLineRange(qsizetype position) const
+std::pair<qsizetype, qsizetype> TextItem::getLineRangeForPosition(qsizetype position) const
{
qsizetype start{m_text.lastIndexOf(u'\n', position - 1)};
if (start == -1 || position == 0) {
diff --git a/src/gui/item/text.hpp b/src/gui/item/text.hpp
index 34234c8c..0d1cf6d7 100644
--- a/src/gui/item/text.hpp
+++ b/src/gui/item/text.hpp
@@ -56,7 +56,7 @@ public:
[[nodiscard]] bool hasSelection() const;
[[nodiscard]] std::pair<qsizetype, qsizetype> getLineRangeForLine(int lineNumber) const;
- [[nodiscard]] std::pair<qsizetype, qsizetype> getLineRange(qsizetype position) const;
+ [[nodiscard]] std::pair<qsizetype, qsizetype> getLineRangeForPosition(qsizetype position) const;
[[nodiscard]] qsizetype getPrevBreak(qsizetype pos) const;
[[nodiscard]] qsizetype getNextBreak(qsizetype pos) const;
diff --git a/src/widgets/tools/texttool.cpp b/src/widgets/tools/texttool.cpp
index e05eb700..8a042944 100644
--- a/src/widgets/tools/texttool.cpp
+++ b/src/widgets/tools/texttool.cpp
@@ -141,7 +141,7 @@ void TextTool::mouseMoved(ApplicationContext *context)
m_curItem->setSelectionEnd(m_curItem->getNextBreak(curIndex));
}
} else if (m_tripleClicked) {
- auto [start, end] = m_curItem->getLineRange(curIndex);
+ auto [start, end] = m_curItem->getLineRangeForPosition(curIndex);
if (isLeft) {
m_curItem->setSelectionStart(std::max(curStart, curEnd));
m_curItem->setSelectionEnd(start);
@@ -217,7 +217,7 @@ void TextTool::mouseTripleClick(ApplicationContext *context)
const qsizetype curIndex{m_curItem->getIndexFromCursor(worldPos)};
- const auto [start, end] = m_curItem->getLineRange(curIndex);
+ const auto [start, end] = m_curItem->getLineRangeForPosition(curIndex);
m_curItem->setSelectionStart(start);
m_curItem->setSelectionEnd(end + 1);
--
GitLab
+19
View File
@@ -0,0 +1,19 @@
# Template file for 'drawy'
pkgname=drawy
version=1.0.1
revision=1
build_style=cmake
configure_args="-DBUILD_TESTING=OFF -DKF6_HOST_TOOLING=/usr/lib/cmake
-DKDE_INSTALL_QTPLUGINDIR=lib/qt6/plugins
-DKDE_INSTALL_QMLDIR=lib/qt6/qml
-DECM_MKSPECS_INSTALL_DIR=/usr/lib/qt6/mkspecs/modules"
hostmakedepends="extra-cmake-modules qt6-tools qt6-base gettext pkg-config
kf6-kconfig kf6-kcoreaddons kf6-kdoctools"
makedepends="kf6-kxmlgui-devel kf6-kcrash-devel kf6-ki18n-devel kf6-kiconthemes-devel
kf6-syntax-highlighting-devel libzstd-devel kf6-kdoctools-devel"
short_desc="Handy, infinite brainstorming tool"
maintainer="Nafis <mnabid.25@outlook.com>"
license="GPL-3.0-or-later"
homepage="https://apps.kde.org/drawy/"
distfiles="${KDE_SITE}/drawy/${version}/drawy-${version}.tar.xz"
checksum=3bf3764784d6c8cfd80bd4fd639d73eaedc4c88889c03215d3add25f685ab227