Skip to content

Commit 4c97541

Browse files
committed
Add icon.rc file and update CMakeLists.txt
Remove commented out code for boot screen in mainwindow.cpp and mainwindow.h Remove commented out code for boot screen in mainwindow.cpp and mainwindow.h
1 parent 4795173 commit 4c97541

File tree

5 files changed

+13
-42
lines changed

5 files changed

+13
-42
lines changed

CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ else()
4545
code.h
4646
titlescreen.h titlescreen.cpp titlescreen.ui
4747
aboutscreen.h aboutscreen.cpp aboutscreen.ui
48+
icon.rc
4849
)
4950
endif()
5051
endif()

main.cpp

-27
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,6 @@
11
#include <QApplication>
2-
#include <QDebug>
3-
#include <QObject>
4-
#include <cstddef>
52

63
#include "mainwindow.h"
7-
struct MemoryManager {
8-
size_t totalAllocated = 0;
9-
size_t totalFreed = 0;
10-
} memoryManager;
11-
12-
void* operator new(size_t size) {
13-
void* p = malloc(size);
14-
memoryManager.totalAllocated += size;
15-
qDebug() << "allocated at " << p;
16-
qDebug() << "total allocated " << memoryManager.totalAllocated << " bytes. Using "
17-
<< memoryManager.totalAllocated - memoryManager.totalFreed
18-
<< " bytes";
19-
// qDebug() << "Allocated " << size << " bytes";
20-
return p;
21-
}
22-
23-
void operator delete(void* p, size_t size) noexcept {
24-
free(p);
25-
qDebug() << "Freed at " << p;
26-
memoryManager.totalFreed += size;
27-
qDebug() << "total freed " << memoryManager.totalFreed << " bytes. Using "
28-
<< memoryManager.totalAllocated - memoryManager.totalFreed
29-
<< " bytes";
30-
}
314

325
int main(int argc, char* argv[]) {
336
QApplication a(argc, argv);

mainwindow.cpp

+7-8
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <QString>
99
#include <QTextEdit>
1010
#include <QTimer>
11+
// #include <cassert>
1112
#include <chrono>
1213
#include <sstream>
1314
#include <string>
@@ -24,7 +25,6 @@ MainWindow::MainWindow(QWidget *parent)
2425
ui(new Ui::MainWindow),
2526
m_timer(new QTimer(this)),
2627
m_sysinfo(new SYSinfo()),
27-
// m_bootScreen(nullptr),
2828
m_effect(nullptr),
2929
m_animation(nullptr),
3030
m_label(nullptr),
@@ -61,6 +61,11 @@ MainWindow::MainWindow(QWidget *parent)
6161
MainWindow::~MainWindow() {
6262
delete ui;
6363
delete m_titlescreen;
64+
// assert(m_sysinfo == nullptr);
65+
// assert(m_effect == nullptr);
66+
// assert(m_animation == nullptr);
67+
// assert(m_label == nullptr);
68+
// assert(m_timer == nullptr);
6469
}
6570

6671
void MainWindow::selfTestUpdate() {
@@ -106,10 +111,6 @@ void MainWindow::loadBootScreen() {
106111
ui->textEdit->hide();
107112
// 设置启动画面
108113
m_label = new QLabel(this);
109-
// m_bootScreen = new QPixmap(":/res/bootScreen.png");
110-
// m_bootScreen->scaled(this->size(), Qt::KeepAspectRatio,
111-
// Qt::SmoothTransformation);
112-
// m_label->setPixmap(*m_bootScreen);
113114
QPixmap bootScreen(":/res/bootScreen.png");
114115
bootScreen = bootScreen.scaled(this->size(), Qt::KeepAspectRatio,
115116
Qt::SmoothTransformation);
@@ -130,11 +131,9 @@ void MainWindow::loadTitleScreen() {
130131
delete m_animation;
131132
delete m_effect;
132133
delete m_label;
133-
// delete m_bootScreen;
134134
m_animation = nullptr;
135135
m_effect = nullptr;
136136
m_label = nullptr;
137-
// m_bootScreen = nullptr;
138137
m_titlescreen = new TitleScreen(this);
139138
m_titlescreen->show();
140139
this->centralWidget()->hide();
@@ -157,4 +156,4 @@ void MainWindow::fadeIn() {
157156
m_animation->setStartValue(0);
158157
m_animation->setEndValue(1);
159158
m_animation->start();
160-
}
159+
}

mainwindow.h

-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ class MainWindow : public QMainWindow {
2929
Ui::MainWindow* ui;
3030
QTimer* m_timer = nullptr;
3131
SYSinfo* m_sysinfo = nullptr;
32-
// QPixmap* m_bootScreen = nullptr;
3332
QGraphicsOpacityEffect* m_effect = nullptr;
3433
QPropertyAnimation* m_animation = nullptr;
3534
QLabel* m_label = nullptr;
@@ -44,6 +43,5 @@ class MainWindow : public QMainWindow {
4443
void fadeIn();
4544
signals:
4645
void bootCompleted();
47-
// void animationFinished();
4846
};
4947
#endif // MAINWINDOW_H

titlescreen.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#include <cassert>
1+
// #include <cassert>
22
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__)
33
#include <windows.h>
44
#endif
@@ -76,6 +76,9 @@ TitleScreen::~TitleScreen() {
7676
delete m_player;
7777
delete m_volumeAnimation;
7878
delete m_aboutScreen;
79+
// assert(m_opacityEffect == nullptr);
80+
// assert(m_opacityAnimation == nullptr);
81+
// assert(m_timer == nullptr);
7982
}
8083

8184
void TitleScreen::btnsOpacityEffect() {
@@ -128,12 +131,9 @@ void TitleScreen::playThemeMusic() {
128131
}
129132

130133
void TitleScreen::jumpToAboutScreen() {
131-
static int count = 0;
132134
if (!m_aboutScreen) {
133135
m_aboutScreen = new AboutScreen(this);
134-
count++;
135136
}
136-
assert(count == 1);
137137
m_aboutScreen->show();
138138
}
139139

@@ -238,4 +238,4 @@ void TitleScreen::quieterThemeMusic() {
238238
m_volumeAnimation->setStartValue(30);
239239
m_volumeAnimation->setEndValue(0);
240240
m_volumeAnimation->start();
241-
}
241+
}

0 commit comments

Comments
 (0)