Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F85807584
D364.1791922566.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Size
10 KB
Referenced Files
None
Subscribers
None
D364.1791922566.diff
View Options
diff --git a/src/contents/ui/RoomPage.qml b/src/contents/ui/RoomPage.qml
--- a/src/contents/ui/RoomPage.qml
+++ b/src/contents/ui/RoomPage.qml
@@ -4,14 +4,14 @@
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
-import QtQuick 2.2
-import QtQuick.Layouts 1.15
-import QtQuick.Controls 2.15
-import QtQuick.Window 2.15
+import QtQuick
+import QtQuick.Layouts
+import QtQuick.Controls
+import QtQuick.Window
import Qt.labs.platform as Platform
-import org.kde.kirigami 2.13 as Kirigami
-import moe.kazv.mxc.kazv 0.0 as MK
+import org.kde.kirigami as Kirigami
+import moe.kazv.mxc.kazv as MK
import '.' as Kazv
import 'matrix-helpers.js' as Helpers
@@ -186,36 +186,46 @@
uploadList.model = kazvIOManager.getUploadJobs(roomId)
}
- footer: Item {
- height: childrenRect.height
+ footer: Control {
width: parent.width
+ property real cornerPadding: getCornerPadding()
+ leftPadding: Math.max(parent.SafeArea.margins.left,
+ Kirigami.Units.largeSpacing, cornerPadding)
+ rightPadding: Math.max(parent.SafeArea.margins.right,
+ Kirigami.Units.largeSpacing, cornerPadding)
+ bottomPadding: Math.max(parent.SafeArea.margins.bottom,
+ cornerPadding) + Kirigami.Units.largeSpacing
+ background: Rectangle {
+ color: Kirigami.Theme.backgroundColor
+ }
- ListView {
- id: uploadList
- width: parent.width
- height: contentHeight
- model: kazvIOManager.getUploadJobs(roomId)
- delegate: Kazv.KazvIOMenu {
- width: parent.width
- jobId: roomId
- isUpload: true
+ contentItem: ColumnLayout {
+ spacing: 0
+ ListView {
+ id: uploadList
+ Layout.fillWidth: true
+ Layout.preferredHeight: contentHeight
+ model: kazvIOManager.getUploadJobs(roomId)
+ delegate: Kazv.KazvIOMenu {
+ width: parent.width
+ jobId: roomId
+ isUpload: true
+ }
}
- }
- Kazv.TypingIndicator {
- id: typingIndicator
- typingUsers: roomPage.room.typingUsers()
- width: parent.width
- anchors.top: uploadList.bottom
- }
+ Kazv.TypingIndicator {
+ id: typingIndicator
+ typingUsers: roomPage.room.typingUsers()
+ Layout.fillWidth: true
+ }
- Kazv.SendMessageBox {
- id: sendMessageBox
- objectName: 'sendMessageBox'
- width: parent.width
- room: roomPage.room
- anchors.top: typingIndicator.bottom
- enabled: isJoin
+ Kazv.SendMessageBox {
+ id: sendMessageBox
+ objectName: 'sendMessageBox'
+ Layout.fillWidth: true
+ room: roomPage.room
+ enabled: isJoin
+ }
}
}
@@ -331,4 +341,11 @@
goToEventTimer.eventId = eventId
goToEventTimer.start();
}
+
+ function getCornerPadding() {
+ if (kazvConfig.roundedCornerRadius < 0) {
+ kazvConfig.setRoundedCornerRadius(MK.KazvUtil.roundedCornerRadius());
+ }
+ return MK.KazvUtil.cornerPadding(kazvConfig.roundedCornerRadius);
+ }
}
diff --git a/src/kazv-config.hpp b/src/kazv-config.hpp
--- a/src/kazv-config.hpp
+++ b/src/kazv-config.hpp
@@ -23,6 +23,7 @@
Q_PROPERTY(QString lastSession READ lastSession WRITE setLastSession)
Q_PROPERTY(QString cacheDirectory READ cacheDirectory WRITE setCacheDirectory NOTIFY cacheDirectoryChanged)
+ Q_PROPERTY(double roundedCornerRadius READ roundedCornerRadius WRITE setRoundedCornerRadius NOTIFY roundedCornerRadiusChanged)
public:
explicit KazvConfig(QObject *parent = 0);
@@ -48,8 +49,13 @@
**/
void setCacheDirectory(QString cacheDirectory);
+ double roundedCornerRadius() const;
+
+ void setRoundedCornerRadius(double roundedCornerRadius);
+
Q_SIGNALS:
void cacheDirectoryChanged();
+ void roundedCornerRadiusChanged();
private:
void migrateOldConfig();
diff --git a/src/kazv-config.cpp b/src/kazv-config.cpp
--- a/src/kazv-config.cpp
+++ b/src/kazv-config.cpp
@@ -51,6 +51,9 @@
connect(
m_d->settings.get(), &KazvSettings::cacheDirectoryChanged,
this, &KazvConfig::cacheDirectoryChanged);
+ connect(
+ m_d->settings.get(), &KazvSettings::roundedCornerRadiusChanged,
+ this, &KazvConfig::roundedCornerRadiusChanged);
migrateOldConfig();
m_d->sessionsSettings->load();
m_d->settings->load();
@@ -91,6 +94,17 @@
m_d->settings->save();
}
+double KazvConfig::roundedCornerRadius() const
+{
+ return m_d->settings->roundedCornerRadius();
+}
+
+void KazvConfig::setRoundedCornerRadius(double roundedCornerRadius)
+{
+ m_d->settings->setRoundedCornerRadius(roundedCornerRadius);
+ m_d->settings->save();
+}
+
void KazvConfig::migrateOldConfig()
{
KSharedConfigPtr appConfig = m_d->appConfig;
diff --git a/src/kazv-settings.kcfg b/src/kazv-settings.kcfg
--- a/src/kazv-settings.kcfg
+++ b/src/kazv-settings.kcfg
@@ -5,11 +5,17 @@
http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" >
<kcfgfile arg="true" />
<signal name="cacheDirectoryChanged" />
+ <signal name="roundedCornerRadiusChanged" />
<group name="General">
<entry name="cacheDirectory" type="String">
<label>Directory for storing the cached files.</label>
<emit signal="cacheDirectoryChanged" />
</entry>
+ <entry name="roundedCornerRadius" type="Double">
+ <label>Rounded corner radius</label>
+ <default>-1</default>
+ <emit signal="roundedCornerRadiusChanged" />
+ </entry>
</group>
</kcfg>
diff --git a/src/kazv-util.hpp b/src/kazv-util.hpp
--- a/src/kazv-util.hpp
+++ b/src/kazv-util.hpp
@@ -25,6 +25,12 @@
KazvUtil(QObject *parent = 0);
~KazvUtil() override;
+ /// Max Android physical rounded-corner radius in dp (logical px).
+ /// 0 on non-Android, pre-API-31, or when unavailable.
+ /// Query WindowInsets.getRoundedCorner() on the Android UI thread.
+ Q_INVOKABLE qreal roundedCornerRadius() const;
+ Q_INVOKABLE qreal cornerPadding(qreal cornerRadius = -1) const;
+
public Q_SLOTS:
QString escapeHtml(const QString &orig) const;
QString mimeTypeForUrl(const QUrl &url) const;
diff --git a/src/kazv-util.cpp b/src/kazv-util.cpp
--- a/src/kazv-util.cpp
+++ b/src/kazv-util.cpp
@@ -13,6 +13,13 @@
#include "kazv-util.hpp"
#include "html-sanitizer/sanitize.hpp"
+#ifdef Q_OS_ANDROID
+#include <QCoreApplication>
+#include <QFuture>
+#include <QJniObject>
+#include <QVariant>
+#endif
+
KazvUtil::KazvUtil(QObject *parent)
: QObject(parent)
, m_kfQtMajorVersion(KAZV_KF_QT_MAJOR_VERSION)
@@ -48,3 +55,89 @@
{
return QString::fromStdString(::sanitizeHtml(raw.toStdString()));
}
+
+qreal KazvUtil::roundedCornerRadius() const
+{
+#ifdef Q_OS_ANDROID
+ // RoundedCorner API needs API 31+. QAndroidApplication::sdkVersion()
+ // wraps Build.VERSION.SDK_INT.
+ if (QNativeInterface::QAndroidApplication::sdkVersion() < 31) {
+ return 0.0;
+ }
+
+ // Must query View/WindowInsets on the Android UI thread.
+ auto fetchInset = []() -> QVariant {
+ const QJniObject activity =
+ QNativeInterface::QAndroidApplication::context();
+ if (!activity.isValid()) {
+ return QVariant(0.0);
+ }
+ const QJniObject window = activity.callObjectMethod(
+ "getWindow", "()Landroid/view/Window;");
+ if (!window.isValid()) {
+ return QVariant(0.0);
+ }
+ const QJniObject decorView = window.callObjectMethod(
+ "getDecorView", "()Landroid/view/View;");
+ if (!decorView.isValid()) {
+ return QVariant(0.0);
+ }
+ const QJniObject insets = decorView.callObjectMethod(
+ "getRootWindowInsets", "()Landroid/view/WindowInsets;");
+ if (!insets.isValid()) {
+ return QVariant(0.0);
+ }
+
+ int maxRadiusPx = 0;
+ // RoundedCorner positions: TOP_LEFT=0, TOP_RIGHT=1,
+ // BOTTOM_RIGHT=2, BOTTOM_LEFT=3
+ for (int pos = 0; pos < 4; ++pos) {
+ const QJniObject corner = insets.callObjectMethod(
+ "getRoundedCorner", "(I)Landroid/view/RoundedCorner;", pos);
+ if (!corner.isValid()) {
+ continue;
+ }
+ const int radius = corner.callMethod<jint>("getRadius", "()I");
+ if (radius > maxRadiusPx) {
+ maxRadiusPx = radius;
+ }
+ }
+ if (maxRadiusPx <= 0) {
+ return QVariant(0.0);
+ }
+
+ // getRadius() is in physical px; QML uses dp. Convert via density.
+ float density = 1.0f;
+ const QJniObject resources = activity.callObjectMethod(
+ "getResources", "()Landroid/content/res/Resources;");
+ if (!resources.isValid()) {
+ return QVariant(static_cast<double>(maxRadiusPx) / density);
+ }
+ const QJniObject metrics = resources.callObjectMethod(
+ "getDisplayMetrics", "()Landroid/util/DisplayMetrics;");
+ if (!metrics.isValid()) {
+ return QVariant(static_cast<double>(maxRadiusPx) / density);
+ }
+ const float d = metrics.getField<float>("density");
+ if (d > 0) {
+ density = d;
+ }
+ return QVariant(static_cast<double>(maxRadiusPx) / density);
+ };
+ QFuture<QVariant> future =
+ QNativeInterface::QAndroidApplication::runOnAndroidMainThread(
+ fetchInset);
+
+ future.waitForFinished();
+ return future.result().toReal();
+#else
+ return 0.0;
+#endif
+}
+
+qreal KazvUtil::cornerPadding(qreal cornerRadius) const
+{
+ cornerRadius = (cornerRadius >= 0) ? cornerRadius : roundedCornerRadius();
+ // (1-cos45°)R clears the corner; full R overpads ~3.4x.
+ return cornerRadius * 0.293;
+}
diff --git a/src/tests/quick-tests/tst_PageManager.qml b/src/tests/quick-tests/tst_PageManager.qml
--- a/src/tests/quick-tests/tst_PageManager.qml
+++ b/src/tests/quick-tests/tst_PageManager.qml
@@ -33,6 +33,13 @@
signal push(var url, var args)
}
+ property var kazvConfig: QtObject {
+ property var roundedCornerRadius: 0
+
+ function setRoundedCornerRadius() {}
+ }
+
+
SignalSpy {
id: pushSignalSpy
}
diff --git a/src/tests/quick-tests/tst_RoomPage.qml b/src/tests/quick-tests/tst_RoomPage.qml
--- a/src/tests/quick-tests/tst_RoomPage.qml
+++ b/src/tests/quick-tests/tst_RoomPage.qml
@@ -69,6 +69,12 @@
timeline: () => Qt.createComponent("QtQml.Models", "ListModel").createObject()
})
+ property var kazvConfig: QtObject {
+ property var roundedCornerRadius: 0
+
+ function setRoundedCornerRadius() {}
+ }
+
Component {
id: pageInviteComp
Kazv.RoomPage {
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Oct 13, 1:16 PM (22 h, 8 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1787137
Default Alt Text
D364.1791922566.diff (10 KB)
Attached To
Mode
D364: Added support for rounded corners on send message box
Attached
Detach File
Event Timeline
Log In to Comment