This repository has been archived by the owner on Feb 19, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathaboutdialog.cpp
54 lines (47 loc) · 1.66 KB
/
aboutdialog.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include "aboutdialog.h"
#include "ui_aboutdialog.h"
#include <dwmapi.h>
#include <QDesktopServices>
#include <QUrl>
AboutDialog::AboutDialog(QWidget *parent)
: QDialog(parent)
, ui(new Ui::AboutDialog)
, m_DwmWidth(0)
{
ui->setupUi(this);
/* 窗口风格 */
this->setFixedSize(this->size());
this->setWindowFlags((this->windowFlags() & ~Qt::WindowMinMaxButtonsHint) | Qt::FramelessWindowHint);
/* 窗口阴影 */
BOOL bEnable = false;
::DwmIsCompositionEnabled(&bEnable);
if (bEnable) {
m_DwmWidth = 7;
DWMNCRENDERINGPOLICY ncrp = DWMNCRP_ENABLED;
::DwmSetWindowAttribute((HWND)winId(), DWMWA_NCRENDERING_POLICY, &ncrp, sizeof(ncrp));
MARGINS margins = { -1 };
::DwmExtendFrameIntoClientArea((HWND)winId(), &margins);
}
/* 信号槽 */
connect(ui->btn_ok, &QPushButton::clicked, this, &AboutDialog::hide);
connect(ui->btn_github, &QPushButton::clicked, this, [=] () {
QDesktopServices::openUrl(QUrl("https://github.com/LeaguePrank/LeagueTeamBoost"));
});
connect(ui->btn_bilibili, &QPushButton::clicked, this, [=] () {
QDesktopServices::openUrl(QUrl("https://space.bilibili.com/248303677"));
QDesktopServices::openUrl(QUrl("https://space.bilibili.com/14671179"));
});
}
AboutDialog::~AboutDialog()
{
delete ui;
}
void AboutDialog::showEvent(QShowEvent *e)
{
Q_UNUSED(e)
int x = parentWidget()->x() + (parentWidget()->width() / 2);
int y = parentWidget()->y() + (parentWidget()->height() / 2);
x -= this->width() / 2 + m_DwmWidth; // m_DwmWidth = 7 可能是dwm的宽度?需要再研究
y -= this->height() / 2;
move(x, y);
}