Skip to content

Commit

Permalink
Merge branch 'dev' of github.com:amnezia-vpn/amnezia-client into fix/…
Browse files Browse the repository at this point in the history
…drawerTypePositioning
  • Loading branch information
Nethius committed Oct 3, 2023
2 parents b1e9e86 + ed1afa7 commit 52124b1
Show file tree
Hide file tree
Showing 9 changed files with 137 additions and 56 deletions.
14 changes: 14 additions & 0 deletions client/ui/models/containers_model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,20 @@ bool ContainersModel::isAmneziaDnsContainerInstalled(const int serverIndex)
return containers.contains(DockerContainer::Dns);
}

bool ContainersModel::isAnyContainerInstalled()
{
for (int row=0; row < rowCount(); row++) {
QModelIndex idx = this->index(row, 0);

if (this->data(idx, IsInstalledRole).toBool() &&
this->data(idx, ServiceTypeRole).toInt() == ServiceType::Vpn) {
return true;
}
}

return false;
}

QHash<int, QByteArray> ContainersModel::roleNames() const
{
QHash<int, QByteArray> roles;
Expand Down
2 changes: 1 addition & 1 deletion client/ui/models/containers_model.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public slots:
bool isAmneziaDnsContainerInstalled();
bool isAmneziaDnsContainerInstalled(const int serverIndex);

// bool isOnlyServicesInstalled(const int serverIndex);
bool isAnyContainerInstalled();

protected:
QHash<int, QByteArray> roleNames() const override;
Expand Down
8 changes: 8 additions & 0 deletions client/ui/qml/Components/ConnectButton.qml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import QtQuick.Shapes
import Qt5Compat.GraphicalEffects

import ConnectionState 1.0
import PageEnum 1.0

Button {
id: root
Expand Down Expand Up @@ -137,6 +138,13 @@ Button {
}

onClicked: {
if (!ContainersModel.isAnyContainerInstalled()) {
ServersModel.currentlyProcessedIndex = ServersModel.getDefaultServerIndex()
PageController.goToPage(PageEnum.PageSetupWizardEasy)

return
}

if (ConnectionController.isConnectionInProgress) {
ConnectionController.closeConnection()
} else if (ConnectionController.isConnected) {
Expand Down
7 changes: 7 additions & 0 deletions client/ui/qml/Controls2/CardType.qml
Original file line number Diff line number Diff line change
Expand Up @@ -123,4 +123,11 @@ RadioButton {
Layout.bottomMargin: 16
}
}

MouseArea {
anchors.fill: parent

cursorShape: Qt.PointingHandCursor
enabled: false
}
}
4 changes: 0 additions & 4 deletions client/ui/qml/Controls2/DrawerType.qml
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,12 @@ Drawer {
}

onOpened: {
isOpened = true

if (needCloseButton) {
PageController.drawerOpen()
}
}

onClosed: {
isOpened = false

if (needCloseButton) {
PageController.drawerClose()
}
Expand Down
9 changes: 6 additions & 3 deletions client/ui/qml/Controls2/ImageButtonType.qml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,11 @@ Button {
property string imageColor: "#878B91"
property string disableImageColor: "#2C2D30"

implicitWidth: 40
implicitHeight: 40
property int backGroudRadius: 12
property int implicitSize: 40

implicitWidth: implicitSize
implicitHeight: implicitSize

hoverEnabled: true

Expand All @@ -31,7 +34,7 @@ Button {
id: background

anchors.fill: parent
radius: 12
radius: backGroudRadius
color: {
if (root.enabled) {
if(root.pressed) {
Expand Down
120 changes: 74 additions & 46 deletions client/ui/qml/Controls2/TextAreaType.qml
Original file line number Diff line number Diff line change
Expand Up @@ -9,71 +9,99 @@ Rectangle {
property alias textArea: textArea
property alias textAreaText: textArea.text

property string borderHoveredColor: "#494B50"
property string borderNormalColor: "#2C2D30"
property string borderFocusedColor: "#d7d8db"

height: 148
color: "#1C1D21"
border.width: 1
border.color: "#2C2D30"
border.color: getBorderColor(borderNormalColor)
radius: 16

FlickableType {
id: fl
interactive: false
MouseArea {
id: parentMouse
anchors.fill: parent
cursorShape: Qt.IBeamCursor
onClicked: textArea.forceActiveFocus()
hoverEnabled: true

FlickableType {
id: fl
interactive: false

anchors.top: parent.top
anchors.bottom: parent.bottom
contentHeight: textArea.implicitHeight
TextArea {
id: textArea
anchors.top: parent.top
anchors.bottom: parent.bottom
contentHeight: textArea.implicitHeight
TextArea {
id: textArea

width: parent.width
width: parent.width

topPadding: 16
leftPadding: 16
anchors.topMargin: 16
anchors.bottomMargin: 16
topPadding: 16
leftPadding: 16
anchors.topMargin: 16
anchors.bottomMargin: 16

color: "#D7D8DB"
selectionColor: "#633303"
selectedTextColor: "#D7D8DB"
placeholderTextColor: "#878B91"
color: "#D7D8DB"
selectionColor: "#633303"
selectedTextColor: "#D7D8DB"
placeholderTextColor: "#878B91"

font.pixelSize: 16
font.weight: Font.Medium
font.family: "PT Root UI VF"
font.pixelSize: 16
font.weight: Font.Medium
font.family: "PT Root UI VF"

placeholderText: root.placeholderText
text: root.text
placeholderText: root.placeholderText
text: root.text

onCursorVisibleChanged: {
if (textArea.cursorVisible) {
fl.interactive = true
} else {
fl.interactive = false
onCursorVisibleChanged: {
if (textArea.cursorVisible) {
fl.interactive = true
} else {
fl.interactive = false
}
}
}

wrapMode: Text.Wrap
wrapMode: Text.Wrap

MouseArea {
anchors.fill: parent
acceptedButtons: Qt.RightButton
onClicked: {
fl.interactive = true
contextMenu.open()
MouseArea {
id: textAreaMouse
anchors.fill: parent
acceptedButtons: Qt.RightButton
hoverEnabled: true
onClicked: {
fl.interactive = true
contextMenu.open()
}
}
}

ContextMenuType {
id: contextMenu
textObj: textArea
onFocusChanged: {
root.border.color = getBorderColor(borderNormalColor)
}

ContextMenuType {
id: contextMenu
textObj: textArea
}
}
}

onPressed: {
root.border.color = getBorderColor(borderFocusedColor)
}

onExited: {
root.border.color = getBorderColor(borderNormalColor)
}

onEntered: {
root.border.color = getBorderColor(borderHoveredColor)
}
}

//todo make whole background clickable, with code below we lose ability to select text by mouse
// MouseArea {
// anchors.fill: parent
// cursorShape: Qt.IBeamCursor
// onClicked: textArea.forceActiveFocus()
// }

function getBorderColor(noneFocusedColor) {
return textArea.focus ? root.borderFocusedColor : noneFocusedColor
}
}
27 changes: 25 additions & 2 deletions client/ui/qml/Controls2/TextFieldWithHeaderType.qml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ Item {

property string backgroundColor: "#1c1d21"
property string backgroundDisabledColor: "transparent"
property string bgBorderHoveredColor: "#494B50"

implicitWidth: content.implicitWidth
implicitHeight: content.implicitHeight
Expand All @@ -44,7 +45,7 @@ Item {
Layout.preferredHeight: input.implicitHeight
color: root.enabled ? root.backgroundColor : root.backgroundDisabledColor
radius: 16
border.color: textField.focus ? root.borderFocusedColor : root.borderColor
border.color: getBackgroundBorderColor(root.borderColor)
border.width: 1

Behavior on border.color {
Expand Down Expand Up @@ -102,12 +103,17 @@ Item {
anchors.fill: parent
acceptedButtons: Qt.RightButton
onClicked: contextMenu.open()
enabled: true
}

ContextMenuType {
id: contextMenu
textObj: textField
}

onFocusChanged: {
backgroud.border.color = getBackgroundBorderColor(root.borderColor)
}
}
}

Expand Down Expand Up @@ -149,11 +155,28 @@ Item {

MouseArea {
anchors.fill: root
cursorShape: Qt.PointingHandCursor
cursorShape: Qt.IBeamCursor

hoverEnabled: true

onPressed: function(mouse) {
textField.forceActiveFocus()
mouse.accepted = false

backgroud.border.color = getBackgroundBorderColor(root.borderColor)
}

onEntered: {
backgroud.border.color = getBackgroundBorderColor(bgBorderHoveredColor)
}


onExited: {
backgroud.border.color = getBackgroundBorderColor(root.borderColor)
}
}

function getBackgroundBorderColor(noneFocusedColor) {
return textField.focus ? root.borderFocusedColor : noneFocusedColor
}
}
2 changes: 2 additions & 0 deletions client/ui/qml/Pages2/PageSetupWizardEasy.qml
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,8 @@ PageType {
textColor: "#D7D8DB"
borderWidth: 1

visible: ContainersModel.isAnyContainerInstalled()

text: qsTr("Set up later")

onClicked: function() {
Expand Down

0 comments on commit 52124b1

Please sign in to comment.