Skip to content

Commit

Permalink
增加“关于”
Browse files Browse the repository at this point in the history
  • Loading branch information
LiaoCheng authored and LiaoCheng committed Jan 28, 2023
1 parent 1bdd466 commit 2883fdc
Show file tree
Hide file tree
Showing 7 changed files with 138 additions and 10 deletions.
27 changes: 27 additions & 0 deletions AboutDlg.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#include "AboutDlg.h"
#include "ui_AboutDlg.h"

#include <QMessageBox>

AboutDlg::AboutDlg(QWidget *parent) :
QDialog(parent),
ui(new Ui::AboutDlg)
{
ui->setupUi(this);
}

AboutDlg::~AboutDlg()
{
delete ui;
}

void AboutDlg::on_toolButton_AboutQt_clicked()
{
QMessageBox::aboutQt(this);
}

void AboutDlg::on_pushButton_Ok_clicked()
{
accept();
}

27 changes: 27 additions & 0 deletions AboutDlg.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#ifndef ABOUTDLG_H
#define ABOUTDLG_H

#include <QDialog>

namespace Ui {
class AboutDlg;
}

class AboutDlg : public QDialog
{
Q_OBJECT

public:
explicit AboutDlg(QWidget *parent = nullptr);
~AboutDlg();

private slots:
void on_toolButton_AboutQt_clicked();

void on_pushButton_Ok_clicked();

private:
Ui::AboutDlg *ui;
};

#endif // ABOUTDLG_H
64 changes: 64 additions & 0 deletions AboutDlg.ui
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>AboutDlg</class>
<widget class="QDialog" name="AboutDlg">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>600</width>
<height>200</height>
</rect>
</property>
<property name="windowTitle">
<string>关于软件</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QPlainTextEdit" name="plainTextEdit">
<property name="plainText">
<string>Email: [email protected]
https://github.com/CharlesLiaoO/EncodingConverter
Build with Qt/C++</string>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByKeyboard|Qt::LinksAccessibleByMouse|Qt::TextBrowserInteraction|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QToolButton" name="toolButton_AboutQt">
<property name="text">
<string>About Qt</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="pushButton_Ok">
<property name="text">
<string>确认</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
3 changes: 3 additions & 0 deletions EncodingConverter.pro
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,16 @@ else: unix:!android: target.path = /opt/$${TARGET}/bin
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0

SOURCES += \
AboutDlg.cpp \
NotPrjRel.cpp \
main.cpp \
MainWindow.cpp

HEADERS += \
AboutDlg.h \
MainWindow.h \
NotPrjRel.h

FORMS += \
AboutDlg.ui \
MainWindow.ui
8 changes: 8 additions & 0 deletions MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ MainWindow::MainWindow(QWidget *parent)
, ui(new Ui::MainWindow)
{
ui->setupUi(this);
ui->toolButton_About->setIcon(style()->standardIcon(QStyle::SP_MessageBoxInformation));

iBigFileSizeMB = (double)iBigFileSize / (1024*1024);
iMaxFileSizeGB = (double)iMaxFileSize / (1024*1024*1024);
Expand Down Expand Up @@ -317,3 +318,10 @@ void MainWindow::UpdateProgress(int lineNum, float percentage)
ui->plainTextEdit_MsgOutput->appendPlainText(sOutputLine);
}

#include <AboutDlg.h>
void MainWindow::on_toolButton_About_clicked()
{
AboutDlg aboutDlg(this);
aboutDlg.exec();
}

2 changes: 2 additions & 0 deletions MainWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ private slots:
void on_comboBox_EncodingDest_currentTextChanged(const QString &arg1);
void closeEvent(QCloseEvent *e);

void on_toolButton_About_clicked();

private:
Ui::MainWindow *ui;

Expand Down
17 changes: 7 additions & 10 deletions MainWindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,13 @@
</property>
</spacer>
</item>
<item>
<widget class="QToolButton" name="toolButton_About">
<property name="text">
<string notr="true"/>
</property>
</widget>
</item>
</layout>
</item>
<item>
Expand Down Expand Up @@ -341,16 +348,6 @@
</item>
</layout>
</widget>
<widget class="QMenuBar" name="menubar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>800</width>
<height>18</height>
</rect>
</property>
</widget>
</widget>
<resources/>
<connections/>
Expand Down

0 comments on commit 2883fdc

Please sign in to comment.