diff --git a/CMakeLists.txt b/CMakeLists.txt index 49c4e10..a4a7759 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,13 +6,14 @@ find_package(Qt6 6.5 REQUIRED COMPONENTS Core Widgets) include_directories( ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/log - ${CMAKE_CURRENT_SOURCE_DIR}/third_party/FFmpeg/include + "~/ffmpeg4.2_build/include" + # ${CMAKE_CURRENT_SOURCE_DIR}/third_party/FFmpeg/include ) file(GLOB EASYLOG_SOURCES "log/*.cc" "log/*.h") file(GLOB UI_SOURCES "*.ui") file(GLOB SOURCES "*.cpp" "*.h") -link_directories(${CMAKE_CURRENT_SOURCE_DIR}/third_party/FFmpeg/lib) +link_directories("~/ffmpeg4.2_build/lib") find_package(SDL2 REQUIRED) diff --git a/customslider.cpp b/customslider.cpp index 670be62..fc48e35 100644 --- a/customslider.cpp +++ b/customslider.cpp @@ -28,7 +28,7 @@ void CustomSlider::mouseReleaseEvent(QMouseEvent *ev) bIsPressed = false; QSlider::mouseReleaseEvent(ev); - //emit SigCustomSliderValueChanged(); + emit SigCustomSliderValueChanged(this->value()); } void CustomSlider::mouseMoveEvent(QMouseEvent *ev) diff --git a/displaywind.cpp b/displaywind.cpp index 5d44ce2..422c623 100644 --- a/displaywind.cpp +++ b/displaywind.cpp @@ -2,6 +2,7 @@ #include "ui_displaywind.h" #include #include +#include DisplayWind::DisplayWind(QWidget *parent) : QWidget(parent), ui(new Ui::DisplayWind), @@ -9,6 +10,7 @@ DisplayWind::DisplayWind(QWidget *parent) : // stParentWidget_(parent) { ui->setupUi(this); + // this->setStyleSheet(GlobalHelper::GetQssStr(":/res/qss/show.css")); win_width_ = width(); win_height_ = height(); memset(&dst_video_frame_, sizeof(VideoFrame), 0); @@ -128,8 +130,19 @@ void DisplayWind::enterFullScreen() } setParent(nullptr); } - setWindowFlags(Qt::Window); - showFullScreen(); + setWindowFlags(Qt::Window | Qt::FramelessWindowHint); + + QScreen *currentScreen = screen() ? screen() : QGuiApplication::primaryScreen(); + if (currentScreen) { + QRect availableGeometry = currentScreen->availableGeometry(); + this->setGeometry(availableGeometry); + this->setStyleSheet("background-color: black;"); + show(); + } + else { + show(); + } + // showFullScreen(); setFocus(); @@ -144,7 +157,7 @@ void DisplayWind::exitFullScreen() bIsFull_ = false; setWindowFlags(Qt::Widget); - hide(); + // hide(); if (stParentWidget_) { setParent(stParentWidget_); @@ -158,12 +171,13 @@ void DisplayWind::exitFullScreen() setGeometry(stOriginalGeometry_); } } - resize(nWinWidthBack_, nWinHeightBack_); - show(); + + // show(); + // resize(nWinWidthBack_, nWinHeightBack_); setFocus(); - stParentLayout_ = nullptr; - nParentLayoutIndex_ = 0; - stOriginalGeometry_ = QRect(); + // stParentLayout_ = nullptr; + // nParentLayoutIndex_ = 0; + // stOriginalGeometry_ = QRect(); emit signalFullScreenChanged(); } diff --git a/homewindow.cpp b/homewindow.cpp index c490fcc..2a037d1 100644 --- a/homewindow.cpp +++ b/homewindow.cpp @@ -43,6 +43,7 @@ HomeWindow::HomeWindow(QWidget *parent) : bIsFull(false) { ui->setupUi(this); + setWindowIcon(QIcon(":/logo/res/logo.png")); ui->playList->Init(); QString str = QString("%1:%2:%3").arg(0, 2, 10, QLatin1Char('0')).arg(0, 2, 10, QLatin1Char('0')).arg(0, 2, 10, QLatin1Char('0')); ui->curPosition->setText(str); @@ -94,6 +95,8 @@ int HomeWindow::InitSignalsAndSlots() connect(ui->openUrlAction, &QAction::triggered, this, &HomeWindow::on_openNetworkUrl); connect(this, &HomeWindow::sig_updatePlayOrPause, this, &HomeWindow::on_updatePlayOrPause); connect(this, &HomeWindow::sig_troggleFull, ui->display, &DisplayWind::onToggleFullScreen); + connect(&setting_wid_, &Setting::sig_bufDurationBox_currentIndexChanged, this, &HomeWindow::on_bufDurationBox_currentIndexChanged); + connect(&setting_wid_, &Setting::sig_jitterBufBox_currentIndexChanged, this, &HomeWindow::on_jitterBufBox_currentIndexChanged); return 0; } @@ -188,49 +191,52 @@ void HomeWindow::resizeEvent(QResizeEvent *event) void HomeWindow::resizeUI() { - int width = this->width(); - int height = this->height(); - LOG(INFO) << "width: " << width; - // 获取当前ctrlwidget的位置 - QRect rect = ui->ctrlBar->geometry(); - rect.setY(height - ui->menuBar->height() - rect.height()); - // LOG(INFO) << "rect: " << rect; - rect.setWidth(width); - ui->ctrlBar->setGeometry(rect); - // 设置setting和listbutton的位置 - rect = ui->settingBtn->geometry(); - // 获取 ctrlBar的大小 计算list的 x位置 - int x1 = ui->ctrlBar->width() - rect.width() - rect.width() / 8 * 2; - ui->listBtn->setGeometry(x1, rect.y(), rect.width(), rect.height()); - // LOG(INFO) << "listBtn: " << ui->listBtn->geometry(); - // 设置setting button的位置,在listbutton左侧 - rect = ui->listBtn->geometry(); - x1 = rect.x() - rect.width() - rect.width() / 8 ; - ui->settingBtn->setGeometry(x1, rect.y(), rect.width(), rect.height()); - // LOG(INFO) << "settingBtn: " << ui->settingBtn->geometry(); - // 设置 显示画面 - if(is_show_file_list_) { - width = this->width() - ui->playList->width(); - } else { - width = this->width(); - } - height = this->height() - ui->ctrlBar->height() - ui->menuBar->height(); - // int y1 = ui->menuBar->height(); - int y1 = 0; - ui->display->setGeometry(0, y1, width, height); - // 设置文件列表 list - if(is_show_file_list_) { - ui->playList->setGeometry(ui->display->width(), y1, ui->playList->width(), height); - } - // 设置播放进度条的长度,设置成和显示控件宽度一致 - rect = ui->playSlider->geometry(); - width = ui->display->width() - 5 - 5; - rect.setWidth(width); - ui->playSlider->setGeometry(5, rect.y(), rect.width(), rect.height()); - // 设置音量条位置 - x1 = this->width() - 5 - ui->volumeSlider->width(); - rect = ui->volumeSlider->geometry(); - ui->volumeSlider->setGeometry(x1, rect.y(), rect.width(), rect.height()); + int width = ui->playwidget->width(); + int height = ui->playwidget->height(); + QRect rect = ui->playwidget->geometry(); + qDebug() << rect; + ui->display->setGeometry(rect); + // LOG(INFO) << "width: " << width; + // // 获取当前ctrlwidget的位置 + // QRect rect = ui->ctrlBar->geometry(); + // rect.setY(height - ui->menuBar->height() - rect.height()); + // // LOG(INFO) << "rect: " << rect; + // rect.setWidth(width); + // ui->ctrlBar->setGeometry(rect); + // // 设置setting和listbutton的位置 + // rect = ui->settingBtn->geometry(); + // // 获取 ctrlBar的大小 计算list的 x位置 + // int x1 = ui->ctrlBar->width() - rect.width() - rect.width() / 8 * 2; + // ui->listBtn->setGeometry(x1, rect.y(), rect.width(), rect.height()); + // // LOG(INFO) << "listBtn: " << ui->listBtn->geometry(); + // // 设置setting button的位置,在listbutton左侧 + // rect = ui->listBtn->geometry(); + // x1 = rect.x() - rect.width() - rect.width() / 8 ; + // ui->settingBtn->setGeometry(x1, rect.y(), rect.width(), rect.height()); + // // LOG(INFO) << "settingBtn: " << ui->settingBtn->geometry(); + // // 设置 显示画面 + // if(is_show_file_list_) { + // width = this->width() - ui->playList->width(); + // } else { + // width = this->width(); + // } + // height = this->height() - ui->ctrlBar->height() - ui->menuBar->height(); + // // int y1 = ui->menuBar->height(); + // int y1 = 0; + // ui->display->setGeometry(0, y1, width, height); + // // 设置文件列表 list + // if(is_show_file_list_) { + // ui->playList->setGeometry(ui->display->width(), y1, ui->playList->width(), height); + // } + // // 设置播放进度条的长度,设置成和显示控件宽度一致 + // rect = ui->playSlider->geometry(); + // width = ui->display->width() - 5 - 5; + // rect.setWidth(width); + // ui->playSlider->setGeometry(5, rect.y(), rect.width(), rect.height()); + // // 设置音量条位置 + // x1 = this->width() - 5 - ui->volumeSlider->width(); + // rect = ui->volumeSlider->geometry(); + // ui->volumeSlider->setGeometry(x1, rect.y(), rect.width(), rect.height()); } void HomeWindow::closeEvent(QCloseEvent *event) @@ -448,9 +454,10 @@ void HomeWindow::on_playOrPauseBtn_clicked() void HomeWindow::on_updatePlayOrPause(int state) { if(state == MP_STATE_STARTED) { - ui->playOrPauseBtn->setText("暂停"); + // ui->playOrPauseBtn->setText("暂停"); + GlobalHelper::SetToolbuttonIcon(ui->playOrPauseBtn, ":/icon/res/icon/pause.png"); } else { - ui->playOrPauseBtn->setText("播放"); + GlobalHelper::SetToolbuttonIcon(ui->playOrPauseBtn, ":/icon/res/icon/play.png"); } LOG(INFO) << "play state: " << state; } @@ -566,7 +573,7 @@ bool HomeWindow::stop() real_time_ = 0; is_accelerate_speed_ = false; ui->display->StopPlay(); // 停止渲染,后续刷黑屏 - ui->playOrPauseBtn->setText("播放"); + GlobalHelper::SetToolbuttonIcon(ui->playOrPauseBtn, ":/icon/res/icon/play.png"); return 0; } else { return -1; @@ -747,6 +754,14 @@ void HomeWindow::on_backFastBtn_clicked() void HomeWindow::on_fullBtn_clicked() { - emit sig_troggleFull(true); + if (mp_ && ((mp_->ijkmp_get_state() == MP_STATE_STARTED) || (mp_->ijkmp_get_state() == MP_STATE_PAUSED))) { + emit sig_troggleFull(true); + } +} + + +void HomeWindow::on_settingBtn_clicked() +{ + setting_wid_.show(); } diff --git a/homewindow.h b/homewindow.h index feff675..ded241b 100644 --- a/homewindow.h +++ b/homewindow.h @@ -5,6 +5,7 @@ #include #include "toast.h" #include "ijkmediaplayer.h" +#include "setting.h" namespace Ui { class HomeWindow; @@ -36,6 +37,9 @@ signals: void sig_stopped(); // 被动停止 void sig_troggleFull(bool); +public slots: + void on_bufDurationBox_currentIndexChanged(int index); + void on_jitterBufBox_currentIndexChanged(int index); private slots: void on_UpdateAudioCacheDuration(int64_t duration); void on_UpdateVideoCacheDuration(int64_t duration); @@ -53,8 +57,8 @@ private slots: // 进度条响应 // 拖动触发 - // void on_playSliderValueChanged(); - // void on_volumeSliderValueChanged(); + // void on_playSliderValueChanged(); + // void on_volumeSliderValueChanged(); void on_updateCurrentPosition(long position); void onTimeOut(); @@ -65,9 +69,7 @@ private slots: void on_screenBtn_clicked(); void on_showTips(Toast::Level leve, QString tips); - void on_bufDurationBox_currentIndexChanged(int index); - void on_jitterBufBox_currentIndexChanged(int index); void on_prevBtn_clicked(); @@ -79,6 +81,8 @@ private slots: void on_fullBtn_clicked(); + void on_settingBtn_clicked(); + private: void startTimer(); @@ -140,6 +144,9 @@ private: int64_t audio_bitrate_duration = 0; int64_t video_bitrate_duration = 0; + // setting dialog + Setting setting_wid_; + bool bIsFull; }; diff --git a/homewindow.ui b/homewindow.ui index 620e569..732178b 100644 --- a/homewindow.ui +++ b/homewindow.ui @@ -6,7 +6,7 @@ 0 0 - 1115 + 1236 757 @@ -26,411 +26,465 @@ GDMP - + - - - - - 160 - 160 - 400 - 240 - - - - - 400 - 240 - - - - - - - - - - 720 - 160 - 240 - 240 - - - - - 240 - 0 - - - - - 240 - 16777215 - - - - - - - + + + 0 + + + 6 + + + + + + 0 + 0 + + + + + 0 + 0 + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 400 + 240 + + + + + + + + + + + + + + + 0 + 0 + + + + + 800 + 128 + + + + + 16777215 + 95 + + + + + + + + + + 0 + 0 + + + + + 300 + 20 + + + + + 16777215 + 20 + + + + PointingHandCursor + + + 65536 + + + Qt::Horizontal + + + + + + + + 65 + 16777215 + + + + 20:10:00 + + + + + + + + 5 + 16777215 + + + + / + + + + + + + + 65 + 16777215 + + + + 24:00:00 + + + + + + + + + + + + 0 + 0 + + + + + + + + 64 + 64 + + + + + 64 + 64 + + + + + + + + + + + + 64 + 64 + + + + + 64 + 64 + + + + + + + + + + + + + + + 64 + 64 + + + + + 64 + 64 + + + + + + + + + + + + 64 + 64 + + + + + 64 + 64 + + + + + + + + + + + + 64 + 64 + + + + + 64 + 64 + + + + + + + + + + + + 64 + 64 + + + + + 64 + 64 + + + + + + + + + + + + 64 + 64 + + + + + 64 + 64 + + + + + + + + + + + + 0 + 0 + + + + + 100 + 20 + + + + + 100 + 20 + + + + PointingHandCursor + + + Qt::ClickFocus + + + Qt::Horizontal + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 0 + 0 + + + + + + + + 64 + 64 + + + + + 64 + 64 + + + + + + + + + + + + 64 + 64 + + + + + 64 + 64 + + + + Qt::LeftToRight + + + + + + + + + + + 64 + 64 + + + + + 64 + 64 + + + + + + + + + + + + 64 + 64 + + + + + 64 + 64 + + + + + + + + + + + + + + + + - - - - 0 - 0 - - + - 800 - 128 + 240 + 0 - 16777215 - 95 + 240 + 16777215 - - - - - - - - 0 - 0 - - - - - 300 - 20 - - - - - 16777215 - 20 - - - - 65536 - - - Qt::Horizontal - - - - - - - - 65 - 16777215 - - - - 20:10:00 - - - - - - - - 5 - 16777215 - - - - / - - - - - - - - 65 - 16777215 - - - - 24:00:00 - - - - - - - - - - - - - - - 64 - 64 - - - - - 64 - 64 - - - - - - - - - - - - 64 - 64 - - - - - 64 - 64 - - - - - - - - - - - - 64 - 64 - - - - - 64 - 64 - - - - - - - - - - - - 64 - 64 - - - - - 64 - 64 - - - - - - - - - - - - 64 - 64 - - - - - 64 - 64 - - - - - - - - - - - - 64 - 64 - - - - - 64 - 64 - - - - - - - - - - - - 64 - 64 - - - - - 64 - 64 - - - - - - - - - - - - 0 - 0 - - - - - 100 - 20 - - - - - 100 - 20 - - - - Qt::Horizontal - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - 64 - 64 - - - - - 64 - 64 - - - - - - - - - - - - 64 - 64 - - - - - 64 - 64 - - - - - - - - - - - - 64 - 64 - - - - - 64 - 64 - - - - - - - - - - - - 64 - 64 - - - - - 64 - 64 - - - - - - - - - - - - - + + + @@ -440,8 +494,8 @@ 0 0 - 1115 - 22 + 1236 + 27 diff --git a/logo.ico b/logo.ico deleted file mode 100644 index 4a0d65d..0000000 Binary files a/logo.ico and /dev/null differ diff --git a/logo.png b/logo.png deleted file mode 100644 index 0c85b13..0000000 Binary files a/logo.png and /dev/null differ diff --git a/播放器.png b/res/logo.png similarity index 100% rename from 播放器.png rename to res/logo.png diff --git a/res/qss/homewindow.css b/res/qss/homewindow.css index 110cac9..4088f26 100644 --- a/res/qss/homewindow.css +++ b/res/qss/homewindow.css @@ -6,6 +6,7 @@ QMainWindow { border-style: none; } + .QToolButton { background-color: transparent; border-style: none; diff --git a/res/qss/homewindow.qss b/res/qss/homewindow.qss index c6db82d..b3fb0f9 100644 --- a/res/qss/homewindow.qss +++ b/res/qss/homewindow.qss @@ -1,27 +1,77 @@ -/*#COLOR#;MAIN_COLOR=#45b0c4;BTN_HOVER_COLOR=#6bc3ce;BTN_PRESSED_COLOR=#30889b;ITEM_HOVER_COLOR=#f1fcfc;ITEM_SELECTED_COLOR=#e9f4f4*/ -/**********窗口样式*************/ QMainWindow { - /* background: #FFFFFF; */ border-style: none; + color: white; + background-color: black; } -.QToolButton { - background-color: transparent; - /* border-style: none; */ - border: 1px solid #FFFFFF; - /* icon-size: 48px; */ - padding: 8px; - /* margin: 2px; */ - /* transition: all 0.3s ease; */ +QWidget { + border-style: none; + color: white; + background-color: black; } -.QToolButton::hover { + + +QWidget#ctrlBar > QLabel { + color: white; +} + +QPushButton { + color: white; +} + +QSlider::groove:horizontal, QSlider::add-page:horizontal { + background-color: #F3F4F4; + height: 8px; + border-radius: 3px; +} +QSlider::sub-page:horizontal { + height: 8px; + border-radius: 3px; + background-color: #F56C3C; +} +QSlider::handle:horizontal { + width: 13px; + margin-top: -3px; + margin-bottom: -3px; + border-radius: 6px;; + background-color: #F56C3C; +} +QSlider::handle:horizontal:hover { + background-color: #ef794e; +} + +QListView { + border: none; + selection-background-color: #F56C3C; + outline: 0px; +} + +QListView::item { + padding: 5px; + margin: 0px; + size: 16px; +} + +QListView::item:selected { + color: white; + background-color: #F56C3C; +} + +QListView::item:hover { + color: white; + background-color: #ef794e; +} + +QToolButton { background-color: transparent; border-style: none; - /* icon-size: 60px; */ - padding: 3px; - - + padding: 10px; +} +QToolButton:hover { + background-color: transparent; + border-style: none; + padding: 0px; } /*QGroupBox#typeGroupBox{ border:1px solid #45b0c4; diff --git a/res/qss/show.css b/res/qss/show.css index bfd3697..d30b415 100644 --- a/res/qss/show.css +++ b/res/qss/show.css @@ -3,4 +3,4 @@ QWidget{ color:white; border: 1px solid black; border-bottom: none; -} +} \ No newline at end of file diff --git a/resource.qrc b/resource.qrc index 5588cc1..ff9fd80 100644 --- a/resource.qrc +++ b/resource.qrc @@ -1,6 +1,6 @@ - logo.ico + res/logo.png res/qss/homewindow.qss @@ -16,6 +16,7 @@ res/radiobutton_checked.png res/radiobutton_checked_disable.png res/radiobutton_unchecked.png + res/qss/show.css res/icon/fast-backward.png diff --git a/setting.cpp b/setting.cpp index b154a29..675e86a 100644 --- a/setting.cpp +++ b/setting.cpp @@ -16,3 +16,27 @@ Setting::~Setting() { delete ui; } + +void Setting::on_bufDurationBox_currentIndexChanged(int index) +{ + emit sig_bufDurationBox_currentIndexChanged(index); +} + + +void Setting::on_jitterBufBox_currentIndexChanged(int index) +{ + emit sig_jitterBufBox_currentIndexChanged(index); +} + + +void Setting::on_audioBufEdit_editingFinished() +{ + emit sig_audioBufEdit_textChangded(ui->audioBufEdit->text()); +} + + +void Setting::on_videoBufEdit_editingFinished() +{ + emit sig_videoBufEdit_textChangded(ui->videoBufEdit->text()); +} + diff --git a/setting.h b/setting.h index d0604bd..933dbd6 100644 --- a/setting.h +++ b/setting.h @@ -15,6 +15,21 @@ public: explicit Setting(QWidget *parent = nullptr); ~Setting(); +signals: + void sig_bufDurationBox_currentIndexChanged(int); + void sig_jitterBufBox_currentIndexChanged(int); + void sig_audioBufEdit_textChangded(QString); + void sig_videoBufEdit_textChangded(QString); + +private slots: + void on_bufDurationBox_currentIndexChanged(int index); + + void on_jitterBufBox_currentIndexChanged(int index); + + void on_audioBufEdit_editingFinished(); + + void on_videoBufEdit_editingFinished(); + private: Ui::Setting *ui; }; diff --git a/setting.ui b/setting.ui index a1e1ba6..2dee731 100644 --- a/setting.ui +++ b/setting.ui @@ -13,255 +13,291 @@ Form - + - 80 - 90 - 274 - 79 + 180 + 200 + 45 + 22 - - - - - - 60 - 0 - - - - - 70 - 30 - - - - 音频缓存 - - - - - - - - 0 - 0 - - - - - 50 - 0 - - - - - 60 - 16777215 - - - - 视频缓存 - - - - - - - - 0 - 0 - - - - - 80 - 30 - - - - - 30ms - - - - - 100ms - - - - - 200ms - - - - - 400ms - - - - - 600ms - - - - - 800ms - - - - - 1000ms - - - - - - - - - 60 - 0 - - - - - 70 - 30 - - - - 视频缓存 - - - - - - - - 0 - 0 - - - - - 80 - 30 - - - - - 30ms - - - - - 100ms - - - - - 200ms - - - - - 400ms - - - - - 600ms - - - - - 800ms - - - - - 1000ms - - - - - 2000ms - - - - - 4000ms - - - - - - - - - 50 - 0 - - - - - 60 - 16777215 - - - - 音频缓存 - - - - - - - - 40 - 0 - - - - - 60 - 16777215 - - - - 缓存阈值 - - - - - - - - 0 - 0 - - - - - 40 - 0 - - - - - 60 - 16777215 - - - - 抖动值 - - - - + + + 0 + 0 + + + + + 40 + 0 + + + + + 60 + 16777215 + + + + 抖动值 + + + + + + 250 + 160 + 80 + 30 + + + + + 0 + 0 + + + + + 80 + 30 + + + + + 30ms + + + + + 100ms + + + + + 200ms + + + + + 400ms + + + + + 600ms + + + + + 800ms + + + + + 1000ms + + + + + 2000ms + + + + + 4000ms + + + + + + + 250 + 80 + 64 + 30 + + + + + 60 + 0 + + + + + 70 + 30 + + + + 音频缓存 + + + + + + 180 + 120 + 60 + 30 + + + + + 0 + 0 + + + + + 50 + 0 + + + + + 60 + 16777215 + + + + 视频缓存 + + + + + + 180 + 160 + 60 + 30 + + + + + 40 + 0 + + + + + 60 + 16777215 + + + + 缓存阈值 + + + + + + 250 + 200 + 80 + 30 + + + + + 0 + 0 + + + + + 80 + 30 + + + + + 30ms + + + + + 100ms + + + + + 200ms + + + + + 400ms + + + + + 600ms + + + + + 800ms + + + + + 1000ms + + + + + + + 180 + 80 + 60 + 30 + + + + + 50 + 0 + + + + + 60 + 16777215 + + + + 音频缓存 + + + + + + 250 + 120 + 64 + 30 + + + + + 60 + 0 + + + + + 70 + 30 + + + + 视频缓存 +