Skip to content
This repository has been archived by the owner on Jan 19, 2024. It is now read-only.

Commit

Permalink
[chore]整理代码
Browse files Browse the repository at this point in the history
  • Loading branch information
SkyD666 committed Mar 29, 2023
1 parent 7b633e8 commit ab1d1f6
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 12 deletions.
4 changes: 2 additions & 2 deletions AutoFirewall/GlobalData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ void GlobalData::readSettings()
settings.endGroup();

settings.beginGroup("Sound");
startSound = settings.value("StartSound", "").toString();
stopSound = settings.value("StopSound", true).toString();
startSound = settings.value("StartSound", "./sound/chimes.wav").toString();
stopSound = settings.value("StopSound", "./sound/ding.wav").toString();
playSound = settings.value("PlaySound", true).toBool();
settings.endGroup();
}
Expand Down
12 changes: 4 additions & 8 deletions AutoFirewall/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,21 +49,17 @@ MainWindow::MainWindow(QWidget* parent)
palette.setColor(QPalette::Window, Qt::green);
labState->setPalette(palette);
if (GlobalData::playSound) {
wchar_t* path = new wchar_t[GlobalData::startSound.size()];
GlobalData::startSound.toWCharArray(path);
PlaySound(path, nullptr, SND_FILENAME | SND_ASYNC);
delete[] path;
PlaySound(GlobalData::startSound.toStdWString().c_str(),
nullptr, SND_FILENAME | SND_ASYNC);
}
} else {
ui.btnEnable->setText(tr("已关闭"));
QPalette palette = labState->palette();
palette.setColor(QPalette::Window, Qt::red);
labState->setPalette(palette);
if (GlobalData::playSound) {
wchar_t* path = new wchar_t[GlobalData::stopSound.size()];
GlobalData::stopSound.toWCharArray(path);
PlaySound(path, nullptr, SND_FILENAME | SND_ASYNC);
delete[] path;
PlaySound(GlobalData::stopSound.toStdWString().c_str(),
nullptr, SND_FILENAME | SND_ASYNC);
}
}
} else {
Expand Down
2 changes: 1 addition & 1 deletion AutoFirewall/MainWindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
</property>
<property name="windowIcon">
<iconset resource="resource.qrc">
<normaloff>:/icon.ico</normaloff>:/icon.ico</iconset>
<normaloff>:/ico.png</normaloff>:/ico.png</iconset>
</property>
<widget class="QWidget" name="centralwidget">
<layout class="QVBoxLayout" name="verticalLayout">
Expand Down
Binary file added AutoFirewall/ico.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions AutoFirewall/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
#include "MainWindow.h"

#include <QApplication>
#include <QIcon>

int main(int argc, char* argv[])
{
QApplication a(argc, argv);
QApplication::setWindowIcon(QIcon(":/icon.png"));
QApplication::setOrganizationName("SkyD666");
QApplication::setApplicationName("AutoFirewall");
QApplication::setApplicationVersion("1.2");
Expand Down
2 changes: 1 addition & 1 deletion AutoFirewall/resource.qrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<RCC>
<qresource prefix="/">
<file>icon.ico</file>
<file>ico.png</file>
</qresource>
</RCC>

0 comments on commit ab1d1f6

Please sign in to comment.