Skip to content

Commit

Permalink
added display of protocols on PageHome
Browse files Browse the repository at this point in the history
  • Loading branch information
Vladimir Kuznetsov authored and Vladimir Kuznetsov committed May 11, 2023
1 parent 1c8dbae commit b66f4bf
Show file tree
Hide file tree
Showing 22 changed files with 237 additions and 138 deletions.
1 change: 0 additions & 1 deletion client/amnezia_application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,6 @@ void AmneziaApplication::loadFonts()
QFontDatabase::addApplicationFont(":/fonts/Lato-Regular.ttf");
QFontDatabase::addApplicationFont(":/fonts/Lato-Thin.ttf");
QFontDatabase::addApplicationFont(":/fonts/Lato-ThinItalic.ttf");

QFontDatabase::addApplicationFont(":/fonts/pt-root-ui_vf.ttf");
}

Expand Down
4 changes: 4 additions & 0 deletions client/images/controls/plus.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions client/resources.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -221,5 +221,6 @@
<file>ui/qml/Controls2/TextTypes/LabelTextType.qml</file>
<file>ui/qml/Controls2/TextTypes/ButtonTextType.qml</file>
<file>ui/qml/Controls2/Header2Type.qml</file>
<file>images/controls/plus.svg</file>
</qresource>
</RCC>
50 changes: 24 additions & 26 deletions client/ui/models/servers_model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,41 +2,34 @@

ServersModel::ServersModel(std::shared_ptr<Settings> settings, QObject *parent) : m_settings(settings), QAbstractListModel(parent)
{
refresh();
}

void ServersModel::refresh()
{
beginResetModel();
const QJsonArray &servers = m_settings->serversArray();
int defaultServer = m_settings->defaultServerIndex();
QVector<ServerModelContent> serverListContent;
for(int i = 0; i < servers.size(); i++) {
ServerModelContent c;
ServerModelContent content;
auto server = servers.at(i).toObject();
c.desc = server.value(config_key::description).toString();
c.address = server.value(config_key::hostName).toString();
if (c.desc.isEmpty()) {
c.desc = c.address;
content.desc = server.value(config_key::description).toString();
content.address = server.value(config_key::hostName).toString();
if (content.desc.isEmpty()) {
content.desc = content.address;
}
c.isDefault = (i == defaultServer);
serverListContent.push_back(c);
content.isDefault = (i == defaultServer);
serverListContent.push_back(content);
}
setContent(serverListContent);
}

void ServersModel::clearData()
{
beginResetModel();
m_content.clear();
endResetModel();
}

void ServersModel::setContent(const QVector<ServerModelContent> &data)
{
beginResetModel();
m_content = data;
m_data = serverListContent;
endResetModel();
}

int ServersModel::rowCount(const QModelIndex &parent) const
{
Q_UNUSED(parent);
return static_cast<int>(m_content.size());
return static_cast<int>(m_data.size());
}

QHash<int, QByteArray> ServersModel::roleNames() const {
Expand All @@ -50,19 +43,24 @@ QHash<int, QByteArray> ServersModel::roleNames() const {
QVariant ServersModel::data(const QModelIndex &index, int role) const
{
if (!index.isValid() || index.row() < 0
|| index.row() >= static_cast<int>(m_content.size())) {
|| index.row() >= static_cast<int>(m_data.size())) {
return QVariant();
}
if (role == DescRole) {
return m_content[index.row()].desc;
return m_data[index.row()].desc;
}
if (role == AddressRole) {
return m_content[index.row()].address;
return m_data[index.row()].address;
}
if (role == IsDefaultRole) {
return m_content[index.row()].isDefault;
return m_data[index.row()].isDefault;
}
return QVariant();
}

void ServersModel::setDefaultServerIndex(int index)
{

}


5 changes: 2 additions & 3 deletions client/ui/models/servers_model.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ class ServersModel : public QAbstractListModel
IsDefaultRole
};

void clearData();
void setContent(const QVector<ServerModelContent>& data);
void refresh();
int rowCount(const QModelIndex &parent = QModelIndex()) const override;

QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
Expand All @@ -33,7 +32,7 @@ class ServersModel : public QAbstractListModel
QHash<int, QByteArray> roleNames() const override;

private:
QVector<ServerModelContent> m_content;
QVector<ServerModelContent> m_data;
std::shared_ptr<Settings> m_settings;
};

Expand Down
2 changes: 1 addition & 1 deletion client/ui/pages_logic/ServerListLogic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,5 @@ void ServerListLogic::onUpdatePage()
c.isDefault = (i == defaultServer);
serverListContent.push_back(c);
}
qobject_cast<ServersModel*>(m_serverListModel)->setContent(serverListContent);
// qobject_cast<ServersModel*>(m_serverListModel)->setContent(serverListContent);
}
2 changes: 1 addition & 1 deletion client/ui/qml/Controls2/BasicButtonType.qml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Button {

contentItem: Text {
anchors.fill: background
font.family: "PT Root UI"
font.family: "PT Root UI VF"
font.styleName: "normal"
font.weight: 400
font.pixelSize: 16
Expand Down
80 changes: 18 additions & 62 deletions client/ui/qml/Controls2/DropDownType.qml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ Item {
property string text
property string descriptionText

property string headerText
property string headerBackButtonImage

property var onClickedFunc
property string buttonImage: "qrc:/images/controls/chevron-down.svg"
property string buttonImageColor: "#494B50"
Expand All @@ -22,7 +25,10 @@ Item {
property string borderColor: "#494B50"
property int borderWidth: 1

property alias menuModel: menuContent.model
property Component menuDelegate
property variant menuModel

property alias menuVisible: menu.visible

implicitWidth: buttonContent.implicitWidth
implicitHeight: buttonContent.implicitHeight
Expand Down Expand Up @@ -128,12 +134,13 @@ Item {
color: Qt.rgba(14/255, 14/255, 17/255, 0.8)
}

Header2TextType {
Header2Type {
id: header
width: parent.width

text: "Данные для подключения"
wrapMode: Text.WordWrap
headerText: root.headerText
backButtonImage: root.headerBackButtonImage

width: parent.width

anchors.top: parent.top
anchors.left: parent.left
Expand Down Expand Up @@ -170,64 +177,13 @@ Item {
clip: true
interactive: false

delegate: Item {
implicitWidth: menuContent.width
implicitHeight: radioButton.implicitHeight

RadioButton {
id: radioButton

implicitWidth: parent.width
implicitHeight: radioButtonContent.implicitHeight

hoverEnabled: true

ButtonGroup.group: radioButtonGroup

indicator: Rectangle {
anchors.fill: parent
color: radioButton.hovered ? "#2C2D30" : "#1C1D21"
}

RowLayout {
id: radioButtonContent
anchors.fill: parent

anchors.rightMargin: 16
anchors.leftMargin: 16

z: 1

Text {
id: text

text: modelData
color: "#D7D8DB"
font.pixelSize: 16
font.weight: 400
font.family: "PT Root UI VF"

height: 24

Layout.fillWidth: true
Layout.topMargin: 20
Layout.bottomMargin: 20
}

Image {
source: "qrc:/images/controls/check.svg"
visible: radioButton.checked
width: 24
height: 24

Layout.rightMargin: 8
}
}
model: root.menuModel

onClicked: {
root.text = modelData
menu.visible = false
}
delegate: Row {
Loader {
id: loader
sourceComponent: root.menuDelegate
property QtObject modelData: model
}
}
}
Expand Down
38 changes: 31 additions & 7 deletions client/ui/qml/Controls2/Header2Type.qml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@ import "TextTypes"
Item {
id: root

property string buttonImage
property string backButtonImage
property string actionButtonImage

property var backButtonFunction
property var actionButtonFunction

property string headerText
property string descriptionText

Expand All @@ -22,22 +27,41 @@ Item {

Layout.leftMargin: -6

image: root.buttonImage
image: root.backButtonImage
imageColor: "#D7D8DB"

visible: image ? true : false

onClicked: {
UiLogic.closePage()
if (backButtonFunction && typeof backButtonFunction === "function") {
backButtonFunction()
}
}
}

Header2TextType {
id: header
RowLayout {
Header2TextType {
id: header

Layout.fillWidth: true
Layout.fillWidth: true

text: root.headerText
}

text: root.headerText
ImageButtonType {
id: headerActionButton

image: root.actionButtonImage
imageColor: "#D7D8DB"

visible: image ? true : false

onClicked: {
if (actionButtonImage && typeof actionButtonImage === "function") {
actionButtonImage()
}
}
}
}

ParagraphTextType {
Expand Down
42 changes: 35 additions & 7 deletions client/ui/qml/Controls2/HeaderType.qml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@ import "TextTypes"
Item {
id: root

property string buttonImage
property string backButtonImage
property string actionButtonImage

property var backButtonFunction
property var actionButtonFunction

property string headerText
property string descriptionText

Expand All @@ -22,22 +27,43 @@ Item {

Layout.leftMargin: -6

image: root.buttonImage
image: root.backButtonImage
imageColor: "#D7D8DB"

visible: image ? true : false

onClicked: {
UiLogic.closePage()
if (backButtonFunction && typeof backButtonFunction === "function") {
backButtonFunction()
}
}
}

Header1TextType {
id: header
RowLayout {
Header1TextType {
id: header

Layout.fillWidth: true
Layout.fillWidth: true

text: root.headerText
}

ImageButtonType {
id: headerActionButton

text: root.headerText
Layout.alignment: Qt.AlignRight

image: root.actionButtonImage
imageColor: "#D7D8DB"

visible: image ? true : false

onClicked: {
if (actionButtonImage && typeof actionButtonImage === "function") {
actionButtonImage()
}
}
}
}

ParagraphTextType {
Expand All @@ -49,6 +75,8 @@ Item {
text: root.descriptionText

color: "#878B91"

visible: root.descriptionText !== ""
}
}
}
Loading

0 comments on commit b66f4bf

Please sign in to comment.