├── .gitignore ├── Bin ├── Image │ ├── Thumbs.db │ └── logo.png └── Skin │ └── skin_default.skin ├── ConfigDialog.cpp ├── ConfigDialog.h ├── Control ├── BaseWidget.cpp ├── BaseWidget.h ├── ObjectFourTuple.h ├── SButton.cpp ├── SButton.h ├── SProgressBar.cpp └── SProgressBar.h ├── LICENSE ├── LogoWidget.cpp ├── LogoWidget.h ├── README.md ├── Resource ├── Thumbs.db ├── backward.png ├── forward.png ├── full.png ├── headclose.png ├── headicon.png ├── headmax.png ├── headmin.png ├── headrestore.png ├── headskin.png ├── next.png ├── openfile.png ├── pause.png ├── play.png ├── pre.png ├── sound.png └── stop.png ├── SPlayer.pro ├── Snapshot └── SPlayer.png ├── StandardDialog ├── StandardBottom.cpp ├── StandardBottom.h ├── StandardDialog.cpp ├── StandardDialog.h ├── StandardHeader.cpp └── StandardHeader.h ├── Style ├── SStyle.cpp └── SStyle.h ├── WindowBottom.cpp ├── WindowBottom.h ├── WindowManager.cpp ├── WindowManager.h ├── main.cpp ├── mainwindow.cpp ├── mainwindow.h ├── pch.h └── res.qrc /.gitignore: -------------------------------------------------------------------------------- 1 | # C++ objects and libs 2 | 3 | *.slo 4 | *.lo 5 | *.o 6 | *.a 7 | *.la 8 | *.lai 9 | *.so 10 | *.dll 11 | *.dylib 12 | 13 | # Qt-es 14 | 15 | /.qmake.cache 16 | /.qmake.stash 17 | *.pro.user 18 | *.pro.user.* 19 | *.qbs.user 20 | *.qbs.user.* 21 | *.moc 22 | moc_*.cpp 23 | moc_*.h 24 | qrc_*.cpp 25 | ui_*.h 26 | Makefile* 27 | *build-* 28 | 29 | # QtCreator 30 | 31 | *.autosave 32 | 33 | # QtCtreator Qml 34 | *.qmlproject.user 35 | *.qmlproject.user.* 36 | 37 | # QtCtreator CMake 38 | CMakeLists.txt.user* 39 | 40 | -------------------------------------------------------------------------------- /Bin/Image/Thumbs.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xibeilang524/SPlayer-Qt-Framework/1eceb28c31c2b51933cfdeb4e91ee30371dd58d4/Bin/Image/Thumbs.db -------------------------------------------------------------------------------- /Bin/Image/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xibeilang524/SPlayer-Qt-Framework/1eceb28c31c2b51933cfdeb4e91ee30371dd58d4/Bin/Image/logo.png -------------------------------------------------------------------------------- /Bin/Skin/skin_default.skin: -------------------------------------------------------------------------------- 1 | StandardHeader QLabel { 2 | color:rgb(255,255,255); 3 | font-size:24px; 4 | } 5 | 6 | WindowBottom QLabel { 7 | color:rgb(255,255,255); 8 | font-size:16px; 9 | } 10 | 11 | QMenu { 12 | background-color:rgb(56,58,66); 13 | margin:0px 6px 0px 6px; 14 | } 15 | 16 | QMenu::item { 17 | background-color: transparent; 18 | color:rgb(255,255,255); 19 | } 20 | 21 | QMenu::item:selected { 22 | background-color:rgb(27,157,255); 23 | } 24 | 25 | QTabWidget::pane { 26 | border-top: 2px solid rgb(74,78,85); 27 | } 28 | 29 | QTabWidget::tab-bar { 30 | left: 2px; 31 | } 32 | 33 | QTabBar::tab { 34 | color:rgb(255,255,255); 35 | font:bold; 36 | background: rgb(55,58,65); 37 | padding: 8px; 38 | min-width: 130px; 39 | } 40 | 41 | QTabBar::tab:hover { 42 | background: rgb(105,191,255); 43 | } 44 | 45 | QTabBar::tab:selected { 46 | background: rgb(36,154,255); 47 | } 48 | 49 | QTabBar::tab:!selected { 50 | margin-top: 0px; 51 | } 52 | 53 | QPushButton { 54 | background-color:rgb(55,58,65); 55 | color:rgb(255,255,255); 56 | border: 2px solid rgb(94,94,94); 57 | border-radius: 4px; 58 | font: bold 14px; 59 | padding: 6px; 60 | min-width: 60px; 61 | } 62 | -------------------------------------------------------------------------------- /ConfigDialog.cpp: -------------------------------------------------------------------------------- 1 | #include "ConfigDialog.h" 2 | #include 3 | 4 | ConfigPage::ConfigPage(QWidget *parent):BaseWidget(parent) 5 | { 6 | m_pTabWidget = new QTabWidget(this); 7 | BaseWidget *pNormalSetting = new BaseWidget(); 8 | m_pTabWidget->addTab(pNormalSetting,tr("Normal Setting")); 9 | BaseWidget *pPlaySetting = new BaseWidget(); 10 | m_pTabWidget->addTab(pPlaySetting,tr("Play Setting")); 11 | 12 | QVBoxLayout *pBoxLayout = new QVBoxLayout(this); 13 | pBoxLayout->setContentsMargins(0,0,0,0); 14 | pBoxLayout->setSpacing(0); 15 | 16 | QLabel *lineTop = new QLabel(this); 17 | lineTop->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred); 18 | lineTop->setFixedHeight(1); 19 | QPalette palette = lineTop->palette(); 20 | palette.setColor(QPalette::Background,QColor(37,36,41)); 21 | lineTop->setPalette(palette); 22 | lineTop->setAutoFillBackground(true); 23 | pBoxLayout->addWidget(lineTop); 24 | pBoxLayout->addWidget(m_pTabWidget); 25 | QLabel *lineBottom = new QLabel(this); 26 | lineBottom->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred); 27 | lineBottom->setFixedHeight(1); 28 | lineBottom->setPalette(palette); 29 | lineBottom->setAutoFillBackground(true); 30 | pBoxLayout->addWidget(lineBottom); 31 | } 32 | 33 | ConfigPage::~ConfigPage() 34 | { 35 | 36 | } 37 | 38 | ConfigBottom::ConfigBottom(QWidget *parent):BaseWidget(parent) 39 | { 40 | //OK按钮 41 | m_pOK = new QPushButton(tr("OK"),this); 42 | //Cancel按钮 43 | m_pCancle = new QPushButton(tr("Cancle"),this); 44 | //Apply按钮 45 | m_pApply = new QPushButton(tr("Apply"),this); 46 | //使用布局 47 | QHBoxLayout *pHBoxLayout = new QHBoxLayout(this); 48 | pHBoxLayout->setContentsMargins(0,0,10,0); 49 | pHBoxLayout->setSpacing(10); 50 | pHBoxLayout->addStretch(1); 51 | pHBoxLayout->addWidget(m_pOK); 52 | pHBoxLayout->addWidget(m_pCancle); 53 | pHBoxLayout->addWidget(m_pApply); 54 | } 55 | 56 | ConfigBottom::~ConfigBottom() 57 | { 58 | } 59 | 60 | 61 | ConfigDialog::ConfigDialog(QWidget *parent):StandardDialog(parent) 62 | { 63 | setWindowFlags(Qt::FramelessWindowHint | Qt::Tool); 64 | 65 | QPalette palette = this->palette(); 66 | palette.setColor(QPalette::Background,QColor(55,58,65)); 67 | this->setPalette(palette); 68 | this->setAutoFillBackground(true); 69 | //设置头部以及底部属性 70 | GetHeader()->SetTitleText(tr("Option")); 71 | GetHeader()->SetTitleCenter(false); 72 | GetHeader()->SetLogoVisible(false); 73 | GetHeader()->SetSkinVisible(false); 74 | GetHeader()->SetMinVisible(false); 75 | GetHeader()->SetMaxVisible(false); 76 | GetHeader()->GetBgColor().SetAllState(QColor(56,58,66)); 77 | GetHeader()->setFixedHeight(40); 78 | GetBottom()->GetBgColor().SetAllState(QColor(56,58,66)); 79 | GetBottom()->setFixedHeight(50); 80 | //设置为不能对窗口进行伸缩 81 | SetFixed(true); 82 | 83 | m_pConfigPage = new ConfigPage(this); 84 | 85 | SetCenterWidget(m_pConfigPage); 86 | 87 | m_pConfigBottom = new ConfigBottom(this); 88 | 89 | SetBottomWidget(m_pConfigBottom); 90 | } 91 | 92 | ConfigDialog::~ConfigDialog() 93 | { 94 | 95 | } 96 | -------------------------------------------------------------------------------- /ConfigDialog.h: -------------------------------------------------------------------------------- 1 | #ifndef CONFIGDIALOG_H 2 | #define CONFIGDIALOG_H 3 | 4 | #include 5 | #include 6 | #include "StandardDialog/StandardDialog.h" 7 | #include "Control/BaseWidget.h" 8 | 9 | class ConfigPage : public BaseWidget 10 | { 11 | public: 12 | ConfigPage(QWidget *parent = 0); 13 | virtual ~ConfigPage(); 14 | private: 15 | QTabWidget *m_pTabWidget; 16 | }; 17 | 18 | class ConfigBottom : public BaseWidget 19 | { 20 | public: 21 | ConfigBottom(QWidget *parent); 22 | virtual ~ConfigBottom(); 23 | 24 | private: 25 | QPushButton *m_pOK; 26 | QPushButton *m_pCancle; 27 | QPushButton *m_pApply; 28 | }; 29 | 30 | //设置界面,继承于StandardDialog 31 | class ConfigDialog : public StandardDialog 32 | { 33 | 34 | public: 35 | ConfigDialog(QWidget *parent = 0); 36 | virtual ~ConfigDialog(); 37 | 38 | private: 39 | ConfigPage *m_pConfigPage; 40 | ConfigBottom *m_pConfigBottom; 41 | }; 42 | 43 | #endif // CONFIGDIALOG_H 44 | -------------------------------------------------------------------------------- /Control/BaseWidget.cpp: -------------------------------------------------------------------------------- 1 | #include "BaseWidget.h" 2 | #include 3 | 4 | BaseWidget::BaseWidget(QWidget *parent) : QWidget(parent) 5 | ,m_margin(0,0,0,0) 6 | ,m_bEnter(false) 7 | ,m_bPress(false) 8 | { 9 | setMouseTracking(true); 10 | } 11 | 12 | BaseWidget::~BaseWidget() 13 | { 14 | 15 | } 16 | 17 | ObjectFourTuple &BaseWidget::GetBgColor() 18 | { 19 | return m_bgColor; 20 | } 21 | 22 | void BaseWidget::enterEvent(QEvent *event) 23 | { 24 | //qDebug() << "BaseWidget::enterEvent"; 25 | 26 | if(!m_bEnter) 27 | { 28 | ResetState(); 29 | m_bEnter = true; 30 | update(); 31 | } 32 | 33 | QWidget::enterEvent(event); 34 | } 35 | 36 | void BaseWidget::leaveEvent(QEvent *event) 37 | { 38 | //qDebug() << "BaseWidget::leaveEvent"; 39 | 40 | if(m_bEnter) 41 | { 42 | ResetState(); 43 | update(); 44 | } 45 | 46 | QWidget::leaveEvent(event); 47 | } 48 | 49 | void BaseWidget::mousePressEvent(QMouseEvent *event) 50 | { 51 | //qDebug() << "BaseWidget::mousePressEvent"; 52 | 53 | if(!m_bPress) 54 | { 55 | ResetState(); 56 | m_bPress = true; 57 | update(); 58 | } 59 | 60 | QWidget::mousePressEvent(event); 61 | } 62 | 63 | void BaseWidget::mouseReleaseEvent(QMouseEvent *event) 64 | { 65 | //qDebug() << "BaseWidget::mouseReleaseEvent"; 66 | 67 | if(m_bPress) 68 | { 69 | ResetState(); 70 | update(); 71 | emit Signal_Clicked(); 72 | } 73 | 74 | QWidget::mouseReleaseEvent(event); 75 | } 76 | 77 | void BaseWidget::paintEvent(QPaintEvent *event) 78 | { 79 | QColor bgColor; 80 | QPen borderPen; 81 | 82 | if(!isEnabled()) 83 | { 84 | bgColor = m_bgColor.GetDisableState(); 85 | borderPen = m_borderPen.GetDisableState(); 86 | } 87 | else 88 | { 89 | if(m_bEnter) 90 | { 91 | bgColor = m_bgColor.GetOverState(); 92 | borderPen = m_borderPen.GetOverState(); 93 | } 94 | else if(m_bPress) 95 | { 96 | bgColor = m_bgColor.GetPressState(); 97 | borderPen = m_borderPen.GetPressState(); 98 | 99 | } 100 | else 101 | { 102 | bgColor = m_bgColor.GetNormalState(); 103 | borderPen = m_borderPen.GetNormalState(); 104 | } 105 | } 106 | 107 | QPainter painter(this); 108 | painter.setRenderHint(QPainter::Antialiasing); 109 | if(bgColor.isValid()) 110 | { 111 | painter.fillRect(rect(),bgColor); 112 | } 113 | if(!m_margin.isNull()) 114 | { 115 | painter.setPen(borderPen); 116 | painter.drawRect(rect().adjusted(m_margin.left(),m_margin.top(),-(m_margin.right()),-(m_margin.bottom()))); 117 | } 118 | 119 | QWidget::paintEvent(event); 120 | } 121 | 122 | void BaseWidget::ResetState() 123 | { 124 | m_bEnter = false; 125 | m_bPress = false; 126 | } 127 | -------------------------------------------------------------------------------- /Control/BaseWidget.h: -------------------------------------------------------------------------------- 1 | #ifndef BASEWIDGET_H 2 | #define BASEWIDGET_H 3 | 4 | #include 5 | #include "ObjectFourTuple.h" 6 | 7 | //控件基类,用于公共属性、公共行为的抽象 8 | class BaseWidget : public QWidget 9 | { 10 | Q_OBJECT 11 | public: 12 | explicit BaseWidget(QWidget *parent = 0); 13 | virtual ~BaseWidget(); 14 | 15 | //信号定义 16 | signals: 17 | void Signal_Clicked(); 18 | 19 | public: 20 | ObjectFourTuple& GetBgColor(); 21 | 22 | //事件重载 23 | protected: 24 | virtual void enterEvent(QEvent *event); 25 | virtual void leaveEvent(QEvent *event); 26 | virtual void mousePressEvent(QMouseEvent *event); 27 | virtual void mouseReleaseEvent(QMouseEvent *event); 28 | //重绘处理 29 | virtual void paintEvent(QPaintEvent *event); 30 | 31 | private: 32 | void ResetState(); 33 | 34 | private: 35 | ObjectFourTuple m_bgColor; 36 | QMargins m_margin; 37 | ObjectFourTuple m_borderPen; 38 | 39 | protected: 40 | bool m_bEnter; 41 | bool m_bPress; 42 | }; 43 | 44 | #endif // BASEWIDGET_H 45 | -------------------------------------------------------------------------------- /Control/ObjectFourTuple.h: -------------------------------------------------------------------------------- 1 | #ifndef OBJECTFOURTUPLE_H 2 | #define OBJECTFOURTUPLE_H 3 | 4 | 5 | template 6 | class ObjectFourTuple 7 | { 8 | public: 9 | ObjectFourTuple(){} 10 | ~ObjectFourTuple(){} 11 | 12 | public: 13 | //Set 14 | void SetNormalState(T normalState) 15 | { 16 | m_normalState = normalState; 17 | } 18 | 19 | void SetOverState(T overState) 20 | { 21 | m_overState = overState; 22 | } 23 | 24 | void SetPressState(T pressState) 25 | { 26 | m_pressState = pressState; 27 | } 28 | 29 | void SetDisableState(T disableState) 30 | { 31 | m_disableState = disableState; 32 | } 33 | void SetAllState(T state) 34 | { 35 | SetNormalState(state); 36 | SetOverState(state); 37 | SetPressState(state); 38 | SetDisableState(state); 39 | } 40 | 41 | //Get 42 | T GetNormalState() 43 | { 44 | return m_normalState; 45 | } 46 | T GetOverState() 47 | { 48 | return m_overState; 49 | } 50 | T GetPressState() 51 | { 52 | return m_pressState; 53 | } 54 | T GetDisableState() 55 | { 56 | return m_disableState; 57 | } 58 | 59 | private: 60 | T m_normalState; 61 | T m_overState; 62 | T m_pressState; 63 | T m_disableState; 64 | }; 65 | 66 | #endif // OBJECTFOURTUPLE_H 67 | -------------------------------------------------------------------------------- /Control/SButton.cpp: -------------------------------------------------------------------------------- 1 | #include "SButton.h" 2 | #include 3 | #include 4 | 5 | SButton::SButton(QWidget *parent):BaseWidget(parent) 6 | { 7 | 8 | } 9 | 10 | SButton::~SButton() 11 | { 12 | 13 | } 14 | 15 | void SButton::AppendImage(const QImage &image) 16 | { 17 | m_listImage.append(image); 18 | update(); 19 | } 20 | 21 | void SButton::ChangeImage(int index,const QImage &image) 22 | { 23 | if(index >= m_listImage.size()) 24 | { 25 | Q_ASSERT(false); 26 | return; 27 | } 28 | 29 | m_listImage[index] = image; 30 | 31 | update(); 32 | } 33 | 34 | void SButton::mouseMoveEvent(QMouseEvent *event) 35 | { 36 | BaseWidget::mouseMoveEvent(event); 37 | //event->accept(); 38 | } 39 | 40 | void SButton::mouseDoubleClickEvent(QMouseEvent *event) 41 | { 42 | BaseWidget::mouseDoubleClickEvent(event); 43 | event->accept(); 44 | } 45 | 46 | //按钮的不同状态,变换图片显示 47 | void SButton::paintEvent(QPaintEvent *event) 48 | { 49 | BaseWidget::paintEvent(event); 50 | 51 | QPainter painter(this); 52 | painter.setRenderHints(QPainter::Antialiasing); 53 | 54 | //nStateIndex 按钮状态表示 55 | int nStateIndex = -1; 56 | 57 | if(!isEnabled()) 58 | { 59 | nStateIndex = 3; //Disable 60 | } 61 | else 62 | { 63 | if(m_bEnter) 64 | { 65 | nStateIndex = 1; //Enter 66 | } 67 | else if(m_bPress) 68 | { 69 | nStateIndex = 2; //Press 70 | } 71 | else 72 | { 73 | nStateIndex = 0; //Normal 74 | } 75 | } 76 | if(nStateIndex < 0 ) 77 | { 78 | Q_ASSERT(false); 79 | } 80 | 81 | //一个状态用图片的1/4来显示 82 | int imageCount = m_listImage.size(); 83 | 84 | for(int i=0; i m_listImage; 25 | }; 26 | 27 | #endif // SBUTTON_H 28 | -------------------------------------------------------------------------------- /Control/SProgressBar.cpp: -------------------------------------------------------------------------------- 1 | #include "SProgressBar.h" 2 | #include 3 | 4 | SProgressBar::SProgressBar(QWidget *parent):BaseWidget(parent) 5 | ,m_currentProgress(0) 6 | { 7 | 8 | } 9 | 10 | SProgressBar::~SProgressBar() 11 | { 12 | 13 | } 14 | 15 | void SProgressBar::SetCurrentProgress(int currentProgress) 16 | { 17 | m_currentProgress = currentProgress; 18 | 19 | update(); 20 | } 21 | 22 | void SProgressBar::paintEvent(QPaintEvent *event) 23 | { 24 | QPainter objPainter(this); 25 | objPainter.setRenderHint(QPainter::Antialiasing); 26 | //绘背景 27 | objPainter.fillRect(rect(),QColor(31,31,31)); 28 | //绘内容区背景 29 | objPainter.fillRect(contentsRect(),QColor(78,78,78)); 30 | int nWidth = contentsRect().width() * m_currentProgress /100; 31 | //绘进度条背景; 32 | objPainter.fillRect(contentsRect().x(),contentsRect().y(),nWidth,contentsRect().height(),QColor(26,158,255)); 33 | 34 | BaseWidget::paintEvent(event); 35 | } 36 | -------------------------------------------------------------------------------- /Control/SProgressBar.h: -------------------------------------------------------------------------------- 1 | #ifndef SPROGRESSBAR_H 2 | #define SPROGRESSBAR_H 3 | 4 | #include "BaseWidget.h" 5 | 6 | //进度条控件,总进度值为100 7 | class SProgressBar : public BaseWidget 8 | { 9 | public: 10 | SProgressBar(QWidget *parent = 0); 11 | virtual ~SProgressBar(); 12 | 13 | public: 14 | //设置当前进度值,在0~100之间 15 | void SetCurrentProgress(int currentProgress); 16 | 17 | protected: 18 | virtual void paintEvent(QPaintEvent *event); 19 | 20 | public: 21 | int m_currentProgress; 22 | }; 23 | 24 | #endif // SPROGRESSBAR_H 25 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 赵宇航 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /LogoWidget.cpp: -------------------------------------------------------------------------------- 1 | #include "LogoWidget.h" 2 | #include 3 | 4 | LogoWidget::LogoWidget(QWidget *parent):BaseWidget(parent) 5 | { 6 | setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding); 7 | 8 | m_pOpenFile = new SButton(this); 9 | QImage image(":/Image/Resource/openfile.png"); 10 | m_pOpenFile->setFixedHeight(image.height()); 11 | m_pOpenFile->setFixedWidth(image.width()/4); 12 | m_pOpenFile->AppendImage(image); 13 | } 14 | 15 | LogoWidget::~LogoWidget() 16 | { 17 | 18 | } 19 | 20 | void LogoWidget::SetLogoImage(const QString &imageFilePath) 21 | { 22 | m_logoImage = QImage(imageFilePath); 23 | update(); 24 | } 25 | 26 | void LogoWidget::paintEvent(QPaintEvent *event) 27 | { 28 | QPainter painter(this); 29 | painter.setRenderHint(QPainter::Antialiasing); 30 | painter.drawImage(QPoint(0,0),m_logoImage.scaled(size())); 31 | 32 | BaseWidget::paintEvent(event); 33 | } 34 | 35 | void LogoWidget::resizeEvent(QResizeEvent *event) 36 | { 37 | m_pOpenFile->move(rect().center().x() - m_pOpenFile->width()/2,rect().center().y() + m_pOpenFile->height()+10); 38 | BaseWidget::resizeEvent(event); 39 | } 40 | -------------------------------------------------------------------------------- /LogoWidget.h: -------------------------------------------------------------------------------- 1 | #ifndef LOGOWIDGET_H 2 | #define LOGOWIDGET_H 3 | 4 | #include "Control/BaseWidget.h" 5 | #include "Control/SButton.h" 6 | 7 | class LogoWidget : public BaseWidget 8 | { 9 | public: 10 | LogoWidget(QWidget *parent = 0); 11 | virtual ~LogoWidget(); 12 | 13 | public: 14 | void SetLogoImage(const QString &imageFilePath); 15 | 16 | protected: 17 | virtual void paintEvent(QPaintEvent *event); 18 | virtual void resizeEvent(QResizeEvent *event); 19 | 20 | private: 21 | QImage m_logoImage; 22 | SButton *m_pOpenFile; 23 | 24 | }; 25 | 26 | #endif // LOGOWIDGET_H 27 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # SPlayer-Qt-Framework 2 | SPlayer项目的Qt界面代码,界面是用纯代码实现的,没有借助Qt设计师,也没有任何业务逻辑代码。此代码实现了一个窗口应有的大部分功能,若需要其他功能请自行扩展。 3 | 4 | ## 效果图 5 | ![01](/Snapshot/SPlayer.png) 6 | -------------------------------------------------------------------------------- /Resource/Thumbs.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xibeilang524/SPlayer-Qt-Framework/1eceb28c31c2b51933cfdeb4e91ee30371dd58d4/Resource/Thumbs.db -------------------------------------------------------------------------------- /Resource/backward.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xibeilang524/SPlayer-Qt-Framework/1eceb28c31c2b51933cfdeb4e91ee30371dd58d4/Resource/backward.png -------------------------------------------------------------------------------- /Resource/forward.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xibeilang524/SPlayer-Qt-Framework/1eceb28c31c2b51933cfdeb4e91ee30371dd58d4/Resource/forward.png -------------------------------------------------------------------------------- /Resource/full.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xibeilang524/SPlayer-Qt-Framework/1eceb28c31c2b51933cfdeb4e91ee30371dd58d4/Resource/full.png -------------------------------------------------------------------------------- /Resource/headclose.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xibeilang524/SPlayer-Qt-Framework/1eceb28c31c2b51933cfdeb4e91ee30371dd58d4/Resource/headclose.png -------------------------------------------------------------------------------- /Resource/headicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xibeilang524/SPlayer-Qt-Framework/1eceb28c31c2b51933cfdeb4e91ee30371dd58d4/Resource/headicon.png -------------------------------------------------------------------------------- /Resource/headmax.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xibeilang524/SPlayer-Qt-Framework/1eceb28c31c2b51933cfdeb4e91ee30371dd58d4/Resource/headmax.png -------------------------------------------------------------------------------- /Resource/headmin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xibeilang524/SPlayer-Qt-Framework/1eceb28c31c2b51933cfdeb4e91ee30371dd58d4/Resource/headmin.png -------------------------------------------------------------------------------- /Resource/headrestore.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xibeilang524/SPlayer-Qt-Framework/1eceb28c31c2b51933cfdeb4e91ee30371dd58d4/Resource/headrestore.png -------------------------------------------------------------------------------- /Resource/headskin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xibeilang524/SPlayer-Qt-Framework/1eceb28c31c2b51933cfdeb4e91ee30371dd58d4/Resource/headskin.png -------------------------------------------------------------------------------- /Resource/next.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xibeilang524/SPlayer-Qt-Framework/1eceb28c31c2b51933cfdeb4e91ee30371dd58d4/Resource/next.png -------------------------------------------------------------------------------- /Resource/openfile.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xibeilang524/SPlayer-Qt-Framework/1eceb28c31c2b51933cfdeb4e91ee30371dd58d4/Resource/openfile.png -------------------------------------------------------------------------------- /Resource/pause.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xibeilang524/SPlayer-Qt-Framework/1eceb28c31c2b51933cfdeb4e91ee30371dd58d4/Resource/pause.png -------------------------------------------------------------------------------- /Resource/play.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xibeilang524/SPlayer-Qt-Framework/1eceb28c31c2b51933cfdeb4e91ee30371dd58d4/Resource/play.png -------------------------------------------------------------------------------- /Resource/pre.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xibeilang524/SPlayer-Qt-Framework/1eceb28c31c2b51933cfdeb4e91ee30371dd58d4/Resource/pre.png -------------------------------------------------------------------------------- /Resource/sound.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xibeilang524/SPlayer-Qt-Framework/1eceb28c31c2b51933cfdeb4e91ee30371dd58d4/Resource/sound.png -------------------------------------------------------------------------------- /Resource/stop.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xibeilang524/SPlayer-Qt-Framework/1eceb28c31c2b51933cfdeb4e91ee30371dd58d4/Resource/stop.png -------------------------------------------------------------------------------- /SPlayer.pro: -------------------------------------------------------------------------------- 1 | #------------------------------------------------- 2 | # 3 | # Project created by QtCreator 2017-04-23T18:07:10 4 | # 5 | #------------------------------------------------- 6 | 7 | QT += core gui 8 | 9 | greaterThan(QT_MAJOR_VERSION, 4): QT += widgets 10 | 11 | TARGET = SPlayer 12 | TEMPLATE = app 13 | 14 | INCLUDEPATH = ./ 15 | 16 | PRECOMPILED_HEADER = PCH.h 17 | 18 | DESTDIR += $$PWD/Bin/ 19 | 20 | # The following define makes your compiler emit warnings if you use 21 | # any feature of Qt which as been marked as deprecated (the exact warnings 22 | # depend on your compiler). Please consult the documentation of the 23 | # deprecated API in order to know how to port your code away from it. 24 | DEFINES += QT_DEPRECATED_WARNINGS 25 | 26 | # You can also make your code fail to compile if you use deprecated APIs. 27 | # In order to do so, uncomment the following line. 28 | # You can also select to disable deprecated APIs only up to a certain version of Qt. 29 | #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 30 | 31 | 32 | SOURCES += main.cpp\ 33 | mainwindow.cpp \ 34 | StandardDialog/StandardDialog.cpp \ 35 | StandardDialog/StandardHeader.cpp \ 36 | Control/BaseWidget.cpp \ 37 | Control/SButton.cpp \ 38 | WindowManager.cpp \ 39 | Style/SStyle.cpp \ 40 | StandardDialog/StandardBottom.cpp \ 41 | LogoWidget.cpp \ 42 | WindowBottom.cpp \ 43 | Control/SProgressBar.cpp \ 44 | ConfigDialog.cpp 45 | 46 | HEADERS += mainwindow.h \ 47 | StandardDialog/StandardDialog.h \ 48 | StandardDialog/StandardHeader.h \ 49 | Control/BaseWidget.h \ 50 | Control/ObjectFourTuple.h \ 51 | Control/SButton.h \ 52 | WindowManager.h \ 53 | pch.h \ 54 | Style/SStyle.h \ 55 | StandardDialog/StandardBottom.h \ 56 | LogoWidget.h \ 57 | WindowBottom.h \ 58 | Control/SProgressBar.h \ 59 | ConfigDialog.h 60 | 61 | RESOURCES += \ 62 | res.qrc 63 | -------------------------------------------------------------------------------- /Snapshot/SPlayer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xibeilang524/SPlayer-Qt-Framework/1eceb28c31c2b51933cfdeb4e91ee30371dd58d4/Snapshot/SPlayer.png -------------------------------------------------------------------------------- /StandardDialog/StandardBottom.cpp: -------------------------------------------------------------------------------- 1 | #include "StandardBottom.h" 2 | 3 | StandardBottom::StandardBottom(QWidget *parent):BaseWidget(parent) 4 | { 5 | m_pHBoxLayout = new QHBoxLayout(this); 6 | m_pHBoxLayout->setContentsMargins(0,0,0,0); 7 | m_pHBoxLayout->setSpacing(0); 8 | } 9 | 10 | StandardBottom::~StandardBottom() 11 | { 12 | 13 | } 14 | 15 | void StandardBottom::AddWidget(QWidget *pWidget) 16 | { 17 | pWidget->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding); 18 | pWidget->setMouseTracking(true); 19 | 20 | m_pHBoxLayout->addWidget(pWidget); 21 | } 22 | -------------------------------------------------------------------------------- /StandardDialog/StandardBottom.h: -------------------------------------------------------------------------------- 1 | #ifndef STANDARDBOTTOM_H 2 | #define STANDARDBOTTOM_H 3 | 4 | #include 5 | #include "Control/BaseWidget.h" 6 | 7 | //界面底部基类 8 | class StandardBottom : public BaseWidget 9 | { 10 | public: 11 | explicit StandardBottom(QWidget *parent = 0); 12 | virtual ~StandardBottom(); 13 | 14 | public: 15 | void AddWidget(QWidget *pWidget); 16 | 17 | public: 18 | QHBoxLayout *m_pHBoxLayout; 19 | }; 20 | 21 | #endif // STANDARDBOTTOM_H 22 | -------------------------------------------------------------------------------- /StandardDialog/StandardDialog.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "StandardDialog.h" 4 | 5 | StandardDialog::StandardDialog(QWidget *parent) : BaseWidget(parent) 6 | ,m_bDialogMaxed(false),m_bFixedSize(false) 7 | { 8 | m_pHeader = new StandardHeader(this); 9 | m_pBottom = new StandardBottom(this); 10 | 11 | m_pVBoxLayout = new QVBoxLayout(this); 12 | m_pVBoxLayout->setContentsMargins(0,0,0,0); 13 | m_pVBoxLayout->setSpacing(0); 14 | m_pVBoxLayout->addWidget(m_pHeader); 15 | m_pVBoxLayout->addWidget(m_pBottom); 16 | 17 | connect(m_pHeader,SIGNAL(Signal_LogoClicked()),this,SLOT(Slot_LogoClicked())); 18 | connect(m_pHeader,SIGNAL(Signal_SkinClicked()),this,SLOT(Slot_SkinClicked())); 19 | connect(m_pHeader,SIGNAL(Signal_MinClicked()),this,SLOT(Slot_MinClicked())); 20 | connect(m_pHeader,SIGNAL(Signal_MaxClicked()),this,SLOT(Slot_MaxClicked())); 21 | connect(m_pHeader,SIGNAL(Signal_CloseClicked()),this,SLOT(Slot_CloseClicked())); 22 | connect(m_pHeader,SIGNAL(Signal_MouseDoubleClicked()),this,SLOT(Slot_MouseDoubleClicked())); 23 | } 24 | 25 | StandardDialog::~StandardDialog() 26 | { 27 | 28 | } 29 | 30 | StandardHeader *StandardDialog::GetHeader() 31 | { 32 | return m_pHeader; 33 | } 34 | 35 | StandardBottom *StandardDialog::GetBottom() 36 | { 37 | return m_pBottom; 38 | } 39 | 40 | void StandardDialog::SetFixed(bool bFixedSize) 41 | { 42 | m_bFixedSize = bFixedSize; 43 | } 44 | 45 | bool StandardDialog::GetFixed() 46 | { 47 | return m_bFixedSize; 48 | } 49 | 50 | void StandardDialog::mousePressEvent(QMouseEvent *event) 51 | { 52 | m_sourcePos = event->globalPos(); 53 | 54 | BaseWidget::mousePressEvent(event); 55 | 56 | } 57 | 58 | //实现拖动以及伸缩窗口效果 59 | void StandardDialog::mouseMoveEvent(QMouseEvent *event) 60 | { 61 | QPoint pt = event->pos(); 62 | 63 | if(!m_sourcePos.isNull()) 64 | { 65 | pt = mapFromGlobal(m_sourcePos); 66 | } 67 | 68 | bool bResize = true; 69 | 70 | QRect dialogGeometry = geometry(); 71 | 72 | int dx = event->globalX() - m_sourcePos.x(); 73 | int dy = event->globalY() - m_sourcePos.y(); 74 | 75 | //qDebug() << "StandardDialog::mouseMoveEvent::" << dx << "__" << dy <<"__"<globalPos() - m_sourcePos)); 169 | } 170 | } 171 | 172 | m_sourcePos = event->globalPos(); 173 | } 174 | } 175 | 176 | void StandardDialog::mouseReleaseEvent(QMouseEvent *event) 177 | { 178 | m_sourcePos = QPoint(); 179 | 180 | BaseWidget::mouseReleaseEvent(event); 181 | } 182 | 183 | void StandardDialog::Slot_LogoClicked() 184 | { 185 | 186 | } 187 | 188 | void StandardDialog::Slot_SkinClicked() 189 | { 190 | 191 | } 192 | 193 | void StandardDialog::Slot_MinClicked() 194 | { 195 | showMinimized(); 196 | } 197 | 198 | //m_restoreGeometry::保留用于还原显示的窗口几何信息 199 | void StandardDialog::Slot_MaxClicked() 200 | { 201 | if(m_bDialogMaxed)//还原 202 | { 203 | setGeometry(m_restoreGeometry); 204 | m_pHeader->SetMaxImage(); 205 | } 206 | else //最大化 207 | { 208 | m_restoreGeometry = geometry(); 209 | setGeometry(qApp->desktop()->availableGeometry()); 210 | m_pHeader->SetRestoreImage(); 211 | } 212 | 213 | m_bDialogMaxed = !m_bDialogMaxed; 214 | } 215 | 216 | void StandardDialog::Slot_CloseClicked() 217 | { 218 | close(); 219 | } 220 | 221 | void StandardDialog::Slot_MouseDoubleClicked() 222 | { 223 | Slot_MaxClicked(); 224 | } 225 | 226 | void StandardDialog::SetCenterWidget(QWidget *pCenterWidget) 227 | { 228 | if(pCenterWidget) 229 | { 230 | pCenterWidget->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding); 231 | int index = m_pVBoxLayout->indexOf(m_pHeader); 232 | m_pVBoxLayout->insertWidget(index+1,pCenterWidget); 233 | } 234 | } 235 | 236 | void StandardDialog::SetBottomWidget(QWidget *pBottomWidget) 237 | { 238 | if(pBottomWidget) 239 | { 240 | pBottomWidget->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding); 241 | m_pBottom->AddWidget(pBottomWidget); 242 | } 243 | } 244 | 245 | -------------------------------------------------------------------------------- /StandardDialog/StandardDialog.h: -------------------------------------------------------------------------------- 1 | #ifndef STANDARDDIALOG_H 2 | #define STANDARDDIALOG_H 3 | 4 | #include 5 | #include "StandardHeader.h" 6 | #include "StandardBottom.h" 7 | #include "Control/BaseWidget.h" 8 | 9 | class StandardDialog : public BaseWidget 10 | { 11 | Q_OBJECT 12 | 13 | public: 14 | explicit StandardDialog(QWidget *parent = 0); 15 | virtual ~StandardDialog(); 16 | 17 | public: 18 | StandardHeader *GetHeader(); 19 | StandardBottom *GetBottom(); 20 | 21 | public: 22 | void SetFixed(bool bFixedSize); 23 | bool GetFixed(); 24 | 25 | protected: 26 | virtual void mousePressEvent(QMouseEvent *event); 27 | virtual void mouseMoveEvent(QMouseEvent *event); 28 | virtual void mouseReleaseEvent(QMouseEvent *event); 29 | 30 | protected slots: 31 | virtual void Slot_LogoClicked(); 32 | virtual void Slot_SkinClicked(); 33 | virtual void Slot_MinClicked(); 34 | virtual void Slot_MaxClicked(); 35 | virtual void Slot_CloseClicked(); 36 | virtual void Slot_MouseDoubleClicked(); 37 | 38 | protected: 39 | void SetCenterWidget(QWidget *pCenterWidget); 40 | void SetBottomWidget(QWidget *pBottomWidget); 41 | 42 | private: 43 | StandardHeader *m_pHeader; 44 | StandardBottom *m_pBottom; 45 | QVBoxLayout *m_pVBoxLayout; 46 | bool m_bDialogMaxed; 47 | QRect m_restoreGeometry; 48 | QPoint m_sourcePos; 49 | bool m_bFixedSize; 50 | }; 51 | 52 | #endif // STANDARDDIALOG_H 53 | -------------------------------------------------------------------------------- /StandardDialog/StandardHeader.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "StandardHeader.h" 4 | 5 | StandardHeader::StandardHeader(QWidget *parent) : BaseWidget(parent) 6 | { 7 | QImage image; 8 | m_pLogo = new SButton(this); 9 | image = QImage(":/Image/Resource/headicon.png"); 10 | m_pLogo->AppendImage(image); 11 | m_pLogo->setFixedSize(image.width()/4,image.height()); 12 | m_pTitle = new QLabel(this); 13 | m_pTitle->setMouseTracking(true); 14 | m_pSkin = new SButton(this); 15 | image = QImage(":/Image/Resource/headskin.png"); 16 | m_pSkin->AppendImage(image); 17 | m_pSkin->setFixedSize(image.width()/4,image.height()); 18 | m_pMin = new SButton(this); 19 | image = QImage(":/Image/Resource/headmin.png"); 20 | m_pMin->AppendImage(image); 21 | m_pMin->setFixedSize(image.width()/4,image.height()); 22 | m_pMax = new SButton(this); 23 | image = QImage(":/Image/Resource/headmax.png"); 24 | m_pMax->AppendImage(image); 25 | m_pMax->setFixedSize(image.width()/4,image.height()); 26 | m_pClose = new SButton(this); 27 | image = QImage(":/Image/Resource/headclose.png"); 28 | m_pClose->AppendImage(image); 29 | m_pClose->setFixedSize(image.width()/4,image.height()); 30 | 31 | CreateLayout(); 32 | 33 | connect(m_pLogo,SIGNAL(Signal_Clicked()),this,SIGNAL(Signal_LogoClicked())); 34 | connect(m_pSkin,SIGNAL(Signal_Clicked()),this,SIGNAL(Signal_SkinClicked())); 35 | connect(m_pMin,SIGNAL(Signal_Clicked()),this,SIGNAL(Signal_MinClicked())); 36 | connect(m_pMax,SIGNAL(Signal_Clicked()),this,SIGNAL(Signal_MaxClicked())); 37 | connect(m_pClose,SIGNAL(Signal_Clicked()),this,SIGNAL(Signal_CloseClicked())); 38 | } 39 | 40 | StandardHeader::~StandardHeader() 41 | { 42 | 43 | } 44 | 45 | void StandardHeader::SetLogoVisible(bool bVisible) 46 | { 47 | m_pLogo->setVisible(bVisible); 48 | } 49 | 50 | void StandardHeader::SetTitleText(const QString &str) 51 | { 52 | m_pTitle->setText(str); 53 | } 54 | 55 | void StandardHeader::SetTitleCenter(bool bCenter) 56 | { 57 | if(bCenter) 58 | { 59 | m_pTitle->setAlignment(Qt::AlignCenter); 60 | } 61 | else 62 | { 63 | m_pTitle->setAlignment(Qt::AlignLeft | Qt::AlignVCenter); 64 | } 65 | } 66 | 67 | void StandardHeader::SetSkinVisible(bool bVisible) 68 | { 69 | m_pSkin->setVisible(bVisible); 70 | } 71 | 72 | void StandardHeader::SetMinVisible(bool bVisible) 73 | { 74 | m_pMin->setVisible(bVisible); 75 | } 76 | 77 | void StandardHeader::SetMaxVisible(bool bVisible) 78 | { 79 | m_pMax->setVisible(bVisible); 80 | } 81 | 82 | void StandardHeader::SetCloseVisible(bool bVisible) 83 | { 84 | m_pClose->setVisible(bVisible); 85 | } 86 | 87 | void StandardHeader::SetMaxImage() 88 | { 89 | m_pMax->ChangeImage(0,QImage(":/Image/Resource/headmax.png")); 90 | } 91 | 92 | void StandardHeader::SetRestoreImage() 93 | { 94 | m_pMax->ChangeImage(0,QImage(":/Image/Resource/headrestore.png")); 95 | } 96 | 97 | void StandardHeader::mouseDoubleClickEvent(QMouseEvent *event) 98 | { 99 | emit Signal_MouseDoubleClicked(); 100 | BaseWidget::mouseDoubleClickEvent(event); 101 | } 102 | 103 | void StandardHeader::CreateLayout() 104 | { 105 | QHBoxLayout *pHBoxLayout = new QHBoxLayout(this); 106 | pHBoxLayout->setContentsMargins(10,0,10,0); 107 | pHBoxLayout->setSpacing(10); 108 | pHBoxLayout->addWidget(m_pLogo); 109 | pHBoxLayout->addWidget(m_pTitle); 110 | pHBoxLayout->addWidget(m_pSkin); 111 | pHBoxLayout->addWidget(m_pMin); 112 | pHBoxLayout->addWidget(m_pMax); 113 | pHBoxLayout->addWidget(m_pClose); 114 | } 115 | 116 | 117 | 118 | 119 | -------------------------------------------------------------------------------- /StandardDialog/StandardHeader.h: -------------------------------------------------------------------------------- 1 | #ifndef STANDARDHEADER_H 2 | #define STANDARDHEADER_H 3 | 4 | #include 5 | #include "Control/BaseWidget.h" 6 | #include "Control/SButton.h" 7 | 8 | class StandardHeader : public BaseWidget 9 | { 10 | Q_OBJECT 11 | public: 12 | explicit StandardHeader(QWidget *parent = 0); 13 | virtual ~StandardHeader(); 14 | 15 | public: 16 | void SetLogoVisible(bool bVisible); 17 | void SetTitleText(const QString &str); 18 | void SetTitleCenter(bool bCenter); 19 | void SetSkinVisible(bool bVisible); 20 | void SetMinVisible(bool bVisible); 21 | void SetMaxVisible(bool bVisible); 22 | void SetCloseVisible(bool bVisible); 23 | void SetMaxImage(); 24 | void SetRestoreImage(); 25 | 26 | protected: 27 | virtual void mouseDoubleClickEvent(QMouseEvent *event); 28 | 29 | signals: 30 | void Signal_LogoClicked(); 31 | void Signal_SkinClicked(); 32 | void Signal_MinClicked(); 33 | void Signal_MaxClicked(); 34 | void Signal_CloseClicked(); 35 | void Signal_MouseDoubleClicked(); 36 | 37 | private: 38 | void CreateLayout(); 39 | 40 | private: 41 | SButton *m_pLogo; 42 | QLabel *m_pTitle; 43 | SButton *m_pSkin; 44 | SButton *m_pMin; 45 | SButton *m_pMax; 46 | SButton *m_pClose; 47 | QColor m_backgroundColor; 48 | }; 49 | 50 | #endif // STANDARDHEADER_H 51 | -------------------------------------------------------------------------------- /Style/SStyle.cpp: -------------------------------------------------------------------------------- 1 | #include "SStyle.h" 2 | #include 3 | #include 4 | 5 | SStyle::SStyle() 6 | { 7 | //读取皮肤样式文本 8 | QFile skinFile("Skin/skin_default.skin"); 9 | skinFile.open(QIODevice::ReadOnly | QIODevice::Text); 10 | QTextStream ts(&skinFile); 11 | m_styleStr = ts.readAll(); 12 | //qDebug() << "m_styleStr::" << m_styleStr; 13 | } 14 | 15 | SStyle::~SStyle() 16 | { 17 | 18 | } 19 | 20 | QString SStyle::GetStyle() 21 | { 22 | return m_styleStr; 23 | } 24 | -------------------------------------------------------------------------------- /Style/SStyle.h: -------------------------------------------------------------------------------- 1 | #ifndef SSTYLE_H 2 | #define SSTYLE_H 3 | 4 | class SStyle 5 | { 6 | 7 | public: 8 | SStyle(); 9 | ~SStyle(); 10 | 11 | public: 12 | QString GetStyle(); 13 | 14 | private: 15 | QString m_styleStr; 16 | }; 17 | 18 | #endif // SSTYLE_H 19 | -------------------------------------------------------------------------------- /WindowBottom.cpp: -------------------------------------------------------------------------------- 1 | #include "WindowBottom.h" 2 | 3 | //播放、停止等主界面底部视图的效果呈现 4 | WindowBottom::WindowBottom(QWidget *parent):BaseWidget(parent) 5 | { 6 | QImage image; 7 | m_pRunTimeLen = new QLabel(this); 8 | m_pRunTimeLen->setText("00:00:00"); 9 | m_pRunTimeLen->setMouseTracking(true); 10 | m_pSign = new QLabel(this); 11 | m_pSign->setText("/"); 12 | m_pTotalTimeLen = new QLabel(this); 13 | m_pTotalTimeLen->setText("00:00:00"); 14 | //图片按钮 15 | m_pStop = new SButton(this); 16 | image = QImage(":/Image/Resource/stop.png"); 17 | m_pStop->setFixedSize(image.width()/4,image.height()); 18 | m_pStop->AppendImage(image); 19 | 20 | m_pPre = new SButton(this); 21 | image = QImage(":/Image/Resource/pre.png"); 22 | m_pPre->setFixedSize(image.width()/4,image.height()); 23 | m_pPre->AppendImage(image); 24 | 25 | m_PPaly = new SButton(this); 26 | image = QImage(":/Image/Resource/play.png"); 27 | m_PPaly->setFixedSize(image.width()/4,image.height()); 28 | m_PPaly->AppendImage(image); 29 | 30 | m_pNext = new SButton(this); 31 | image = QImage(":/Image/Resource/next.png"); 32 | m_pNext->setFixedSize(image.width()/4,image.height()); 33 | m_pNext->AppendImage(image); 34 | 35 | m_pSound = new SButton(this); 36 | image = QImage(":/Image/Resource/sound.png"); 37 | m_pSound->setFixedSize(image.width()/4,image.height()); 38 | m_pSound->AppendImage(image); 39 | 40 | m_pProgressBar = new SProgressBar(this); 41 | m_pProgressBar->setFixedSize(60,4); 42 | m_pProgressBar->SetCurrentProgress(50); 43 | 44 | m_pFull = new SButton(this); 45 | image = QImage(":/Image/Resource/full.png"); 46 | m_pFull->setFixedSize(image.width()/4,image.height()); 47 | m_pFull->AppendImage(image); 48 | 49 | //水平布局 50 | QHBoxLayout *pHBoxLayout = new QHBoxLayout(this); 51 | pHBoxLayout->setContentsMargins(10,0,10,0); 52 | pHBoxLayout->setSpacing(0); 53 | //依次添加Stretch以及Widget 54 | pHBoxLayout->addStretch(1); 55 | pHBoxLayout->addWidget(m_pStop); 56 | pHBoxLayout->addSpacing(10); 57 | pHBoxLayout->addWidget(m_pPre); 58 | pHBoxLayout->addWidget(m_PPaly); 59 | pHBoxLayout->addWidget(m_pNext); 60 | pHBoxLayout->addSpacing(10); 61 | pHBoxLayout->addWidget(m_pSound); 62 | pHBoxLayout->addStretch(1); 63 | } 64 | 65 | WindowBottom::~WindowBottom() 66 | { 67 | 68 | } 69 | 70 | //自动布局与手动布局结合方式 71 | void WindowBottom::resizeEvent(QResizeEvent *event) 72 | { 73 | int textWidth = QFontMetrics(font()).width("00:00:00"); 74 | int textHeight = QFontMetrics(font()).height(); 75 | 76 | m_pRunTimeLen->setGeometry(10,(height()-textHeight)/2,textWidth,textHeight); 77 | m_pSign->setGeometry(m_pRunTimeLen->geometry().right()+5,m_pRunTimeLen->y(),QFontMetrics(font()).width("/"),textHeight); 78 | m_pTotalTimeLen->setGeometry(m_pSign->geometry().right()+5,m_pRunTimeLen->y(),textWidth,textHeight); 79 | 80 | m_pProgressBar->move(m_pSound->geometry().right(),(height()-4)/2); 81 | m_pFull->move(geometry().right()-10-m_pFull->width(),(height()-m_pFull->height())/2); 82 | 83 | QWidget::resizeEvent(event); 84 | } 85 | -------------------------------------------------------------------------------- /WindowBottom.h: -------------------------------------------------------------------------------- 1 | #ifndef WINDOWBOTTOM_H 2 | #define WINDOWBOTTOM_H 3 | 4 | #include 5 | #include "Control/SButton.h" 6 | #include "Control/SProgressBar.h" 7 | #include "Control/BaseWidget.h" 8 | 9 | class WindowBottom : public BaseWidget 10 | { 11 | Q_OBJECT 12 | 13 | public: 14 | WindowBottom(QWidget *parent); 15 | virtual ~WindowBottom(); 16 | 17 | protected: 18 | virtual void resizeEvent(QResizeEvent *event); 19 | 20 | private: 21 | QLabel *m_pRunTimeLen; 22 | QLabel *m_pSign; 23 | QLabel *m_pTotalTimeLen; 24 | SButton *m_pStop; 25 | SButton *m_pPre; 26 | SButton *m_PPaly; 27 | SButton *m_pNext; 28 | SButton *m_pSound; 29 | SProgressBar *m_pProgressBar; 30 | SButton *m_pFull; 31 | }; 32 | 33 | #endif // WINDOWBOTTOM_H 34 | -------------------------------------------------------------------------------- /WindowManager.cpp: -------------------------------------------------------------------------------- 1 | #include "WindowManager.h" 2 | 3 | WindowManager::WindowManager():m_pMainWindow(NULL) 4 | { 5 | 6 | } 7 | 8 | WindowManager::~WindowManager() 9 | { 10 | 11 | } 12 | 13 | WindowManager *WindowManager::Instance() 14 | { 15 | static WindowManager windowManager; 16 | 17 | return &windowManager; 18 | } 19 | 20 | void WindowManager::SetMainWindow(MainWindow *pMainWindow) 21 | { 22 | m_pMainWindow = pMainWindow; 23 | } 24 | 25 | MainWindow *WindowManager::GetMainWindow() 26 | { 27 | return m_pMainWindow; 28 | } 29 | -------------------------------------------------------------------------------- /WindowManager.h: -------------------------------------------------------------------------------- 1 | #ifndef WINDOWMANAGER_H 2 | #define WINDOWMANAGER_H 3 | #include "mainwindow.h" 4 | 5 | //窗口管理类,可用于后期扩展使用 6 | class WindowManager 7 | { 8 | 9 | private: 10 | WindowManager(); 11 | ~WindowManager(); 12 | 13 | public: 14 | //单例模式 15 | static WindowManager* Instance(); 16 | void SetMainWindow(MainWindow *pMainWindow); 17 | MainWindow* GetMainWindow(); 18 | 19 | private: 20 | MainWindow *m_pMainWindow; 21 | }; 22 | 23 | #endif // WINDOWMANAGER_H 24 | -------------------------------------------------------------------------------- /main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "mainwindow.h" 3 | #include "Style/SStyle.h" 4 | 5 | //重载QApplication,使用其消息分发处理; 6 | class SApplication : public QApplication 7 | { 8 | public: 9 | SApplication(int &argc, char **argv):QApplication(argc,argv) 10 | { 11 | } 12 | 13 | protected: 14 | //消息投递; 15 | virtual bool notify(QObject *object, QEvent *event) 16 | { 17 | return QApplication::notify(object,event); 18 | } 19 | 20 | }; 21 | 22 | //程序入口; 23 | int main(int argc, char *argv[]) 24 | { 25 | SApplication a(argc, argv); 26 | //设置应用系统的字体,如切换字体; 27 | a.setFont(QFont("msyh")); 28 | //皮肤样式类; 29 | SStyle style; 30 | a.setStyleSheet(style.GetStyle()); 31 | //显示主界面; 32 | MainWindow w; 33 | w.show(); 34 | 35 | return a.exec(); 36 | } 37 | -------------------------------------------------------------------------------- /mainwindow.cpp: -------------------------------------------------------------------------------- 1 | #include "mainwindow.h" 2 | #include 3 | 4 | #define MAIN_HB_COLOR (QColor(56,58,66)) 5 | 6 | //构造函数 7 | MainWindow::MainWindow(QWidget *parent): StandardDialog(parent) 8 | { 9 | setWindowFlags(Qt::FramelessWindowHint); 10 | 11 | //设置头部区域属性 12 | GetHeader()->SetTitleText(tr("SPlayer")); 13 | GetHeader()->SetTitleCenter(true); 14 | GetHeader()->GetBgColor().SetAllState(MAIN_HB_COLOR); 15 | GetHeader()->setFixedHeight(30); 16 | GetBottom()->GetBgColor().SetAllState(MAIN_HB_COLOR); 17 | GetBottom()->setFixedHeight(65); 18 | //设置内容区域属性 19 | BaseWidget *pCenterContainer = new BaseWidget(this); 20 | m_pCenterWidget = new QOpenGLWidget(pCenterContainer); 21 | m_pCenterWidget->setMouseTracking(true); 22 | m_pProgressBar = new SProgressBar(pCenterContainer); 23 | m_pProgressBar->SetCurrentProgress(50); 24 | m_pProgressBar->setFixedHeight(12); 25 | m_pProgressBar->setContentsMargins(25,4,25,4); 26 | QVBoxLayout *pVBoxLayout = new QVBoxLayout(pCenterContainer); 27 | pVBoxLayout->setContentsMargins(0,0,0,0); 28 | pVBoxLayout->setSpacing(0); 29 | pVBoxLayout->addWidget(m_pCenterWidget); 30 | pVBoxLayout->addWidget(m_pProgressBar); 31 | SetCenterWidget(pCenterContainer); 32 | //快进和快退按钮 33 | QImage image; 34 | m_pBackward = new SButton(this); 35 | image = QImage(":/Image/Resource/backward.png"); 36 | m_pBackward->setFixedSize(image.width()/4,image.height()); 37 | m_pBackward->AppendImage(image); 38 | m_pForward = new SButton(this); 39 | image = QImage(":/Image/Resource/forward.png"); 40 | m_pForward->setFixedSize(image.width()/4,image.height()); 41 | m_pForward->AppendImage(image); 42 | 43 | CreateLogoWidget(m_pCenterWidget); 44 | //设置底部区域 45 | m_pWindowBottom = new WindowBottom(this); 46 | SetBottomWidget(m_pWindowBottom); 47 | 48 | CreateMainMenu(); 49 | 50 | m_pConfigDialog = new ConfigDialog(); 51 | m_pConfigDialog->setVisible(false); 52 | 53 | QSize size(860,500+30+65); 54 | //setMinimumSize(size);//设置窗口最小大小 55 | resize(size); 56 | } 57 | 58 | MainWindow::~MainWindow() 59 | { 60 | 61 | } 62 | 63 | //创建菜单项 64 | void MainWindow::CreateMainMenu() 65 | { 66 | m_pMainMenu = new QMenu(this); 67 | m_pMainMenu->addAction(tr("File(&F)")); 68 | m_pMainMenu->addAction(tr("Play(&P)")); 69 | QAction *pOptionAct = m_pMainMenu->addAction(tr("Option")); 70 | connect(pOptionAct,SIGNAL(triggered(bool)),this,SLOT(Slot_OptionActToggled(bool))); 71 | m_pMainMenu->addAction(tr("Exit")); 72 | } 73 | 74 | void MainWindow::CreateLogoWidget(QWidget *parent) 75 | { 76 | QHBoxLayout *pLogoLayout = new QHBoxLayout(parent); 77 | pLogoLayout->setContentsMargins(0,0,0,0); 78 | pLogoLayout->setSpacing(0); 79 | m_pLogoWidget = new LogoWidget(parent); 80 | m_pLogoWidget->SetLogoImage("./Image/logo.png"); 81 | pLogoLayout->addWidget(m_pLogoWidget); 82 | } 83 | 84 | void MainWindow::resizeEvent(QResizeEvent *event) 85 | { 86 | m_pBackward->move(5,height()-GetBottom()->height()-m_pBackward->height()); 87 | m_pForward->move(width()-m_pForward->width()-5,height()-GetBottom()->height()-m_pBackward->height()); 88 | StandardDialog::resizeEvent(event); 89 | } 90 | 91 | //单击Logo图标,弹出菜单 92 | void MainWindow::Slot_LogoClicked() 93 | { 94 | QPoint pt = GetHeader()->rect().bottomLeft(); 95 | m_pMainMenu->popup(GetHeader()->mapToGlobal(QPoint(pt.x(),pt.y()+1))); 96 | } 97 | 98 | //单击Option菜单项,弹出设置对话框 99 | void MainWindow::Slot_OptionActToggled(bool) 100 | { 101 | int nWidth = 560; 102 | int nHeight = 458; 103 | int nX= geometry().left()+(width()-nWidth)/2; 104 | int nY= geometry().top()+30+(height()-30-65-nHeight)/2; 105 | m_pConfigDialog->setGeometry(nX,nY,nWidth,nHeight); 106 | m_pConfigDialog->show(); 107 | } 108 | 109 | -------------------------------------------------------------------------------- /mainwindow.h: -------------------------------------------------------------------------------- 1 | #ifndef MAINWINDOW_H 2 | #define MAINWINDOW_H 3 | 4 | #include 5 | #include 6 | #include "StandardDialog/StandardDialog.h" 7 | #include "LogoWidget.h" 8 | #include "Control/SProgressBar.h" 9 | #include "Control/SButton.h" 10 | #include "WindowBottom.h" 11 | #include "ConfigDialog.h" 12 | 13 | class MainWindow : public StandardDialog 14 | { 15 | Q_OBJECT 16 | 17 | public: 18 | MainWindow(QWidget *parent = 0); 19 | ~MainWindow(); 20 | 21 | private: 22 | //创建菜单 23 | void CreateMainMenu(); 24 | //创建Logo视图 25 | void CreateLogoWidget(QWidget *parent); 26 | 27 | protected: 28 | //覆盖resizeEvent函数,用于手动定位控件位置 29 | virtual void resizeEvent(QResizeEvent *event); 30 | 31 | protected slots: 32 | virtual void Slot_LogoClicked(); 33 | void Slot_OptionActToggled(bool); 34 | 35 | //控件成员 36 | private: 37 | QOpenGLWidget *m_pCenterWidget; 38 | LogoWidget *m_pLogoWidget; 39 | SProgressBar *m_pProgressBar; 40 | SButton *m_pBackward; 41 | SButton *m_pForward; 42 | WindowBottom *m_pWindowBottom; 43 | QMenu *m_pMainMenu; 44 | ConfigDialog *m_pConfigDialog; 45 | }; 46 | #endif // MAINWINDOW_H 47 | -------------------------------------------------------------------------------- /pch.h: -------------------------------------------------------------------------------- 1 | #ifndef PCH_H 2 | #define PCH_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | #endif // PCH_H 9 | -------------------------------------------------------------------------------- /res.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | Resource/headicon.png 4 | Resource/headclose.png 5 | Resource/headmax.png 6 | Resource/headmin.png 7 | Resource/headrestore.png 8 | Resource/headskin.png 9 | Resource/openfile.png 10 | Resource/next.png 11 | Resource/pause.png 12 | Resource/play.png 13 | Resource/pre.png 14 | Resource/sound.png 15 | Resource/full.png 16 | Resource/stop.png 17 | Resource/backward.png 18 | Resource/forward.png 19 | 20 | 21 | --------------------------------------------------------------------------------