forked from AmuUncle/MusicPlayer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcfgdlg.cpp
99 lines (78 loc) · 1.97 KB
/
cfgdlg.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#include "cfgdlg.h"
#include "ui_cfgdlg.h"
#include <QVBoxLayout>
#include <QFileDialog>
#include <QDir>
#include <QDebug>
#include "musicmgr.h"
#ifdef WIN32
#include "Windows.h"
#pragma comment(lib, "User32.lib")
#endif
#if _MSC_VER >= 1600
#pragma execution_character_set("utf-8")
#endif
CfgDlg::CfgDlg(QWidget *parent) :
BoderPane(parent),
ui(new Ui::CfgDlg)
{
ui->setupUi(this);
setWindowFlags(Qt::FramelessWindowHint | Qt::Popup);
setProperty("form", "cfgdlg");
setAttribute(Qt::WA_StyledBackground); // 禁止父窗口样式影响子控件样式
CreateAllChildWnd();
InitCtrl();
InitSolts();
Relayout();
}
CfgDlg::~CfgDlg()
{
delete ui;
}
void CfgDlg::CreateAllChildWnd()
{
}
void CfgDlg::InitCtrl()
{
}
void CfgDlg::InitSolts()
{
}
void CfgDlg::Relayout()
{
QVBoxLayout *layoutMain = new QVBoxLayout();
layoutMain->addWidget(ui->m_widgetCenter);
layoutMain->setMargin(8);
centralWidget()->setLayout(layoutMain);
}
bool CfgDlg::event(QEvent *event)
{
static bool class_amended = false;
if (event->type() == QEvent::WinIdChange)
{
HWND hwnd = reinterpret_cast<HWND>(winId());
if (class_amended == false)
{
class_amended = true;
DWORD class_style = ::GetClassLong(hwnd, GCL_STYLE);
class_style &= ~CS_DROPSHADOW;
::SetClassLong(hwnd, GCL_STYLE, class_style); // windows系统函数
}
}
else if (event->type() == QEvent::Show)
{
ui->m_editDir->setText(DATAMGR->GetRootDir());
}
return BoderPane::event(event);
}
void CfgDlg::on_m_btnModify_clicked()
{
QString strCurDir = ui->m_editDir->text();
if (strCurDir.isEmpty())
strCurDir = QDir::currentPath(); // 获取系统当前目录
QString strDir = QFileDialog::getExistingDirectory(this, tr("选择目录"), strCurDir);
if (strDir.isEmpty())
return;
ui->m_editDir->setText(strDir);
DATAMGR->SetRootDir(strDir);
}