Skip to content

Commit

Permalink
添加读取本地背景图功能
Browse files Browse the repository at this point in the history
  • Loading branch information
GengGode committed Jul 20, 2021
1 parent 6661617 commit 8982b5d
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 1 deletion.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -258,4 +258,5 @@ paket-files/

# Python Tools for Visual Studio (PTVS)
__pycache__/
*.pyc
*.pyc
/source.7z
19 changes: 19 additions & 0 deletions GenshinImpactNaturalLaw/GenshinImpactNaturalLaw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ GenshinImpactNaturalLaw::GenshinImpactNaturalLaw(QWidget *parent)

uiConnectButton();
uiConnectButtonLabel();
uiShowImage();

Tray = new QSystemTrayIcon(this);
Tray->setIcon(QIcon(QPixmap(":/icon/resource/icon/ICON.png")));
Expand Down Expand Up @@ -41,6 +42,9 @@ GenshinImpactNaturalLaw::GenshinImpactNaturalLaw(QWidget *parent)
shadow->setBlurRadius(15);
ui.MainBackgroundImageRect->setGraphicsEffect(shadow);




connect(ui.pushButton_TitleSet, SIGNAL(clicked()), this, SLOT(NewWidgetsSetting()));
connect(ui.pushButton_TitleExit, SIGNAL(clicked()), this, SLOT(CloseEvent()));
connect(ui.pushButton_StartGame, SIGNAL(clicked()), this, SLOT(StartGame()));
Expand Down Expand Up @@ -158,6 +162,21 @@ void GenshinImpactNaturalLaw::uiConnectButtonLabel()
connect(LinkeButtonLabelList[i], SIGNAL(clicked()), this, SLOT(OpenButtonLabelLinkeUrl()));
}
}

void GenshinImpactNaturalLaw::uiShowImage()
{
QPixmap BackgroundImage;
QString ImagePath = QApplication::applicationDirPath()+"/background/" + setting.game_dynamic_bg_name;
QFileInfo file(ImagePath);
if (file.exists() == false)
{
return;
}
BackgroundImage.load(ImagePath);
BackgroundImage=BackgroundImage.scaled(ui.MainBackgroundImageRect->width(), ui.MainBackgroundImageRect->height());
ui.MainBackgroundImageRect->setPixmap(BackgroundImage);
}

void GenshinImpactNaturalLaw::CloseEvent()
{
if (setting.is_exit_ismini)
Expand Down
1 change: 1 addition & 0 deletions GenshinImpactNaturalLaw/GenshinImpactNaturalLaw.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class GenshinImpactNaturalLaw : public QMainWindow
private:
void uiConnectButton();
void uiConnectButtonLabel();
void uiShowImage();
private:
void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
void mouseReleaseEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
Expand Down
1 change: 1 addition & 0 deletions GenshinImpactNaturalLaw/QtWidgetsSetting.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <QUrl>
#include <QFileInfo>
#include <QFileDialog>
#include <QApplication>
#include <QPropertyAnimation>
#include <QScrollBar>
#include <QScrollArea>
Expand Down

0 comments on commit 8982b5d

Please sign in to comment.