diff --git a/QtScrcpy/QtScrcpy.pro b/QtScrcpy/QtScrcpy.pro index e06ead7..d0a273d 100644 --- a/QtScrcpy/QtScrcpy.pro +++ b/QtScrcpy/QtScrcpy.pro @@ -47,6 +47,7 @@ include ($$PWD/decoder/decoder.pri) include ($$PWD/render/render.pri) include ($$PWD/android/android.pri) include ($$PWD/inputcontrol/inputcontrol.pri) +include ($$PWD/fontawesome/fontawesome.pri) # 附加包含路径 INCLUDEPATH += \ @@ -57,7 +58,8 @@ INCLUDEPATH += \ $$PWD/decoder \ $$PWD/render \ $$PWD/android \ - $$PWD/inputcontrol + $$PWD/inputcontrol \ + $$PWD/fontawesome # *********************************************************** diff --git a/QtScrcpy/fontawesome/fontawesome.pri b/QtScrcpy/fontawesome/fontawesome.pri new file mode 100644 index 0000000..36be843 --- /dev/null +++ b/QtScrcpy/fontawesome/fontawesome.pri @@ -0,0 +1,5 @@ +HEADERS += \ + $$PWD/iconhelper.h + +SOURCES += \ + $$PWD/iconhelper.cpp diff --git a/QtScrcpy/fontawesome/iconhelper.cpp b/QtScrcpy/fontawesome/iconhelper.cpp new file mode 100644 index 0000000..e8e8024 --- /dev/null +++ b/QtScrcpy/fontawesome/iconhelper.cpp @@ -0,0 +1,24 @@ +#include "iconhelper.h" + +IconHelper* IconHelper::_instance = 0; +IconHelper::IconHelper(QObject*): + QObject(qApp) +{ + int fontId = QFontDatabase::addApplicationFont(":/res/fontawesome-webfont.ttf"); + QString fontName = QFontDatabase::applicationFontFamilies(fontId).at(0); + iconFont = QFont(fontName); +} + +void IconHelper::SetIcon(QLabel* lab, QChar c, int size) +{ + iconFont.setPointSize(size); + lab->setFont(iconFont); + lab->setText(c); +} + +void IconHelper::SetIcon(QPushButton* btn, QChar c, int size) +{ + iconFont.setPointSize(size); + btn->setFont(iconFont); + btn->setText(c); +} diff --git a/QtScrcpy/fontawesome/iconhelper.h b/QtScrcpy/fontawesome/iconhelper.h new file mode 100644 index 0000000..32cc543 --- /dev/null +++ b/QtScrcpy/fontawesome/iconhelper.h @@ -0,0 +1,37 @@ +#ifndef ICONHELPER_H +#define ICONHELPER_H + +#include +#include +#include +#include +#include +#include +#include + +class IconHelper : public QObject +{ +private: + explicit IconHelper(QObject *parent = 0); + QFont iconFont; + static IconHelper* _instance; + +public: + static IconHelper* Instance() + { + static QMutex mutex; + if (!_instance) { + QMutexLocker locker(&mutex); + if (!_instance) { + _instance = new IconHelper; + } + } + return _instance; + } + + void SetIcon(QLabel* lab, QChar c, int size = 10); + void SetIcon(QPushButton* btn, QChar c, int size = 10); + +}; + +#endif // ICONHELPER_H diff --git a/QtScrcpy/res.qrc b/QtScrcpy/res.qrc index f9d4a2a..8b1a966 100644 --- a/QtScrcpy/res.qrc +++ b/QtScrcpy/res.qrc @@ -1,5 +1,6 @@ res/psblack.css + res/fontawesome-webfont.ttf diff --git a/QtScrcpy/res/fontawesome-webfont.pdf b/QtScrcpy/res/fontawesome-webfont.pdf new file mode 100644 index 0000000..628a4a6 Binary files /dev/null and b/QtScrcpy/res/fontawesome-webfont.pdf differ diff --git a/QtScrcpy/res/fontawesome-webfont.ttf b/QtScrcpy/res/fontawesome-webfont.ttf new file mode 100644 index 0000000..35acda2 Binary files /dev/null and b/QtScrcpy/res/fontawesome-webfont.ttf differ diff --git a/QtScrcpy/videoform.cpp b/QtScrcpy/videoform.cpp index 36b17cf..e113742 100644 --- a/QtScrcpy/videoform.cpp +++ b/QtScrcpy/videoform.cpp @@ -7,6 +7,7 @@ #include "videoform.h" #include "ui_videoform.h" +#include "iconhelper.h" VideoForm::VideoForm(const QString& serial, QWidget *parent) : QWidget(parent), @@ -94,6 +95,7 @@ VideoForm::VideoForm(const QString& serial, QWidget *parent) : }); updateShowSize(size()); + initStyle(); } VideoForm::~VideoForm() @@ -105,6 +107,12 @@ VideoForm::~VideoForm() delete ui; } +void VideoForm::initStyle() +{ + IconHelper::Instance()->SetIcon(ui->fullScrcenbtn, QChar(0xf0b2), 13); + IconHelper::Instance()->SetIcon(ui->returnBtn, QChar(0xf104), 15); +} + void VideoForm::updateShowSize(const QSize &newSize) { if (frameSize != newSize) { @@ -123,15 +131,18 @@ void VideoForm::updateShowSize(const QSize &newSize) showSize.setHeight(showSize.width()/2); } - // 窗口居中 + if (isFullScreen()) { + switchFullScreen(); + } + // 窗口居中 move(screenRect.center() - QRect(0, 0, showSize.width(), showSize.height()).center()); } int titleBarHeight = style()->pixelMetric(QStyle::PM_TitleBarHeight); // 减去标题栏高度 showSize.setHeight(showSize.height() - titleBarHeight); - if (showSize != size()) { - resize(showSize); + if (showSize != size()) { + resize(showSize); } } } @@ -149,22 +160,22 @@ void VideoForm::switchFullScreen() void VideoForm::mousePressEvent(QMouseEvent *event) { - m_inputConvert.mouseEvent(event, ui->videoWidget->frameSize(), size()); + m_inputConvert.mouseEvent(event, ui->videoWidget->frameSize(), ui->videoWidget->size()); } void VideoForm::mouseReleaseEvent(QMouseEvent *event) { - m_inputConvert.mouseEvent(event, ui->videoWidget->frameSize(), size()); + m_inputConvert.mouseEvent(event, ui->videoWidget->frameSize(), ui->videoWidget->size()); } void VideoForm::mouseMoveEvent(QMouseEvent *event) { - m_inputConvert.mouseEvent(event, ui->videoWidget->frameSize(), size()); + m_inputConvert.mouseEvent(event, ui->videoWidget->frameSize(), ui->videoWidget->size()); } void VideoForm::wheelEvent(QWheelEvent *event) { - m_inputConvert.wheelEvent(event, ui->videoWidget->frameSize(), size()); + m_inputConvert.wheelEvent(event, ui->videoWidget->frameSize(), ui->videoWidget->size()); } @@ -176,16 +187,21 @@ void VideoForm::keyPressEvent(QKeyEvent *event) switchFullScreen(); } //qDebug() << "keyPressEvent" << event->isAutoRepeat(); - m_inputConvert.keyEvent(event, ui->videoWidget->frameSize(), size()); + m_inputConvert.keyEvent(event, ui->videoWidget->frameSize(), ui->videoWidget->size()); } void VideoForm::keyReleaseEvent(QKeyEvent *event) { //qDebug() << "keyReleaseEvent" << event->isAutoRepeat(); - m_inputConvert.keyEvent(event, ui->videoWidget->frameSize(), size()); + m_inputConvert.keyEvent(event, ui->videoWidget->frameSize(), ui->videoWidget->size()); } void VideoForm::on_fullScrcenbtn_clicked() { switchFullScreen(); } + +void VideoForm::on_returnBtn_clicked() +{ + +} diff --git a/QtScrcpy/videoform.h b/QtScrcpy/videoform.h index d4d79ba..a17145b 100644 --- a/QtScrcpy/videoform.h +++ b/QtScrcpy/videoform.h @@ -24,6 +24,7 @@ public: private: void updateShowSize(const QSize &newSize); void switchFullScreen(); + void initStyle(); protected: void mousePressEvent(QMouseEvent *event); @@ -36,6 +37,8 @@ protected: private slots: void on_fullScrcenbtn_clicked(); + void on_returnBtn_clicked(); + private: Ui::videoForm *ui; QSize frameSize; diff --git a/QtScrcpy/videoform.ui b/QtScrcpy/videoform.ui index b1f13eb..785897d 100644 --- a/QtScrcpy/videoform.ui +++ b/QtScrcpy/videoform.ui @@ -36,21 +36,39 @@ - 40 + 60 0 - 40 + 60 16777215 - + + 0 + + + 0 + + + + + 40 + 40 + + + + + 40 + 40 + + - F + @@ -67,6 +85,25 @@ + + + + + 40 + 40 + + + + + 40 + 40 + + + + + + +