Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bugfix: ui fixes after merge with android tab navigation branch #1339

Merged
merged 9 commits into from
Jan 8, 2025
17 changes: 8 additions & 9 deletions client/ui/controllers/focusController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,15 @@ FocusController::FocusController(QQmlApplicationEngine *engine, QObject *parent)
m_focusChain {},
m_focusedItem { nullptr },
m_rootObjects {},
m_defaultFocusItem { QSharedPointer<QQuickItem>() },
m_defaultFocusItem { nullptr },
m_lvfc { nullptr }
{
QObject::connect(m_engine.get(), &QQmlApplicationEngine::objectCreated, this,
[this](QObject *object, const QUrl &url) {
QQuickItem *newDefaultFocusItem = object->findChild<QQuickItem *>("defaultFocusItem");
if (newDefaultFocusItem && m_defaultFocusItem != newDefaultFocusItem) {
m_defaultFocusItem.reset(newDefaultFocusItem);
}
});
QObject::connect(m_engine, &QQmlApplicationEngine::objectCreated, this, [this](QObject *object, const QUrl &url) {
QQuickItem *newDefaultFocusItem = object->findChild<QQuickItem *>("defaultFocusItem");
if (newDefaultFocusItem && m_defaultFocusItem != newDefaultFocusItem) {
m_defaultFocusItem = newDefaultFocusItem;
}
});

QObject::connect(this, &FocusController::focusedItemChanged, this,
[this]() { m_focusedItem->forceActiveFocus(Qt::TabFocusReason); });
Expand Down Expand Up @@ -65,7 +64,7 @@ void FocusController::setFocusItem(QQuickItem *item)

void FocusController::setFocusOnDefaultItem()
{
setFocusItem(m_defaultFocusItem.get());
setFocusItem(m_defaultFocusItem);
}

void FocusController::pushRootObject(QObject *object)
Expand Down
10 changes: 5 additions & 5 deletions client/ui/controllers/focusController.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ class FocusController : public QObject
void focusPreviousListViewItem();
void dropListView();

QSharedPointer<QQmlApplicationEngine> m_engine; // Pointer to engine to get root object
QList<QObject *> m_focusChain; // List of current objects to be focused
QQuickItem *m_focusedItem; // Pointer to the active focus item
QStack<QObject *> m_rootObjects;
QSharedPointer<QQuickItem> m_defaultFocusItem;
QQmlApplicationEngine *m_engine; // Pointer to engine to get root object
QList<QObject *> m_focusChain; // List of current objects to be focused
QQuickItem *m_focusedItem; // Pointer to the active focus item
QStack<QObject *> m_rootObjects; // Pointer to stack of roots for focus chain
QQuickItem *m_defaultFocusItem;

ListViewFocusController *m_lvfc; // ListView focus manager

Expand Down
4 changes: 2 additions & 2 deletions client/ui/models/apiServicesModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ QVariant ApiServicesModel::data(const QModelIndex &index, int role) const
.arg(speed);
} else if (serviceType == serviceType::amneziaFree){
QString description = tr("VPN to access blocked sites in regions with high levels of Internet censorship. ");
if (isServiceAvailable) {
if (!isServiceAvailable) {
description += tr("<p><a style=\"color: #EB5757;\">Not available in your region. If you have VPN enabled, disable it, return to the previous screen, and try again.</a>");
}
return description;
Expand All @@ -86,7 +86,7 @@ QVariant ApiServicesModel::data(const QModelIndex &index, int role) const
}
case IsServiceAvailableRole: {
if (serviceType == serviceType::amneziaFree) {
if (isServiceAvailable) {
if (!isServiceAvailable) {
return false;
}
}
Expand Down
4 changes: 2 additions & 2 deletions client/ui/qml/Controls2/DrawerType2.qml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Item {
readonly property string drawerExpandedStateName: "expanded"
readonly property string drawerCollapsedStateName: "collapsed"

readonly property bool isOpened: isExpandedStateActive() || (isCollapsedStateActive && (dragArea.drag.active === true))
readonly property bool isOpened: isExpandedStateActive() || (isCollapsedStateActive() && (dragArea.drag.active === true))
readonly property bool isClosed: isCollapsedStateActive() && (dragArea.drag.active === false)

property Component collapsedStateContent
Expand Down Expand Up @@ -123,7 +123,7 @@ Item {
id: background

anchors.fill: parent
color: root.isCollapsed ? AmneziaStyle.color.transparent : AmneziaStyle.color.translucentMidnightBlack
color: root.isCollapsedStateActive() ? AmneziaStyle.color.transparent : AmneziaStyle.color.translucentMidnightBlack

Behavior on color {
PropertyAnimation { duration: 200 }
Expand Down
26 changes: 7 additions & 19 deletions client/ui/qml/Controls2/DropDownType.qml
Original file line number Diff line number Diff line change
Expand Up @@ -216,41 +216,29 @@ Item {
ColumnLayout {
id: header

anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
anchors.fill: parent
anchors.topMargin: 16

BackButtonType {
id: backButton
backButtonImage: root.headerBackButtonImage
backButtonFunction: function() { menu.closeTriggered() }
}
}

Column {
id: col
anchors.top: header.bottom
anchors.left: parent.left
anchors.right: parent.right
anchors.topMargin: 16

spacing: 16

Header2Type {
anchors.left: parent.left
anchors.right: parent.right
anchors.leftMargin: 16
anchors.rightMargin: 16
Layout.leftMargin: 16
Layout.rightMargin: 16
Layout.bottomMargin: 16
Layout.fillWidth: true

headerText: root.headerText

width: parent.width
}

Loader {
id: listViewLoader
sourceComponent: root.listView

Layout.fillHeight: true
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions client/ui/qml/Controls2/ListViewWithRadioButtonType.qml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ ListView {

property bool isFocusable: true

ScrollBar.vertical: ScrollBarType {}

ButtonGroup {
id: buttonGroup
}
Expand Down
1 change: 0 additions & 1 deletion client/ui/qml/Controls2/PageType.qml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ Item {
id: timer
interval: 200 // Milliseconds
onTriggered: {
console.debug(">>> PageType timer triggered")
FocusController.resetRootObject()
FocusController.setFocusOnDefaultItem()
}
Expand Down
8 changes: 4 additions & 4 deletions client/ui/qml/Pages2/PageHome.qml
Original file line number Diff line number Diff line change
Expand Up @@ -256,11 +256,11 @@ PageType {
objectName: "rowLayoutLabel"
Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
Layout.topMargin: 8
Layout.bottomMargin: drawer.isCollapsed ? 44 : ServersModel.isDefaultServerFromApi ? 61 : 16
Layout.bottomMargin: drawer.isCollapsedStateActive ? 44 : ServersModel.isDefaultServerFromApi ? 61 : 16
spacing: 0

BasicButtonType {
enabled: (ServersModel.defaultServerImagePathCollapsed !== "") && drawer.isCollapsed
enabled: (ServersModel.defaultServerImagePathCollapsed !== "") && drawer.isCollapsedStateActive
hoverEnabled: enabled

implicitHeight: 36
Expand All @@ -278,8 +278,9 @@ PageType {
buttonTextLabel.font.pixelSize: 13
buttonTextLabel.font.weight: 400

text: drawer.isCollapsed ? ServersModel.defaultServerDescriptionCollapsed : ServersModel.defaultServerDescriptionExpanded
text: drawer.isCollapsedStateActive ? ServersModel.defaultServerDescriptionCollapsed : ServersModel.defaultServerDescriptionExpanded
leftImageSource: ServersModel.defaultServerImagePathCollapsed
leftImageColor: ""
changeLeftImageSize: false

rightImageSource: hoverEnabled ? "qrc:/images/controls/chevron-down.svg" : ""
Expand Down Expand Up @@ -337,7 +338,6 @@ PageType {
objectName: "containersListView"

rootWidth: root.width
height: 500 // TODO: make calculated

Connections {
objectName: "rowLayoutConnections"
Expand Down
24 changes: 2 additions & 22 deletions client/ui/qml/Pages2/PageProtocolAwgSettings.qml
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ PageType {
ListView {
id: listview

property bool isFocusable: true

anchors.top: backButtonLayout.bottom
anchors.bottom: parent.bottom

width: parent.width

property bool isFocusable: true

Keys.onTabPressed: {
FocusController.nextKeyTabItem()
}
Expand Down Expand Up @@ -138,26 +138,6 @@ PageType {
checkEmptyText: true
}

TextFieldWithHeaderType {
id: mtuTextField
Layout.fillWidth: true
Layout.topMargin: 16

headerText: qsTr("MTU")
textFieldText: mtu
textField.validator: IntValidator { bottom: 576; top: 65535 }

textField.onEditingFinished: {
if (textFieldText === "") {
textFieldText = "0"
}
if (textFieldText !== mtu) {
mtu = textFieldText
}
}
checkEmptyText: true
}

TextFieldWithHeaderType {
id: junkPacketCountTextField
Layout.fillWidth: true
Expand Down
2 changes: 0 additions & 2 deletions client/ui/qml/Pages2/PageProtocolOpenVpnSettings.qml
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,6 @@ PageType {
headerText: qsTr("Hash")

drawerParent: root
parentFlickable: fl

listView: ListViewWithRadioButtonType {
id: hashListView
Expand Down Expand Up @@ -225,7 +224,6 @@ PageType {
headerText: qsTr("Cipher")

drawerParent: root
parentFlickable: fl

listView: ListViewWithRadioButtonType {
id: cipherListView
Expand Down
2 changes: 0 additions & 2 deletions client/ui/qml/Pages2/PageProtocolWireGuardClientSettings.qml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ import "../Components"
PageType {
id: root

//defaultActiveFocusItem: listview.currentItem.mtuTextField.textField

Item {
id: focusItem
onFocusChanged: {
Expand Down
20 changes: 0 additions & 20 deletions client/ui/qml/Pages2/PageProtocolWireGuardSettings.qml
Original file line number Diff line number Diff line change
Expand Up @@ -122,26 +122,6 @@ PageType {
checkEmptyText: true
}

TextFieldWithHeaderType {
id: mtuTextField
Layout.fillWidth: true
Layout.topMargin: 16

headerText: qsTr("MTU")
textFieldText: mtu
textField.validator: IntValidator { bottom: 576; top: 65535 }

textField.onEditingFinished: {
if (textFieldText === "") {
textFieldText = "0"
}
if (textFieldText !== mtu) {
mtu = textFieldText
}
}
checkEmptyText: true
}

BasicButtonType {
id: saveButton
Layout.fillWidth: true
Expand Down
10 changes: 5 additions & 5 deletions client/ui/qml/Pages2/PageSettingsApiLanguageList.qml
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ PageType {
ListView {
id: menuContent

property var selectedText
property bool isFocusable: true

width: parent.width
height: menuContent.contentItem.height
height: parent.height

clip: true
interactive: false
interactive: true
model: ApiCountryModel

ButtonGroup {
Expand All @@ -34,8 +34,8 @@ PageType {
delegate: ColumnLayout {
id: content

implicitWidth: parent.width
implicitHeight: content.implicitHeight
width: menuContent.width
height: content.implicitHeight

RowLayout {
VerticalRadioButton {
Expand Down
7 changes: 0 additions & 7 deletions client/ui/qml/Pages2/PageSettingsApplication.qml
Original file line number Diff line number Diff line change
Expand Up @@ -221,15 +221,8 @@ PageType {
SettingsController.clearSettings()
PageController.goToPageHome()
}

if (!GC.isMobile()) {
// root.defaultActiveFocusItem.forceActiveFocus()
}
}
var noButtonFunction = function() {
if (!GC.isMobile()) {
// root.defaultActiveFocusItem.forceActiveFocus()
}
}

showQuestionDrawer(headerText, descriptionText, yesButtonText, noButtonText, yesButtonFunction, noButtonFunction)
Expand Down
7 changes: 0 additions & 7 deletions client/ui/qml/Pages2/PageSettingsDns.qml
Original file line number Diff line number Diff line change
Expand Up @@ -109,15 +109,8 @@ PageType {
SettingsController.secondaryDns = "1.0.0.1"
secondaryDns.textFieldText = SettingsController.secondaryDns
PageController.showNotificationMessage(qsTr("Settings have been reset"))

if (!GC.isMobile()) {
// defaultActiveFocusItem.forceActiveFocus()
}
}
var noButtonFunction = function() {
if (!GC.isMobile()) {
// defaultActiveFocusItem.forceActiveFocus()
}
}

showQuestionDrawer(headerText, "", yesButtonText, noButtonText, yesButtonFunction, noButtonFunction)
Expand Down
Loading
Loading