├── .gitignore ├── .main.png ├── LICENSE ├── README.md ├── kuplayer.ico ├── kuplayer.pro ├── kuplayer.pro.user ├── kuplayer.rc ├── kuplayer_zn.ts ├── pyscript └── py_kuplayer.py ├── resources └── libs │ ├── QtSingleApplication │ ├── libQtSingleApplication.so │ ├── libboost_python.a │ ├── libboost_system.a │ └── liboptions_64.so ├── src ├── about_widget.ui ├── base_set_weidget.ui ├── common.cpp ├── common.h ├── conf_info.cpp ├── conf_info.h ├── control_label.cpp ├── control_label.h ├── control_widget.cpp ├── control_widget.h ├── detail_label.cpp ├── detail_label.h ├── gloal_func.h ├── img │ ├── controlButton │ │ ├── backward.png │ │ ├── foreward.png │ │ ├── pause.png │ │ ├── play.png │ │ └── stop.png │ ├── logo │ │ ├── logo.ico │ │ ├── logo.png │ │ ├── logo_min.ico │ │ └── welcome.png │ ├── shadow │ │ ├── shadow_bottom.png │ │ ├── shadow_left.png │ │ ├── shadow_left_bottom.png │ │ ├── shadow_left_top.png │ │ ├── shadow_right.png │ │ ├── shadow_right_bottom.png │ │ ├── shadow_right_top.png │ │ └── shadow_top.png │ ├── skin │ │ ├── 0_big.png │ │ ├── 10_big.png │ │ ├── 11_big.png │ │ ├── 12_big.png │ │ ├── 13_big.png │ │ ├── 14_big.png │ │ ├── 15_big.jpg │ │ ├── 16_big.jpg │ │ ├── 1_big.png │ │ ├── 2_big.png │ │ ├── 3_big.png │ │ ├── 4_big.png │ │ ├── 5_big.png │ │ ├── 6_big.png │ │ ├── 7_big.png │ │ ├── 8_big.png │ │ └── 9_big.png │ └── sysButton │ │ ├── close.png │ │ ├── close_hover.png │ │ ├── close_pressed.png │ │ ├── menu.png │ │ ├── menu_hover.png │ │ ├── menu_pressed.png │ │ ├── min.png │ │ ├── min_hover.png │ │ ├── min_pressed.png │ │ ├── skin.png │ │ ├── skin_hover.png │ │ └── skin_pressed.png ├── kuplayer.cpp ├── kuplayer.h ├── kuplayer.qrc ├── kuplayer_en.qm ├── kuplayer_zn.qm ├── list_widget.cpp ├── list_widget.h ├── loadimage.h ├── main.cpp ├── main_menu.cpp ├── main_menu.h ├── mplayer_widget.cpp ├── mplayer_widget.h ├── mthread.h ├── play_list_widget.cpp ├── play_list_widget.h ├── play_set_widget.ui ├── program_options.h ├── push_button.cpp ├── push_button.h ├── pyscript.cpp ├── pyscript.h ├── select_label.cpp ├── select_label.h ├── shadow_widget.cpp ├── shadow_widget.h ├── skin_widget.cpp ├── skin_widget.h ├── system_notify.h ├── title_widget.cpp ├── title_widget.h ├── ui_control_classes.cpp └── ui_control_classes.h └── testkuplayer ├── testkuplayer.pro └── tst_kuplayertest.cpp /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files 2 | *.slo 3 | *.lo 4 | *.o 5 | 6 | # Compiled Dynamic libraries 7 | *.dylib 8 | 9 | # Compiled Static libraries 10 | *.lai 11 | *.la 12 | -------------------------------------------------------------------------------- /.main.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zrmei/kuplayer/06b3fb9ffc13184086c5098cd50224c6c60d162f/.main.png -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | This is free and unencumbered software released into the public domain. 2 | 3 | Anyone is free to copy, modify, publish, use, compile, sell, or 4 | distribute this software, either in source code form or as a compiled 5 | binary, for any purpose, commercial or non-commercial, and by any 6 | means. 7 | 8 | In jurisdictions that recognize copyright laws, the author or authors 9 | of this software dedicate any and all copyright interest in the 10 | software to the public domain. We make this dedication for the benefit 11 | of the public at large and to the detriment of our heirs and 12 | successors. We intend this dedication to be an overt act of 13 | relinquishment in perpetuity of all present and future rights to this 14 | software under copyright law. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | For more information, please refer to 25 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | kuplayer:一个基于对优酷网站的分析获得播放地址,经过播放地址的解码,由开源的QtAV的播放库相应解码播放。 2 | 3 | 引用的相关开源库:https://github.com/wang-bin/QtAV 4 | 5 | ![image](https://github.com/listener/kuplayer/blob/master/.main.png) 6 | -------------------------------------------------------------------------------- /kuplayer.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zrmei/kuplayer/06b3fb9ffc13184086c5098cd50224c6c60d162f/kuplayer.ico -------------------------------------------------------------------------------- /kuplayer.pro: -------------------------------------------------------------------------------- 1 | #------------------------------------------------- 2 | # 3 | # Project created by QtCreator 2014-10-01T10:53:06 4 | # 5 | #------------------------------------------------- 6 | 7 | QT += core gui widgets network av avwidgets 8 | 9 | TARGET = kuplayer 10 | TEMPLATE = app 11 | 12 | PRECOMPILED_HEADER = src/common.h 13 | 14 | QMAKE_CXXFLAGS += -std=c++11 15 | QMAKE_CXXFLAGS_DEBUG += -O0 -g3 16 | QMAKE_CXXFLAGS_RELEASE += -DQT_NO_DEBUG_OUTPUT 17 | 18 | #DEFINES += NO_WIFI_TEST 19 | 20 | QMAKE_LFLAGS += -Wl,-rpath,"../lib" 21 | QMAKE_LFLAGS_RELEASE += -Wl,-s -Wl,-O2 22 | 23 | QMAKE_PROJECT_NAME = kuplayer 24 | 25 | SOURCES += src/control_widget.cpp \ 26 | src/detail_label.cpp \ 27 | src/kuplayer.cpp \ 28 | src/list_widget.cpp \ 29 | src/main.cpp \ 30 | src/main_menu.cpp \ 31 | src/mplayer_widget.cpp \ 32 | src/play_list_widget.cpp \ 33 | src/push_button.cpp \ 34 | src/pyscript.cpp \ 35 | src/select_label.cpp \ 36 | src/shadow_widget.cpp \ 37 | src/skin_widget.cpp \ 38 | src/title_widget.cpp \ 39 | src/ui_control_classes.cpp \ 40 | src/control_label.cpp \ 41 | src/common.cpp \ 42 | src/conf_info.cpp 43 | 44 | HEADERS += src/common.h \ 45 | src/control_widget.h \ 46 | src/detail_label.h \ 47 | src/kuplayer.h \ 48 | src/list_widget.h \ 49 | src/loadimage.h \ 50 | src/main_menu.h \ 51 | src/mplayer_widget.h \ 52 | src/mthread.h \ 53 | src/play_list_widget.h \ 54 | src/program_options.h \ 55 | src/push_button.h \ 56 | src/pyscript.h \ 57 | src/select_label.h \ 58 | src/shadow_widget.h \ 59 | src/skin_widget.h \ 60 | src/system_notify.h \ 61 | src/title_widget.h \ 62 | src/ui_control_classes.h \ 63 | src/gloal_func.h \ 64 | src/control_label.h \ 65 | src/conf_info.h 66 | 67 | RESOURCES += \ 68 | src/kuplayer.qrc 69 | 70 | RC_FILE += kuplayer.rc 71 | 72 | OTHER_FILES += \ 73 | kuplayer.ico \ 74 | kuplayer.rc 75 | 76 | FORMS += \ 77 | src/about_widget.ui \ 78 | src/base_set_weidget.ui \ 79 | src/play_set_widget.ui 80 | 81 | TRANSLATIONS += kuplayer_zn.ts 82 | 83 | 84 | unix: { 85 | INCLUDEPATH += /usr/include/python2.7/ \ 86 | $$PWD/resources/libs 87 | 88 | LIBS += -L$$PWD/resources/libs \ 89 | $$PWD/resources/libs/libboost_python.a \ 90 | $$PWD/resources/libs/libboost_system.a \ 91 | -lQtSingleApplication \ 92 | -loptions_64 \ 93 | -lpython2.7 94 | 95 | exists( /usr/include/libnotify/notify.h ) { 96 | INCLUDEPATH += /usr/include/glib-2.0/ 97 | INCLUDEPATH += /usr/lib/x86_64-linux-gnu/glib-2.0/include/ 98 | INCLUDEPATH += /usr/include/gdk-pixbuf-2.0/ 99 | 100 | LIBS += -lnotify 101 | DEFINES += USE_NOTIFY 102 | } else { 103 | message("Can not find libnotify.so. You can: sudo apt-get install libnotify4-dev") 104 | } 105 | } 106 | 107 | SUBDIRS += \ 108 | testkuplayer/testkuplayer.pro 109 | 110 | 111 | -------------------------------------------------------------------------------- /kuplayer.rc: -------------------------------------------------------------------------------- 1 | IDI_ICON1 ICON DISCARDABLE "kuplayer.ico" 2 | -------------------------------------------------------------------------------- /kuplayer_zn.ts: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | mei::kuplayer::ControlWidget 6 | 7 | 8 | Backward 9 | 快退 10 | 11 | 12 | 13 | Stop 14 | 停止 15 | 16 | 17 | 18 | Play/Pause 19 | 播放/暂停 20 | 21 | 22 | 23 | Foreward 24 | 快进 25 | 26 | 27 | 28 | Episode 29 | 选集 30 | 31 | 32 | 33 | mei::kuplayer::MainWidget 34 | 35 | 36 | kuplayer: free for youku! 37 | 酷播:免费的优酷播放器! 38 | 39 | 40 | 41 | kuplayer 42 | 酷播 43 | 44 | 45 | 46 | Showing by double-click ! 47 | 双击这显示! 48 | 49 | 50 | 51 | 52 | Exit 53 | 退出 54 | 55 | 56 | 57 | Really want to quit? 58 | 是否真的要退出? 59 | 60 | 61 | 62 | 63 | Currently playing: 64 | 正在播放: 65 | 66 | 67 | 68 | Settings 69 | 设置 70 | 71 | 72 | 73 | About 74 | 关于 75 | 76 | 77 | 78 | QObject 79 | 80 | 81 | Error 82 | 错误 83 | 84 | 85 | 86 | Network error,Please try later ! 87 | 网络连接错误,请重试,错误代码110 88 | 89 | 90 | 91 | Power on ... 92 | 93 | 94 | 95 | 96 | Loading core file ... 97 | 98 | 99 | 100 | 101 | Loading module ... 102 | 103 | 104 | 105 | 106 | Initializing the TV module ... 107 | 正在初始化电视模块…… 108 | 109 | 110 | 111 | Initializing the Movie module... 112 | 正在初始化电影模块…… 113 | 114 | 115 | 116 | Initializing the Music module... 117 | 正在初始化音乐模块…… 118 | 119 | 120 | 121 | Initializing the Comic module... 122 | 正在初始化动漫模块…… 123 | 124 | 125 | 126 | Initializing the Zongyi module... 127 | 正在初始化综艺模块…… 128 | 129 | 130 | 131 | 132 | 133 | Basic Settings 134 | 基本设置 135 | 136 | 137 | 138 | 139 | 140 | About 141 | 关于 142 | 143 | 144 | 145 | 146 | Play Settings 147 | 播放设置 148 | 149 | 150 | 151 | 152 | Save 153 | 保存 154 | 155 | 156 | 157 | 158 | Cancel 159 | 取消 160 | 161 | 162 | 163 | mei::kuplayer::TitleWidget 164 | 165 | 166 | Close 167 | 关闭 168 | 169 | 170 | 171 | Min 172 | 最小化 173 | 174 | 175 | 176 | Skin 177 | 皮肤 178 | 179 | 180 | 181 | Menu 182 | 菜单 183 | 184 | 185 | 186 | TVShow 187 | 电视剧 188 | 189 | 190 | 191 | Movies 192 | 电影 193 | 194 | 195 | 196 | Variety 197 | 综艺 198 | 199 | 200 | 201 | Music 202 | 音乐 203 | 204 | 205 | 206 | Cartoon 207 | 动漫 208 | 209 | 210 | 211 | Player 212 | 播放器 213 | 214 | 215 | 216 | about_widget 217 | 218 | 219 | Form 220 | 221 | 222 | 223 | 224 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> 225 | <html><head><meta name="qrichtext" content="1" /><style type="text/css"> 226 | p, li { white-space: pre-wrap; } 227 | </style></head><body style=" font-family:'Ubuntu'; font-size:11pt; font-weight:400; font-style:normal;"> 228 | <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'consolas'; font-weight:600; color:#000000;">MadeBy : </span><a href="https://github.com/listener/kuplayer"><span style=" font-family:'consolas'; font-weight:600; color:#000000;">MeiZhaorui(Mason)</span></a><span style=" font-family:'consolas'; font-weight:600; color:#000000;"> </span></p> 229 | <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'consolas'; font-weight:600; color:#000000;">E-Mail : listener_mei@163.com</span></p> 230 | <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'consolas'; font-weight:600; color:#000000;"> Phone : (0)131-5898-7498</span></p> 231 | <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'consolas'; font-weight:600; color:#000000;"> Date : 2014/10/20 </span></p></body></html> 232 | 233 | 234 | 235 | 236 | base_set_weidget 237 | 238 | 239 | Form 240 | 241 | 242 | 243 | 244 | Startup Settings: 245 | 启动选项 246 | 247 | 248 | 249 | Automatically start at pc on 250 | 开机自启动 251 | 252 | 253 | 254 | When you close the client, turn off All 255 | 关闭客户端关闭所有后台应用 256 | 257 | 258 | 259 | Closing main form: 260 | 关闭选项 261 | 262 | 263 | 264 | Minimize to system tray 265 | 最小化到系统盘 266 | 267 | 268 | 269 | Exit 270 | 退出 271 | 272 | 273 | 274 | Language: 275 | 中文 276 | 277 | 278 | 279 | 中文 280 | 281 | 282 | 283 | 284 | English 285 | 286 | 287 | 288 | 289 | <html><head/><body><p><span style=" color:#d50000;">changed when restart !</span></p></body></html> 290 | <html><head/><body><p><span style=" color:#d50000;">此选项需重新启动后才生效!</span></p></body></html> 291 | 292 | 293 | 294 | play_set_widget 295 | 296 | 297 | Form 298 | 299 | 300 | 301 | 302 | Play: 303 | 播放: 304 | 305 | 306 | 307 | Play next automatic 308 | 是否自动连播 309 | 310 | 311 | 312 | Always skip titles credits 313 | 跳过片头片尾 314 | 315 | 316 | 317 | Priority for my choice: 318 | 优先为我选择: 319 | 320 | 321 | 322 | Super 323 | 超清 324 | 325 | 326 | 327 | High 328 | 高清 329 | 330 | 331 | 332 | Standard 333 | 标清 334 | 335 | 336 | 337 | <html><head/><body><p>Recommendation: 2M choose High, 4M more choose Super</p></body></html> 338 | 宽带建议:2M选择高清,4M以上选择超清 339 | 340 | 341 | 342 | Hotkey: 343 | 热键: 344 | 345 | 346 | 347 | Play / Pause 348 | 播放/暂停 349 | 350 | 351 | 352 | Fast Forward 353 | 快进 354 | 355 | 356 | 357 | Rewind 358 | 快退 359 | 360 | 361 | 362 | Volume + 363 | 音量加 364 | 365 | 366 | 367 | Volume - 368 | 音量减 369 | 370 | 371 | 372 | Exit Full Screen 373 | 退出全屏 374 | 375 | 376 | 377 | space 378 | 379 | 380 | 381 | 382 | → 383 | 384 | 385 | 386 | 387 | ← 388 | 389 | 390 | 391 | 392 | ↑ 393 | 394 | 395 | 396 | 397 | ↓ 398 | 399 | 400 | 401 | 402 | Esc 403 | 404 | 405 | 406 | 407 | -------------------------------------------------------------------------------- /pyscript/py_kuplayer.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*-coding:utf-8-*- 3 | 4 | import urllib 5 | import urllib2 6 | import re 7 | import threading 8 | import time 9 | import base64 10 | import json 11 | 12 | # from py_kuplayer import * 13 | # L = get_html("http://box.zhangmen.baidu.com/x?op=12&count=1&title=最炫民族风$$凤凰传奇$$$$") 14 | # print L 15 | 16 | 17 | 18 | fake_headers = { 19 | 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', 20 | 'Accept-Charset': 'UTF-8,*;q=0.5', 21 | 'Accept-Language': 'en-US,en;q=0.8', 22 | 'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64; rv:13.0) Gecko/20100101 Firefox/13.0' 23 | } 24 | 25 | def get_html(url): 26 | req = urllib2.Request(url,headers=fake_headers) 27 | response = urllib2.urlopen(req) 28 | return response.read() 29 | 30 | 31 | class Youku(): 32 | 33 | def __init__(self, *args): 34 | self.url = None 35 | self.vid = None 36 | self.streams = {} 37 | # self.audiolang = None 38 | 39 | stream_types = [ 40 | {'id': 'hd2', 'container': 'flv'}, 41 | {'id': 'mp4', 'container': 'mp4'}, 42 | {'id': 'flv', 'container': 'flv'} 43 | ] 44 | 45 | @staticmethod 46 | def generate_ep(vid, ep): 47 | f_code_1 = 'becaf9be' 48 | f_code_2 = 'bf7e5f01' 49 | 50 | def trans_e(a, c): 51 | f = h = 0 52 | b = list(range(256)) 53 | result = '' 54 | while h < 256: 55 | f = (f + b[h] + ord(a[h % len(a)])) % 256 56 | b[h], b[f] = b[f], b[h] 57 | h += 1 58 | q = f = h = 0 59 | while q < len(c): 60 | h = (h + 1) % 256 61 | f = (f + b[h]) % 256 62 | b[h], b[f] = b[f], b[h] 63 | if isinstance(c[q], int): 64 | result += chr(c[q] ^ b[(b[h] + b[f]) % 256]) 65 | else: 66 | result += chr(ord(c[q]) ^ b[(b[h] + b[f]) % 256]) 67 | q += 1 68 | 69 | return result 70 | 71 | e_code = trans_e(f_code_1, base64.b64decode(bytes(ep))) 72 | sid, token = e_code.split('_') 73 | new_ep = trans_e(f_code_2, '%s_%s_%s' % (sid, vid, token)) 74 | return base64.b64encode(bytes(new_ep)), sid, token 75 | 76 | @staticmethod 77 | def parse_m3u8(m3u8): 78 | return re.findall(r'(http://[^?]+)\?ts_start=0', m3u8) 79 | 80 | @staticmethod 81 | def match_vid(text, pattern): 82 | match = re.search(pattern, text) 83 | if match: 84 | return match.group(1) 85 | else: 86 | return None 87 | 88 | @staticmethod 89 | def get_vid_from_url(url): 90 | return Youku.match_vid(url, r'youku\.com/v_show/id_([a-zA-Z0-9=]+)') 91 | 92 | def prepare(self, **kwargs): 93 | assert self.url or self.vid 94 | 95 | if self.url and not self.vid: 96 | self.vid = self.__class__.get_vid_from_url(self.url) 97 | 98 | playlist = json.loads( 99 | get_html('http://v.youku.com/player/getPlayList/VideoIDS/%s/Pf/4/ctype/12/ev/1' % self.vid) 100 | ) 101 | playlistdata0 = playlist['data'][0] 102 | 103 | self.ep = playlistdata0['ep'] 104 | self.ip = playlistdata0['ip'] 105 | 106 | for stream_type in self.stream_types: 107 | if stream_type['id'] in playlistdata0['streamsizes']: 108 | stream_id = stream_type['id'] 109 | stream_size = int(playlistdata0['streamsizes'][stream_id]) 110 | self.streams[stream_id] = {'container': stream_type['container'], 'size': stream_size} 111 | 112 | def extract(self, **kwargs): 113 | if 'stream_id' in kwargs and kwargs['stream_id']: 114 | stream_id = kwargs['stream_id'] 115 | 116 | if stream_id not in self.streams: 117 | stream_id = "flv" 118 | else: 119 | stream_id = "flv" 120 | 121 | new_ep, sid, token = self.__class__.generate_ep(self.vid, self.ep) 122 | m3u8_query = urllib.urlencode(dict( 123 | ctype=12, 124 | ep=new_ep, 125 | ev=1, 126 | keyframe=1, 127 | oip=self.ip, 128 | sid=sid, 129 | token=token, 130 | ts=int(time.time()), 131 | type=stream_id, 132 | vid=self.vid, 133 | )) 134 | m3u8_url = 'http://pl.youku.com/playlist/m3u8?' + m3u8_query 135 | 136 | m3u8 = get_html(m3u8_url) 137 | self.streams[stream_id]['src'] = self.parse_m3u8(m3u8) 138 | 139 | 140 | def getVideoUrls(self, url, **kwargs): 141 | self.url = url 142 | self.prepare(**kwargs) 143 | self.extract(**kwargs) 144 | 145 | return self.download(**kwargs) 146 | 147 | def download(self, **kwargs): 148 | if 'stream_id' in kwargs and kwargs['stream_id']: 149 | stream_id = kwargs['stream_id'] 150 | else: 151 | stream_id = 'flv' 152 | 153 | if stream_id in self.streams and 'src' in self.streams[stream_id]: 154 | urls = self.streams[stream_id]['src'] 155 | else: 156 | urls = self.streams['flv']['src'] 157 | 158 | return urls 159 | 160 | 161 | 162 | def getVideoUrls(url,f): 163 | site = Youku() 164 | return site.getVideoUrls(url,stream_id=f) 165 | 166 | 167 | def downUrl(the_page, re_qb, key=-2, source=1): 168 | videourl = re_qb.findall(the_page) 169 | table_aa = {} 170 | for i in range(len(videourl)): 171 | tmp = videourl[i].strip().split("\"") 172 | table_aa[tmp[key]] = tmp[source] 173 | return table_aa # table 174 | 175 | def video_url(the_page): 176 | re_qb = re.compile(r'(?<=)') 177 | re_qc = re.compile(r'(?<=)') 178 | table = downUrl(the_page, re_qc) 179 | if not table: 180 | table = downUrl(the_page, re_qb) 181 | return table 182 | 183 | def video_img(the_page): 184 | re_qb = re.compile(r'(?<=)', re.DOTALL) 185 | return downUrl(the_page, re_qb) 186 | 187 | def getplayUrl(url): 188 | the_page = get_html(url) 189 | re_db1 = re.compile('(?<=class="btnShow btnplay" href=")http://v\.youku\.com/v_show/.*?(?=\?from)') 190 | re_db = re.compile('(?<=href=")http://v\.youku\.com/v_show/.*?(?=\?from)') 191 | videourl = re_db1.findall(the_page) 192 | if not videourl: 193 | videourl = re_db.findall(the_page) 194 | return videourl 195 | 196 | #TV 197 | def get_tv_all(url): 198 | the_page = get_html(url) 199 | re_qb = re.compile("(?<=title=)\"第[0-9]{,3}.*?')[1].split('<')[0]+"$$"+table[i]) 225 | return L 226 | 227 | def getGotoPage(the_page): 228 | re_db = re.compile("(?<=location\.href =).*?(?=\+)") 229 | videourl = re_db.findall(the_page) 230 | return 'http://www.youku.com' + videourl[0].split("'")[1] 231 | 232 | def getShowList(): 233 | re_qb = re.compile('(?<=
  • 电视剧'][:-5]) 238 | L.append("http://www.youku.com" + table['>电影' ][:-5]) 239 | L.append("http://www.youku.com" + table['>综艺' ][:-5]) 240 | L.append("http://www.youku.com" + table['>音乐' ][:-5]) 241 | L.append("http://www.youku.com" + table['>动漫' ][:-5]) 242 | return L 243 | 244 | 245 | def GetUrlByname(name, locate, classes, time): 246 | return name + '_g_' + classes + '_a_' + locate + '_s_1_d_1_r_' + time + '.html' 247 | 248 | 249 | class mythread(threading.Thread): 250 | def __init__(self,the_page): 251 | threading.Thread.__init__(self) 252 | self.the_page = the_page 253 | 254 | def run(self): 255 | self.table1 = video_img(self.the_page) 256 | 257 | def mcheck(self): 258 | while self.is_alive(): 259 | pass 260 | return self.table1 261 | 262 | class mythread1(threading.Thread): 263 | def __init__(self,the_page): 264 | threading.Thread.__init__(self) 265 | self.the_page = the_page 266 | 267 | def run(self): 268 | self.table1 = video_url(self.the_page) 269 | 270 | def mcheck(self): 271 | while self.is_alive(): 272 | pass 273 | return self.table1 274 | 275 | def connect_img_url(url): 276 | the_page = get_html(url) 277 | t = mythread(the_page) 278 | t1 = mythread1(the_page) 279 | t.setDaemon(True) 280 | t.start() 281 | t1.setDaemon(True) 282 | t1.start() 283 | 284 | L = [] 285 | L.append(getGotoPage(the_page)) 286 | 287 | table1 = t.mcheck() 288 | table2 = t1.mcheck() 289 | for i in table1: 290 | L.append(i+"$$"+table1[i]+"$$"+table2[i]) 291 | return L -------------------------------------------------------------------------------- /resources/libs/QtSingleApplication: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). 4 | ** Contact: http://www.qt-project.org/legal 5 | ** 6 | ** This file is part of the Qt Solutions component. 7 | ** 8 | ** $QT_BEGIN_LICENSE:BSD$ 9 | ** You may use this file under the terms of the BSD license as follows: 10 | ** 11 | ** "Redistribution and use in source and binary forms, with or without 12 | ** modification, are permitted provided that the following conditions are 13 | ** met: 14 | ** * Redistributions of source code must retain the above copyright 15 | ** notice, this list of conditions and the following disclaimer. 16 | ** * Redistributions in binary form must reproduce the above copyright 17 | ** notice, this list of conditions and the following disclaimer in 18 | ** the documentation and/or other materials provided with the 19 | ** distribution. 20 | ** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names 21 | ** of its contributors may be used to endorse or promote products derived 22 | ** from this software without specific prior written permission. 23 | ** 24 | ** 25 | ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 26 | ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 27 | ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 28 | ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 29 | ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 30 | ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 31 | ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 32 | ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 33 | ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 34 | ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 35 | ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." 36 | ** 37 | ** $QT_END_LICENSE$ 38 | ** 39 | ****************************************************************************/ 40 | 41 | #ifndef QTSINGLEAPPLICATION_H 42 | #define QTSINGLEAPPLICATION_H 43 | 44 | #include 45 | 46 | class QtLocalPeer; 47 | 48 | #if defined(Q_OS_WIN) 49 | # if !defined(QT_QTSINGLEAPPLICATION_EXPORT) && !defined(QT_QTSINGLEAPPLICATION_IMPORT) 50 | # define QT_QTSINGLEAPPLICATION_EXPORT 51 | # elif defined(QT_QTSINGLEAPPLICATION_IMPORT) 52 | # if defined(QT_QTSINGLEAPPLICATION_EXPORT) 53 | # undef QT_QTSINGLEAPPLICATION_EXPORT 54 | # endif 55 | # define QT_QTSINGLEAPPLICATION_EXPORT __declspec(dllimport) 56 | # elif defined(QT_QTSINGLEAPPLICATION_EXPORT) 57 | # undef QT_QTSINGLEAPPLICATION_EXPORT 58 | # define QT_QTSINGLEAPPLICATION_EXPORT __declspec(dllexport) 59 | # endif 60 | #else 61 | # define QT_QTSINGLEAPPLICATION_EXPORT 62 | #endif 63 | 64 | class QT_QTSINGLEAPPLICATION_EXPORT QtSingleApplication : public QApplication 65 | { 66 | Q_OBJECT 67 | 68 | public: 69 | QtSingleApplication(int &argc, char **argv, bool GUIenabled = true); 70 | QtSingleApplication(const QString &id, int &argc, char **argv); 71 | #if QT_VERSION < 0x050000 72 | QtSingleApplication(int &argc, char **argv, Type type); 73 | # if defined(Q_WS_X11) 74 | QtSingleApplication(Display* dpy, Qt::HANDLE visual = 0, Qt::HANDLE colormap = 0); 75 | QtSingleApplication(Display *dpy, int &argc, char **argv, Qt::HANDLE visual = 0, Qt::HANDLE cmap= 0); 76 | QtSingleApplication(Display* dpy, const QString &appId, int argc, char **argv, Qt::HANDLE visual = 0, Qt::HANDLE colormap = 0); 77 | # endif // Q_WS_X11 78 | #endif // QT_VERSION < 0x050000 79 | 80 | bool isRunning(); 81 | QString id() const; 82 | 83 | void setActivationWindow(QWidget* aw, bool activateOnMessage = true); 84 | QWidget* activationWindow() const; 85 | 86 | // Obsolete: 87 | void initialize(bool dummy = true) 88 | { isRunning(); Q_UNUSED(dummy) } 89 | 90 | public Q_SLOTS: 91 | bool sendMessage(const QString &message, int timeout = 5000); 92 | void activateWindow(); 93 | 94 | 95 | Q_SIGNALS: 96 | void messageReceived(const QString &message); 97 | 98 | 99 | private: 100 | void sysInit(const QString &appId = QString()); 101 | QtLocalPeer *peer; 102 | QWidget *actWin; 103 | }; 104 | 105 | #endif // QTSINGLEAPPLICATION_H 106 | -------------------------------------------------------------------------------- /resources/libs/libQtSingleApplication.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zrmei/kuplayer/06b3fb9ffc13184086c5098cd50224c6c60d162f/resources/libs/libQtSingleApplication.so -------------------------------------------------------------------------------- /resources/libs/libboost_python.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zrmei/kuplayer/06b3fb9ffc13184086c5098cd50224c6c60d162f/resources/libs/libboost_python.a -------------------------------------------------------------------------------- /resources/libs/libboost_system.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zrmei/kuplayer/06b3fb9ffc13184086c5098cd50224c6c60d162f/resources/libs/libboost_system.a -------------------------------------------------------------------------------- /resources/libs/liboptions_64.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zrmei/kuplayer/06b3fb9ffc13184086c5098cd50224c6c60d162f/resources/libs/liboptions_64.so -------------------------------------------------------------------------------- /src/about_widget.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | about_widget 4 | 5 | 6 | 7 | 0 8 | 0 9 | 400 10 | 300 11 | 12 | 13 | 14 | Form 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | Qt::Vertical 23 | 24 | 25 | 26 | 20 27 | 40 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | Qt::Horizontal 38 | 39 | 40 | 41 | 40 42 | 20 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | Qt::AutoText 56 | 57 | 58 | :/logo/logo 59 | 60 | 61 | Qt::AlignCenter 62 | 63 | 64 | 65 | 66 | 67 | 68 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> 69 | <html><head><meta name="qrichtext" content="1" /><style type="text/css"> 70 | p, li { white-space: pre-wrap; } 71 | </style></head><body style=" font-family:'Ubuntu'; font-size:11pt; font-weight:400; font-style:normal;"> 72 | <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'consolas'; font-weight:600; color:#000000;">MadeBy : </span><a href="https://github.com/listener/kuplayer"><span style=" font-family:'consolas'; font-weight:600; color:#000000;">MeiZhaorui(Mason)</span></a><span style=" font-family:'consolas'; font-weight:600; color:#000000;"> </span></p> 73 | <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'consolas'; font-weight:600; color:#000000;">E-Mail : listener_mei@163.com</span></p> 74 | <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'consolas'; font-weight:600; color:#000000;"> Phone : (+86)131-5898-7498</span></p> 75 | <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'consolas'; font-weight:600; color:#000000;"> Date : 2014/10/20 </span></p></body></html> 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | Qt::Horizontal 85 | 86 | 87 | 88 | 40 89 | 20 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | Qt::Vertical 100 | 101 | 102 | 103 | 20 104 | 40 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | -------------------------------------------------------------------------------- /src/base_set_weidget.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | base_set_weidget 4 | 5 | 6 | 7 | 0 8 | 0 9 | 400 10 | 300 11 | 12 | 13 | 14 | Form 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 微软雅黑 24 | 10 25 | 26 | 27 | 28 | Startup Settings: 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | Qt::Horizontal 38 | 39 | 40 | QSizePolicy::Maximum 41 | 42 | 43 | 44 | 40 45 | 20 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 0 54 | 55 | 56 | QLayout::SetMinimumSize 57 | 58 | 59 | 60 | 61 | 62 | 0 63 | 0 64 | 65 | 66 | 67 | 68 | 微软雅黑 69 | 10 70 | 71 | 72 | 73 | true 74 | 75 | 76 | Automatically start at pc on 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 0 85 | 0 86 | 87 | 88 | 89 | 90 | 微软雅黑 91 | 10 92 | 93 | 94 | 95 | When you close the client, turn off All 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | Qt::Horizontal 105 | 106 | 107 | 108 | 40 109 | 20 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | Qt::Horizontal 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 微软雅黑 128 | 10 129 | 130 | 131 | 132 | Closing main form: 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | Qt::Horizontal 142 | 143 | 144 | QSizePolicy::Maximum 145 | 146 | 147 | 148 | 40 149 | 20 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 微软雅黑 161 | 10 162 | 163 | 164 | 165 | Minimize to system tray 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 微软雅黑 174 | 10 175 | 176 | 177 | 178 | Exit 179 | 180 | 181 | true 182 | 183 | 184 | 185 | 186 | 187 | 188 | Qt::Horizontal 189 | 190 | 191 | 192 | 40 193 | 20 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | Qt::Horizontal 206 | 207 | 208 | 209 | 210 | 211 | 212 | Language: 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | Qt::Horizontal 222 | 223 | 224 | QSizePolicy::Maximum 225 | 226 | 227 | 228 | 40 229 | 20 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 中文 239 | 240 | 241 | 242 | 243 | English 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | Qt::Horizontal 252 | 253 | 254 | 255 | 40 256 | 20 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | <html><head/><body><p><span style=" color:#d50000;">changed when restart !</span></p></body></html> 267 | 268 | 269 | 270 | 271 | 272 | 273 | Qt::Vertical 274 | 275 | 276 | 277 | 20 278 | 40 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | -------------------------------------------------------------------------------- /src/common.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2015 MeiZhaorui(Mason) 3 | 4 | The File is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Lesser General Public 6 | License as published by the Free Software Foundation; either 7 | version 2.1 of the License, or (at your option) any later version. 8 | 9 | The File is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public 15 | License along with the Library; if not, see 16 | . 17 | */ 18 | 19 | #include "common.h" 20 | USR_NAMESPACE_KUPLAYER 21 | 22 | int NAMESPACE_KUPLAYER::SHADOW_WIDTH = 5; 23 | int NAMESPACE_KUPLAYER::SHADOW_HEIGHT = 5; 24 | int NAMESPACE_KUPLAYER::WINDOW_WIDTH = 1002; 25 | int NAMESPACE_KUPLAYER::WINDOW_HEIGHT = 657; 26 | 27 | QString NAMESPACE_KUPLAYER::SHOW_PAGE = "http://www.youku.com/show_page/"; -------------------------------------------------------------------------------- /src/common.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2015 MeiZhaorui(Mason) 3 | 4 | The File is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Lesser General Public 6 | License as published by the Free Software Foundation; either 7 | version 2.1 of the License, or (at your option) any later version. 8 | 9 | The File is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public 15 | License along with the Library; if not, see 16 | . 17 | */ 18 | #ifndef COMMON_H 19 | #define COMMON_H 20 | 21 | #if defined(__GNUC__) && !defined(__clang__) 22 | #if (__GNUC__ < 4) || (__GNUC__ == 4 && __GNUC_MINOR__ < 6) 23 | #error Please use gcc4.6.0 or higher to support some new feature. 24 | #endif 25 | #elif defined(__clang__) 26 | #if (__clang_major__ < 3) || (__clang_major__ == 3 && __clang_minor__ < 4) 27 | #error Please use clang3.5.0 or higher to support some new feature. 28 | #endif 29 | #endif 30 | 31 | #ifndef NO_KUPLAYER_NAMESPACE 32 | #define KUPLAYER_NAMESPACE_BEGIN namespace mei { namespace kuplayer { 33 | #define KUPLAYER_NAMESPACE_END } } 34 | #define USR_NAMESPACE_KUPLAYER using namespace mei::kuplayer; 35 | #define NAMESPACE_KUPLAYER mei::kuplayer 36 | #else 37 | #define KUPLAYER_NAMESPACE_BEGIN 38 | #define KUPLAYER_NAMESPACE_END 39 | #define USR_NAMESPACE_KUPLAYER 40 | #define NAMESPACE_KUPLAYER 41 | #endif 42 | 43 | #include 44 | #include 45 | #include 46 | #include 47 | #include 48 | 49 | #include 50 | #include 51 | #include 52 | 53 | using std::for_each; 54 | using std::find_if; 55 | using std::find_if_not; 56 | using std::bind; 57 | using std::function; 58 | 59 | KUPLAYER_NAMESPACE_BEGIN //namespace begin 60 | 61 | 62 | extern int SHADOW_WIDTH; 63 | extern int SHADOW_HEIGHT; 64 | extern int WINDOW_WIDTH; 65 | extern int WINDOW_HEIGHT; 66 | 67 | extern QString SHOW_PAGE; 68 | 69 | typedef unsigned short CLASS; 70 | const CLASS TV{0}, MOVIE{1}, ZONGYI{2}, MUSIC{3}, COMIC{4}, PLAYER{5}, NONE{5}; 71 | 72 | 73 | KUPLAYER_NAMESPACE_END // namespace end 74 | #endif 75 | -------------------------------------------------------------------------------- /src/conf_info.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2015 MeiZhaorui(Mason) 3 | 4 | The File is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Lesser General Public 6 | License as published by the Free Software Foundation; either 7 | version 2.1 of the License, or (at your option) any later version. 8 | 9 | The File is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public 15 | License along with the Library; if not, see 16 | . 17 | */ 18 | 19 | 20 | -------------------------------------------------------------------------------- /src/conf_info.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2015 MeiZhaorui(Mason) 3 | 4 | The File is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Lesser General Public 6 | License as published by the Free Software Foundation; either 7 | version 2.1 of the License, or (at your option) any later version. 8 | 9 | The File is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public 15 | License along with the Library; if not, see 16 | . 17 | */ 18 | 19 | #ifndef CONF_INFO_H 20 | #define CONF_INFO_H 21 | #include "common.h" 22 | #include 23 | #include 24 | 25 | KUPLAYER_NAMESPACE_BEGIN 26 | 27 | struct conf_info { 28 | bool start_when_pc_on; 29 | bool close_all; 30 | bool min_or_close; 31 | bool auto_play_next; 32 | bool language; 33 | QString default_video_format; 34 | }; 35 | 36 | inline void 37 | conf_info_to_file(conf_info* setting,QSettings* iniFile) 38 | { 39 | setting->default_video_format = iniFile->value("setting/format", "flv").toString(); 40 | setting->close_all = iniFile->value("setting/close_all", true).toBool(); 41 | setting->auto_play_next = iniFile->value("setting/auto_play_next", false).toBool(); 42 | setting->min_or_close = iniFile->value("setting/min_or_close", false).toBool(); 43 | setting->start_when_pc_on = iniFile->value("setting/start_when_pc_on", false).toBool(); 44 | setting->language = iniFile->value("setting/language", true).toBool(); 45 | } 46 | 47 | inline void 48 | conf_info_from_file(conf_info*setting,QSettings* iniFile) 49 | { 50 | iniFile->setValue("setting/format", setting->default_video_format); 51 | iniFile->setValue("setting/close_all", setting->close_all); 52 | iniFile->setValue("setting/auto_play_next", setting->auto_play_next); 53 | iniFile->setValue("setting/min_or_close", setting->min_or_close); 54 | iniFile->setValue("setting/start_when_pc_on", setting->start_when_pc_on); 55 | iniFile->setValue("setting/language", setting->language); 56 | } 57 | 58 | KUPLAYER_NAMESPACE_END 59 | #endif // CONF_INFO_H 60 | -------------------------------------------------------------------------------- /src/control_label.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2015 MeiZhaorui(Mason) 3 | 4 | The File is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Lesser General Public 6 | License as published by the Free Software Foundation; either 7 | version 2.1 of the License, or (at your option) any later version. 8 | 9 | The File is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public 15 | License along with the Library; if not, see 16 | . 17 | */ 18 | 19 | #include "control_label.h" 20 | 21 | USR_NAMESPACE_KUPLAYER 22 | 23 | ControlLabel::ControlLabel(const QString &name, QWidget *parent) 24 | : QLabel(parent) 25 | { 26 | setObjectName(name.split("/").last()); 27 | setPixmap(QPixmap(name).scaled(26, 26)); 28 | setFixedSize(30, 30); 29 | } 30 | void ControlLabel::mousePressEvent(QMouseEvent *ev) 31 | { 32 | QLabel::mousePressEvent(ev); 33 | emit clicked(); 34 | } 35 | -------------------------------------------------------------------------------- /src/control_label.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2015 MeiZhaorui(Mason) 3 | 4 | The File is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Lesser General Public 6 | License as published by the Free Software Foundation; either 7 | version 2.1 of the License, or (at your option) any later version. 8 | 9 | The File is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public 15 | License along with the Library; if not, see 16 | . 17 | */ 18 | 19 | #ifndef CONTROL_LABEL_H 20 | #define CONTROL_LABEL_H 21 | #include "common.h" 22 | 23 | #include 24 | class QMouseEvent; 25 | 26 | 27 | KUPLAYER_NAMESPACE_BEGIN //namespace begin 28 | 29 | class ControlLabel final : public QLabel 30 | { 31 | Q_OBJECT 32 | signals: 33 | void clicked(); 34 | public: 35 | ControlLabel(const QString &name, QWidget *parent = 0); 36 | protected: 37 | void mousePressEvent(QMouseEvent *); 38 | }; 39 | 40 | KUPLAYER_NAMESPACE_END //namespace end 41 | 42 | #endif // CONTROL_LABEL_H 43 | -------------------------------------------------------------------------------- /src/control_widget.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2015 MeiZhaorui(Mason) 3 | 4 | The File is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Lesser General Public 6 | License as published by the Free Software Foundation; either 7 | version 2.1 of the License, or (at your option) any later version. 8 | 9 | The File is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public 15 | License along with the Library; if not, see 16 | . 17 | */ 18 | 19 | #include "common.h" 20 | #include "control_widget.h" 21 | #include "control_label.h" 22 | #include "select_label.h" 23 | USR_NAMESPACE_KUPLAYER //using namespace mei::kuplayer 24 | 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | 31 | #include 32 | using std::bind; 33 | 34 | struct ControlWidget::ControlWidget_Impl { 35 | Q_DISABLE_COPY(ControlWidget_Impl) 36 | 37 | QAction *backward_key; 38 | QAction *stop_key; 39 | QAction *pause_key; 40 | QAction *foreward_key; 41 | QAction *vol_up_key; 42 | QAction *vol_down_key; 43 | QAction *mute_key; 44 | QLabel *time_current; 45 | ControlLabel *backward_; 46 | ControlLabel *stop_; 47 | ControlLabel *play_pause; 48 | ControlLabel *foreward_; 49 | QLabel *time_all; 50 | SelectLabel *xuan_ji; 51 | 52 | ControlWidget_Impl() { 53 | time_current = new QLabel; 54 | time_current->setText("00:00:00"); 55 | QPalette text_palette; 56 | text_palette.setColor(QPalette::WindowText, QColor(255, 255, 255)); 57 | time_current->setPalette(text_palette); 58 | time_current->setMinimumWidth(65); 59 | backward_ = new ControlLabel(":/control/backward"); 60 | backward_->setToolTip(ControlWidget::tr("Backward")); 61 | stop_ = new ControlLabel(":/control/stop"); 62 | stop_->setToolTip(ControlWidget::tr("Stop")); 63 | play_pause = new ControlLabel(":/control/play"); 64 | play_pause->setToolTip(ControlWidget::tr("Play/Pause")); 65 | foreward_ = new ControlLabel(":/control/foreward"); 66 | foreward_->setToolTip(ControlWidget::tr("Foreward")); 67 | time_all = new QLabel; 68 | time_all->setText("00:00:00"); 69 | time_all->setMinimumWidth(65); 70 | time_all->setPalette(text_palette); 71 | xuan_ji = new SelectLabel(ControlWidget::tr("Episode"), ""); 72 | xuan_ji->setFixedSize(60, 30); 73 | } 74 | 75 | ~ControlWidget_Impl() { 76 | delete time_current; 77 | delete backward_; 78 | delete backward_key; 79 | delete stop_; 80 | delete stop_key; 81 | delete play_pause; 82 | delete pause_key; 83 | delete foreward_; 84 | delete foreward_key; 85 | delete vol_up_key; 86 | delete vol_down_key; 87 | } 88 | }; 89 | 90 | ControlWidget::ControlWidget(QWidget *parent) 91 | : QWidget(parent) 92 | , isRuning(false) 93 | , pImpl(new ControlWidget_Impl()) 94 | { 95 | connect(pImpl->backward_, SIGNAL(clicked()), this, SIGNAL(backward_clicked())); 96 | connect(pImpl->stop_, SIGNAL(clicked()), this, SIGNAL(stop_clicked())); 97 | connect(pImpl->play_pause, &ControlLabel::clicked, bind(&ControlWidget::on_play_pause_triggered, this, false)); 98 | connect(pImpl->foreward_, SIGNAL(clicked()), this, SIGNAL(foreward_clicked())); 99 | connect(pImpl->xuan_ji, SIGNAL(be_selected(QString, QString)), this, SIGNAL(xuan_ji_clcked(QString, QString))); 100 | init_actions(); 101 | QHBoxLayout *main_layout = new QHBoxLayout(this); 102 | main_layout->setContentsMargins(0, 3, 0, 0); 103 | main_layout->addStretch(); 104 | main_layout->addWidget(pImpl->time_current); 105 | main_layout->addWidget(pImpl->backward_); 106 | main_layout->addWidget(pImpl->stop_); 107 | main_layout->addWidget(pImpl->play_pause); 108 | main_layout->addWidget(pImpl->foreward_); 109 | main_layout->addWidget(pImpl->time_all); 110 | main_layout->addStretch(); 111 | main_layout->addWidget(pImpl->xuan_ji); 112 | } 113 | ControlWidget::~ControlWidget() 114 | { 115 | } 116 | QList ControlWidget::reg_actions() 117 | { 118 | return {{ 119 | pImpl->backward_key, pImpl->stop_key, pImpl->pause_key, 120 | pImpl->foreward_key, pImpl->vol_up_key, pImpl->vol_down_key 121 | } 122 | }; 123 | } 124 | void ControlWidget::init_actions() 125 | { 126 | pImpl->backward_key = new QAction(this); 127 | pImpl->backward_key->setShortcut(QKeySequence(Qt::Key_Left)); 128 | connect(pImpl->backward_key, SIGNAL(triggered()), this, SIGNAL(backward_clicked())); 129 | pImpl->stop_key = new QAction(this); 130 | pImpl->stop_key->setShortcut(QKeySequence(Qt::Key_End)); 131 | connect(pImpl->stop_key, SIGNAL(triggered()), this, SIGNAL(stop_clicked())); 132 | pImpl->pause_key = new QAction(this); 133 | pImpl->pause_key->setShortcut(QKeySequence(Qt::Key_Space)); 134 | connect(pImpl->pause_key, SIGNAL(triggered(bool)), this, SLOT(on_play_pause_triggered(bool))); 135 | pImpl->foreward_key = new QAction(this); 136 | pImpl->foreward_key->setShortcut(QKeySequence(Qt::Key_Right)); 137 | connect(pImpl->foreward_key, SIGNAL(triggered()), this, SIGNAL(foreward_clicked())); 138 | pImpl->vol_up_key = new QAction(this); 139 | pImpl->vol_up_key->setShortcut(QKeySequence(Qt::Key_Up)); 140 | connect(pImpl->vol_up_key, SIGNAL(triggered()), this, SIGNAL(vol_up_clicked())); 141 | pImpl->vol_down_key = new QAction(this); 142 | pImpl->vol_down_key->setShortcut(QKeySequence(Qt::Key_Down)); 143 | connect(pImpl->vol_down_key, SIGNAL(triggered()), this, SIGNAL(vol_down_clicked())); 144 | pImpl->mute_key = new QAction(this); 145 | pImpl->mute_key->setShortcut(QKeySequence(Qt::Key_M)); 146 | connect(pImpl->mute_key, SIGNAL(triggered()), this, SIGNAL(vol_mute_clicked())); 147 | } 148 | 149 | void ControlWidget::on_play_pause_triggered(bool) 150 | { 151 | static QPixmap pause = QPixmap(":/control/pause").scaled(26, 26); 152 | static QPixmap play = QPixmap(":/control/play").scaled(26, 26); 153 | qDebug() << "pImpl->play_pause->objectName(): " << pImpl->play_pause->objectName(); 154 | 155 | if (pImpl->play_pause->objectName() == "play") { 156 | pImpl->play_pause->setObjectName("pause"); 157 | pImpl->play_pause->setPixmap(pause); 158 | emit play_pause_clicked(false); 159 | } else { 160 | pImpl->play_pause->setObjectName("play"); 161 | pImpl->play_pause->setPixmap(play); 162 | emit play_pause_clicked(true); 163 | } 164 | } 165 | 166 | static void setText(QLabel *label, qint64 pos) 167 | { 168 | static QTime t(0, 0, 0); 169 | label->setText(t.addMSecs(pos).toString("HH:mm:ss")); 170 | t.setHMS(0, 0, 0); 171 | } 172 | 173 | void ControlWidget::on_time_changed(qint64 pos) 174 | { 175 | setText(pImpl->time_current, pos); 176 | } 177 | 178 | void ControlWidget::on_douration_changed(qint64 pos) 179 | { 180 | setText(pImpl->time_all, pos); 181 | } 182 | -------------------------------------------------------------------------------- /src/control_widget.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2015 MeiZhaorui(Mason) 3 | 4 | The File is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Lesser General Public 6 | License as published by the Free Software Foundation; either 7 | version 2.1 of the License, or (at your option) any later version. 8 | 9 | The File is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public 15 | License along with the Library; if not, see 16 | . 17 | */ 18 | #ifndef CONTROL_WIDGET_H 19 | #define CONTROL_WIDGET_H 20 | #include "common.h" 21 | 22 | #include 23 | class QAction; 24 | 25 | KUPLAYER_NAMESPACE_BEGIN //namespace begin 26 | 27 | 28 | class ControlWidget : public QWidget 29 | { 30 | Q_OBJECT 31 | signals: 32 | void backward_clicked(); 33 | void stop_clicked(); 34 | void play_pause_clicked(bool); 35 | void foreward_clicked(); 36 | void xuan_ji_clcked(QString, QString); 37 | void vol_up_clicked(); 38 | void vol_down_clicked(); 39 | void vol_mute_clicked(); 40 | 41 | public: 42 | explicit ControlWidget(QWidget *parent = 0); 43 | virtual ~ControlWidget(); 44 | QList reg_actions(); 45 | bool isRuning; 46 | 47 | public slots: 48 | void on_play_pause_triggered(bool); 49 | void on_time_changed(qint64); 50 | void on_douration_changed(qint64); 51 | 52 | private: 53 | void init_actions(); 54 | 55 | struct ControlWidget_Impl; 56 | std::unique_ptr pImpl; 57 | }; 58 | 59 | 60 | KUPLAYER_NAMESPACE_END //namespace end 61 | #endif // CONTROL_WIDGET_H 62 | -------------------------------------------------------------------------------- /src/detail_label.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2015 MeiZhaorui(Mason) 3 | 4 | The File is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Lesser General Public 6 | License as published by the Free Software Foundation; either 7 | version 2.1 of the License, or (at your option) any later version. 8 | 9 | The File is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public 15 | License along with the Library; if not, see 16 | . 17 | */ 18 | 19 | #include "detail_label.h" 20 | USR_NAMESPACE_KUPLAYER //using namespace mei::kuplayer 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | 31 | struct NAMESPACE_KUPLAYER::DetailLabel::DetailLabel_Impl { 32 | Label *lblImg_; 33 | Label *lblTitle_; 34 | QString url_; 35 | QVBoxLayout *verticalLayout; 36 | 37 | DetailLabel_Impl() 38 | : lblImg_(new Label) 39 | , lblTitle_(new Label) 40 | , verticalLayout(new QVBoxLayout) 41 | 42 | { 43 | verticalLayout->setSpacing(0); 44 | lblImg_->setAlignment(Qt::AlignCenter); 45 | lblTitle_->setMaximumHeight(36); 46 | lblTitle_->setAlignment(Qt::AlignHCenter | Qt::AlignBottom); 47 | verticalLayout->addWidget(lblImg_); 48 | verticalLayout->addWidget(lblTitle_); 49 | } 50 | ~DetailLabel_Impl() { 51 | delete lblImg_; 52 | delete lblTitle_; 53 | delete verticalLayout; 54 | } 55 | }; 56 | 57 | /****************************************************************************/ 58 | 59 | Label::Label(QWidget *parent) 60 | : QLabel(parent) 61 | { 62 | } 63 | 64 | void Label::mouseDoubleClickEvent(QMouseEvent *ev) 65 | { 66 | QLabel::mouseDoubleClickEvent(ev); 67 | 68 | if (ev->button() == Qt::LeftButton) { 69 | emit clicked(); 70 | } 71 | } 72 | void Label::enterEvent(QEvent *ev) 73 | { 74 | QLabel::enterEvent(ev); 75 | this->setCursor(QCursor(Qt::PointingHandCursor)); 76 | } 77 | 78 | void Label::leaveEvent(QEvent *ev) 79 | { 80 | QLabel::leaveEvent(ev); 81 | this->setCursor(QCursor(Qt::ArrowCursor)); 82 | } 83 | 84 | /****************************************************************************/ 85 | 86 | DetailLabel::DetailLabel(QWidget *parent) 87 | : QWidget(parent) 88 | , pImpl(new DetailLabel_Impl()) 89 | { 90 | QHBoxLayout *horizontalLayout = new QHBoxLayout(this); 91 | horizontalLayout->addLayout(pImpl->verticalLayout); 92 | connect(pImpl->lblImg_, SIGNAL(clicked()), this, SLOT(this_url_triggered())); 93 | connect(pImpl->lblTitle_, SIGNAL(clicked()), this, SLOT(this_url_triggered())); 94 | } 95 | 96 | DetailLabel::DetailLabel(QPixmap img, const QString &title, const QString &url, QWidget *parent) 97 | : DetailLabel(parent) 98 | { 99 | set_Pixmap(std::move(img)); 100 | set_Title(title); 101 | set_Url(url); 102 | } 103 | 104 | DetailLabel::~DetailLabel() 105 | { 106 | // qDebug() <<"DetailLabel("<text()<<") deleted"; 107 | } 108 | void DetailLabel::this_url_triggered() 109 | { 110 | emit url_triggered(pImpl->lblTitle_->text(), pImpl->url_); 111 | } 112 | 113 | void DetailLabel::set_Pixmap(QPixmap &&img) 114 | { 115 | pImpl->lblImg_->setPixmap(img); 116 | setFixedSize(img.width() + 20, img.height() + 36); 117 | } 118 | 119 | void DetailLabel::set_Title(const QString &title) 120 | { 121 | pImpl->lblTitle_->setText(title); 122 | pImpl->lblTitle_->setToolTip(title); 123 | pImpl->lblImg_->setToolTip(title); 124 | } 125 | 126 | void DetailLabel::set_Url(const QString &url) 127 | { 128 | pImpl->url_ = url; 129 | } 130 | 131 | QString DetailLabel::text() const 132 | { 133 | return pImpl->lblTitle_->text(); 134 | } 135 | -------------------------------------------------------------------------------- /src/detail_label.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2015 MeiZhaorui(Mason) 3 | 4 | The File is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Lesser General Public 6 | License as published by the Free Software Foundation; either 7 | version 2.1 of the License, or (at your option) any later version. 8 | 9 | The File is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public 15 | License along with the Library; if not, see 16 | . 17 | */ 18 | 19 | #ifndef DETAILLABEL_H 20 | #define DETAILLABEL_H 21 | #include "common.h" 22 | 23 | #include 24 | class QMouseEvent; 25 | 26 | KUPLAYER_NAMESPACE_BEGIN //namespace begin 27 | 28 | class Label : public QLabel 29 | { 30 | Q_OBJECT 31 | signals: 32 | void clicked(); 33 | public: 34 | explicit Label(QWidget *parent = 0); 35 | protected: 36 | virtual void mouseDoubleClickEvent(QMouseEvent *); 37 | virtual void enterEvent(QEvent *); 38 | virtual void leaveEvent(QEvent *); 39 | }; 40 | 41 | class DetailLabel : public QWidget 42 | { 43 | Q_OBJECT 44 | signals: 45 | void url_triggered(QString/*name*/, QString/*url*/); 46 | 47 | public: 48 | DetailLabel(QWidget *parent = 0); 49 | DetailLabel(QPixmap, const QString &, const QString &, QWidget *parent = 0); 50 | virtual ~DetailLabel(); 51 | 52 | inline void set_Pixmap(QPixmap &&img); 53 | inline void set_Url(const QString &url); 54 | inline void set_Title(const QString &title); 55 | QString text() const; 56 | 57 | private slots: 58 | void this_url_triggered(); 59 | 60 | private: 61 | struct DetailLabel_Impl; 62 | std::unique_ptr pImpl; 63 | }; 64 | 65 | 66 | KUPLAYER_NAMESPACE_END //namespace end 67 | #endif // DETAILLABEL_H 68 | -------------------------------------------------------------------------------- /src/gloal_func.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2015 MeiZhaorui(Mason) 3 | 4 | The File is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Lesser General Public 6 | License as published by the Free Software Foundation; either 7 | version 2.1 of the License, or (at your option) any later version. 8 | 9 | The File is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public 15 | License along with the Library; if not, see 16 | . 17 | */ 18 | 19 | #ifndef GLOAL_H 20 | #define GLOAL_H 21 | #include "common.h" 22 | #include 23 | KUPLAYER_NAMESPACE_BEGIN //namespace begin 24 | 25 | template 26 | inline void set_no_margin(T *layout) 27 | { 28 | layout->setMargin(0); 29 | layout->setSpacing(0); 30 | layout->setContentsMargins(0, 0, 0, 0); 31 | } 32 | template 33 | inline void delete_list(T *store) 34 | { 35 | while (store->size()) { 36 | delete store->at(0); 37 | store->removeAt(0); 38 | } 39 | 40 | delete store; 41 | } 42 | 43 | inline QString msg_font_style(const QString &text) 44 | { 45 | QString tmp; 46 | tmp.insert(0, "

    "); 47 | tmp.insert(tmp.size(), text); 48 | tmp.insert(tmp.size(), "

    "); 49 | return std::move(tmp); 50 | } 51 | 52 | KUPLAYER_NAMESPACE_END // namespace end 53 | #endif // GLOAL_H 54 | -------------------------------------------------------------------------------- /src/img/controlButton/backward.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zrmei/kuplayer/06b3fb9ffc13184086c5098cd50224c6c60d162f/src/img/controlButton/backward.png -------------------------------------------------------------------------------- /src/img/controlButton/foreward.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zrmei/kuplayer/06b3fb9ffc13184086c5098cd50224c6c60d162f/src/img/controlButton/foreward.png -------------------------------------------------------------------------------- /src/img/controlButton/pause.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zrmei/kuplayer/06b3fb9ffc13184086c5098cd50224c6c60d162f/src/img/controlButton/pause.png -------------------------------------------------------------------------------- /src/img/controlButton/play.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zrmei/kuplayer/06b3fb9ffc13184086c5098cd50224c6c60d162f/src/img/controlButton/play.png -------------------------------------------------------------------------------- /src/img/controlButton/stop.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zrmei/kuplayer/06b3fb9ffc13184086c5098cd50224c6c60d162f/src/img/controlButton/stop.png -------------------------------------------------------------------------------- /src/img/logo/logo.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zrmei/kuplayer/06b3fb9ffc13184086c5098cd50224c6c60d162f/src/img/logo/logo.ico -------------------------------------------------------------------------------- /src/img/logo/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zrmei/kuplayer/06b3fb9ffc13184086c5098cd50224c6c60d162f/src/img/logo/logo.png -------------------------------------------------------------------------------- /src/img/logo/logo_min.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zrmei/kuplayer/06b3fb9ffc13184086c5098cd50224c6c60d162f/src/img/logo/logo_min.ico -------------------------------------------------------------------------------- /src/img/logo/welcome.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zrmei/kuplayer/06b3fb9ffc13184086c5098cd50224c6c60d162f/src/img/logo/welcome.png -------------------------------------------------------------------------------- /src/img/shadow/shadow_bottom.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zrmei/kuplayer/06b3fb9ffc13184086c5098cd50224c6c60d162f/src/img/shadow/shadow_bottom.png -------------------------------------------------------------------------------- /src/img/shadow/shadow_left.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zrmei/kuplayer/06b3fb9ffc13184086c5098cd50224c6c60d162f/src/img/shadow/shadow_left.png -------------------------------------------------------------------------------- /src/img/shadow/shadow_left_bottom.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zrmei/kuplayer/06b3fb9ffc13184086c5098cd50224c6c60d162f/src/img/shadow/shadow_left_bottom.png -------------------------------------------------------------------------------- /src/img/shadow/shadow_left_top.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zrmei/kuplayer/06b3fb9ffc13184086c5098cd50224c6c60d162f/src/img/shadow/shadow_left_top.png -------------------------------------------------------------------------------- /src/img/shadow/shadow_right.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zrmei/kuplayer/06b3fb9ffc13184086c5098cd50224c6c60d162f/src/img/shadow/shadow_right.png -------------------------------------------------------------------------------- /src/img/shadow/shadow_right_bottom.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zrmei/kuplayer/06b3fb9ffc13184086c5098cd50224c6c60d162f/src/img/shadow/shadow_right_bottom.png -------------------------------------------------------------------------------- /src/img/shadow/shadow_right_top.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zrmei/kuplayer/06b3fb9ffc13184086c5098cd50224c6c60d162f/src/img/shadow/shadow_right_top.png -------------------------------------------------------------------------------- /src/img/shadow/shadow_top.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zrmei/kuplayer/06b3fb9ffc13184086c5098cd50224c6c60d162f/src/img/shadow/shadow_top.png -------------------------------------------------------------------------------- /src/img/skin/0_big.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zrmei/kuplayer/06b3fb9ffc13184086c5098cd50224c6c60d162f/src/img/skin/0_big.png -------------------------------------------------------------------------------- /src/img/skin/10_big.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zrmei/kuplayer/06b3fb9ffc13184086c5098cd50224c6c60d162f/src/img/skin/10_big.png -------------------------------------------------------------------------------- /src/img/skin/11_big.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zrmei/kuplayer/06b3fb9ffc13184086c5098cd50224c6c60d162f/src/img/skin/11_big.png -------------------------------------------------------------------------------- /src/img/skin/12_big.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zrmei/kuplayer/06b3fb9ffc13184086c5098cd50224c6c60d162f/src/img/skin/12_big.png -------------------------------------------------------------------------------- /src/img/skin/13_big.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zrmei/kuplayer/06b3fb9ffc13184086c5098cd50224c6c60d162f/src/img/skin/13_big.png -------------------------------------------------------------------------------- /src/img/skin/14_big.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zrmei/kuplayer/06b3fb9ffc13184086c5098cd50224c6c60d162f/src/img/skin/14_big.png -------------------------------------------------------------------------------- /src/img/skin/15_big.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zrmei/kuplayer/06b3fb9ffc13184086c5098cd50224c6c60d162f/src/img/skin/15_big.jpg -------------------------------------------------------------------------------- /src/img/skin/16_big.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zrmei/kuplayer/06b3fb9ffc13184086c5098cd50224c6c60d162f/src/img/skin/16_big.jpg -------------------------------------------------------------------------------- /src/img/skin/1_big.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zrmei/kuplayer/06b3fb9ffc13184086c5098cd50224c6c60d162f/src/img/skin/1_big.png -------------------------------------------------------------------------------- /src/img/skin/2_big.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zrmei/kuplayer/06b3fb9ffc13184086c5098cd50224c6c60d162f/src/img/skin/2_big.png -------------------------------------------------------------------------------- /src/img/skin/3_big.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zrmei/kuplayer/06b3fb9ffc13184086c5098cd50224c6c60d162f/src/img/skin/3_big.png -------------------------------------------------------------------------------- /src/img/skin/4_big.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zrmei/kuplayer/06b3fb9ffc13184086c5098cd50224c6c60d162f/src/img/skin/4_big.png -------------------------------------------------------------------------------- /src/img/skin/5_big.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zrmei/kuplayer/06b3fb9ffc13184086c5098cd50224c6c60d162f/src/img/skin/5_big.png -------------------------------------------------------------------------------- /src/img/skin/6_big.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zrmei/kuplayer/06b3fb9ffc13184086c5098cd50224c6c60d162f/src/img/skin/6_big.png -------------------------------------------------------------------------------- /src/img/skin/7_big.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zrmei/kuplayer/06b3fb9ffc13184086c5098cd50224c6c60d162f/src/img/skin/7_big.png -------------------------------------------------------------------------------- /src/img/skin/8_big.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zrmei/kuplayer/06b3fb9ffc13184086c5098cd50224c6c60d162f/src/img/skin/8_big.png -------------------------------------------------------------------------------- /src/img/skin/9_big.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zrmei/kuplayer/06b3fb9ffc13184086c5098cd50224c6c60d162f/src/img/skin/9_big.png -------------------------------------------------------------------------------- /src/img/sysButton/close.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zrmei/kuplayer/06b3fb9ffc13184086c5098cd50224c6c60d162f/src/img/sysButton/close.png -------------------------------------------------------------------------------- /src/img/sysButton/close_hover.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zrmei/kuplayer/06b3fb9ffc13184086c5098cd50224c6c60d162f/src/img/sysButton/close_hover.png -------------------------------------------------------------------------------- /src/img/sysButton/close_pressed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zrmei/kuplayer/06b3fb9ffc13184086c5098cd50224c6c60d162f/src/img/sysButton/close_pressed.png -------------------------------------------------------------------------------- /src/img/sysButton/menu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zrmei/kuplayer/06b3fb9ffc13184086c5098cd50224c6c60d162f/src/img/sysButton/menu.png -------------------------------------------------------------------------------- /src/img/sysButton/menu_hover.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zrmei/kuplayer/06b3fb9ffc13184086c5098cd50224c6c60d162f/src/img/sysButton/menu_hover.png -------------------------------------------------------------------------------- /src/img/sysButton/menu_pressed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zrmei/kuplayer/06b3fb9ffc13184086c5098cd50224c6c60d162f/src/img/sysButton/menu_pressed.png -------------------------------------------------------------------------------- /src/img/sysButton/min.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zrmei/kuplayer/06b3fb9ffc13184086c5098cd50224c6c60d162f/src/img/sysButton/min.png -------------------------------------------------------------------------------- /src/img/sysButton/min_hover.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zrmei/kuplayer/06b3fb9ffc13184086c5098cd50224c6c60d162f/src/img/sysButton/min_hover.png -------------------------------------------------------------------------------- /src/img/sysButton/min_pressed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zrmei/kuplayer/06b3fb9ffc13184086c5098cd50224c6c60d162f/src/img/sysButton/min_pressed.png -------------------------------------------------------------------------------- /src/img/sysButton/skin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zrmei/kuplayer/06b3fb9ffc13184086c5098cd50224c6c60d162f/src/img/sysButton/skin.png -------------------------------------------------------------------------------- /src/img/sysButton/skin_hover.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zrmei/kuplayer/06b3fb9ffc13184086c5098cd50224c6c60d162f/src/img/sysButton/skin_hover.png -------------------------------------------------------------------------------- /src/img/sysButton/skin_pressed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zrmei/kuplayer/06b3fb9ffc13184086c5098cd50224c6c60d162f/src/img/sysButton/skin_pressed.png -------------------------------------------------------------------------------- /src/kuplayer.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2015 MeiZhaorui(Mason) 3 | 4 | The File is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Lesser General Public 6 | License as published by the Free Software Foundation; either 7 | version 2.1 of the License, or (at your option) any later version. 8 | 9 | The File is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public 15 | License along with the Library; if not, see 16 | . 17 | */ 18 | 19 | #ifndef KUPLAYER_H 20 | #define KUPLAYER_H 21 | #include "common.h" 22 | #include "shadow_widget.h" 23 | 24 | #include 25 | class QSettings; 26 | 27 | KUPLAYER_NAMESPACE_BEGIN //namespace begin 28 | class PyScript; 29 | 30 | class MainWidget : public ShadowWidget 31 | { 32 | Q_OBJECT 33 | signals: 34 | void send_status(int); 35 | 36 | public: 37 | MainWidget(PyScript *pyinit, const QString &, QWidget *parent = 0); 38 | virtual ~MainWidget(); 39 | void setIniFile(QSettings *); 40 | 41 | public slots: 42 | void on_showMin_clicked(); 43 | void on_skin_changed(QString); 44 | void on_Fullscreen_changed(); 45 | void on_play_finished(); 46 | void on_stop_clicked(); 47 | void on_loadImage_started(int, QStringList); 48 | void on_nextPage_loaded(CLASS); 49 | void on_loadImage_finished(CLASS, QPixmap, QString, QString); 50 | void on_url_triggered(QString, QString); 51 | void on_url_ji_triggered(QString, QString); 52 | void on_url_changed(CLASS, int, QString); 53 | 54 | private slots: 55 | void on_trayIcon_clicked(QSystemTrayIcon::ActivationReason); 56 | void on_title_widget_closed(); 57 | 58 | private: 59 | void init_module(); 60 | bool is_fullscreen_can_changed(); 61 | bool is_can_auto_play_next(); 62 | 63 | void init_setting(); 64 | void to_inifile(); 65 | void init_trayicon(); 66 | 67 | private: 68 | struct MainWidget_Impl; 69 | std::unique_ptr pImpl; 70 | }; 71 | 72 | KUPLAYER_NAMESPACE_END //namespace end 73 | #endif // KUPLAYER_H 74 | -------------------------------------------------------------------------------- /src/kuplayer.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | img/sysButton/close.png 4 | img/sysButton/close_hover.png 5 | img/sysButton/close_pressed.png 6 | img/sysButton/min.png 7 | img/sysButton/min_hover.png 8 | img/sysButton/min_pressed.png 9 | img/sysButton/skin.png 10 | img/sysButton/skin_hover.png 11 | img/sysButton/skin_pressed.png 12 | img/sysButton/menu.png 13 | img/sysButton/menu_hover.png 14 | img/sysButton/menu_pressed.png 15 | 16 | 17 | img/skin/0_big.png 18 | 19 | 20 | img/shadow/shadow_bottom.png 21 | img/shadow/shadow_left.png 22 | img/shadow/shadow_left_bottom.png 23 | img/shadow/shadow_left_top.png 24 | img/shadow/shadow_right.png 25 | img/shadow/shadow_right_bottom.png 26 | img/shadow/shadow_right_top.png 27 | img/shadow/shadow_top.png 28 | 29 | 30 | img/logo/logo.png 31 | img/logo/welcome.png 32 | img/logo/logo_min.ico 33 | 34 | 35 | img/controlButton/backward.png 36 | img/controlButton/foreward.png 37 | img/controlButton/pause.png 38 | img/controlButton/play.png 39 | img/controlButton/stop.png 40 | 41 | 42 | kuplayer_zn.qm 43 | kuplayer_en.qm 44 | 45 | 46 | -------------------------------------------------------------------------------- /src/kuplayer_en.qm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zrmei/kuplayer/06b3fb9ffc13184086c5098cd50224c6c60d162f/src/kuplayer_en.qm -------------------------------------------------------------------------------- /src/kuplayer_zn.qm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zrmei/kuplayer/06b3fb9ffc13184086c5098cd50224c6c60d162f/src/kuplayer_zn.qm -------------------------------------------------------------------------------- /src/list_widget.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2015 MeiZhaorui(Mason) 3 | 4 | The File is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Lesser General Public 6 | License as published by the Free Software Foundation; either 7 | version 2.1 of the License, or (at your option) any later version. 8 | 9 | The File is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public 15 | License along with the Library; if not, see 16 | . 17 | */ 18 | 19 | #include "common.h" 20 | #include "gloal_func.h" 21 | #include "list_widget.h" 22 | #include "select_label.h" 23 | #include "detail_label.h" 24 | USR_NAMESPACE_KUPLAYER //using namespace mei::kuplayer 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | 32 | #include 33 | using std::for_each; 34 | 35 | struct NAMESPACE_KUPLAYER::AreaWidget::AreaWidget_Impl { 36 | QGridLayout *scroll_layout; 37 | mScrollArea *view; 38 | QWidget *viewWidgetContents; 39 | 40 | int row {0}, col {0}; 41 | QList *label_stores; 42 | 43 | AreaWidget_Impl() 44 | : scroll_layout(new QGridLayout) 45 | , view(new mScrollArea) 46 | , viewWidgetContents(new QWidget) 47 | , label_stores(new QList) { 48 | view->setWidgetResizable(true); 49 | view->setContentsMargins(0, 0, 0, 0); 50 | scroll_layout->setContentsMargins(0, 0, 0, 0); 51 | viewWidgetContents->setLayout(scroll_layout); 52 | view->setWidget(viewWidgetContents); 53 | } 54 | ~AreaWidget_Impl() { 55 | delete_list(label_stores); 56 | delete scroll_layout; 57 | delete viewWidgetContents; 58 | delete view; 59 | } 60 | }; 61 | 62 | struct NAMESPACE_KUPLAYER::ListWidget::ListWidget_Impl { 63 | /*存储指针,退出时释放资源*/ 64 | QList *locate_labels; 65 | QList *type_labels; 66 | QList *time_labels; 67 | 68 | QStringList locate_name; 69 | QStringList type_name; 70 | QStringList time_name; 71 | 72 | ListWidget_Impl() 73 | : locate_labels(new QList) 74 | , type_labels(new QList) 75 | , time_labels(new QList) 76 | , time_name({ 77 | "全部", "2014", "2013", "2012", "2010", 78 | "00年代", "90年代", "80年代", "70年代" 79 | }) { } 80 | 81 | ~ListWidget_Impl() { 82 | delete_list(locate_labels); 83 | delete_list(type_labels); 84 | delete_list(time_labels); 85 | } 86 | }; 87 | 88 | /****************************************************************************/ 89 | mScrollArea::mScrollArea(QWidget *parent) 90 | : QScrollArea(parent) 91 | { 92 | connect(verticalScrollBar(), SIGNAL(valueChanged(int)), SLOT(valueChanged(int))); 93 | } 94 | void mScrollArea::wheelEvent(QWheelEvent *ev) 95 | { 96 | QScrollArea::wheelEvent(ev); 97 | valueChanged(verticalScrollBar()->value()); 98 | } 99 | 100 | void mScrollArea::valueChanged(int value) 101 | { 102 | static int mid_min; 103 | mid_min = verticalScrollBar()->maximum() * 0.95; 104 | 105 | if (value > 100 && value >= mid_min) { 106 | qDebug() << "emit load_next_page: value= " << value 107 | << " mid_min=" << mid_min; 108 | emit load_next_page(); 109 | } 110 | } 111 | 112 | /*****************************************************************************/ 113 | AreaWidget::AreaWidget(QWidget *parent) 114 | : QWidget(parent) 115 | , pImpl(new AreaWidget_Impl()) 116 | { 117 | QVBoxLayout *main_layout = new QVBoxLayout(this); 118 | main_layout->addWidget(pImpl->view); 119 | main_layout->setSpacing(0); 120 | connect(pImpl->view, SIGNAL(load_next_page()), this, SIGNAL(load_next_page())); 121 | QPalette text_palette = palette(); 122 | text_palette.setColor(QPalette::Background, QColor(230, 230, 230)); 123 | text_palette.setColor(QPalette::Background, QColor(255, 255, 255, 0)); 124 | pImpl->viewWidgetContents->setPalette(text_palette); 125 | } 126 | AreaWidget::~AreaWidget() 127 | { 128 | } 129 | 130 | void AreaWidget::addDetailLabel(DetailLabel *label) 131 | { 132 | pImpl->label_stores->append(label); 133 | label->setParent(qobject_cast(pImpl->scroll_layout)); 134 | pImpl->scroll_layout->addWidget(label, pImpl->row, pImpl->col); 135 | ++(pImpl->col); 136 | 137 | if (pImpl->col == 4) { 138 | ++(pImpl->row); 139 | pImpl->col = 0; 140 | } 141 | } 142 | 143 | void AreaWidget::reset() 144 | { 145 | pImpl->row = pImpl->col = 0; 146 | 147 | while (pImpl->label_stores->size()) { 148 | delete pImpl->label_stores->at(0); 149 | pImpl->label_stores->removeAt(0); 150 | } 151 | } 152 | 153 | /*****************************************************************************/ 154 | ListWidget::ListWidget(CLASS type, QWidget *parent) 155 | : QWidget(parent) 156 | , down_list_widget(new AreaWidget) 157 | , type_(type) 158 | , pImpl(new ListWidget_Impl()) 159 | { 160 | connect(down_list_widget, &AreaWidget::load_next_page, [&]() { emit emit_next_page(type_);}); 161 | /*以下初始化函数顺序不能改*/ 162 | QHBoxLayout *locate_layout = new QHBoxLayout; 163 | init_locate(locate_layout); 164 | QHBoxLayout *type_layout = new QHBoxLayout; 165 | init_type(type_layout); 166 | QHBoxLayout *time_layout = new QHBoxLayout; 167 | init_time(time_layout); 168 | QVBoxLayout *main_vlayout = new QVBoxLayout(this); 169 | main_vlayout->addLayout(locate_layout); 170 | main_vlayout->addLayout(type_layout); 171 | main_vlayout->addLayout(time_layout); 172 | main_vlayout->addWidget(down_list_widget); 173 | main_vlayout->setContentsMargins(0, 0, 0, 0); 174 | setAutoFillBackground(true); 175 | } 176 | 177 | ListWidget::~ListWidget() 178 | { 179 | delete down_list_widget; 180 | } 181 | 182 | void ListWidget::init_locate(QHBoxLayout *locate_layout) 183 | { 184 | pImpl->locate_name << "全部" << "大陆" << "香港" << "台湾" << "韩国" << "美国" << "英国"; 185 | 186 | switch (type_) { 187 | case TV: 188 | pImpl->locate_name << "泰国" << "新加坡"; 189 | break; 190 | 191 | case MOVIE: 192 | pImpl->locate_name << "法国" << "印度" << "泰国" << "其他"; 193 | break; 194 | 195 | case ZONGYI: 196 | pImpl->locate_name << "澳大利亚"; 197 | break; 198 | 199 | case MUSIC: 200 | pImpl->locate_name.clear(); 201 | pImpl->locate_name << "全部" << "大陆" << "港台" << "日韩" << "欧美"; 202 | break; 203 | 204 | default: 205 | pImpl->locate_name << "日本"; 206 | break; 207 | } 208 | 209 | for_each(pImpl->locate_name.cbegin(), pImpl->locate_name.cend(), 210 | [&](const QStringList::value_type & locate_name) { 211 | SelectLabel *label = new SelectLabel(locate_name, ""); 212 | label->setFixedSize(60, 25); 213 | pImpl->locate_labels->append(label); 214 | locate_layout->addWidget(label, 0, Qt::AlignTop); 215 | connect(label, SIGNAL(be_selected(QString, QString)), 216 | this, SLOT(on_locate_clicked(QString, QString))); 217 | }); 218 | 219 | if (pImpl->locate_labels->size()) { 220 | pImpl->locate_labels->at(0)->set_selected(true); 221 | } 222 | 223 | locate_layout->addStretch(); 224 | locate_layout->setContentsMargins(5, 5, 0, 0); 225 | } 226 | 227 | void ListWidget::init_type(QHBoxLayout *type_layout) 228 | { 229 | pImpl->type_name << "全部"; 230 | 231 | switch (type_) { 232 | case TV: 233 | pImpl->type_name << "古装" << "武侠" << "警匪" << "军事" << "神话" << "科幻" << "悬疑" 234 | << "历史" << "都市" << "搞笑" << "偶像" << "言情"; 235 | break; 236 | 237 | case MOVIE: 238 | pImpl->type_name << "武侠" << "警匪" << "犯罪" << "科幻" << "战争" << "恐怖" << "惊悚" 239 | << "动作" << "喜剧" << "爱情" << "剧情" << "冒险" << "悬疑" << "历史"; 240 | break; 241 | 242 | case ZONGYI: 243 | pImpl->type_name << "优酷出品" << "优酷牛人" << "脱口秀" << "真人秀" << "选秀" 244 | << "美食" << "搞笑" << "访谈" << "纪实"; 245 | break; 246 | 247 | case MUSIC: 248 | pImpl->type_name << "流行" << "摇滚" << "舞曲" << "电子" << "民谣" << "拉丁" 249 | << "爵士" << "古典" << "轻音乐"; 250 | break; 251 | 252 | case COMIC: 253 | pImpl->type_name << "热血" << "格斗" << "恋爱" << "美少女" << "校园" << "搞笑" 254 | << "机战" << "真人" << "青春" << "魔法" << "神话"; 255 | break; 256 | 257 | default: 258 | break; 259 | } 260 | 261 | for_each(pImpl->type_name.cbegin(), pImpl->type_name.cend(), 262 | [&](const QStringList::value_type & type_name) { 263 | SelectLabel *label = new SelectLabel(type_name, ""); 264 | label->setFixedSize(60, 25); 265 | pImpl->type_labels->append(label); 266 | type_layout->addWidget(label); 267 | connect(label, SIGNAL(be_selected(QString, QString)), 268 | this, SLOT(on_type_clicked(QString, QString))); 269 | }); 270 | 271 | if (pImpl->type_labels->size()) { 272 | pImpl->type_labels->at(0)->set_selected(true); 273 | } 274 | 275 | type_layout->addStretch(); 276 | type_layout->setContentsMargins(5, 0, 0, 0); 277 | } 278 | 279 | void ListWidget::init_time(QHBoxLayout *time_layout) 280 | { 281 | for_each(pImpl->time_name.cbegin(), pImpl->time_name.cend(), 282 | [&](const QStringList::value_type & time_name) { 283 | SelectLabel *label = new SelectLabel(time_name, ""); 284 | label->setFixedSize(60, 25); 285 | pImpl->time_labels->append(label); 286 | time_layout->addWidget(label, 0, Qt::AlignBottom); 287 | connect(label, SIGNAL(be_selected(QString, QString)), 288 | this, SLOT(on_time_clicked(QString, QString))); 289 | }); 290 | 291 | if (pImpl->time_labels->size()) { 292 | pImpl->time_labels->at(0)->set_selected(true); 293 | } 294 | 295 | time_layout->addStretch(); 296 | time_layout->setContentsMargins(5, 0, 0, 0); 297 | } 298 | 299 | 300 | void ListWidget::on_locate_clicked(QString locate, QString) 301 | { 302 | int index = pImpl->locate_name.indexOf(locate); 303 | 304 | for (SelectLabel * item : * (pImpl->locate_labels)) { 305 | item->set_selected(false); 306 | } 307 | 308 | pImpl->locate_labels->at(index)->set_selected(true); 309 | emit clicked(type_, 0, locate); 310 | } 311 | 312 | void ListWidget::on_type_clicked(QString type, QString) 313 | { 314 | int index = pImpl->type_name.indexOf(type); 315 | 316 | for (SelectLabel * item : * (pImpl->type_labels)) { 317 | item->set_selected(false); 318 | } 319 | 320 | pImpl->type_labels->at(index)->set_selected(true); 321 | emit clicked(type_, 1, type); 322 | } 323 | 324 | void ListWidget::on_time_clicked(QString time, QString) 325 | { 326 | int index = pImpl->time_name.indexOf(time); 327 | 328 | for (SelectLabel * item : * (pImpl->time_labels)) { 329 | item->set_selected(false); 330 | } 331 | 332 | pImpl->time_labels->at(index)->set_selected(true); 333 | emit clicked(type_, 2, time); 334 | } 335 | -------------------------------------------------------------------------------- /src/list_widget.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2015 MeiZhaorui(Mason) 3 | 4 | The File is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Lesser General Public 6 | License as published by the Free Software Foundation; either 7 | version 2.1 of the License, or (at your option) any later version. 8 | 9 | The File is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public 15 | License along with the Library; if not, see 16 | . 17 | */ 18 | 19 | #ifndef LIST_WIDGET_H 20 | #define LIST_WIDGET_H 21 | #include "common.h" 22 | #include 23 | class QHBoxLayout; 24 | 25 | KUPLAYER_NAMESPACE_BEGIN //namespace begin 26 | class DetailLabel; 27 | class SelectLabel; 28 | 29 | class mScrollArea : public QScrollArea 30 | { 31 | Q_OBJECT 32 | signals: 33 | void load_next_page(); 34 | public: 35 | explicit mScrollArea(QWidget *parent = 0); 36 | protected: 37 | virtual void wheelEvent(QWheelEvent *); 38 | private slots: 39 | void valueChanged(int); 40 | }; 41 | 42 | class AreaWidget : public QWidget 43 | { 44 | Q_OBJECT 45 | signals: 46 | void load_next_page(); 47 | 48 | public: 49 | explicit AreaWidget(QWidget *parent = 0); 50 | virtual ~AreaWidget(); 51 | void addDetailLabel(DetailLabel *); 52 | void reset(); 53 | 54 | private: 55 | struct AreaWidget_Impl; 56 | std::unique_ptr pImpl; 57 | }; 58 | 59 | class ListWidget final : public QWidget 60 | { 61 | Q_OBJECT 62 | signals: 63 | /* 某一个标签被触发,返回当前视频类型(如电影)、类型(如时间)、具体的类型(如2014)*/ 64 | void clicked(CLASS, int, QString); 65 | /*滚动区域的触发,返回的是当前的页面的类型(如电影)*/ 66 | void emit_next_page(CLASS); 67 | 68 | public: 69 | ListWidget(CLASS type, QWidget *parent = 0); 70 | ~ListWidget(); 71 | void addDetailLabel(DetailLabel *label); 72 | void reset(); 73 | 74 | private slots: 75 | void on_locate_clicked(QString, QString); 76 | void on_type_clicked(QString, QString); 77 | void on_time_clicked(QString, QString); 78 | 79 | private: 80 | void init_locate(QHBoxLayout *locate_layout); 81 | void init_type(QHBoxLayout *type_layout); 82 | void init_time(QHBoxLayout *time_layout); 83 | 84 | private: 85 | AreaWidget *down_list_widget; 86 | CLASS type_; 87 | struct ListWidget_Impl; 88 | std::unique_ptr pImpl; 89 | }; 90 | 91 | inline void ListWidget::addDetailLabel(DetailLabel *label) 92 | { 93 | down_list_widget->addDetailLabel(label); 94 | } 95 | 96 | inline void ListWidget::reset() 97 | { 98 | down_list_widget->reset(); 99 | } 100 | 101 | KUPLAYER_NAMESPACE_END //namespace end 102 | #endif // LIST_layout_H 103 | -------------------------------------------------------------------------------- /src/loadimage.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2015 MeiZhaorui(Mason) 3 | 4 | The File is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Lesser General Public 6 | License as published by the Free Software Foundation; either 7 | version 2.1 of the License, or (at your option) any later version. 8 | 9 | The File is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public 15 | License along with the Library; if not, see 16 | . 17 | */ 18 | 19 | 20 | #ifndef LOADIMAGE_H 21 | #define LOADIMAGE_H 22 | 23 | #include "common.h" 24 | 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | 33 | KUPLAYER_NAMESPACE_BEGIN //namespace begin 34 | 35 | #define KUPLAYER_RES_NAME 0 36 | #define KUPLAYER_PIC_URL 1 37 | #define KUPLAYER_ADDR_URL 2 38 | 39 | class LoadImage final : public QObject 40 | { 41 | Q_OBJECT 42 | 43 | signals: 44 | void loadImageFinished(CLASS/*视频种类*/, QPixmap/*图片*/, QString/*图片名称*/, QString/*所指url*/); 45 | public: 46 | LoadImage(CLASS index, QObject *parent = 0) 47 | : index(index) 48 | , currentIndex(0) 49 | , list_(new QList) 50 | , request(new QNetworkRequest) 51 | , manager(new QNetworkAccessManager) 52 | { 53 | Q_UNUSED(parent); 54 | connect(manager, SIGNAL(finished(QNetworkReply *)),this, SLOT(replyFinished(QNetworkReply *))); 55 | } 56 | 57 | void setFileName(const QStringList &listname, QString const& separator = "$$") 58 | { 59 | for (const QStringList::value_type & item : listname) { 60 | list_->append(item.split(separator)); 61 | } 62 | } 63 | void start() 64 | { 65 | if (currentIndex == list_->length()) { 66 | emit loadImageFinished(index, QPixmap(), "", ""); 67 | currentIndex = 0; 68 | deleteLater(); 69 | return; 70 | } else { 71 | request->setUrl(QUrl(list_->at(currentIndex)[KUPLAYER_PIC_URL])); 72 | manager->get(*request); 73 | } 74 | } 75 | 76 | private slots: 77 | void replyFinished(QNetworkReply *reply) 78 | { 79 | QPixmap pix; 80 | pix.loadFromData(reply->readAll()); 81 | emit loadImageFinished( 82 | index, 83 | std::move(pix) 84 | , list_->at(currentIndex)[KUPLAYER_RES_NAME] 85 | , list_->at(currentIndex)[KUPLAYER_ADDR_URL] 86 | ); 87 | ++currentIndex; 88 | start(); 89 | } 90 | 91 | private: 92 | virtual ~LoadImage() 93 | { 94 | qDebug() << "delete loadimage:" << index; 95 | delete request; 96 | delete manager; 97 | delete list_; 98 | } 99 | 100 | int index; 101 | int currentIndex; 102 | QList *list_; 103 | QNetworkRequest *request; 104 | QNetworkAccessManager *manager; 105 | }; 106 | 107 | #undef KUPLAYER_RES_NAME 108 | #undef KUPLAYER_RES_PIC_URL 109 | #undef KUPLAYER_RES_ADDR_URL 110 | 111 | KUPLAYER_NAMESPACE_END //namespace end 112 | #endif // LOADIMAGE_H 113 | -------------------------------------------------------------------------------- /src/main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2015 MeiZhaorui(Mason) 3 | 4 | The File is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Lesser General Public 6 | License as published by the Free Software Foundation; either 7 | version 2.1 of the License, or (at your option) any later version. 8 | 9 | The File is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public 15 | License along with the Library; if not, see 16 | . 17 | */ 18 | 19 | 20 | #include "common.h" 21 | #include "gloal_func.h" 22 | #include "kuplayer.h" 23 | #include "program_options.h" 24 | #include "pyscript.h" 25 | #include "ui_control_classes.h" 26 | USR_NAMESPACE_KUPLAYER 27 | 28 | 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | 37 | #include 38 | 39 | 40 | int main(int argc, char *argv[]) 41 | { 42 | if (!opt::program_options(argc, argv, VERSION)) { 43 | return -1; 44 | } 45 | 46 | QtSingleApplication a("listener_mei@kuplayer",argc, argv); 47 | a.connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit())); 48 | 49 | if (a.isRunning()) { 50 | a.sendMessage("", 800); 51 | return 0; 52 | } 53 | qDebug() << a.id() << ": is running"; 54 | 55 | QTextCodec::setCodecForLocale(QTextCodec::codecForName("System")); 56 | QTranslator translator; 57 | std::shared_ptr iniFile(new QSettings( 58 | QDir::homePath() + "/.kuplayer/kuplayer.conf", 59 | QSettings::IniFormat)); 60 | 61 | if (iniFile->value("setting/language", true).toBool()) { 62 | translator.load(QString(":/qm/kuplayer_zn")); 63 | } else { 64 | translator.load(QString(":/qm/kuplayer_en")); 65 | } 66 | 67 | a.installTranslator(&translator); 68 | QString ico_path = QDir::homePath() + "/.kuplayer/kuplayer.ico"; 69 | 70 | if (!QFileInfo(ico_path).isFile()) { 71 | QPixmap(":/logo/logo").save(ico_path); 72 | } 73 | 74 | std::shared_ptr pyinit = std::make_shared(); 75 | 76 | if (!pyinit.get()->getShowList()) { 77 | QMessageBox::warning(NULL, 78 | QObject::tr("Error"), 79 | msg_font_style(QObject::tr("Network error,Please try later !"))); 80 | a.quit(); 81 | return -1; 82 | } 83 | 84 | QDesktopWidget *desk = new QDesktopWidget; 85 | QSplashScreen *splash = new QSplashScreen(QPixmap(":/logo/welcome"), Qt::WindowStaysOnTopHint); 86 | int x = (desk->screen(0)->width() - splash->width()) >> 1; 87 | int y = (desk->screen(0)->height() - splash->height()) >> 1; 88 | splash->move(x, y); 89 | splash->show(); 90 | 91 | MainWidget w(pyinit.get(), ico_path); 92 | a.setActivationWindow(&w, false); 93 | a.connect(&a, &QtSingleApplication::messageReceived, [&](const QString &) { 94 | w.setWindowState(Qt::WindowActive); 95 | w.showNormal(); 96 | qDebug() << "The first instance activated !"; 97 | }); 98 | 99 | a.connect(&w, &MainWidget::send_status, [&](int index) { 100 | static int time_ = 0; 101 | static auto showMessage = bind(&QSplashScreen::showMessage, 102 | splash, 103 | _1, 104 | Qt::AlignBottom | Qt::AlignRight, 105 | Qt::black); 106 | 107 | switch (index) { 108 | case TV: 109 | showMessage(QObject::tr("Initializing the TV module ...")); 110 | a.processEvents(); 111 | ++ time_; 112 | break; 113 | 114 | case MOVIE: 115 | showMessage(QObject::tr("Initializing the Movie module...")); 116 | a.processEvents(); 117 | ++ time_; 118 | break; 119 | 120 | case ZONGYI: 121 | showMessage(QObject::tr("Initializing the Zongyi module...")); 122 | a.processEvents(); 123 | ++ time_; 124 | break; 125 | 126 | case MUSIC: 127 | showMessage(QObject::tr("Initializing the Music module...")); 128 | a.processEvents(); 129 | ++ time_; 130 | break; 131 | 132 | case COMIC: 133 | showMessage(QObject::tr("Initializing the Comic module...")); 134 | a.processEvents(); 135 | ++ time_; 136 | break; 137 | 138 | default: 139 | break; 140 | } 141 | 142 | if (5 == time_) { 143 | w.showNormal(); 144 | w.disconnect(SIGNAL(send_status(int))); 145 | delete splash; delete desk; 146 | } 147 | }); 148 | 149 | w.move(x, y); 150 | w.setIniFile(iniFile.get()); 151 | w.hide(); 152 | 153 | return a.exec(); 154 | } -------------------------------------------------------------------------------- /src/main_menu.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2015 MeiZhaorui(Mason) 3 | 4 | The File is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Lesser General Public 6 | License as published by the Free Software Foundation; either 7 | version 2.1 of the License, or (at your option) any later version. 8 | 9 | The File is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public 15 | License along with the Library; if not, see 16 | . 17 | */ 18 | 19 | #include "conf_info.h" 20 | #include "gloal_func.h" 21 | #include "main_menu.h" 22 | #include "select_label.h" 23 | #include "push_button.h" 24 | #include "ui_control_classes.h" 25 | 26 | USR_NAMESPACE_KUPLAYER //using namespace mei::kuplayer 27 | 28 | #include 29 | #include 30 | #include 31 | 32 | 33 | struct NAMESPACE_KUPLAYER::MenuWidget::MenuWidget_Impl { 34 | PushButton *btn_close; 35 | down_widget_ *down_widget; 36 | 37 | MenuWidget_Impl() 38 | : btn_close(new PushButton) 39 | , down_widget(new down_widget_) { 40 | btn_close->setPicName(":/sysbutton/close"); 41 | } 42 | ~MenuWidget_Impl() { 43 | delete btn_close; 44 | delete down_widget; 45 | } 46 | }; 47 | 48 | MenuWidget::MenuWidget(QWidget *parent) 49 | : ShadowWidget(parent) 50 | , pImpl(new MenuWidget_Impl()) 51 | { 52 | setAttribute(Qt::WA_QuitOnClose, false); 53 | setWindowModality(Qt::ApplicationModal); 54 | setMinimumSize(600, 400); 55 | QPalette text_palette = palette(); 56 | text_palette.setColor(QPalette::Background, QColor(255, 255, 255, 50)); 57 | setPalette(text_palette); 58 | QHBoxLayout *up_title_layout = new QHBoxLayout; 59 | set_no_margin(up_title_layout); 60 | connect(pImpl->btn_close, SIGNAL(clicked()), this, SLOT(hide())); 61 | up_title_layout->addWidget(pImpl->btn_close, 0, Qt::AlignTop); 62 | up_title_layout->addStretch(); 63 | pImpl->down_widget->setAutoFillBackground(true); 64 | QVBoxLayout *main_layout = new QVBoxLayout(this); 65 | main_layout->addLayout(up_title_layout); 66 | main_layout->addWidget(pImpl->down_widget); 67 | main_layout->setSpacing(0); 68 | main_layout->setContentsMargins(5, 5, 5, 5); 69 | } 70 | 71 | MenuWidget::~MenuWidget() 72 | { } 73 | 74 | void MenuWidget::on_showed() 75 | { 76 | if (isHidden()) { 77 | QPoint pos_ = QCursor::pos(); 78 | move(pos_.x() + 120, pos_.y() + 100); 79 | pImpl->down_widget->be_selected(QObject::tr("Basic Settings"), ""); 80 | show(); 81 | } else { 82 | hide(); 83 | } 84 | } 85 | 86 | void MenuWidget::show_about() 87 | { 88 | pImpl->down_widget->be_selected(QObject::tr("About"), ""); 89 | show(); 90 | } 91 | 92 | void MenuWidget::init_setting(conf_info *info) 93 | { 94 | pImpl->down_widget->init_setting(info); 95 | } 96 | 97 | /*********************************************************************************/ 98 | 99 | struct NAMESPACE_KUPLAYER::down_widget_::down_widget_Impl { 100 | conf_info *settings; 101 | SelectLabel *base_set; 102 | SelectLabel *play_set; 103 | SelectLabel *about_set; 104 | SelectLabel *btn_save; 105 | SelectLabel *btn_exit; 106 | QList *label_sores; 107 | base_set_weidget *base_set_widget; 108 | play_set_widget *play_set_widget_; 109 | about_widget *about_widget_; 110 | Ui::base_set_weidget *base_ui; 111 | Ui::play_set_widget *play_ui; 112 | 113 | const QStringList setting_strs { 114 | QObject::tr("Basic Settings"), QObject::tr("Play Settings"), 115 | QObject::tr("About"), QObject::tr("Save"), 116 | QObject::tr("Cancel") 117 | }; 118 | 119 | down_widget_Impl() 120 | : base_set(new SelectLabel(QObject::tr("Basic Settings"))) 121 | , play_set(new SelectLabel(QObject::tr("Play Settings"))) 122 | , about_set(new SelectLabel(QObject::tr("About"))) 123 | , btn_save(new SelectLabel(QObject::tr("Save"))) 124 | , btn_exit(new SelectLabel(QObject::tr("Cancel"))) 125 | , label_sores(new QList) 126 | , base_set_widget(new base_set_weidget) 127 | , play_set_widget_(new play_set_widget) 128 | , about_widget_(new about_widget) { 129 | base_ui = base_set_widget->ui; 130 | play_ui = play_set_widget_->ui; 131 | base_set->setFixedSize(125, 32); 132 | label_sores->append(base_set); 133 | base_set->set_selected(true); 134 | play_set->setFixedHeight(32); 135 | label_sores->append(play_set); 136 | about_set->setFixedHeight(32); 137 | label_sores->append(about_set); 138 | btn_save->setFixedSize(80, 32); 139 | btn_exit->setFixedSize(80, 32); 140 | } 141 | 142 | ~down_widget_Impl() { 143 | delete_list(label_sores); 144 | delete base_set_widget; 145 | delete play_set_widget_; 146 | delete about_widget_; 147 | } 148 | }; 149 | 150 | down_widget_::down_widget_(QWidget *parent) 151 | : QWidget(parent) 152 | , pImpl(new down_widget_Impl()) 153 | { 154 | connect(pImpl->base_set, SIGNAL(be_selected(QString, QString)), this, SLOT(be_selected(QString, QString))); 155 | connect(pImpl->play_set, SIGNAL(be_selected(QString, QString)), this, SLOT(be_selected(QString, QString))); 156 | connect(pImpl->about_set, SIGNAL(be_selected(QString, QString)), this, SLOT(be_selected(QString, QString))); 157 | connect(pImpl->btn_save, SIGNAL(be_selected(QString, QString)), this, SLOT(btn_selected(QString, QString))); 158 | connect(pImpl->btn_exit, SIGNAL(be_selected(QString, QString)), this, SLOT(btn_selected(QString, QString))); 159 | QWidget *left_widget = new QWidget; 160 | left_widget->setAutoFillBackground(true); 161 | QPalette text_palette = palette(); 162 | text_palette.setColor(QPalette::Window, QColor(225, 225, 225)); 163 | text_palette.setColor(QPalette::Background, QColor(255, 255, 255, 120)); 164 | left_widget->setPalette(text_palette); 165 | QVBoxLayout *left_layout = new QVBoxLayout(left_widget); 166 | left_layout->addWidget(pImpl->base_set); 167 | left_layout->addWidget(pImpl->play_set); 168 | left_layout->addWidget(pImpl->about_set); 169 | left_layout->addStretch(); 170 | left_layout->setSpacing(1); 171 | left_layout->setContentsMargins(0, 0, 0, 0); 172 | text_palette.setColor(QPalette::Window, QColor(240, 240, 240)); 173 | text_palette.setColor(QPalette::Background, QColor(255, 255, 255, 50)); 174 | right_widget = new QStackedWidget; 175 | right_widget->setAutoFillBackground(true); 176 | right_widget->setPalette(text_palette); 177 | connect(pImpl->base_ui->comboBox, SIGNAL(currentIndexChanged(int)), 178 | SLOT(LanguageChanged(int))); 179 | right_widget->addWidget(pImpl->base_set_widget); 180 | right_widget->setCurrentIndex(0); 181 | right_widget->addWidget(pImpl->play_set_widget_); 182 | right_widget->addWidget(pImpl->about_widget_); 183 | QWidget *down_back_widget = new QWidget; 184 | down_back_widget->setAutoFillBackground(true); 185 | down_back_widget->setPalette(text_palette); 186 | QHBoxLayout *down_layout = new QHBoxLayout(down_back_widget); 187 | down_layout->addStretch(); 188 | down_layout->addWidget(pImpl->btn_save); 189 | down_layout->addWidget(pImpl->btn_exit); 190 | QVBoxLayout *right_layout = new QVBoxLayout; 191 | right_layout->addWidget(right_widget); 192 | right_layout->addWidget(down_back_widget); 193 | QHBoxLayout *main_layout = new QHBoxLayout(this); 194 | main_layout->addWidget(left_widget); 195 | main_layout->addLayout(right_layout); 196 | main_layout->setSpacing(0); 197 | main_layout->setContentsMargins(0, 0, 0, 0); 198 | } 199 | down_widget_::~down_widget_() 200 | { 201 | delete right_widget; 202 | } 203 | 204 | void down_widget_::init_setting(conf_info *info) 205 | { 206 | if (info->default_video_format.isEmpty()) { return; } 207 | 208 | pImpl->settings = info; 209 | pImpl->play_ui->checkBox_auto_play_next->setChecked(pImpl->settings->auto_play_next); 210 | pImpl->base_ui->checkBox_close->setChecked(pImpl->settings->close_all); 211 | pImpl->base_ui->radioButton_min->setChecked(pImpl->settings->min_or_close); 212 | pImpl->base_ui->checkBox_start->setChecked(pImpl->settings->start_when_pc_on); 213 | 214 | if (pImpl->settings->default_video_format == "mp4") { 215 | pImpl->play_ui->format_high->setChecked(true); 216 | } else if (pImpl->settings->default_video_format == "flv") { 217 | pImpl->play_ui->format_normal->setChecked(true); 218 | } else { 219 | pImpl->play_ui->format_spuer->setChecked(true); 220 | } 221 | 222 | pImpl->base_ui->comboBox->setCurrentIndex(pImpl->settings->language ? 0 : 1); 223 | } 224 | 225 | void down_widget_::be_selected(QString name, QString) 226 | { 227 | auto index = pImpl->setting_strs.indexOf(name); 228 | for_each(pImpl->label_sores->begin(), pImpl->label_sores->end(), 229 | [](QList::value_type item) {item->set_selected(false);}); 230 | pImpl->label_sores->at(index)->set_selected(true); 231 | right_widget->setCurrentIndex(index); 232 | } 233 | 234 | void down_widget_::LanguageChanged(int index) 235 | { 236 | pImpl->settings->language = (index == 0); 237 | } 238 | #define BUTTON_OK_STR 3 239 | void down_widget_::btn_selected(QString name, QString) 240 | { 241 | if (name == pImpl->setting_strs[BUTTON_OK_STR]) { 242 | pImpl->settings->auto_play_next = pImpl->play_ui->checkBox_auto_play_next->isChecked(); 243 | pImpl->settings->close_all = pImpl->base_ui->checkBox_close->isChecked(); 244 | pImpl->settings->min_or_close = pImpl->base_ui->radioButton_min->isChecked(); 245 | pImpl->settings->start_when_pc_on = pImpl->base_ui->checkBox_start->isChecked(); 246 | 247 | if (pImpl->play_ui->format_high->isChecked()) { 248 | pImpl->settings->default_video_format = "mp4"; 249 | } else if (pImpl->play_ui->format_normal->isChecked()) { 250 | pImpl->settings->default_video_format = "flv"; 251 | } else { 252 | pImpl->settings->default_video_format = "hd2"; 253 | } 254 | } else { 255 | init_setting(pImpl->settings); 256 | } 257 | 258 | qobject_cast(parent())->hide(); 259 | } 260 | 261 | -------------------------------------------------------------------------------- /src/main_menu.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2015 MeiZhaorui(Mason) 3 | 4 | The File is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Lesser General Public 6 | License as published by the Free Software Foundation; either 7 | version 2.1 of the License, or (at your option) any later version. 8 | 9 | The File is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public 15 | License along with the Library; if not, see 16 | . 17 | */ 18 | 19 | #ifndef MAIN_MENU_H 20 | #define MAIN_MENU_H 21 | #include "common.h" 22 | #include "shadow_widget.h" 23 | 24 | class QStackedWidget; 25 | 26 | KUPLAYER_NAMESPACE_BEGIN //namespace begin 27 | struct conf_info; 28 | 29 | class MenuWidget : public ShadowWidget 30 | { 31 | Q_OBJECT 32 | public: 33 | explicit MenuWidget(QWidget *parent = 0); 34 | ~MenuWidget(); 35 | public slots: 36 | void on_showed(); 37 | void show_about(); 38 | void init_setting(conf_info *); 39 | private: 40 | struct MenuWidget_Impl; 41 | std::unique_ptr pImpl; 42 | }; 43 | 44 | /**********************************************/ 45 | class down_widget_ : public QWidget 46 | { 47 | Q_OBJECT 48 | public: 49 | explicit down_widget_(QWidget *parent = 0); 50 | ~down_widget_(); 51 | QStackedWidget *operator->() { return right_widget;} 52 | public slots: 53 | void init_setting(conf_info *); 54 | void be_selected(QString, QString); 55 | void btn_selected(QString, QString); 56 | void LanguageChanged(int); 57 | 58 | private: 59 | QStackedWidget *right_widget; 60 | struct down_widget_Impl; 61 | std::unique_ptr pImpl; 62 | }; 63 | 64 | KUPLAYER_NAMESPACE_END //namespace end 65 | #endif // MAIN_MENU_H 66 | -------------------------------------------------------------------------------- /src/mplayer_widget.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2015 MeiZhaorui(Mason) 3 | 4 | The File is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Lesser General Public 6 | License as published by the Free Software Foundation; either 7 | version 2.1 of the License, or (at your option) any later version. 8 | 9 | The File is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public 15 | License along with the Library; if not, see 16 | . 17 | */ 18 | 19 | #include "common.h" 20 | #include "gloal_func.h" 21 | #include "mplayer_widget.h" 22 | 23 | #include 24 | #include 25 | 26 | USR_NAMESPACE_KUPLAYER //using namespace mei::kuplayer 27 | 28 | 29 | /****************************************************************/ 30 | MPlayer::MPlayer(QObject *parent) 31 | : QtAV::AVPlayer(parent) 32 | , list_file(qApp->applicationDirPath() + "/.playlist") 33 | { 34 | connect(this, SIGNAL(stopped()), this, SLOT(mStarted())); 35 | #ifdef AV_NO_DEBUG_OUTPUT 36 | QtAV::setLogLevel(QtAV::LogLevel::LogOff); 37 | #else 38 | QtAV::setLogLevel(QtAV::LogAll); 39 | #endif 40 | } 41 | 42 | MPlayer::~MPlayer() 43 | { 44 | list_file.remove(); 45 | } 46 | 47 | void MPlayer::setPlayList(QStringList &list) 48 | { 49 | play_list = std::move(list); 50 | } 51 | 52 | void MPlayer::mPlay() 53 | { 54 | if (isPlaying()) { 55 | stop(); 56 | } else { 57 | mStarted(); 58 | } 59 | } 60 | void MPlayer::mStarted() 61 | { 62 | if (play_list.size()) { 63 | play(play_list.at(0)); 64 | play_list.removeAt(0); 65 | QTimer::singleShot(1000, this, SLOT(setDuration())); 66 | } else { 67 | emit mFinished(); 68 | } 69 | } 70 | 71 | void MPlayer::mStop() 72 | { 73 | play_list.clear(); 74 | stop(); 75 | } 76 | 77 | void MPlayer::play_pause(bool p) 78 | { 79 | if (isPlaying()) { 80 | pause(p); 81 | } else { 82 | mPlay(); 83 | } 84 | } 85 | 86 | void MPlayer::setDuration() 87 | { 88 | emit mSetDuration(duration()); 89 | } 90 | 91 | void MPlayer::mSeekBack() 92 | { 93 | int pos = position() - 10000/*10s*/; 94 | 95 | if (pos <= 0) { pos = 0; } 96 | 97 | setPosition(pos); 98 | } 99 | 100 | void MPlayer::mSeekFore() 101 | { 102 | setPosition(position() + 10000/*10s*/); 103 | } 104 | 105 | void MPlayer::vol_up() 106 | { 107 | QtAV::AudioOutput *ao = audio(); 108 | 109 | if (ao && ao->isAvailable()) { 110 | qreal v = ao->volume(); 111 | #ifdef QT_NO_DEBUG_OUTPUT 112 | 113 | if (v >= 1.0) { 114 | return; 115 | } 116 | 117 | #endif 118 | v += 0.02; 119 | ao->setVolume(v); 120 | qDebug("vol = %.3f", audio()->volume()); 121 | } 122 | } 123 | 124 | void MPlayer::vol_down() 125 | { 126 | QtAV::AudioOutput *ao = audio(); 127 | 128 | if (ao && ao->isAvailable()) { 129 | qreal v = ao->volume(); 130 | #ifdef QT_NO_DEBUG_OUTPUT 131 | 132 | if (v <= 0.0) { 133 | return; 134 | } 135 | 136 | #endif 137 | v -= 0.02; 138 | ao->setVolume(v); 139 | qDebug("vol = %.3f", audio()->volume()); 140 | } 141 | } 142 | 143 | 144 | /*****************************************************************/ 145 | #include "control_widget.h" 146 | #include 147 | MPlayerWidget::MPlayerWidget(QWidget *parent) 148 | : QWidget(parent) 149 | { 150 | renderer = new RendererWidget(this); 151 | control_widget = new ControlWidget; 152 | control_widget->setFixedHeight(32); 153 | QVBoxLayout *main_layout = new QVBoxLayout(this); 154 | main_layout->addWidget(renderer); 155 | main_layout->addWidget(control_widget); 156 | set_no_margin(main_layout); 157 | } 158 | MPlayerWidget::~MPlayerWidget() 159 | { 160 | delete renderer; 161 | delete control_widget; 162 | } 163 | 164 | void MPlayerWidget::keyPressEvent(QKeyEvent *ev) 165 | { 166 | if (ev->key() == Qt::Key_Escape) { 167 | emit escape_clicked(); 168 | } 169 | } 170 | -------------------------------------------------------------------------------- /src/mplayer_widget.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2015 MeiZhaorui(Mason) 3 | 4 | The File is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Lesser General Public 6 | License as published by the Free Software Foundation; either 7 | version 2.1 of the License, or (at your option) any later version. 8 | 9 | The File is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public 15 | License along with the Library; if not, see 16 | . 17 | */ 18 | 19 | #ifndef MPLAYER_WIDGET_H 20 | #define MPLAYER_WIDGET_H 21 | 22 | #include "common.h" 23 | 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | KUPLAYER_NAMESPACE_BEGIN //namespace begin 30 | 31 | class MPlayer : public QtAV::AVPlayer 32 | { 33 | Q_OBJECT 34 | signals: 35 | void mFinished(); 36 | void mSetDuration(qint64); 37 | public: 38 | MPlayer(QObject *parent = 0); 39 | virtual ~MPlayer(); 40 | void mPlay(); 41 | void mStop(); 42 | void setPlayList(QStringList &list); 43 | 44 | public slots: 45 | void setDuration(); 46 | void mSeekBack(); 47 | void mSeekFore(); 48 | void play_pause(bool); 49 | 50 | void vol_down(); 51 | void vol_up(); 52 | private slots: 53 | void mStarted(); 54 | private: 55 | QStringList play_list; 56 | QFile list_file; 57 | }; 58 | 59 | class RendererWidget final : public QtAV::WidgetRenderer 60 | { 61 | Q_OBJECT 62 | signals: 63 | void double_clicked(); 64 | public: 65 | RendererWidget(QWidget *parent = 0) 66 | : QtAV::WidgetRenderer(parent) 67 | {} 68 | protected: 69 | virtual void mouseDoubleClickEvent(QMouseEvent *) 70 | { emit double_clicked(); } 71 | }; 72 | 73 | class ControlWidget; 74 | class MPlayerWidget : public QWidget 75 | { 76 | Q_OBJECT 77 | signals: 78 | void escape_clicked(); 79 | public: 80 | MPlayerWidget(QWidget *parent = 0); 81 | ~MPlayerWidget(); 82 | ControlWidget *operator->() const 83 | {return control_widget;} 84 | protected: 85 | virtual void keyPressEvent(QKeyEvent *); 86 | public: 87 | ControlWidget *control_widget; 88 | RendererWidget *renderer; 89 | }; 90 | 91 | KUPLAYER_NAMESPACE_END // namespace end 92 | #endif // MPLAYER_WIDGET_H 93 | -------------------------------------------------------------------------------- /src/mthread.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2015 MeiZhaorui(Mason) 3 | 4 | The File is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Lesser General Public 6 | License as published by the Free Software Foundation; either 7 | version 2.1 of the License, or (at your option) any later version. 8 | 9 | The File is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public 15 | License along with the Library; if not, see 16 | . 17 | */ 18 | 19 | #ifndef MTHREAD_H 20 | #define MTHREAD_H 21 | 22 | #include "common.h" 23 | 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | KUPLAYER_NAMESPACE_BEGIN //namespace begin 31 | 32 | class mThread : public QThread 33 | { 34 | Q_OBJECT 35 | typedef unsigned int CLASS; 36 | typedef std::function F; 37 | signals: 38 | void load_finished(int, QStringList); 39 | public: 40 | mThread(const int &page, const F &func, QObject *parent = 0) 41 | : QThread(parent) 42 | , page_(page) 43 | , func_(func) 44 | {} 45 | protected: 46 | virtual void run() { 47 | emit load_finished(page_, func_()); 48 | deleteLater(); 49 | } 50 | 51 | private: 52 | ~mThread() { 53 | qDebug() << "thread over" << page_; 54 | } 55 | 56 | CLASS page_; 57 | F func_; 58 | 59 | }; 60 | 61 | KUPLAYER_NAMESPACE_END // namespace end 62 | #endif // MTHREAD_H 63 | -------------------------------------------------------------------------------- /src/play_list_widget.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2015 MeiZhaorui(Mason) 3 | 4 | The File is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Lesser General Public 6 | License as published by the Free Software Foundation; either 7 | version 2.1 of the License, or (at your option) any later version. 8 | 9 | The File is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public 15 | License along with the Library; if not, see 16 | . 17 | */ 18 | 19 | #include "common.h" 20 | #include "gloal_func.h" 21 | #include "push_button.h" 22 | #include "play_list_widget.h" 23 | #include "select_label.h" 24 | USR_NAMESPACE_KUPLAYER //using namespace mei::kuplayer 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | 32 | struct PlayListWidget::PlayListWidget_Impl { 33 | QAction *play_next_key; 34 | QAction *play_prev_key; 35 | QGridLayout *scroll_layout; 36 | PushButton *btn_close; 37 | QList *label_store; 38 | 39 | explicit PlayListWidget_Impl(QObject *parent = 0) 40 | : play_next_key(new QAction(parent)) 41 | , play_prev_key(new QAction(parent)) 42 | , scroll_layout(new QGridLayout) 43 | , btn_close(new PushButton) 44 | , label_store(new QList) { 45 | btn_close->setPicName(":/sysbutton/close"); 46 | play_next_key->setShortcut(QKeySequence(Qt::Key_PageDown)); 47 | play_prev_key->setShortcut(QKeySequence(Qt::Key_PageUp)); 48 | scroll_layout->setContentsMargins(0, 0, 0, 0); 49 | } 50 | ~PlayListWidget_Impl() { 51 | delete_list(label_store); 52 | delete play_next_key; 53 | delete play_prev_key; 54 | delete btn_close; 55 | delete scroll_layout; 56 | } 57 | }; 58 | 59 | PlayListWidget::PlayListWidget(QWidget *parent) 60 | : ShadowWidget(parent) 61 | , col(1) 62 | , currentIndex(0) 63 | , pImpl(new PlayListWidget_Impl()) 64 | { 65 | setAttribute(Qt::WA_QuitOnClose, false); 66 | setWindowModality(Qt::ApplicationModal); 67 | QPalette text_palette = palette(); 68 | text_palette.setColor(QPalette::Window, QColor(225, 225, 225)); 69 | text_palette.setColor(QPalette::Background, QColor(255, 255, 255, 120)); 70 | setPalette(text_palette); 71 | QHBoxLayout *up_title_layout = new QHBoxLayout; 72 | set_no_margin(up_title_layout); 73 | connect(pImpl->btn_close, SIGNAL(clicked()), this, SLOT(hide())); 74 | up_title_layout->addWidget(pImpl->btn_close, 0, Qt::AlignTop); 75 | up_title_layout->addStretch(); 76 | QVBoxLayout *main_layout = new QVBoxLayout(this); 77 | QScrollArea *view = new QScrollArea; 78 | view->setWidgetResizable(true); 79 | view->setContentsMargins(0, 0, 0, 0); 80 | QWidget *viewWidgetContents = new QWidget(view); 81 | QVBoxLayout *tmp_layout = new QVBoxLayout(viewWidgetContents); 82 | tmp_layout->addLayout(pImpl->scroll_layout); 83 | tmp_layout->addStretch(); 84 | view->setWidget(viewWidgetContents); 85 | main_layout->addLayout(up_title_layout); 86 | main_layout->addWidget(view); 87 | main_layout->setSpacing(0); 88 | viewWidgetContents->setPalette(text_palette); 89 | main_layout->setContentsMargins(5, 5, 5, 5); 90 | viewWidgetContents->setFixedWidth(380); 91 | setFixedSize(400, 300); 92 | connect(pImpl->play_next_key, SIGNAL(triggered()), SLOT(on_playNext_clicked())); 93 | connect(pImpl->play_prev_key, SIGNAL(triggered()), SLOT(on_playPrev_clicked())); 94 | } 95 | PlayListWidget::~PlayListWidget() 96 | { 97 | } 98 | 99 | QList PlayListWidget::init_action() 100 | { 101 | return { {pImpl->play_next_key, pImpl->play_prev_key} }; 102 | } 103 | 104 | #include 105 | using std::find_if; 106 | using std::find_if_not; 107 | using std::sort; 108 | #include 109 | using std::for_each; 110 | 111 | void PlayListWidget::sort(const QStringList &list) 112 | { 113 | static QString first; 114 | static QString second; 115 | static QStringList tmp; 116 | static auto comp = [](QString::value_type it) {return it.isDigit();}; 117 | for_each(list.begin(), list.end(), [&](const QStringList::value_type & item) { 118 | second.clear(); 119 | tmp = item.split("$$"); 120 | first = tmp[0]; 121 | auto digit_begin = find_if(first.begin(), first.end(), comp); 122 | auto digit_end = find_if_not(digit_begin, first.end(), comp); 123 | std::copy(digit_begin, digit_end, std::back_inserter(second)); 124 | play_list.append(list_map {std::make_tuple( 125 | QString("%1").arg(second.toInt(), 10, 10, QChar('0')), 126 | std::move(first), 127 | std::move(tmp[1])) 128 | }); 129 | }); 130 | std::sort(play_list.begin(), play_list.end(), 131 | [](list_map::const_iterator::value_type lvalue, 132 | list_map::const_iterator::value_type rvalue) { 133 | return std::get<0>(lvalue) < std::get<0>(rvalue); 134 | }); 135 | } 136 | 137 | void PlayListWidget::on_list_changed(int, const QStringList &list) 138 | { 139 | qDebug() <<__func__ << list; 140 | play_list.clear(); 141 | IsEnd = false; 142 | currentIndex = 0; 143 | 144 | while (pImpl->label_store->size()) { 145 | delete pImpl->label_store->at(0); 146 | pImpl->label_store->removeAt(0); 147 | } 148 | 149 | if (list.isEmpty()) { 150 | return; 151 | } 152 | 153 | sort(list); 154 | int row {0}, ccol {0}; 155 | auto func_add_label = [&](list_map::value_type i) { 156 | if (ccol > col) { ++row; ccol = 0; } 157 | 158 | SelectLabel *sl = new SelectLabel(std::get<1>(i), std::get<2>(i)); 159 | connect(sl, SIGNAL(be_selected(QString, QString)), 160 | this, SLOT(this_click(QString, QString))); 161 | pImpl->label_store->append(sl); 162 | pImpl->scroll_layout->addWidget(sl, row, ccol); 163 | sl->setFixedHeight(32); 164 | ++ccol; 165 | }; 166 | func_add_label(*(play_list.begin())); 167 | static SelectLabel *item = nullptr; 168 | item = pImpl->label_store->at(0); 169 | item->adjustSize(); 170 | 171 | if (item->width() > 80) { 172 | col = 0; 173 | } else { 174 | col = 360 / (item->width() + 15) - 1; 175 | } 176 | 177 | for_each(play_list.begin() + 1, play_list.end(), func_add_label); 178 | } 179 | 180 | void PlayListWidget::on_xuan_ji_show(QString, QString) 181 | { 182 | if (isHidden()) { 183 | QPoint pos_ = QCursor::pos(); 184 | move(pos_.x() - 400, pos_.y() - 300); 185 | show(); 186 | } else { 187 | hide(); 188 | } 189 | } 190 | 191 | void PlayListWidget::this_click(QString name, QString url) 192 | { 193 | for (int i = 0; i < play_list.size(); ++i) { 194 | if (std::get<1>(play_list[i]) == name) { 195 | currentIndex = i; 196 | pImpl->label_store->at(i)->set_selected(true); 197 | qDebug() << __func__ <<": "<< name << ", "<< url; 198 | emit click(name, url); 199 | return; 200 | } 201 | } 202 | } 203 | void PlayListWidget::on_playNext_clicked() 204 | { 205 | ++currentIndex; 206 | 207 | if (currentIndex >= play_list.size()) { 208 | currentIndex = play_list.size() - 1; 209 | emit click(QString(), QString()); 210 | IsEnd = true; 211 | return; 212 | } 213 | 214 | pImpl->label_store->at(currentIndex)->set_selected(true); 215 | emit click(std::get<1>(play_list[currentIndex]), 216 | std::get<2>(play_list[currentIndex])); 217 | } 218 | 219 | void PlayListWidget::on_playPrev_clicked() 220 | { 221 | --currentIndex; 222 | 223 | if (currentIndex < 0) { 224 | currentIndex = 0; 225 | emit click(QString(), QString()); 226 | IsEnd = true; 227 | return; 228 | } 229 | 230 | pImpl->label_store->at(currentIndex)->set_selected(true); 231 | emit click(std::get<1>(play_list[currentIndex]), 232 | std::get<2>(play_list[currentIndex])); 233 | } 234 | 235 | #include 236 | void PlayListWidget::leaveEvent(QEvent *) 237 | { 238 | QTimer::singleShot(800, this, SLOT(hide())); 239 | } 240 | -------------------------------------------------------------------------------- /src/play_list_widget.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2015 MeiZhaorui(Mason) 3 | 4 | The File is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Lesser General Public 6 | License as published by the Free Software Foundation; either 7 | version 2.1 of the License, or (at your option) any later version. 8 | 9 | The File is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public 15 | License along with the Library; if not, see 16 | . 17 | */ 18 | 19 | #ifndef PLAY_LIST_WIDGET_H 20 | #define PLAY_LIST_WIDGET_H 21 | 22 | #include "shadow_widget.h" 23 | #include 24 | 25 | KUPLAYER_NAMESPACE_BEGIN //namespace begin 26 | class PushButton; 27 | class SelectLabel; 28 | 29 | typedef QList> list_map; 30 | 31 | class PlayListWidget : public ShadowWidget 32 | { 33 | Q_OBJECT 34 | signals: 35 | void click(QString, QString); 36 | public: 37 | explicit PlayListWidget(QWidget *parent = 0); 38 | ~PlayListWidget(); 39 | void sort(const QStringList &list); 40 | QList init_action(); 41 | bool IsEnd {false}; 42 | public slots: 43 | void on_list_changed(int, const QStringList &); 44 | void on_xuan_ji_show(QString, QString); 45 | void on_playNext_clicked(); 46 | void on_playPrev_clicked(); 47 | protected: 48 | void leaveEvent(QEvent *); 49 | private slots: 50 | void this_click(QString name, QString url); 51 | private: 52 | int col , currentIndex; 53 | list_map play_list; 54 | struct PlayListWidget_Impl; 55 | std::unique_ptr pImpl; 56 | }; 57 | 58 | KUPLAYER_NAMESPACE_END // namespace end 59 | #endif // PLAY_LIST_WIDGET_H 60 | -------------------------------------------------------------------------------- /src/play_set_widget.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | play_set_widget 4 | 5 | 6 | 7 | 0 8 | 0 9 | 442 10 | 382 11 | 12 | 13 | 14 | Form 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | Play: 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | Qt::Horizontal 36 | 37 | 38 | QSizePolicy::Fixed 39 | 40 | 41 | 42 | 40 43 | 20 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | Play next automatic 52 | 53 | 54 | 55 | 56 | 57 | 58 | Always skip titles credits 59 | 60 | 61 | 62 | 63 | 64 | 65 | Qt::Horizontal 66 | 67 | 68 | 69 | 40 70 | 20 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | Qt::Horizontal 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | Priority for my choice: 90 | 91 | 92 | 93 | 94 | 95 | 96 | Qt::Horizontal 97 | 98 | 99 | 100 | 40 101 | 20 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | Qt::Horizontal 114 | 115 | 116 | QSizePolicy::Fixed 117 | 118 | 119 | 120 | 40 121 | 20 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | Super 130 | 131 | 132 | 133 | 134 | 135 | 136 | High 137 | 138 | 139 | 140 | 141 | 142 | 143 | Standard 144 | 145 | 146 | 147 | 148 | 149 | 150 | Qt::Horizontal 151 | 152 | 153 | 154 | 40 155 | 20 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 9 167 | 168 | 169 | 170 | <html><head/><body><p>Recommendation: 2M choose High, 4M more choose Super</p></body></html> 171 | 172 | 173 | 174 | 175 | 176 | 177 | Qt::Horizontal 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | Hotkey: 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | Qt::Horizontal 198 | 199 | 200 | QSizePolicy::Fixed 201 | 202 | 203 | 204 | 40 205 | 20 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | Play / Pause 216 | 217 | 218 | 219 | 220 | 221 | 222 | Fast Forward 223 | 224 | 225 | 226 | 227 | 228 | 229 | Rewind 230 | 231 | 232 | 233 | 234 | 235 | 236 | Volume + 237 | 238 | 239 | 240 | 241 | 242 | 243 | Volume - 244 | 245 | 246 | 247 | 248 | 249 | 250 | Exit Full Screen 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | Qt::Horizontal 260 | 261 | 262 | QSizePolicy::Fixed 263 | 264 | 265 | 266 | 40 267 | 20 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 60 279 | 0 280 | 281 | 282 | 283 | border-color: rgb(0, 0, 0); 284 | 285 | 286 | 1 287 | 288 | 289 | space 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | 60 298 | 0 299 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | 309 | 310 | 60 311 | 0 312 | 313 | 314 | 315 | 316 | 317 | 318 | 319 | 320 | 321 | 322 | 323 | 60 324 | 0 325 | 326 | 327 | 328 | 329 | 330 | 331 | 332 | 333 | 334 | 335 | 336 | 30 337 | 0 338 | 339 | 340 | 341 | 342 | 343 | 344 | 345 | 346 | 347 | 348 | 349 | 60 350 | 0 351 | 352 | 353 | 354 | Esc 355 | 356 | 357 | 358 | 359 | 360 | 361 | 362 | 363 | Qt::Horizontal 364 | 365 | 366 | 367 | 40 368 | 20 369 | 370 | 371 | 372 | 373 | 374 | 375 | 376 | 377 | 378 | 379 | 380 | Qt::Vertical 381 | 382 | 383 | 384 | 20 385 | 40 386 | 387 | 388 | 389 | 390 | 391 | 392 | 393 | 394 | 395 | -------------------------------------------------------------------------------- /src/program_options.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2015 MeiZhaorui(Mason) 3 | 4 | The File is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Lesser General Public 6 | License as published by the Free Software Foundation; either 7 | version 2.1 of the License, or (at your option) any later version. 8 | 9 | The File is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public 15 | License along with the Library; if not, see 16 | . 17 | */ 18 | 19 | #ifndef PROGRAM_OPTIONS_H 20 | #define PROGRAM_OPTIONS_H 21 | 22 | const char *const VERSION = \ 23 | "\t******************************************\n" 24 | "\t* MadeBy : MeiZhaorui(Mason) *\n" 25 | "\t* E-Mail : listener_mei@163.com *\n" 26 | "\t* Phone : (+86)131-5898-7498 *\n" 27 | "\t* LastUpdate : 2014/10/29 *\n" 28 | "\t* host : Ubuntu x86_64 3.13.0 *\n" 29 | "\t******************************************\n"; 30 | 31 | namespace opt 32 | { 33 | 34 | bool program_options(int argc, char *argv[], const char *version); 35 | 36 | } 37 | 38 | #endif // PROGRAM_OPTIONS_H 39 | -------------------------------------------------------------------------------- /src/push_button.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2015 MeiZhaorui(Mason) 3 | 4 | The File is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Lesser General Public 6 | License as published by the Free Software Foundation; either 7 | version 2.1 of the License, or (at your option) any later version. 8 | 9 | The File is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public 15 | License along with the Library; if not, see 16 | . 17 | */ 18 | 19 | #include "push_button.h" 20 | USR_NAMESPACE_KUPLAYER //using namespace mei::kuplayer 21 | 22 | #include 23 | #include 24 | 25 | PushButton::PushButton(QWidget *parent) 26 | : QPushButton(parent) 27 | { 28 | status = NORMAL; 29 | is_left_pressed = false; 30 | } 31 | 32 | PushButton::~PushButton() 33 | { 34 | } 35 | 36 | void PushButton::setPicName(QString pic_name) 37 | { 38 | this->pic_name = pic_name; 39 | setFixedSize(QPixmap(pic_name).size()); 40 | } 41 | 42 | void PushButton::enterEvent(QEvent *) 43 | { 44 | status = ENTER; 45 | update(); 46 | } 47 | 48 | void PushButton::mousePressEvent(QMouseEvent *event) 49 | { 50 | //若点击鼠标左键 51 | if (event->button() == Qt::LeftButton) { 52 | is_left_pressed = true; 53 | status = PRESS; 54 | update(); 55 | } 56 | } 57 | 58 | void PushButton::mouseReleaseEvent(QMouseEvent *event) 59 | { 60 | //若点击鼠标左键 61 | if (is_left_pressed && rect().contains(event->pos())) { 62 | is_left_pressed = false; 63 | status = ENTER; 64 | update(); 65 | emit clicked(); 66 | } 67 | } 68 | 69 | void PushButton::leaveEvent(QEvent *) 70 | { 71 | status = NORMAL; 72 | update(); 73 | } 74 | 75 | void PushButton::paintEvent(QPaintEvent *) 76 | { 77 | QPainter painter(this); 78 | QPixmap pixmap; 79 | 80 | switch (status) { 81 | case NOSTATUS: 82 | case NORMAL: 83 | pixmap.load(pic_name); 84 | break; 85 | 86 | case ENTER: 87 | pixmap.load(pic_name + QString("_hover")); 88 | break; 89 | 90 | case PRESS: 91 | pixmap.load(pic_name + QString("_pressed")); 92 | break; 93 | 94 | default: 95 | return; 96 | } 97 | 98 | painter.drawPixmap(rect(), pixmap); 99 | } 100 | -------------------------------------------------------------------------------- /src/push_button.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2015 MeiZhaorui(Mason) 3 | 4 | The File is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Lesser General Public 6 | License as published by the Free Software Foundation; either 7 | version 2.1 of the License, or (at your option) any later version. 8 | 9 | The File is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public 15 | License along with the Library; if not, see 16 | . 17 | */ 18 | 19 | #ifndef PUSH_BUTTON_H 20 | #define PUSH_BUTTON_H 21 | #include "common.h" 22 | 23 | #include 24 | 25 | KUPLAYER_NAMESPACE_BEGIN //namespace begin 26 | 27 | class PushButton final : public QPushButton 28 | { 29 | Q_OBJECT 30 | public: 31 | explicit PushButton(QWidget *parent = 0); 32 | ~PushButton(); 33 | void setPicName(QString pic_name); 34 | 35 | protected: 36 | virtual void enterEvent(QEvent *); 37 | virtual void leaveEvent(QEvent *); 38 | virtual void mousePressEvent(QMouseEvent *event); 39 | virtual void mouseReleaseEvent(QMouseEvent *event); 40 | virtual void paintEvent(QPaintEvent *); 41 | 42 | private: 43 | //枚举按钮的几种状态 44 | enum ButtonStatus {NORMAL, ENTER, PRESS, NOSTATUS}; 45 | ButtonStatus status; 46 | QString pic_name; 47 | 48 | int btn_width; //按钮宽度 49 | int btn_height; //按钮高度 50 | bool is_left_pressed; //按钮左键是否按下 51 | }; 52 | 53 | KUPLAYER_NAMESPACE_END // namespace end 54 | #endif // PUSH_BUTTON_H 55 | -------------------------------------------------------------------------------- /src/pyscript.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2015 MeiZhaorui(Mason) 3 | 4 | The File is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Lesser General Public 6 | License as published by the Free Software Foundation; either 7 | version 2.1 of the License, or (at your option) any later version. 8 | 9 | The File is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public 15 | License along with the Library; if not, see 16 | . 17 | */ 18 | 19 | #ifndef PYSCRIPT_CPP 20 | #define PYSCRIPT_CPP 21 | 22 | #include "pyscript.h" 23 | USR_NAMESPACE_KUPLAYER //using namespace mei::kuplayer 24 | 25 | #include 26 | 27 | using namespace boost; 28 | using namespace boost::python; 29 | 30 | PyScript::PyScript() 31 | : init_(new Python::pyinit) 32 | { 33 | module = init_->module(); 34 | } 35 | PyScript::~PyScript() 36 | { 37 | delete init_; 38 | } 39 | 40 | QStringList PyScript::GetVideoUrls(QString keyurl, QString format) 41 | { 42 | qDebug() <<"url:" << keyurl <<"htlp format:" << format; 43 | std::lock_guard lock(mu); 44 | std::shared_ptr pylock; 45 | return_list.clear(); 46 | static list tmp ; 47 | PYTHON_CATCH_EXCEPTION_BEGIN 48 | tmp = python::call_method(module, "getVideoUrls", 49 | keyurl.toStdString().c_str(), 50 | format.toStdString().c_str() 51 | ); 52 | PYTHON_CATCH_EXCEPTION_END(return_list) 53 | qDebug() << python::len(tmp); 54 | for (ssize_t i = 0; i < python::len(tmp); ++i) { 55 | return_list.append(QString(extract(tmp[i]))); 56 | } 57 | 58 | return return_list; 59 | } 60 | 61 | bool PyScript::getShowList() 62 | { 63 | std::lock_guard lock(mu); 64 | std::shared_ptr pylock; 65 | static list tmp; 66 | PYTHON_CATCH_EXCEPTION_BEGIN 67 | tmp = python::call_method(module, "getShowList"); 68 | PYTHON_CATCH_EXCEPTION_END(false) 69 | 70 | for (ssize_t i = 0; i < python::len(tmp); ++i) { 71 | show_list.append(QString(extract(tmp[i]))); 72 | } 73 | 74 | qDebug() << show_list; 75 | return true; 76 | } 77 | 78 | QStringList 79 | PyScript::getUrlByName(CLASS name, QString locate, QString classes, QString time) 80 | { 81 | std::lock_guard lock(mu); 82 | std::shared_ptr pylock; 83 | python::str p(""); 84 | return_list.clear(); 85 | PYTHON_CATCH_EXCEPTION_BEGIN 86 | p = python::call_method(module, "GetUrlByname" 87 | , show_list[name].toStdString().c_str() 88 | , locate.toStdString().c_str() 89 | , classes.toStdString().c_str() 90 | , time.toStdString().c_str()); 91 | PYTHON_CATCH_EXCEPTION_END(return_list) 92 | return_list << QString(extract(p)); 93 | 94 | qDebug()<< __LINE__<<" "<< return_list[0]; 95 | return return_list; 96 | } 97 | 98 | QStringList PyScript::connect_img_url(QString url, QString name) 99 | { 100 | std::lock_guard lock(mu); 101 | std::shared_ptr pylock; 102 | return_list.clear(); 103 | static list tmp ; 104 | PYTHON_CATCH_EXCEPTION_BEGIN 105 | tmp = python::call_method(module 106 | , "connect_img_url" 107 | , url.toStdString().c_str()); 108 | PYTHON_CATCH_EXCEPTION_END(return_list) 109 | 110 | if (python::len(tmp)) { 111 | if (next_page_.contains(name)) { 112 | next_page_.remove(name); 113 | } 114 | 115 | next_page_.insert(name, QString(extract(tmp[0]))); 116 | 117 | for (ssize_t i = 1; i < python::len(tmp); ++i) { 118 | return_list.append(QString(extract(tmp[i]))); 119 | } 120 | } 121 | 122 | return return_list; 123 | } 124 | 125 | QStringList PyScript::gotoNextPage(QString name, int index) 126 | { 127 | std::lock_guard lock(mu); 128 | std::shared_ptr pylock; 129 | return_list.clear(); 130 | PYTHON_CATCH_EXCEPTION_BEGIN 131 | return_list << next_page_.value(name) + QString::number(index) + ".html"; 132 | PYTHON_CATCH_EXCEPTION_END(return_list) 133 | return return_list; 134 | } 135 | 136 | QStringList PyScript::getplayUrl(QString url) 137 | { 138 | std::lock_guard lock(mu); 139 | std::shared_ptr pylock; 140 | return_list.clear(); 141 | static python::list sstr; 142 | PYTHON_CATCH_EXCEPTION_BEGIN 143 | sstr = python::call_method(module 144 | , "getplayUrl" 145 | , url.toStdString().c_str()); 146 | PYTHON_CATCH_EXCEPTION_END(return_list) 147 | 148 | if (python::len(sstr)) { 149 | return_list << QString(extract(sstr[0])); 150 | } else { 151 | return_list << ""; 152 | } 153 | 154 | return return_list; 155 | } 156 | 157 | QStringList PyScript::getAll(CLASS classes, QString url) 158 | { 159 | std::lock_guard lock(mu); 160 | std::shared_ptr pylock; 161 | return_list.clear(); 162 | QString func; 163 | 164 | switch (classes) { 165 | case TV: 166 | func = "get_tv_all"; 167 | break; 168 | 169 | case ZONGYI: 170 | func = "get_zy_all"; 171 | break; 172 | 173 | case COMIC: 174 | func = "get_comic_all"; 175 | break; 176 | 177 | default: 178 | return return_list; 179 | } 180 | 181 | static python::list sstr; 182 | PYTHON_CATCH_EXCEPTION_BEGIN 183 | sstr = python::call_method(module 184 | , func.toStdString().c_str() 185 | , url.toStdString().c_str()); 186 | PYTHON_CATCH_EXCEPTION_END(return_list) 187 | 188 | for (ssize_t i = 0; i < python::len(sstr); ++i) { 189 | return_list << QString(extract(sstr[i])); 190 | } 191 | 192 | return return_list; 193 | } 194 | 195 | #endif //PYSCRIPT_CPP 196 | -------------------------------------------------------------------------------- /src/pyscript.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2015 MeiZhaorui(Mason) 3 | 4 | The File is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Lesser General Public 6 | License as published by the Free Software Foundation; either 7 | version 2.1 of the License, or (at your option) any later version. 8 | 9 | The File is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public 15 | License along with the Library; if not, see 16 | . 17 | */ 18 | 19 | #ifndef PYSCRIPT_H_H 20 | #define PYSCRIPT_H_H 21 | 22 | #include "common.h" 23 | 24 | class QStringList; 25 | class QString; 26 | #include 27 | #include 28 | 29 | #include 30 | #include 31 | 32 | #ifndef PYTHON_DONOT_CATCH_EXCEPTION 33 | #define PYTHON_CATCH_EXCEPTION_BEGIN try{ 34 | #define PYTHON_CATCH_EXCEPTION_END(return_value) }catch(boost::python::error_already_set){\ 35 | printf("\n=================================================================\n"\ 36 | "The [%d] line function[%s] in file[%s] has error\n",__LINE__,__func__,__FILE__); PyErr_Print();\ 37 | printf("\n=================================================================\n");\ 38 | return return_value;} 39 | #else 40 | #define PYTHON_CATCH_EXCEPTION_BEGIN try{ 41 | #define PYTHON_CATCH_EXCEPTION_END(return_value) }catch(boost::python::error_already_set){return return_value;} 42 | #endif 43 | namespace Python 44 | { 45 | 46 | class pyinit final 47 | { 48 | Q_DISABLE_COPY(pyinit) 49 | public: 50 | pyinit(int initsigs = 1) { 51 | assert(initsigs == 0 || initsigs == 1); 52 | Py_InitializeEx(initsigs); 53 | PyEval_InitThreads(); 54 | PyRun_SimpleString("import sys"); 55 | PyRun_SimpleString("sys.path.append('../pyscript/')"); 56 | _module = PyImport_ImportModule("py_kuplayer"); 57 | } 58 | ~pyinit() { /*Py_Finalize(); */} 59 | inline bool isInitialized() { return Py_IsInitialized();} 60 | static void err_print() { PyErr_Print(); } 61 | inline PyObject *module() { return _module; } 62 | private: 63 | PyObject *_module; 64 | }; 65 | 66 | class PyThreadStateLock final 67 | { 68 | Q_DISABLE_COPY(PyThreadStateLock) 69 | public: 70 | PyThreadStateLock() { state = PyGILState_Ensure(); } 71 | ~PyThreadStateLock() { PyGILState_Release(state); } 72 | private: 73 | PyGILState_STATE state; 74 | }; 75 | 76 | } 77 | KUPLAYER_NAMESPACE_BEGIN //namespace begin 78 | 79 | class PyScript final 80 | { 81 | Q_DISABLE_COPY(PyScript) 82 | 83 | using dict = boost::python::dict; 84 | using list = boost::python::list; 85 | public: 86 | PyScript(); 87 | ~PyScript(); 88 | bool getShowList(); 89 | 90 | QStringList GetVideoUrls(QString keyurl, QString format); 91 | QStringList connect_img_url(QString, QString); 92 | QStringList getUrlByName(CLASS, QString, QString, QString); 93 | QStringList gotoNextPage(QString name, int index); 94 | QStringList getplayUrl(QString); 95 | QStringList getAll(CLASS, QString); 96 | 97 | QStringList show_list; 98 | private: 99 | Python::pyinit *init_; 100 | PyObject *module; 101 | QStringList return_list; 102 | QMap next_page_; 103 | 104 | std::mutex mu; 105 | }; 106 | 107 | KUPLAYER_NAMESPACE_END // namespace end 108 | #endif // PYSCRIPT_H_H 109 | -------------------------------------------------------------------------------- /src/select_label.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2015 MeiZhaorui(Mason) 3 | 4 | The File is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Lesser General Public 6 | License as published by the Free Software Foundation; either 7 | version 2.1 of the License, or (at your option) any later version. 8 | 9 | The File is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public 15 | License along with the Library; if not, see 16 | . 17 | */ 18 | 19 | #include "select_label.h" 20 | USR_NAMESPACE_KUPLAYER //using namespace mei::kuplayer 21 | 22 | #include 23 | 24 | #define THIS_WIDGET_COLOR(r,g,b){ QPalette text_palette = palette();\ 25 | text_palette.setColor(QPalette::WindowText, QColor(r, g, b));\ 26 | setPalette(text_palette);} 27 | 28 | SelectLabel::SelectLabel(QString name, QString url, QWidget *parent) 29 | : QLabel(parent) 30 | , url_(url) 31 | { 32 | setText(name); 33 | setAlignment(Qt::AlignHCenter | Qt::AlignVCenter); 34 | THIS_WIDGET_COLOR(0, 0, 0); 35 | QFont ft; 36 | ft.setPixelSize(15); 37 | ft.setBold(false); 38 | setFont(ft); 39 | } 40 | 41 | SelectLabel::~SelectLabel() 42 | { 43 | } 44 | void SelectLabel::enterEvent(QEvent *) 45 | { 46 | mouse_pressed = true; 47 | update(); 48 | } 49 | 50 | 51 | 52 | void SelectLabel::mouseReleaseEvent(QMouseEvent *ev) 53 | { 54 | QLabel::mouseReleaseEvent(ev); 55 | 56 | if (be_select) { 57 | return; 58 | } 59 | 60 | if (ev->button() == Qt::LeftButton && 61 | rect().contains(ev->pos())) { 62 | mouse_pressed = true; 63 | emit be_selected(text(), url_); 64 | } 65 | 66 | update(); 67 | } 68 | 69 | void SelectLabel::leaveEvent(QEvent *ev) 70 | { 71 | QLabel::leaveEvent(ev); 72 | 73 | if (!be_select) { 74 | mouse_pressed = false; 75 | } 76 | 77 | update(); 78 | } 79 | 80 | void SelectLabel::set_selected(bool is_selected) 81 | { 82 | be_select = is_selected; 83 | mouse_pressed = is_selected; 84 | update(); 85 | } 86 | 87 | void SelectLabel::paintEvent(QPaintEvent *ev) 88 | { 89 | QLabel::paintEvent(ev); 90 | static auto old = this->styleSheet(); 91 | 92 | if (mouse_pressed) { 93 | setStyleSheet("background-color:#25BCDA"); 94 | THIS_WIDGET_COLOR(255, 255, 255); 95 | } else { 96 | setStyleSheet(old); 97 | THIS_WIDGET_COLOR(0, 0, 0); 98 | } 99 | } 100 | 101 | -------------------------------------------------------------------------------- /src/select_label.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2015 MeiZhaorui(Mason) 3 | 4 | The File is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Lesser General Public 6 | License as published by the Free Software Foundation; either 7 | version 2.1 of the License, or (at your option) any later version. 8 | 9 | The File is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public 15 | License along with the Library; if not, see 16 | . 17 | */ 18 | 19 | #ifndef SELECT_LABEL_H 20 | #define SELECT_LABEL_H 21 | #include "common.h" 22 | #include 23 | 24 | KUPLAYER_NAMESPACE_BEGIN //namespace begin 25 | 26 | class SelectLabel final : public QLabel 27 | { 28 | Q_OBJECT 29 | signals: 30 | void be_selected(QString, QString); 31 | public: 32 | SelectLabel(QString name, QString url = "", QWidget *parent = 0); 33 | virtual ~SelectLabel(); 34 | void set_selected(bool); 35 | protected: 36 | virtual void enterEvent(QEvent *); 37 | virtual void leaveEvent(QEvent *); 38 | virtual void mouseReleaseEvent(QMouseEvent *); 39 | virtual void paintEvent(QPaintEvent *ev); 40 | private: 41 | bool mouse_pressed {false}; 42 | bool be_select {false}; 43 | QString url_; 44 | }; 45 | 46 | KUPLAYER_NAMESPACE_END // namespace end 47 | #endif // SELECT_LABEL_H 48 | -------------------------------------------------------------------------------- /src/shadow_widget.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2015 MeiZhaorui(Mason) 3 | 4 | The File is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Lesser General Public 6 | License as published by the Free Software Foundation; either 7 | version 2.1 of the License, or (at your option) any later version. 8 | 9 | The File is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public 15 | License along with the Library; if not, see 16 | . 17 | */ 18 | 19 | #include "common.h" 20 | #include "gloal_func.h" 21 | #include "shadow_widget.h" 22 | USR_NAMESPACE_KUPLAYER //using namespace mei::kuplayer 23 | 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | ShadowWidget::ShadowWidget(QWidget *parent) 31 | : QWidget(parent) 32 | , desk(new QDesktopWidget) 33 | , pixmaps(new QList) 34 | { 35 | setWindowFlags(Qt::FramelessWindowHint | Qt::Widget); 36 | setAttribute(Qt::WA_TranslucentBackground); 37 | pixmaps->append(QPixmap(":/shadow/shadow_left")); 38 | pixmaps->append(QPixmap(":/shadow/shadow_right")); 39 | pixmaps->append(QPixmap(":/shadow/shadow_top")); 40 | pixmaps->append(QPixmap(":/shadow/shadow_bottom")); 41 | pixmaps->append(QPixmap(":/shadow/shadow_left_top")); 42 | pixmaps->append(QPixmap(":/shadow/shadow_right_top")); 43 | pixmaps->append(QPixmap(":/shadow/shadow_left_bottom")); 44 | pixmaps->append(QPixmap(":/shadow/shadow_right_bottom")); 45 | } 46 | 47 | ShadowWidget::~ShadowWidget() 48 | { 49 | } 50 | 51 | 52 | void ShadowWidget::change_skin(QString pic_name) 53 | { 54 | static const QString PIC_PATH {qApp->applicationDirPath() + "/../sources/img/skin/"}; 55 | skin = PIC_PATH + pic_name; 56 | qDebug() <pos().y() < TITLE_CONTROL_HEIGHT) { 69 | if (is_max) { 70 | setGeometry(original_rect); 71 | } else { 72 | original_rect = geometry(); 73 | setGeometry(desk->geometry()); 74 | } 75 | 76 | is_max = !is_max; 77 | } 78 | } 79 | 80 | void ShadowWidget::mousePressEvent(QMouseEvent *ev) 81 | { 82 | QWidget::mousePressEvent(ev); 83 | 84 | if (ev->button() == Qt::LeftButton && ev->pos().y() < TITLE_CONTROL_HEIGHT) { 85 | isLeftPressDown = true; 86 | m_ptPressGlobal = ev->globalPos() - pos(); 87 | } 88 | } 89 | 90 | void ShadowWidget::mouseMoveEvent(QMouseEvent *ev) 91 | { 92 | QWidget::mouseMoveEvent(ev); 93 | 94 | if (isLeftPressDown) { 95 | move(ev->globalPos() - m_ptPressGlobal); 96 | } 97 | } 98 | 99 | void ShadowWidget::mouseReleaseEvent(QMouseEvent *ev) 100 | { 101 | QWidget::mouseReleaseEvent(ev); 102 | isLeftPressDown = false; 103 | } 104 | 105 | void ShadowWidget::paintEvent(QPaintEvent *) 106 | { 107 | if (!is_full_screen) { 108 | static QPixmap qskin; 109 | qskin.load(skin); 110 | 111 | QPainter painter(this); 112 | drawWindowShadow(painter); 113 | painter.setPen(Qt::NoPen); 114 | painter.setBrush(Qt::white); 115 | painter.drawPixmap(QRect(SHADOW_WIDTH, SHADOW_WIDTH, 116 | width() - 2 * SHADOW_WIDTH, 117 | height() - 2 * SHADOW_WIDTH), 118 | qskin); 119 | } 120 | } 121 | 122 | void ShadowWidget::drawWindowShadow(QPainter &painter) 123 | { 124 | static int w_height{0},w_width{0}; 125 | w_height = height() - 2 * SHADOW_WIDTH; 126 | w_width = width() - 2 * SHADOW_WIDTH; 127 | 128 | static auto pix0 = (*pixmaps)[0].scaled(SHADOW_WIDTH, w_height); 129 | static auto pix1 = (*pixmaps)[1].scaled(SHADOW_WIDTH, w_height); 130 | static auto pix2 = (*pixmaps)[2].scaled(w_width, SHADOW_WIDTH); 131 | static auto pix3 = (*pixmaps)[3].scaled(w_width, SHADOW_WIDTH); 132 | 133 | //绘制左上角、左下角、右上角、右下角、上、下、左、右边框 134 | painter.drawPixmap(0, 0, SHADOW_WIDTH, SHADOW_WIDTH, (*pixmaps)[4]); 135 | painter.drawPixmap(width() - SHADOW_WIDTH, 0, SHADOW_WIDTH, SHADOW_WIDTH, (*pixmaps)[5]); 136 | painter.drawPixmap(0, height() - SHADOW_WIDTH, SHADOW_WIDTH, SHADOW_WIDTH, (*pixmaps)[6]); 137 | painter.drawPixmap(width() - SHADOW_WIDTH, height() - SHADOW_WIDTH, SHADOW_WIDTH, SHADOW_WIDTH, (*pixmaps)[7]); 138 | painter.drawPixmap(0, SHADOW_WIDTH, SHADOW_WIDTH, w_height,pix0) ; 139 | painter.drawPixmap(width() - SHADOW_WIDTH, SHADOW_WIDTH, SHADOW_WIDTH, w_height, pix1); 140 | painter.drawPixmap(SHADOW_WIDTH, 0, w_width, SHADOW_WIDTH, pix2); 141 | painter.drawPixmap(SHADOW_WIDTH, height() - SHADOW_WIDTH, w_width, SHADOW_WIDTH, pix3); 142 | } -------------------------------------------------------------------------------- /src/shadow_widget.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2015 MeiZhaorui(Mason) 3 | 4 | The File is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Lesser General Public 6 | License as published by the Free Software Foundation; either 7 | version 2.1 of the License, or (at your option) any later version. 8 | 9 | The File is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public 15 | License along with the Library; if not, see 16 | . 17 | */ 18 | 19 | #ifndef SHADOW_WIDGET_H 20 | #define SHADOW_WIDGET_H 21 | 22 | #include "common.h" 23 | 24 | #include 25 | class QDesktopWidget; 26 | 27 | #define TITLE_CONTROL_HEIGHT 29 28 | #define VALUE_DIS 5 29 | 30 | KUPLAYER_NAMESPACE_BEGIN //namespace begin 31 | 32 | class ShadowWidget : public QWidget 33 | { 34 | Q_OBJECT 35 | public: 36 | explicit ShadowWidget(QWidget *parent = 0); 37 | virtual ~ShadowWidget(); 38 | 39 | void change_skin(QString); 40 | 41 | protected: 42 | virtual void mouseDoubleClickEvent(QMouseEvent *); 43 | virtual void mousePressEvent(QMouseEvent *); 44 | virtual void mouseMoveEvent(QMouseEvent *); 45 | virtual void mouseReleaseEvent(QMouseEvent *); 46 | virtual void paintEvent(QPaintEvent *); 47 | 48 | void drawWindowShadow(QPainter &painter); 49 | 50 | QString skin; 51 | inline QString get_skin() const; 52 | 53 | bool is_full_screen {false}; 54 | bool is_max {false}; 55 | QRect original_rect; 56 | bool isLeftPressDown {false}; 57 | QPoint m_ptPressGlobal; 58 | std::shared_ptr desk; 59 | std::shared_ptr> pixmaps; 60 | }; 61 | 62 | inline QString ShadowWidget::get_skin() const 63 | { 64 | return skin.split('/').last(); 65 | } 66 | 67 | KUPLAYER_NAMESPACE_END // namespace end 68 | #endif // SHADOW_WIDGET_H 69 | -------------------------------------------------------------------------------- /src/skin_widget.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2015 MeiZhaorui(Mason) 3 | 4 | The File is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Lesser General Public 6 | License as published by the Free Software Foundation; either 7 | version 2.1 of the License, or (at your option) any later version. 8 | 9 | The File is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public 15 | License along with the Library; if not, see 16 | . 17 | */ 18 | 19 | #include "common.h" 20 | #include "gloal_func.h" 21 | #include "detail_label.h" 22 | #include "skin_widget.h" 23 | #include "push_button.h" 24 | USR_NAMESPACE_KUPLAYER //using namespace mei::kuplayer 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | 33 | struct SkinWidget::SkinWidget_Impl { 34 | QList *label_store; 35 | QScrollArea *view; 36 | QGridLayout *scroll_layout; 37 | PushButton *btn_close; 38 | 39 | SkinWidget_Impl() 40 | : label_store(new QList) 41 | , view(new QScrollArea) 42 | , scroll_layout(new QGridLayout) 43 | , btn_close(new PushButton) 44 | {} 45 | ~SkinWidget_Impl() { 46 | delete_list(label_store); 47 | delete view; 48 | delete scroll_layout; 49 | delete btn_close; 50 | } 51 | }; 52 | 53 | SkinWidget::SkinWidget(QWidget *parent) 54 | : ShadowWidget(parent) 55 | , PIC_PATH(qApp->applicationDirPath() + "/../sources/img/skin/") 56 | , pImpl(new SkinWidget_Impl()) 57 | { 58 | setAttribute(Qt::WA_QuitOnClose, false); 59 | setWindowModality(Qt::ApplicationModal); 60 | QHBoxLayout *up_title_layout = new QHBoxLayout; 61 | set_no_margin(up_title_layout); 62 | pImpl->btn_close->setPicName(":/sysbutton/close"); 63 | connect(pImpl->btn_close, SIGNAL(clicked()), this, SLOT(hide())); 64 | up_title_layout->addWidget(pImpl->btn_close, 0, Qt::AlignTop); 65 | up_title_layout->addStretch(); 66 | QVBoxLayout *main_layout = new QVBoxLayout(this); 67 | pImpl->view->setWidgetResizable(true); 68 | pImpl->view->setContentsMargins(0, 0, 0, 0); 69 | QWidget *viewWidgetContents = new QWidget(pImpl->view); 70 | pImpl->scroll_layout->setContentsMargins(0, 0, 0, 0); 71 | pImpl->scroll_layout->setSpacing(2); 72 | viewWidgetContents->setLayout(pImpl->scroll_layout); 73 | pImpl->view->setWidget(viewWidgetContents); 74 | main_layout->addLayout(up_title_layout); 75 | main_layout->addWidget(pImpl->view); 76 | main_layout->setSpacing(0); 77 | main_layout->setContentsMargins(5, 5, 5, 5); 78 | QPalette text_palette = palette(); 79 | text_palette.setColor(QPalette::Background, QColor(255, 255, 255, 50)); 80 | setPalette(text_palette); 81 | setMinimumSize(800, 430); 82 | find_file(PIC_PATH); 83 | } 84 | 85 | void SkinWidget::find_file(QString path) 86 | { 87 | QDir picdir(path); 88 | QStringList filters; 89 | filters << "*.bmp" << "*.jpg" << "*.png" << "*.gif"; 90 | picdir.setNameFilters(filters); 91 | 92 | if (!picdir.exists()) { 93 | return; 94 | } 95 | 96 | picdir.setFilter(QDir::Dirs | QDir::Files); 97 | picdir.setSorting(QDir::DirsFirst); 98 | QFileInfoList list = picdir.entryInfoList(); 99 | for_each(list.begin(), list.end(), 100 | [&](QFileInfoList::value_type fileInfo) { 101 | if (pic_list.count(fileInfo.fileName()) 102 | || (fileInfo.fileName() == ".") 103 | || (fileInfo.fileName() == "..")) { 104 | return; 105 | } else { 106 | pic_list.append(fileInfo.fileName()); 107 | init_skin(fileInfo.fileName()); 108 | } 109 | }); 110 | } 111 | 112 | void SkinWidget::init_skin(QString name) 113 | { 114 | static int row {0}, col {0}; 115 | QString pic = PIC_PATH + name; 116 | auto *l = new DetailLabel(QPixmap(pic).scaled(QSize(170, 96)), QString(), name); 117 | connect(l, SIGNAL(url_triggered(QString, QString)), 118 | this, SLOT(on_url_triggered(QString, QString))); 119 | pImpl->label_store->append(l); 120 | pImpl->scroll_layout->addWidget(l, row, col); 121 | ++col; 122 | 123 | if (col == 4) { 124 | ++row; 125 | col = 0; 126 | } 127 | } 128 | 129 | void SkinWidget::on_url_triggered(QString, QString index) 130 | { 131 | change_skin(index); 132 | emit skin_change_clicked(index); 133 | } 134 | 135 | void SkinWidget::on_showed() 136 | { 137 | if (isHidden()) { 138 | QPoint pos_ = QCursor::pos(); 139 | move(pos_.x() + 30, pos_.y() + 120); 140 | show(); 141 | find_file(PIC_PATH); 142 | } else { 143 | hide(); 144 | } 145 | } 146 | -------------------------------------------------------------------------------- /src/skin_widget.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2015 MeiZhaorui(Mason) 3 | 4 | The File is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Lesser General Public 6 | License as published by the Free Software Foundation; either 7 | version 2.1 of the License, or (at your option) any later version. 8 | 9 | The File is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public 15 | License along with the Library; if not, see 16 | . 17 | */ 18 | 19 | #ifndef SKIN_WIDGET_H 20 | #define SKIN_WIDGET_H 21 | #include "common.h" 22 | #include "shadow_widget.h" 23 | 24 | KUPLAYER_NAMESPACE_BEGIN //namespace begin 25 | 26 | class SkinWidget final : public ShadowWidget 27 | { 28 | Q_OBJECT 29 | signals: 30 | void skin_change_clicked(QString); 31 | public: 32 | explicit SkinWidget(QWidget *parent = 0); 33 | ~SkinWidget() {} 34 | 35 | public slots: 36 | void on_showed(); 37 | void on_url_triggered(QString, QString); 38 | 39 | private: 40 | void init_skin(QString name); 41 | void find_file(QString path); 42 | 43 | QStringList pic_list; 44 | QString PIC_PATH; 45 | struct SkinWidget_Impl; 46 | std::shared_ptr pImpl; 47 | }; 48 | 49 | KUPLAYER_NAMESPACE_END // namespace end 50 | #endif // SKIN_WIDGET_H 51 | -------------------------------------------------------------------------------- /src/system_notify.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2015 MeiZhaorui(Mason) 3 | 4 | The File is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Lesser General Public 6 | License as published by the Free Software Foundation; either 7 | version 2.1 of the License, or (at your option) any later version. 8 | 9 | The File is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public 15 | License along with the Library; if not, see 16 | . 17 | */ 18 | 19 | #ifndef SYSTEM_NOTIFY_H 20 | #define SYSTEM_NOTIFY_H 21 | 22 | #include 23 | 24 | #if defined(Q_OS_LINUX) && defined(USE_NOTIFY) 25 | #ifdef signals //主要是以下包括的头文件中有signals的变量名不这 26 | #undef signals //样的话不能通过编译因为在QT中signals中关键字。 27 | #include 28 | #endif 29 | #define signals public //恢复关键字定义,幸好是个宏定义 30 | 31 | 32 | bool notification_show(const QString &title, const QString &body, const QString &icon) 33 | { 34 | GError *error = nullptr; 35 | static NotifyNotification *notify_p = nullptr; 36 | 37 | if (title == NULL) { 38 | qDebug() << __LINE__ << ": init notify fail ! title is null " ; 39 | return false; 40 | } 41 | 42 | if (notify_is_initted() == FALSE) { 43 | if (notify_init("kuplayer") == FALSE) { 44 | qDebug() << __LINE__ << ": kuplayer notify init fail ! " ; 45 | return false; 46 | } 47 | 48 | notify_p = notify_notification_new( 49 | title.toStdString().c_str(), 50 | body.toStdString().c_str(), 51 | icon.toStdString().c_str()); 52 | notify_notification_set_timeout(notify_p, 8000); 53 | notify_notification_set_urgency(notify_p, NOTIFY_URGENCY_NORMAL); 54 | } else { 55 | notify_notification_update(notify_p, 56 | title.toStdString().c_str(), 57 | body.toStdString().c_str(), 58 | icon.toStdString().c_str()); 59 | } 60 | 61 | if (notify_notification_show(notify_p, &error) == FALSE) { 62 | qDebug() << "show notify fail !" ; 63 | return false; 64 | } 65 | 66 | return true; 67 | } 68 | #endif //Q_OS_LINUX 69 | #endif // SYSTEM_NOTIFY_H 70 | -------------------------------------------------------------------------------- /src/title_widget.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2015 MeiZhaorui(Mason) 3 | 4 | The File is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Lesser General Public 6 | License as published by the Free Software Foundation; either 7 | version 2.1 of the License, or (at your option) any later version. 8 | 9 | The File is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public 15 | License along with the Library; if not, see 16 | . 17 | */ 18 | 19 | #include "common.h" 20 | #include "gloal_func.h" 21 | #include "title_widget.h" 22 | #include "push_button.h" 23 | USR_NAMESPACE_KUPLAYER //using namespace mei::kuplayer 24 | 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | #define THIS_WIDGET_COLOR(r,g,b){ QPalette text_palette = palette();\ 31 | text_palette.setColor(QPalette::WindowText, QColor(r, g, b));\ 32 | setPalette(text_palette);} 33 | 34 | TypeLabel::TypeLabel(QString title, QWidget *parent) 35 | : QLabel(parent) 36 | { 37 | setText(title); 38 | setAlignment(Qt::AlignHCenter | Qt::AlignBottom); 39 | //set txt color 40 | THIS_WIDGET_COLOR(28, 161, 227); 41 | //set the font size and blod 42 | QFont ft; 43 | ft.setFamily("Ubuntu"); 44 | ft.setPointSize(18); 45 | setFont(ft); 46 | setFixedHeight(TITLE_WIDGET_HEIGHT - TITLE_CONTROL_HEIGHT); 47 | setFixedWidth(TITLE_WIDGET_WIDTH); 48 | } 49 | 50 | TypeLabel::~TypeLabel() 51 | { 52 | } 53 | 54 | void TypeLabel::enterEvent(QEvent *) 55 | { 56 | mouse_hover = true; 57 | THIS_WIDGET_COLOR(28, 121, 227); 58 | } 59 | 60 | void TypeLabel::leaveEvent(QEvent *) 61 | { 62 | mouse_hover = false; 63 | THIS_WIDGET_COLOR(28, 161, 227); 64 | } 65 | 66 | void TypeLabel::mousePressEvent(QMouseEvent *event) 67 | { 68 | if (event->button() == Qt::LeftButton) { 69 | THIS_WIDGET_COLOR(185, 74, 70); 70 | emit clicked(text()); 71 | } 72 | } 73 | 74 | void TypeLabel::mouseReleaseEvent(QMouseEvent *) 75 | { 76 | THIS_WIDGET_COLOR(28, 121, 227); 77 | } 78 | 79 | void TypeLabel::setMousePress(bool mouse_pressed) 80 | { 81 | this->mouse_pressed = mouse_pressed; 82 | update(); 83 | } 84 | 85 | void TypeLabel::paintEvent(QPaintEvent *event) 86 | { 87 | if (mouse_hover | mouse_pressed) { 88 | //绘制鼠标移到按钮上的按钮效果 89 | painterInfo(0, 100, 150); 90 | } 91 | 92 | QLabel::paintEvent(event); 93 | } 94 | 95 | void TypeLabel::painterInfo(int top_color, int middle_color, int bottom_color) 96 | { 97 | QPainter painter(this); 98 | QPen pen(Qt::NoBrush, 1); 99 | painter.setPen(pen); 100 | QLinearGradient linear(rect().topLeft(), rect().bottomLeft()); 101 | linear.setColorAt(0, QColor(220, 220, 220, top_color)); 102 | linear.setColorAt(0.5, QColor(220, 220, 220, middle_color)); 103 | linear.setColorAt(1, QColor(222, 222, 222, bottom_color)); 104 | painter.setBrush(linear); 105 | painter.drawRect(rect()); 106 | } 107 | 108 | 109 | /***********************************************************************************/ 110 | struct NAMESPACE_KUPLAYER::TitleWidget::TitleWidget_Impl { 111 | PushButton *btn_min; 112 | PushButton *btn_close; 113 | PushButton *btn_skin; 114 | PushButton *btn_menu; 115 | QLabel *title; 116 | QHBoxLayout *down_title_layout; 117 | QHBoxLayout *up_title_layout; 118 | #ifdef HAS_LOGO 119 | QLabel *logo; 120 | QHBoxLayout *right_title_layout; 121 | #endif 122 | QList *labels_store; 123 | QList *push_button_store; 124 | 125 | TitleWidget_Impl() 126 | #ifdef HAS_LOGO 127 | , right_title_layout(new QHBoxLayout) 128 | #endif 129 | : labels_store(new QList) 130 | , push_button_store(new QList) 131 | 132 | { 133 | btn_close = new PushButton; 134 | btn_close->setObjectName("close"); 135 | btn_close->setToolTip(TitleWidget::tr("Close")); 136 | btn_min = new PushButton; 137 | btn_min->setObjectName("min"); 138 | btn_min->setToolTip(TitleWidget::tr("Min")); 139 | btn_skin = new PushButton; 140 | btn_skin->setObjectName("skin"); 141 | btn_skin->setToolTip(TitleWidget::tr("Skin")); 142 | btn_menu = new PushButton; 143 | btn_menu->setObjectName("menu"); 144 | btn_menu->setToolTip(TitleWidget::tr("Menu")); 145 | title = new QLabel; 146 | push_button_store->append(btn_close); 147 | push_button_store->append(btn_min); 148 | push_button_store->append(btn_skin); 149 | push_button_store->append(btn_menu); 150 | down_title_layout = new QHBoxLayout; 151 | up_title_layout = new QHBoxLayout; 152 | btn_close->setPicName(":/sysbutton/close"); 153 | up_title_layout->addWidget(btn_close, 0, Qt::AlignTop); 154 | btn_min->setPicName(":/sysbutton/min"); 155 | up_title_layout->addWidget(btn_min, 0, Qt::AlignTop); 156 | btn_skin->setPicName(":/sysbutton/skin"); 157 | up_title_layout->addWidget(btn_skin, 0, Qt::AlignTop); 158 | btn_menu->setPicName(":/sysbutton/menu"); 159 | up_title_layout->addWidget(btn_menu, 0, Qt::AlignTop); 160 | #ifdef HAS_LOGO 161 | logo = new QLabel; 162 | logo->setPixmap(QString(":/logo/logo")); 163 | right_title_layout->addWidget(logo); 164 | set_no_margin(right_title_layout); 165 | #endif 166 | up_title_layout->addStretch(2); 167 | up_title_layout->addWidget(title); 168 | up_title_layout->addStretch(3); 169 | set_no_margin(up_title_layout); 170 | } 171 | 172 | ~TitleWidget_Impl() { 173 | delete_list(push_button_store); 174 | delete_list(labels_store); 175 | delete title; 176 | delete down_title_layout; 177 | delete up_title_layout; 178 | #ifdef HAS_LOGO 179 | delete logo; 180 | delete right_title_layout; 181 | #endif 182 | } 183 | }; 184 | 185 | TitleWidget::TitleWidget(QWidget *parent) 186 | : QWidget(parent) 187 | , pImpl(new TitleWidget_Impl()) 188 | { 189 | connect(pImpl->btn_close, SIGNAL(clicked()), this, SIGNAL(close_clicked())); 190 | connect(pImpl->btn_min, SIGNAL(clicked()), this, SIGNAL(min_clicked())); 191 | connect(pImpl->btn_skin, SIGNAL(clicked()), this, SIGNAL(skin_clicked())); 192 | connect(pImpl->btn_menu, SIGNAL(clicked()), this, SIGNAL(menu_clicked())); 193 | for_each(down_title.cbegin(), down_title.cend(), 194 | [&](const QStringList::value_type & name) { 195 | TypeLabel *label = new TypeLabel(name); 196 | pImpl->down_title_layout->addWidget(label, 0, Qt::AlignBottom | Qt::AlignHCenter); 197 | pImpl->labels_store->append(label); 198 | connect(label, SIGNAL(clicked(QString)), SLOT(on_turepage_triggered(QString))); 199 | }); 200 | pImpl->down_title_layout->addStretch(); 201 | pImpl->down_title_layout->setMargin(0); 202 | pImpl->down_title_layout->setSpacing(2); 203 | pImpl->down_title_layout->setContentsMargins(0, 0, 0, 0); 204 | QVBoxLayout *left_layout = new QVBoxLayout; 205 | set_no_margin(left_layout); 206 | left_layout->addLayout(pImpl->up_title_layout); 207 | left_layout->addLayout(pImpl->down_title_layout); 208 | QHBoxLayout *main_layout = new QHBoxLayout(this); 209 | set_no_margin(main_layout); 210 | main_layout->addLayout(left_layout); 211 | #ifdef HAS_LOGO 212 | main_layout->addStretch(5); 213 | main_layout->addLayout(pImpl->right_title_layout); 214 | main_layout->addStretch(1); 215 | #endif 216 | setFixedHeight(TITLE_WIDGET_HEIGHT); 217 | } 218 | 219 | TitleWidget::~TitleWidget() 220 | { 221 | } 222 | void TitleWidget::set_text(QString name) 223 | { 224 | pImpl->title->setText(name); 225 | pImpl->title->adjustSize(); 226 | } 227 | QString TitleWidget::get_text() const 228 | { 229 | return pImpl->title->text(); 230 | } 231 | void TitleWidget::on_turepage_triggered(int index) 232 | { 233 | for_each(pImpl->labels_store->cbegin(), pImpl->labels_store->cend(), 234 | [](const QList::value_type & label) { 235 | label->setMousePress(false); 236 | }); 237 | pImpl->labels_store->at(index)->setMousePress(true); 238 | emit ture_page(index); 239 | } 240 | 241 | void TitleWidget::on_turepage_triggered(QString name) 242 | { 243 | unsigned int index = down_title.indexOf(name); 244 | 245 | if (index > PLAYER) { index = PLAYER; } 246 | 247 | on_turepage_triggered(index); 248 | } 249 | -------------------------------------------------------------------------------- /src/title_widget.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2015 MeiZhaorui(Mason) 3 | 4 | The File is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Lesser General Public 6 | License as published by the Free Software Foundation; either 7 | version 2.1 of the License, or (at your option) any later version. 8 | 9 | The File is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public 15 | License along with the Library; if not, see 16 | . 17 | */ 18 | 19 | #ifndef TITLE_WIDGET_H 20 | #define TITLE_WIDGET_H 21 | #include "common.h" 22 | #include 23 | #include 24 | 25 | #define TITLE_WIDGET_HEIGHT 72 26 | #define TITLE_WIDGET_WIDTH 100 27 | #define TITLE_CONTROL_HEIGHT 29 28 | class QMouseEvent; 29 | 30 | KUPLAYER_NAMESPACE_BEGIN //namespace begin 31 | 32 | class TypeLabel final : public QLabel 33 | { 34 | Q_OBJECT 35 | public: 36 | explicit TypeLabel(QString title, QWidget *paren = 0); 37 | virtual ~TypeLabel(); 38 | void setMousePress(bool mouse_press); 39 | signals: 40 | void clicked(QString); 41 | protected: 42 | virtual void enterEvent(QEvent *); 43 | virtual void leaveEvent(QEvent *); 44 | virtual void mousePressEvent(QMouseEvent *event); 45 | virtual void mouseReleaseEvent(QMouseEvent *); 46 | virtual void paintEvent(QPaintEvent *event); 47 | private: 48 | void painterInfo(int, int, int); 49 | 50 | private: 51 | bool mouse_hover {false}; 52 | bool mouse_pressed {false}; 53 | }; 54 | 55 | class TitleWidget : public QWidget 56 | { 57 | Q_OBJECT 58 | signals: 59 | void skin_clicked(); 60 | void min_clicked(); 61 | void close_clicked(); 62 | void menu_clicked(); 63 | void ture_page(int); 64 | public: 65 | explicit TitleWidget(QWidget *parent_ = 0); 66 | virtual ~TitleWidget(); 67 | void set_text(QString); 68 | QString get_text() const; 69 | public slots: 70 | void on_turepage_triggered(int); 71 | void on_turepage_triggered(QString); 72 | private: 73 | QStringList down_title { 74 | tr("TVShow"), tr("Movies"), tr("Variety"), 75 | tr("Music"), tr("Cartoon"), tr("Player") 76 | }; 77 | struct TitleWidget_Impl; 78 | std::unique_ptr pImpl; 79 | 80 | }; 81 | 82 | KUPLAYER_NAMESPACE_END // namespace end 83 | #endif // TITLE_WIDGET_H 84 | -------------------------------------------------------------------------------- /src/ui_control_classes.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2015 MeiZhaorui(Mason) 3 | 4 | The File is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Lesser General Public 6 | License as published by the Free Software Foundation; either 7 | version 2.1 of the License, or (at your option) any later version. 8 | 9 | The File is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public 15 | License along with the Library; if not, see 16 | . 17 | */ 18 | 19 | #include "ui_control_classes.h" 20 | USR_NAMESPACE_KUPLAYER //using namespace mei::kuplayer 21 | 22 | base_set_weidget::base_set_weidget(QWidget *parent) : 23 | QWidget(parent), 24 | ui(new Ui::base_set_weidget) 25 | { 26 | ui->setupUi(this); 27 | } 28 | 29 | base_set_weidget::~base_set_weidget() 30 | { 31 | delete ui; 32 | } 33 | 34 | /*******************************************************************************************/ 35 | 36 | play_set_widget::play_set_widget(QWidget *parent) : 37 | QWidget(parent), 38 | ui(new Ui::play_set_widget) 39 | { 40 | ui->setupUi(this); 41 | } 42 | play_set_widget::~play_set_widget() 43 | { 44 | delete ui; 45 | } 46 | /*******************************************************************************************/ 47 | 48 | about_widget::about_widget(QWidget *parent) : 49 | QWidget(parent), 50 | ui(new Ui::about_widget) 51 | { 52 | ui->setupUi(this); 53 | } 54 | 55 | about_widget::~about_widget() 56 | { 57 | delete ui; 58 | } 59 | 60 | #include 61 | #include 62 | void about_widget::on_label_linkActivated(const QString &link) 63 | { 64 | QDesktopServices::openUrl(QUrl(link)); 65 | } 66 | 67 | -------------------------------------------------------------------------------- /src/ui_control_classes.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2015 MeiZhaorui(Mason) 3 | 4 | The File is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Lesser General Public 6 | License as published by the Free Software Foundation; either 7 | version 2.1 of the License, or (at your option) any later version. 8 | 9 | The File is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public 15 | License along with the Library; if not, see 16 | . 17 | */ 18 | 19 | #ifndef UI_CONTROL_CLASSES_H 20 | #define UI_CONTROL_CLASSES_H 21 | 22 | #include "common.h" 23 | 24 | #include 25 | #include "shadow_widget.h" 26 | #include "ui_base_set_weidget.h" 27 | #include "ui_play_set_widget.h" 28 | #include "ui_about_widget.h" 29 | 30 | KUPLAYER_NAMESPACE_BEGIN //namespace begin 31 | 32 | /**********************************************/ 33 | class base_set_weidget : public QWidget 34 | { 35 | Q_OBJECT 36 | public: 37 | explicit base_set_weidget(QWidget *parent = 0); 38 | ~base_set_weidget(); 39 | 40 | Ui::base_set_weidget *ui; 41 | }; 42 | 43 | /**********************************************/ 44 | 45 | class play_set_widget : public QWidget 46 | { 47 | Q_OBJECT 48 | friend class down_widget_; 49 | public: 50 | explicit play_set_widget(QWidget *parent = 0); 51 | ~play_set_widget(); 52 | 53 | Ui::play_set_widget *ui; 54 | }; 55 | 56 | /**********************************************/ 57 | 58 | class about_widget : public QWidget 59 | { 60 | Q_OBJECT 61 | 62 | public: 63 | explicit about_widget(QWidget *parent = 0); 64 | ~about_widget(); 65 | Ui::about_widget *ui; 66 | private slots: 67 | void on_label_linkActivated(const QString &link); 68 | }; 69 | 70 | KUPLAYER_NAMESPACE_END // namespace end 71 | #endif // UI_CONTROL_CLASSES_H 72 | -------------------------------------------------------------------------------- /testkuplayer/testkuplayer.pro: -------------------------------------------------------------------------------- 1 | #------------------------------------------------- 2 | # 3 | # Project created by QtCreator 2015-04-19T21:32:20 4 | # 5 | #------------------------------------------------- 6 | 7 | QT += widgets network testlib av avwidgets 8 | 9 | TARGET = tst_kuplayertest 10 | CONFIG += console 11 | CONFIG -= app_bundle 12 | 13 | TEMPLATE = app 14 | 15 | 16 | SOURCES += tst_kuplayertest.cpp 17 | DEFINES += SRCDIR=\\\"$$PWD/\\\" 18 | DEFINES += 19 | SOURCES += ../src/control_widget.cpp \ 20 | ../src/detail_label.cpp \ 21 | ../src/kuplayer.cpp \ 22 | ../src/list_widget.cpp \ 23 | ../src/main_menu.cpp \ 24 | ../src/mplayer_widget.cpp \ 25 | ../src/play_list_widget.cpp \ 26 | ../src/push_button.cpp \ 27 | ../src/pyscript.cpp \ 28 | ../src/select_label.cpp \ 29 | ../src/shadow_widget.cpp \ 30 | ../src/skin_widget.cpp \ 31 | ../src/title_widget.cpp \ 32 | ../src/ui_control_classes.cpp \ 33 | ../src/control_label.cpp \ 34 | ../src/common.cpp \ 35 | ../src/conf_info.cpp 36 | 37 | HEADERS += ../src/common.h \ 38 | ../src/control_widget.h \ 39 | ../src/detail_label.h \ 40 | ../src/kuplayer.h \ 41 | ../src/list_widget.h \ 42 | ../src/loadimage.h \ 43 | ../src/main_menu.h \ 44 | ../src/mplayer_widget.h \ 45 | ../src/mthread.h \ 46 | ../src/play_list_widget.h \ 47 | ../src/program_options.h \ 48 | ../src/push_button.h \ 49 | ../src/pyscript.h \ 50 | ../src/select_label.h \ 51 | ../src/shadow_widget.h \ 52 | ../src/skin_widget.h \ 53 | ../src/system_notify.h \ 54 | ../src/title_widget.h \ 55 | ../src/ui_control_classes.h \ 56 | ../src/gloal_func.h \ 57 | ../src/control_label.h \ 58 | ../src/conf_info.h 59 | 60 | RESOURCES += \ 61 | ../src/kuplayer.qrc 62 | #------------------------------------------------- 63 | # 64 | # Project created by QtCreator 2014-10-01T10:53:06 65 | # 66 | #------------------------------------------------- 67 | 68 | QMAKE_CXXFLAGS += -std=c++11 -DQT_NO_DEBUG_OUTPUT -DAV_NO_DEBUG_OUTPUT -DPYTHON_DONOT_CATCH_EXCEPTION 69 | #DEFINES += NO_WIFI_TEST 70 | 71 | QMAKE_LFLAGS += -Wl,-rpath,"../lib" 72 | QMAKE_LFLAGS_RELEASE += -Wl,-s -Wl,-O2 73 | 74 | 75 | 76 | unix: { 77 | INCLUDEPATH += /usr/include/python2.7/ \ 78 | $$PWD/../resources/libs 79 | 80 | LIBS += -L$$PWD/../resources/libs \ 81 | $$PWD/../resources/libs/libboost_python.a \ 82 | $$PWD/../resources/libs/libboost_system.a \ 83 | -lQtSingleApplication \ 84 | -loptions_64 \ 85 | -lpython2.7 86 | 87 | exists( /usr/include/libnotify/notify.h ) { 88 | INCLUDEPATH += /usr/include/glib-2.0/ 89 | INCLUDEPATH += /usr/lib/x86_64-linux-gnu/glib-2.0/include/ 90 | INCLUDEPATH += /usr/include/gdk-pixbuf-2.0/ 91 | 92 | LIBS += -lnotify 93 | DEFINES += USE_NOTIFY 94 | } else { 95 | message("Can not find libnotify.so. You can: sudo apt-get install libnotify4-dev") 96 | } 97 | } 98 | 99 | 100 | -------------------------------------------------------------------------------- /testkuplayer/tst_kuplayertest.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2015 MeiZhaorui(Mason) 3 | 4 | The File is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Lesser General Public 6 | License as published by the Free Software Foundation; either 7 | version 2.1 of the License, or (at your option) any later version. 8 | 9 | The File is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public 15 | License along with the Library; if not, see 16 | . 17 | */ 18 | 19 | #include 20 | #include 21 | #include 22 | #include "../src/pyscript.h" 23 | USR_NAMESPACE_KUPLAYER 24 | 25 | class kuplayerTest : public QObject 26 | { 27 | Q_OBJECT 28 | 29 | public: 30 | kuplayerTest(); 31 | 32 | private Q_SLOTS: 33 | void testgetShowList(); 34 | }; 35 | kuplayerTest::kuplayerTest() 36 | { 37 | 38 | } 39 | 40 | void kuplayerTest::testgetShowList() 41 | { 42 | PyScript p; 43 | QCOMPARE(true,p.getShowList()); 44 | } 45 | 46 | QTEST_MAIN(kuplayerTest) 47 | 48 | #include "tst_kuplayertest.moc" 49 | --------------------------------------------------------------------------------