1.0 finish
This commit is contained in:
@@ -2,12 +2,11 @@
|
||||
#include "ui_frmsetting.h"
|
||||
#include <QDebug>
|
||||
|
||||
FrmSetting::FrmSetting(FileConfigDecode* fileConfig, QWidget *parent)
|
||||
FrmSetting::FrmSetting(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
, ui(new Ui::FrmSetting)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
this->fileConfig = fileConfig;
|
||||
initForm();
|
||||
initWidget();
|
||||
}
|
||||
@@ -43,13 +42,21 @@ void FrmSetting::initForm()
|
||||
|
||||
|
||||
serversetting = new ServerSetting();
|
||||
connect(serversetting, &ServerSetting::signal_updateServerConfig, this, &FrmSetting::slot_updateServerConfig);
|
||||
serversetting->hide();
|
||||
|
||||
QString address = FileConfigDecode::getInstance()->getAddress();
|
||||
QString username = FileConfigDecode::getInstance()->getUserName();
|
||||
QString password = FileConfigDecode::getInstance()->getPassword();
|
||||
|
||||
serversetting->setAddress(address);
|
||||
serversetting->setPassword(password);
|
||||
serversetting->setUserName(username);
|
||||
}
|
||||
|
||||
void FrmSetting::initWidget()
|
||||
{
|
||||
if (fileConfig->getRename()) {
|
||||
if (FileConfigDecode::getInstance()->getRename()) {
|
||||
ui->labRenameOpen->setStyleSheet(OPENQSS);
|
||||
ui->labRenameClose->setStyleSheet(CLOSEQSS);
|
||||
}
|
||||
@@ -57,7 +64,7 @@ void FrmSetting::initWidget()
|
||||
ui->labRenameOpen->setStyleSheet(CLOSEQSS);
|
||||
ui->labRenameClose->setStyleSheet(OPENQSS);
|
||||
}
|
||||
if (fileConfig->getAutoSetup()) {
|
||||
if (FileConfigDecode::getInstance()->getAutoSetup()) {
|
||||
ui->labAutoSetupOpen->setStyleSheet(OPENQSS);
|
||||
ui->labAutoSetupClose->setStyleSheet(CLOSEQSS);
|
||||
}
|
||||
@@ -65,7 +72,7 @@ void FrmSetting::initWidget()
|
||||
ui->labAutoSetupOpen->setStyleSheet(CLOSEQSS);
|
||||
ui->labAutoSetupClose->setStyleSheet(OPENQSS);
|
||||
}
|
||||
if (fileConfig->getTimeRename()) {
|
||||
if (FileConfigDecode::getInstance()->getTimeRename()) {
|
||||
ui->labTimeRenameOpen->setStyleSheet(OPENQSS);
|
||||
ui->labTimeRenameClose->setStyleSheet(CLOSEQSS);
|
||||
}
|
||||
@@ -73,7 +80,7 @@ void FrmSetting::initWidget()
|
||||
ui->labTimeRenameOpen->setStyleSheet(CLOSEQSS);
|
||||
ui->labTimeRenameClose->setStyleSheet(OPENQSS);
|
||||
}
|
||||
if (fileConfig->getAutoCopy()) {
|
||||
if (FileConfigDecode::getInstance()->getAutoCopy()) {
|
||||
ui->labEnableSsl->setStyleSheet(OPENQSS);
|
||||
ui->labEnableSsl->setStyleSheet(CLOSEQSS);
|
||||
}
|
||||
@@ -82,10 +89,10 @@ void FrmSetting::initWidget()
|
||||
ui->labEnableSsl->setStyleSheet(OPENQSS);
|
||||
}
|
||||
|
||||
ui->schRename->setChecked(fileConfig->getRename());
|
||||
ui->schAutoSetup->setChecked(fileConfig->getAutoSetup());
|
||||
ui->schTimeRename->setChecked(fileConfig->getTimeRename());
|
||||
ui->schEnableSsl->setChecked(fileConfig->getAutoCopy());
|
||||
ui->schRename->setChecked(FileConfigDecode::getInstance()->getRename());
|
||||
ui->schAutoSetup->setChecked(FileConfigDecode::getInstance()->getAutoSetup());
|
||||
ui->schTimeRename->setChecked(FileConfigDecode::getInstance()->getTimeRename());
|
||||
ui->schEnableSsl->setChecked(FileConfigDecode::getInstance()->getAutoCopy());
|
||||
|
||||
connect(ui->schRename, &SwitchButton::checkedChanged, this, &FrmSetting::schRenameSlot);
|
||||
connect(ui->schAutoSetup, &SwitchButton::checkedChanged, this, &FrmSetting::schAutoSetup);
|
||||
@@ -97,28 +104,31 @@ void FrmSetting::initWidget()
|
||||
|
||||
void FrmSetting::schRenameSlot(bool checked)
|
||||
{
|
||||
fileConfig->setRename(checked);
|
||||
FileConfigDecode::getInstance()->setRename(checked);
|
||||
ui->labRenameOpen->setStyleSheet(checked?OPENQSS:CLOSEQSS);
|
||||
ui->labRenameClose->setStyleSheet(checked?CLOSEQSS:OPENQSS);
|
||||
}
|
||||
|
||||
void FrmSetting::schAutoSetup(bool checked)
|
||||
{
|
||||
fileConfig->setAutoSetup(checked);
|
||||
FileConfigDecode::getInstance()->setAutoSetup(checked);
|
||||
ui->labAutoSetupOpen->setStyleSheet(checked?OPENQSS:CLOSEQSS);
|
||||
ui->labAutoSetupClose->setStyleSheet(checked?CLOSEQSS:OPENQSS);
|
||||
}
|
||||
|
||||
void FrmSetting::schTimeRename(bool checked)
|
||||
{
|
||||
fileConfig->setTimeRename(checked);
|
||||
if (ui->schRename->getChecked())
|
||||
FileConfigDecode::getInstance()->setTimeRename(checked, 1);
|
||||
else
|
||||
FileConfigDecode::getInstance()->setTimeRename(checked, 0);
|
||||
ui->labTimeRenameOpen->setStyleSheet(checked?OPENQSS:CLOSEQSS);
|
||||
ui->labTimeRenameClose->setStyleSheet(checked?CLOSEQSS:OPENQSS);
|
||||
}
|
||||
|
||||
void FrmSetting::schEnableSsl(bool checked)
|
||||
{
|
||||
fileConfig->setAutoCopy(checked);
|
||||
FileConfigDecode::getInstance()->setAutoCopy(checked);
|
||||
ui->labEnableSslOpen->setStyleSheet(checked?OPENQSS:CLOSEQSS);
|
||||
ui->labEnableSslClose->setStyleSheet(checked?CLOSEQSS:OPENQSS);
|
||||
|
||||
@@ -126,5 +136,12 @@ void FrmSetting::schEnableSsl(bool checked)
|
||||
|
||||
}
|
||||
|
||||
void FrmSetting::slot_updateServerConfig(QString address, QString username, QString password)
|
||||
{
|
||||
FileConfigDecode::getInstance()->setAddress(address);
|
||||
FileConfigDecode::getInstance()->setUserName(username);
|
||||
FileConfigDecode::getInstance()->setPassword(password);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ class FrmSetting : public QWidget
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit FrmSetting(FileConfigDecode* fileConfig, QWidget *parent = nullptr);
|
||||
explicit FrmSetting(QWidget *parent = nullptr);
|
||||
~FrmSetting();
|
||||
|
||||
private:
|
||||
@@ -38,9 +38,11 @@ private slots:
|
||||
void schTimeRename(bool checked);
|
||||
void schEnableSsl(bool checked);
|
||||
|
||||
void slot_updateServerConfig(QString address, QString username, QString password);
|
||||
|
||||
private:
|
||||
Ui::FrmSetting *ui;
|
||||
FileConfigDecode* fileConfig = nullptr;
|
||||
// FileConfigDecode* fileConfig = nullptr;
|
||||
ServerSetting* serversetting;
|
||||
};
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
<enum>Qt::Orientation::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
@@ -47,7 +47,7 @@
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>35</height>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
@@ -66,7 +66,7 @@
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
<enum>Qt::Orientation::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -82,7 +82,7 @@
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
<enum>Qt::Orientation::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
@@ -115,8 +115,8 @@
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>200</width>
|
||||
<height>30</height>
|
||||
<width>100</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
@@ -139,7 +139,7 @@
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
<enum>Qt::Orientation::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -155,7 +155,7 @@
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
<enum>Qt::Orientation::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
@@ -188,8 +188,8 @@
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>200</width>
|
||||
<height>30</height>
|
||||
<width>100</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
@@ -212,7 +212,7 @@
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
<enum>Qt::Orientation::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -228,7 +228,7 @@
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_4">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
<enum>Qt::Orientation::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
@@ -261,8 +261,8 @@
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>200</width>
|
||||
<height>30</height>
|
||||
<width>100</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
@@ -285,7 +285,7 @@
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
<enum>Qt::Orientation::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -293,6 +293,9 @@
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_5">
|
||||
<item>
|
||||
<widget class="QLabel" name="labEnableSsl">
|
||||
<property name="styleSheet">
|
||||
<string notr="true">color: rgb(255, 255, 255);</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>开启SSL</string>
|
||||
</property>
|
||||
@@ -301,7 +304,7 @@
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_5">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
<enum>Qt::Orientation::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
@@ -334,8 +337,8 @@
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>200</width>
|
||||
<height>30</height>
|
||||
<width>100</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#include "ui_frmupload.h"
|
||||
#include <QtDebug>
|
||||
#include <QImageReader>
|
||||
#include <QStandardPaths>
|
||||
|
||||
FrmUpload::FrmUpload(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
@@ -11,6 +12,29 @@ FrmUpload::FrmUpload(QWidget *parent)
|
||||
initFrom();
|
||||
initWidget();
|
||||
connect(TCHttpService::getInstance(), &TCHttpService::signal_uploadFileSec, this, &FrmUpload::slot_uploadFileSec);
|
||||
|
||||
QButtonGroup *buttonGroup = new QButtonGroup(this);
|
||||
buttonGroup->setExclusive(true); // 确保每次只有一个按钮被选中
|
||||
|
||||
// 添加按钮到组中
|
||||
buttonGroup->addButton(ui->btnHTML);
|
||||
buttonGroup->addButton(ui->btnMarkdown);
|
||||
buttonGroup->addButton(ui->btnUBB);
|
||||
buttonGroup->addButton(ui->btnUrl);
|
||||
|
||||
// 设置样式表
|
||||
QString buttonStyle = R"(
|
||||
QPushButton {
|
||||
color: black;
|
||||
}
|
||||
QPushButton:checked {
|
||||
color: #409EFF
|
||||
}
|
||||
)";
|
||||
ui->btnHTML->setStyleSheet(buttonStyle);
|
||||
ui->btnMarkdown->setStyleSheet(buttonStyle);
|
||||
ui->btnUBB->setStyleSheet(buttonStyle);
|
||||
ui->btnUrl->setStyleSheet(buttonStyle);
|
||||
}
|
||||
|
||||
FrmUpload::~FrmUpload()
|
||||
@@ -20,14 +44,26 @@ FrmUpload::~FrmUpload()
|
||||
|
||||
void FrmUpload::slot_uploadFileSec(QString url)
|
||||
{
|
||||
qDebug() << "slot_uploadFileSec:" << url;
|
||||
QClipboard* clipboard = QApplication::clipboard();
|
||||
|
||||
if (copyState == 0) {
|
||||
|
||||
if (copyType == COPY_TYPE_MARKDOWN) {
|
||||
clipboard->setText(QString("").arg(url));
|
||||
}
|
||||
else {
|
||||
if (copyType == COPY_TYPE_URL) {
|
||||
clipboard->setText(url);
|
||||
}
|
||||
if (copyType == COPY_TYPE_UBB) {
|
||||
// [IMG]https://imagehyj.oss-cn-hangzhou.aliyuncs.com/blog/logo512.png[/IMG]
|
||||
clipboard->setText(QString("[IMG]%1[/IMG]").arg(url));
|
||||
}
|
||||
if (copyType == COPY_TYPE_HTML) {
|
||||
clipboard->setText(QString("<img src=\"%1\"/>").arg(url));
|
||||
|
||||
// QThread::sleep(50);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
bool FrmUpload::eventFilter(QObject *watched, QEvent *event)
|
||||
@@ -106,12 +142,19 @@ void FrmUpload::initFrom()
|
||||
ui->btnMarkdown->setText("Markdown");
|
||||
ui->btnUrl->setText("URL");
|
||||
ui->btnUBB->setText("UBB");
|
||||
|
||||
ui->btnMarkdown->setChecked(true);
|
||||
ui->btnHTML->setChecked(false);
|
||||
ui->btnUBB->setChecked(false);
|
||||
ui->btnUrl->setChecked(false);
|
||||
}
|
||||
|
||||
void FrmUpload::initWidget()
|
||||
{
|
||||
ui->frmUpload->installEventFilter(this);
|
||||
this->setAcceptDrops(true);
|
||||
setWindowFlags(Qt::FramelessWindowHint); // 移除系统边框
|
||||
setAttribute(Qt::WA_TranslucentBackground); // 启用透明背景
|
||||
// ui->frmUpload->setAcceptDrops(true);
|
||||
}
|
||||
|
||||
@@ -127,3 +170,108 @@ void FrmUpload::uploadFiles(QStringList fileList)
|
||||
// TCHttpService::getInstance()->apiMyfileNormal();
|
||||
|
||||
}
|
||||
|
||||
void FrmUpload::on_btnFastUpload_clicked()
|
||||
{
|
||||
// QString addDataPath = QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation);
|
||||
// QString cacheDirPath = addDataPath + "/cache/";
|
||||
QDir cacheDir(QStandardPaths::writableLocation(QStandardPaths::CacheLocation));
|
||||
if (!cacheDir.exists()) {
|
||||
cacheDir.mkpath(".");
|
||||
}
|
||||
QClipboard* clipboard = QApplication::clipboard();
|
||||
const QMimeData* mimeData = clipboard->mimeData();
|
||||
|
||||
if (mimeData->hasImage()) {
|
||||
QImage image = clipboard->image();
|
||||
if (!image.isNull()) {
|
||||
RenameType renametype = FileConfigDecode::getInstance()->getRenameType();
|
||||
qDebug() << "renameType:" << renametype;
|
||||
if (renametype == RENAME_TYPE_NORMAL) {
|
||||
bool ok;
|
||||
QString timestamp = QDateTime::currentDateTime().toString("yyyyMMdd_hhmmsszzz");
|
||||
QString text = QInputDialog::getText(this, "重命名图片", "输入文件名", QLineEdit::Normal, timestamp, &ok);
|
||||
if (ok && !text.isEmpty()) {
|
||||
QString filePath = cacheDir.filePath(text + ".png");
|
||||
|
||||
if (image.save(filePath, "PNG")) {
|
||||
TCHttpService::getInstance()->apiUpload(filePath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (renametype == RENAME_TYPE_TIME) {
|
||||
qDebug() << "time rename";
|
||||
QString timestamp = QDateTime::currentDateTime().toString("yyyyMMdd_hhmmsszzz");
|
||||
QString filePath = cacheDir.filePath(timestamp + ".png");
|
||||
|
||||
if (image.save(filePath, "PNG")) {
|
||||
TCHttpService::getInstance()->apiUpload(filePath);
|
||||
}
|
||||
}
|
||||
else {
|
||||
QString timestamp = QDateTime::currentDateTime().toString("yyyyMMdd_hhmmsszzz");
|
||||
QString filePath = cacheDir.filePath("clipboard_" + timestamp + ".png");
|
||||
|
||||
if (image.save(filePath, "PNG")) {
|
||||
TCHttpService::getInstance()->apiUpload(filePath);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
clipboard->clear();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void FrmUpload::on_btnMarkdown_clicked()
|
||||
{
|
||||
if (!ui->btnMarkdown->isChecked())
|
||||
return;
|
||||
copyType = COPY_TYPE_MARKDOWN;
|
||||
ui->btnMarkdown->setChecked(true);
|
||||
ui->btnUrl->setChecked(false);
|
||||
ui->btnHTML->setChecked(false);
|
||||
ui->btnUBB->setChecked(false);
|
||||
qDebug() << copyType;
|
||||
}
|
||||
|
||||
|
||||
void FrmUpload::on_btnUrl_clicked()
|
||||
{
|
||||
if (!ui->btnUrl->isChecked())
|
||||
return;
|
||||
copyType = COPY_TYPE_URL;
|
||||
ui->btnMarkdown->setChecked(false);
|
||||
ui->btnUrl->setChecked(true);
|
||||
ui->btnHTML->setChecked(false);
|
||||
ui->btnUBB->setChecked(false);
|
||||
qDebug() << copyType;
|
||||
}
|
||||
|
||||
|
||||
void FrmUpload::on_btnHTML_clicked()
|
||||
{
|
||||
if (!ui->btnHTML->isChecked())
|
||||
return;
|
||||
copyType = COPY_TYPE_HTML;
|
||||
ui->btnMarkdown->setChecked(false);
|
||||
ui->btnUrl->setChecked(false);
|
||||
ui->btnHTML->setChecked(true);
|
||||
ui->btnUBB->setChecked(false);
|
||||
qDebug() << copyType;
|
||||
}
|
||||
|
||||
|
||||
void FrmUpload::on_btnUBB_clicked()
|
||||
{
|
||||
if (!ui->btnUBB->isChecked())
|
||||
return;
|
||||
copyType = COPY_TYPE_UBB;
|
||||
ui->btnMarkdown->setChecked(false);
|
||||
ui->btnUrl->setChecked(false);
|
||||
ui->btnHTML->setChecked(false);
|
||||
ui->btnUBB->setChecked(true);
|
||||
qDebug() << copyType;
|
||||
}
|
||||
|
||||
|
||||
@@ -12,10 +12,26 @@
|
||||
#include <tchttpservice.h>
|
||||
#include <QFileInfo>
|
||||
#include <QClipboard>
|
||||
#include <QPixmap>
|
||||
#include <QMimeData>
|
||||
#include <QDebug>
|
||||
#include <QBuffer>
|
||||
#include <QDateTime>
|
||||
#include <QInputDialog>
|
||||
#include <QButtonGroup>
|
||||
#include <QThread>
|
||||
#include "fileconfigdecode.h"
|
||||
#include "tchttpservice.h"
|
||||
|
||||
#define DEBUG 1
|
||||
|
||||
typedef enum{
|
||||
COPY_TYPE_MARKDOWN = 0,
|
||||
COPY_TYPE_URL,
|
||||
COPY_TYPE_UBB,
|
||||
COPY_TYPE_HTML
|
||||
} CopyType;
|
||||
|
||||
namespace Ui {
|
||||
class FrmUpload;
|
||||
}
|
||||
@@ -36,12 +52,23 @@ protected:
|
||||
virtual void dragEnterEvent(QDragEnterEvent *event) override;
|
||||
virtual void dropEvent(QDropEvent *event) override;
|
||||
|
||||
private slots:
|
||||
void on_btnFastUpload_clicked();
|
||||
|
||||
void on_btnMarkdown_clicked();
|
||||
|
||||
void on_btnUrl_clicked();
|
||||
|
||||
void on_btnHTML_clicked();
|
||||
|
||||
void on_btnUBB_clicked();
|
||||
|
||||
private:
|
||||
void initFrom();
|
||||
void initWidget();
|
||||
void uploadFiles(QStringList fileList);
|
||||
// 0 md 1 url
|
||||
int copyState = 0;
|
||||
CopyType copyType = COPY_TYPE_MARKDOWN;
|
||||
|
||||
private:
|
||||
Ui::FrmUpload *ui;
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
<item>
|
||||
<widget class="QLabel" name="labTitle">
|
||||
<property name="text">
|
||||
<string>LennDFS 快捷助手</string>
|
||||
<string>LennDFS PicPanel</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignmentFlag::AlignCenter</set>
|
||||
@@ -208,12 +208,18 @@
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>20</height>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="cursor">
|
||||
<cursorShape>PointingHandCursor</cursorShape>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>PushButton</string>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
@@ -227,12 +233,18 @@
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>75</width>
|
||||
<height>20</height>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="cursor">
|
||||
<cursorShape>PointingHandCursor</cursorShape>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>PushButton</string>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
@@ -246,12 +258,18 @@
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>75</width>
|
||||
<height>20</height>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="cursor">
|
||||
<cursorShape>PointingHandCursor</cursorShape>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>PushButton</string>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
@@ -265,12 +283,18 @@
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>20</height>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="cursor">
|
||||
<cursorShape>PointingHandCursor</cursorShape>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>PushButton</string>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
@@ -313,9 +337,12 @@
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>20</height>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="cursor">
|
||||
<cursorShape>PointingHandCursor</cursorShape>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>PushButton</string>
|
||||
</property>
|
||||
|
||||
@@ -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); // 填充白色
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user