Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions apps/readest-sync/qml/DecisionDialog.qml
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import QtQuick

Item {
ModalSurface {
id: root
objectName: "nativeDecisionDialog"
required property var shell
z: 60
readonly property var choices: shell.view.actionPresentation ? shell.view.actionPresentation.choices : []

Rectangle { anchors.fill: parent; color: "#dddddd"; opacity: 0.92 }
Rectangle {
anchors.centerIn: parent
width: Math.min(parent.width - 2 * shell.metrics.largeGap, 1200 * shell.metrics.scale)
Expand All @@ -33,6 +32,7 @@ Item {
model: root.choices
delegate: Rectangle {
required property var modelData
objectName: "nativeDecisionChoice_" + modelData.command
width: dialogColumn.width
height: shell.metrics.primaryAction
color: choiceTap.pressed ? "black" : "white"
Expand All @@ -50,6 +50,7 @@ Item {
}
}
Rectangle {
objectName: "nativeDecisionDismiss"
width: parent.width
height: shell.metrics.primaryAction
color: finalTap.pressed ? "black" : "white"
Expand Down
12 changes: 12 additions & 0 deletions apps/readest-sync/qml/ModalSurface.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import QtQuick

Item {
Rectangle { anchors.fill: parent; z: -2; color: "#dddddd"; opacity: 0.92 }
// Content remains above the input shield; background taps never reach pages.
MouseArea {
anchors.fill: parent
z: -1
acceptedButtons: Qt.AllButtons
onWheel: function(wheel) { wheel.accepted = true }
}
}
4 changes: 2 additions & 2 deletions apps/readest-sync/qml/OperationSurface.qml
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import QtQuick

Item {
ModalSurface {
id: root
objectName: "nativeOperationSurface"
required property var shell
z: 50
Rectangle { anchors.fill: parent; color: "#dddddd"; opacity: 0.92 }
Rectangle {
anchors.centerIn: parent
width: Math.min(parent.width - 2 * shell.metrics.largeGap, 1200 * shell.metrics.scale)
Expand All @@ -27,6 +26,7 @@ Item {
wrapMode: Text.Wrap
}
Rectangle {
objectName: "nativeOperationCancel"
width: parent.width
height: shell.metrics.primaryAction
color: cancelTap.pressed ? "black" : "white"
Expand Down
2 changes: 1 addition & 1 deletion apps/readest-sync/qml/readest.qrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<RCC><qresource prefix="/"><file>Main.qml</file><file>NativeMetrics.qml</file><file>NativeHeader.qml</file><file>MessageBand.qml</file><file>OperationSurface.qml</file><file>DecisionDialog.qml</file><file>BusyPage.qml</file><file>ErrorPage.qml</file><file>SignInPage.qml</file><file>LibraryPage.qml</file><file>BookDetailsPage.qml</file><file>ActionButton.qml</file><file>BodyText.qml</file></qresource></RCC>
<RCC><qresource prefix="/"><file>Main.qml</file><file>NativeMetrics.qml</file><file>NativeHeader.qml</file><file>MessageBand.qml</file><file>ModalSurface.qml</file><file>OperationSurface.qml</file><file>DecisionDialog.qml</file><file>BusyPage.qml</file><file>ErrorPage.qml</file><file>SignInPage.qml</file><file>LibraryPage.qml</file><file>BookDetailsPage.qml</file><file>ActionButton.qml</file><file>BodyText.qml</file></qresource></RCC>
46 changes: 43 additions & 3 deletions apps/readest-sync/tests/qt_ui_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <QQuickItem>
#include <QQuickWindow>
#include <QMouseEvent>
#include <QStyleHints>
#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <QQmlContext>
Expand Down Expand Up @@ -43,14 +44,18 @@ static QQuickItem* find_item(QQuickItem* item,const QString& name) {
for(auto* child:item->childItems()) if(auto* found=find_item(child,name)) return found;
return nullptr;
}
static void tap_book(QQuickWindow* window) {
auto* row=find_item(window->contentItem(),"detailedBookRow"); assert(row);
const auto point=row->mapToScene(QPointF(row->width()/2,row->height()/2));
static void tap_item(QQuickWindow* window,QQuickItem* item,int hold=0) {
assert(item);
const auto point=item->mapToScene(QPointF(item->width()/2,item->height()/2));
QMouseEvent press(QEvent::MouseButtonPress,point,point,Qt::LeftButton,Qt::LeftButton,Qt::NoModifier);
QCoreApplication::sendEvent(window,&press);
if(hold) settle(hold);
QMouseEvent release(QEvent::MouseButtonRelease,point,point,Qt::LeftButton,Qt::NoButton,Qt::NoModifier);
QCoreApplication::sendEvent(window,&release); settle();
}
static void tap_book(QQuickWindow* window,int hold=0) {
tap_item(window,find_item(window->contentItem(),"detailedBookRow"),hold);
}
static ApplicationConfig configAt(const QString& base) {
ApplicationConfig config;
config.root=(base+"/system/readest-sync").toStdString();
Expand Down Expand Up @@ -552,6 +557,8 @@ int main(int argc,char** argv) {
QMetaObject::invokeMethod(window,"handleHardwareButton",Q_ARG(QVariant,QVariant(Qt::Key_Menu))); settle();
assert(!libraryPage->property("menuOpen").toBool());
hold_foreground=true; control.refreshLibrary(); settle(); assert(control.busy());
tap_book(window,QGuiApplication::styleHints()->mousePressAndHoldInterval()+100);
assert(!libraryPage->property("contextOpen").toBool());
tap_book(window); assert(!control.detail());
QMetaObject::invokeMethod(window,"handleHardwareButton",Q_ARG(QVariant,QVariant(Qt::Key_Menu))); settle();
assert(!libraryPage->property("menuOpen").toBool());
Expand All @@ -570,6 +577,12 @@ int main(int argc,char** argv) {
auto view=menuView;
if(!guard.isEmpty()) view[guard]=true;
window->setProperty("view",view); settle();
if(!guard.isEmpty()) {
tap_book(window,QGuiApplication::styleHints()->mousePressAndHoldInterval()+100);
assert(!libraryPage->property("contextOpen").toBool());
tap_book(window);
assert(!libraryPage->property("activating").toBool());
}
for(bool hardware:{false,true}) {
libraryPage->setProperty("menuOpen",false);
if(hardware) QMetaObject::invokeMethod(window,"handleHardwareButton",Q_ARG(QVariant,QVariant(Qt::Key_Menu)));
Expand All @@ -578,6 +591,33 @@ int main(int argc,char** argv) {
}
}
window->setProperty("view",QVariant::fromValue(&control)); settle();
// Dialog controls must still receive real taps above the shared shield.
for(const auto& mode:{QString("busy"),QString("decision"),QString("blocking")}) {
auto view=engine.toScriptValue(menuView);
view.setProperty(mode,true);
view.setProperty("lastCommand",QString());
view.setProperty("close",engine.evaluate("(function() { this.lastCommand = 'close'; })"));
view.setProperty("cancelDecision",engine.evaluate("(function() { this.lastCommand = 'cancel'; })"));
view.setProperty("acknowledgeBlocking",engine.evaluate("(function() { this.lastCommand = 'acknowledge'; })"));
view.setProperty("runAction",engine.evaluate("(function(command) { this.lastCommand = command; })"));
view.setProperty("actionPresentation",engine.toScriptValue(QVariantMap{{"choices",QVariantList{
QVariantMap{{"command","usePocketBook"},{"text","Use PocketBook position"}},
QVariantMap{{"command","useReadest"},{"text","Use Readest position"}}}}}));
window->setProperty("view",QVariant::fromValue(view)); settle();
if(mode=="decision") {
for(const auto& command:{QString("usePocketBook"),QString("useReadest")}) {
tap_item(window,find_item(window->contentItem(),"nativeDecisionChoice_"+command));
assert(view.property("lastCommand").toString()==command);
}
}
tap_item(window,find_item(window->contentItem(),mode=="busy"?"nativeOperationCancel":"nativeDecisionDismiss"));
assert(view.property("lastCommand").toString()==(mode=="busy"?"close":mode=="decision"?"cancel":"acknowledge"));
}
window->setProperty("view",QVariant::fromValue(&control)); settle();
tap_book(window,QGuiApplication::styleHints()->mousePressAndHoldInterval()+100);
assert(libraryPage->property("contextOpen").toBool());
QMetaObject::invokeMethod(window,"handleHardwareButton",Q_ARG(QVariant,QVariant(Qt::Key_Back))); settle();
assert(!libraryPage->property("contextOpen").toBool());
libraryPage->setProperty("menuOpen",true); settle();
assert(window->findChild<QQuickItem*>("nativeLibraryMenu")->isVisible());
QMetaObject::invokeMethod(window,"handleHardwareButton",Q_ARG(QVariant,QVariant(Qt::Key_Back))); settle();
Expand Down