-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathcloudwindow.cpp
More file actions
145 lines (116 loc) · 3.31 KB
/
Copy pathcloudwindow.cpp
File metadata and controls
145 lines (116 loc) · 3.31 KB
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
#include "stdafx.h"
#include "cloudwindow.h"
#include "titlebar.h"
#include "content.h"
#include "statusbar.h"
#include "webaxwidget.h"
CloudWindow::CloudWindow(QFrame *parent)
: BaseWindow(parent)
{
setObjectName("cloudWindow");
resize(CLOUD_WINDOW_WIDTH, CLOUD_WINDOW_HEIGHT);
InitControl();
}
CloudWindow::~CloudWindow()
{
}
void CloudWindow::paintEvent(QPaintEvent *event)
{
//先显示阴影
BaseWindow::paintEvent(event);
//再显示背景
QPainter painter(this);
painter.setPen(Qt::NoPen);
painter.setBrush(Qt::white);
painter.drawPixmap(QRect(SHADOW_WIDTH, SHADOW_WIDTH, width()-2*SHADOW_WIDTH, height()-2*SHADOW_WIDTH), QPixmap(g_skinName));
}
bool CloudWindow::nativeEvent(const QByteArray &eventType, void *message, long *result)
{
return BaseWindow::nativeEvent(eventType, message, result);
}
void CloudWindow::moveEvent(QMoveEvent * event)
{
Q_UNUSED(event);
QPoint point = pos();
point.setY(point.y() + m_pTitleBar->height() + SHADOW_WIDTH);
point.setX(point.x() + SHADOW_WIDTH);
m_pWebAxWidget->move(point);
}
void CloudWindow::resizeEvent(QResizeEvent *event)
{
Q_UNUSED(event);
QSize size = this->size();
size.setHeight(height() - m_pTitleBar->height() - SHADOW_WIDTH*2);
size.setWidth(width() - SHADOW_WIDTH*2);
m_pWebAxWidget->resize(size);
}
void CloudWindow::showEvent(QShowEvent *event)
{
Q_UNUSED(event);
m_pWebAxWidget->show();
}
void CloudWindow::hideEvent(QHideEvent *event)
{
Q_UNUSED(event);
m_pWebAxWidget->hide();
stop();
}
void CloudWindow::stop()
{
if(g_playChannel == CHANNEL_THUNDER)
{
m_pWebAxWidget->dynamicCall("Navigate(const QString&)", THUNDER_CLOUD_PLAY_URL);
}
else if(g_playChannel == CHANNEL_QQ)
{
}
else if(g_playChannel == CHANNEL_OTHER)
{
m_pWebAxWidget->dynamicCall("Navigate(const QString&)", HUOYAN_CLOUD_PLAY_URL);
}
}
void CloudWindow::InitControl()
{
//创建标题栏
m_pTitleBar = new TitleBar(this);
//创建内容区域
m_pContent = new Content(this);
//创建状态栏
m_pStatusBar = new StatusBar(this);
m_pStatusBar->setVisible(false);
//创建布局
QVBoxLayout *layout = new QVBoxLayout();
//设置间距与边缘空白
layout->setSpacing(0);
layout->setContentsMargins(SHADOW_WIDTH, SHADOW_WIDTH, SHADOW_WIDTH, SHADOW_WIDTH);
//将部件加入到布局中
layout->addWidget(m_pTitleBar);
layout->addWidget(m_pContent);
layout->addWidget(m_pStatusBar);
setLayout(layout);
//隐藏按钮
m_pTitleBar->m_pSkinButton->setVisible(false);
m_pTitleBar->m_pCloudPlayButton->setVisible(false);
m_pTitleBar->m_pMiniPortalButton->setVisible(false);
m_pTitleBar->m_pMenuButton->setVisible(false);
m_pWebAxWidget = new WebAxWidget(this);
m_pWebAxWidget->setObjectName("webAxWidget");
m_pWebAxWidget->setProtocolName("openVodClientWindow");
if(g_playChannel == CHANNEL_THUNDER)
{
m_pWebAxWidget->dynamicCall("Navigate(const QString&)", THUNDER_CLOUD_PLAY_URL);
}
else if(g_playChannel == CHANNEL_QQ)
{
}
else if(g_playChannel == CHANNEL_OTHER)
{
m_pWebAxWidget->dynamicCall("Navigate(const QString&)", HUOYAN_CLOUD_PLAY_URL);
}
m_pWebAxWidget->setWindowFlags(Qt::FramelessWindowHint | Qt::Tool | Qt::Popup); //Qt::Tool不显示任务栏图标,需设置CloudWindow的parent
QVBoxLayout *contentLayout = new QVBoxLayout();
contentLayout->setSpacing(0);
contentLayout->setContentsMargins(0, 0, 0, 0);
//contentLayout->addWidget(m_pWebAxWidget);
m_pContent->setLayout(contentLayout);
}