-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
216 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,15 @@ | ||
#include "candyitem.h" | ||
#include "candy.h" | ||
|
||
CandyItem::CandyItem() {} | ||
CandyItem::CandyItem() | ||
{ | ||
setTextAlignment(Qt::AlignCenter); | ||
setSizeHint(QSize(0, 40)); | ||
|
||
candy = candy_client_create(); | ||
} | ||
|
||
CandyItem::~CandyItem() | ||
{ | ||
candy_client_release(candy); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,16 @@ | ||
#include "candylist.h" | ||
|
||
CandyList::CandyList() {} | ||
CandyItem *CandyList::addButton = new CandyItem; | ||
|
||
CandyList::CandyList() | ||
{ | ||
// 网络列表最后一项 '+', 用于添加新客户端 | ||
addButton->setText("+"); | ||
addItem(addButton); | ||
} | ||
|
||
void CandyList::addCandyItem(CandyItem *item) | ||
{ | ||
insertItem(count() - 1, item); | ||
setCurrentItem(item); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,16 @@ | ||
#ifndef CANDYLIST_H | ||
#define CANDYLIST_H | ||
|
||
#include "candyitem.h" | ||
#include <QListWidget> | ||
|
||
class CandyList : public QListWidget | ||
{ | ||
public: | ||
explicit CandyList(); | ||
void addCandyItem(CandyItem *item); | ||
|
||
static CandyItem *addButton; | ||
}; | ||
|
||
#endif // CANDYLIST_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,68 @@ | ||
#include "detailarea.h" | ||
#include "candylist.h" | ||
#include <QLabel> | ||
#include <QLineEdit> | ||
#include <QPushButton> | ||
#include <QVBoxLayout> | ||
|
||
DetailArea::DetailArea() {} | ||
DetailArea::DetailArea() | ||
{ | ||
detailWidget = new QWidget(this); | ||
detailWidget->hide(); | ||
QVBoxLayout *layout = new QVBoxLayout(detailWidget); | ||
|
||
void DetailArea::update(QListWidgetItem *item) {} | ||
password->setEchoMode(QLineEdit::Password); | ||
|
||
layout->addWidget(createInputWidget("网卡名", name)); | ||
layout->addWidget(createInputWidget("服务器地址", websocket)); | ||
layout->addWidget(createInputWidget("口令", password)); | ||
layout->addWidget(createInputWidget("静态地址", tun)); | ||
layout->addWidget(createInputWidget("STUN", stun)); | ||
layout->addWidget(createInputWidget("对等连接端口", port)); | ||
layout->addWidget(createInputWidget("主动发现间隔", discovery)); | ||
layout->addWidget(createInputWidget("本机路由代价", route)); | ||
layout->addWidget(createInputWidget("本机内网地址", localhost)); | ||
layout->addWidget(createSaveButton()); | ||
} | ||
|
||
void DetailArea::update(QListWidgetItem *item) | ||
{ | ||
detailWidget->show(); | ||
if (item == CandyList::addButton) { | ||
return; | ||
} | ||
|
||
name->setReadOnly(true); | ||
} | ||
|
||
void DetailArea::save() | ||
{ | ||
// TODO: 读出参数,根据网卡名更新配置,并重启对应的网络 | ||
return; | ||
} | ||
|
||
QWidget *DetailArea::createInputWidget(QString key, QLineEdit *input) | ||
{ | ||
QWidget *widget = new QWidget; | ||
QHBoxLayout *layout = new QHBoxLayout(widget); | ||
QLabel *label = new QLabel; | ||
label->setText(key); | ||
label->setFixedWidth(110); | ||
label->setAlignment(Qt::AlignRight); | ||
label->setContentsMargins(0, 0, 10, 0); | ||
input->setFixedWidth(400); | ||
layout->addWidget(label, 1); | ||
layout->addWidget(input, 5); | ||
return widget; | ||
} | ||
|
||
QWidget *DetailArea::createSaveButton() | ||
{ | ||
QWidget *widget = new QWidget; | ||
QHBoxLayout *layout = new QHBoxLayout(widget); | ||
QPushButton *saveButton = new QPushButton("保存"); | ||
saveButton->setFixedWidth(150); | ||
connect(saveButton, &QPushButton::clicked, this, &DetailArea::save); | ||
layout->addWidget(saveButton); | ||
return widget; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<RCC> | ||
<qresource prefix="/"> | ||
<file>logo.png</file> | ||
</qresource> | ||
</RCC> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters