1.0 finish

This commit is contained in:
2025-03-25 02:44:59 +08:00
parent cc7c995549
commit c84b88a422
23 changed files with 1126 additions and 127 deletions

View File

@@ -15,10 +15,27 @@ ServerSetting::~ServerSetting()
delete ui;
}
void ServerSetting::setAddress(QString address)
{
ui->ledAddress->setText(address);
}
void ServerSetting::setUserName(QString username)
{
ui->ledPort->setText(username);
}
void ServerSetting::setPassword(QString password)
{
ui->ledPwd->setText(password);
}
void ServerSetting::initForm()
{
this->setWindowFlag(Qt::FramelessWindowHint);
this->setWindowFlags(this->windowFlags() | Qt::WindowSystemMenuHint | Qt::WindowMaximizeButtonHint);
this->setWindowFlags(this->windowFlags() | Qt::WindowSystemMenuHint | Qt::WindowMinMaxButtonsHint);
setAttribute(Qt::WA_TranslucentBackground);
ui->ledAddress->setPlaceholderText("example.com/ip:port");
ui->ledPort->setPlaceholderText("admin");
}
@@ -32,6 +49,8 @@ void ServerSetting::initWidget()
emit okClicked(ui->ledAddress->text(), ui->ledPort->text().toInt());
this->hide();
});
this->setWindowModality(Qt::ApplicationModal);
}
void ServerSetting::on_btnOk_clicked()
@@ -44,5 +63,27 @@ void ServerSetting::on_btnOk_clicked()
QString userName = ui->ledPort->text();
QString password = ui->ledPwd->text();
emit signal_updateServerConfig(address, userName, password);
TCHttpService::getInstance()->setConfiguration(userName, password, address);
}
void ServerSetting::paintEvent(__attribute__((unused))QPaintEvent *event)
{
// QStyleOption opt;
// #if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
// opt.init(this);
// #else
// opt.initFrom(this);
// #endif
// QPainter painter(this);
// style()->drawPrimitive(QStyle::PE_Widget, &opt, &painter, this);
QPainter painter(this);
painter.setRenderHint(QPainter::Antialiasing); // 抗锯齿
// 绘制圆角背景
QPainterPath path;
path.addRoundedRect(rect(), 15, 15); // 30px 圆角半径
painter.fillPath(path, Qt::white); // 填充白色
}

View File

@@ -2,6 +2,11 @@
#define SERVERSETTING_H
#include <QWidget>
#include <QObject>
#include <QPaintEvent>
#include <QPainter>
#include <QStyleOption>
#include <QPainterPath>
#include "tchttpservice.h"
namespace Ui {
@@ -16,15 +21,24 @@ public:
explicit ServerSetting(QWidget *parent = nullptr);
~ServerSetting();
void setAddress(QString address);
void setUserName(QString username);
void setPassword(QString password);
signals:
void okClicked(QString addr, quint16 port);
void signal_updateServerConfig(QString address, QString username, QString password);
private slots:
void on_btnOk_clicked();
private:
Ui::ServerSetting *ui;
protected:
virtual void paintEvent(QPaintEvent* event);
private:
void initForm();
void initWidget();

View File

@@ -7,12 +7,15 @@
<x>0</x>
<y>0</y>
<width>281</width>
<height>188</height>
<height>121</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QFormLayout" name="formLayout">
@@ -44,16 +47,23 @@
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="ledPwd"/>
<widget class="QLineEdit" name="ledPwd">
<property name="inputMethodHints">
<set>Qt::InputMethodHint::ImhHiddenText|Qt::InputMethodHint::ImhNoAutoUppercase|Qt::InputMethodHint::ImhNoPredictiveText|Qt::InputMethodHint::ImhSensitiveData</set>
</property>
<property name="echoMode">
<enum>QLineEdit::EchoMode::Password</enum>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
@@ -64,33 +74,61 @@
</spacer>
</item>
<item>
<widget class="QPushButton" name="btnCencel">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>取消</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnOk">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="text">
<string>确定</string>
</property>
</widget>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QPushButton" name="btnCencel">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>50</width>
<height>35</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>100</width>
<height>50</height>
</size>
</property>
<property name="text">
<string>取消</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnOk">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>50</width>
<height>35</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>100</width>
<height>50</height>
</size>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="text">
<string>确定</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>