Skip to content

Commit

Permalink
feat: add about page
Browse files Browse the repository at this point in the history
  • Loading branch information
lanthora committed May 10, 2024
1 parent b88d48b commit 332a7fa
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 9 deletions.
5 changes: 3 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 3.5)
project(cake LANGUAGES CXX)

set (CANDY_VERSION "5.8")
set (CAKE_RELEASE "2")
set (CAKE_RELEASE "3")

set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
Expand All @@ -19,7 +19,7 @@ add_compile_definitions(CAKE_VERSION="${CAKE_VERSION}")
find_package(Qt6 REQUIRED COMPONENTS Widgets Gui Core Network)

add_executable(cake
main.cc
define.h main.cc
mainwindow.h mainwindow.cc
candylist.h candylist.cc
candyitem.h candyitem.cc
Expand All @@ -28,6 +28,7 @@ add_executable(cake
feedback.h feedback.cc
keepalive.h keepalive.cc
update.h update.cc
about.h about.cc
images.qrc admin.rc
)

Expand Down
26 changes: 26 additions & 0 deletions about.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#include "about.h"
#include "define.h"
#include <QLabel>
#include <QVBoxLayout>

About::About(QWidget *parent)
: QDialog(parent)
{
setWindowTitle("关于");
setFixedSize(500, 200);

QLabel *label = new QLabel(
"<a href=\"https://github.com/lanthora/cake\">Cake</a> "
"是使用 Qt 并基于 "
"<a href=\"https://github.com/lanthora/candy\">Candy</a> "
"开发的桌面应用程序<br>"
"当前版本: " CAKE_VERSION "<br>",
this);

label->setAlignment(Qt::AlignCenter);
label->setOpenExternalLinks(true);

QVBoxLayout *layout = new QVBoxLayout(this);
layout->addWidget(label, 0, Qt::AlignCenter);
layout->setAlignment(Qt::AlignCenter);
}
14 changes: 14 additions & 0 deletions about.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#ifndef ABOUT_H
#define ABOUT_H

#include <QDialog>
#include <QObject>

class About : public QDialog
{
Q_OBJECT
public:
About(QWidget *parent = nullptr);
};

#endif
8 changes: 8 additions & 0 deletions define.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#ifndef DEFINE_H
#define DEFINE_H

#ifndef CAKE_VERSION
#define CAKE_VERSION "Unknown"
#endif

#endif
16 changes: 14 additions & 2 deletions mainwindow.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "mainwindow.h"
#include "about.h"
#include "feedback.h"
#include "startoption.h"
#include "update.h"
Expand Down Expand Up @@ -94,7 +95,12 @@ void MainWindow::addFileMenu()
QAction *newAction = new QAction("新建", fileMenu);
QAction *quitAction = new QAction("退出", fileMenu);
connect(newAction, &QAction::triggered, [&] { detailArea->reset(candyList->count() == 0); });
connect(quitAction, &QAction::triggered, this, &MainWindow::directQuit);
connect(quitAction, &QAction::triggered, [&] {
// 新建的时候可能会误触退出,再确认一次
if (QMessageBox::question(this, "退出", "退出后将断开所有虚拟网络连接,确认退出?") == QMessageBox::Yes) {
directQuit();
}
});

fileMenu->addAction(newAction);
fileMenu->addAction(quitAction);
Expand All @@ -114,12 +120,18 @@ void MainWindow::addEditMenu()
void MainWindow::addHelpMenu()
{
QMenu *helpMenu = menuBar()->addMenu("帮助");
QAction *feedbackAction = new QAction("问题反馈", helpMenu);

QAction *feedbackAction = new QAction("问题反馈", helpMenu);
Feedback *feedback = new Feedback(this);

QAction *aboutAction = new QAction("关于", helpMenu);
About *about = new About(this);

connect(feedbackAction, &QAction::triggered, feedback, &Feedback::show);
connect(aboutAction, &QAction::triggered, about, &About::show);

helpMenu->addAction(feedbackAction);
helpMenu->addAction(aboutAction);
}

void MainWindow::addCentralWidget()
Expand Down
2 changes: 1 addition & 1 deletion startoption.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ StartOption::StartOption(QWidget *parent)
: QDialog(parent)
{
setWindowTitle("启动选项");
setFixedSize(300, 200);
setFixedSize(500, 300);

autoStartup->setFixedWidth(100);
showMainWindow->setFixedWidth(100);
Expand Down
5 changes: 1 addition & 4 deletions update.cc
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
#include "update.h"
#include "define.h"
#include <QJsonDocument>
#include <QJsonObject>
#include <QNetworkReply>
#include <QNetworkRequest>
#include <QSettings>
#include <QString>

#ifndef CAKE_VERSION
#define CAKE_VERSION "Unknown"
#endif

Update::Update(QObject *parent)
: QObject(parent)
{
Expand Down

0 comments on commit 332a7fa

Please sign in to comment.