Skip to content

Commit

Permalink
Merge pull request #148 from barry-ran/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
barry-ran authored Apr 25, 2020
2 parents 1313faa + deda6f6 commit 06e77ad
Show file tree
Hide file tree
Showing 20 changed files with 220 additions and 86 deletions.
13 changes: 13 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

# These are supported funding model platforms

github: barry-ran
patreon: # Replace with a single Patreon username
open_collective: QtScrcpy
ko_fi: # Replace with a single Ko-fi username
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username
custom: ["https://paypal.me/QtScrcpy", "https://gitee.com/Barryda/MyPictureBed/blob/master/QtScrcpy/payme.md"]
1 change: 1 addition & 0 deletions QtScrcpy/device/decoder/fpscounter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ void FpsCounter::timerEvent(QTimerEvent *event)
m_curRendered = m_rendered;
m_curSkipped = m_skipped;
resetCounter();
emit updateFPS(m_curRendered);
//qInfo("FPS:%d Discard:%d", m_curRendered, m_skipped);
}
}
Expand Down
3 changes: 3 additions & 0 deletions QtScrcpy/device/decoder/fpscounter.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ class FpsCounter : public QObject
void addRenderedFrame();
void addSkippedFrame();

signals:
void updateFPS(quint32 fps);

protected:
virtual void timerEvent(QTimerEvent *event);

Expand Down
5 changes: 5 additions & 0 deletions QtScrcpy/device/decoder/videobuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,11 @@ void VideoBuffer::interrupt()
}
}

FpsCounter *VideoBuffer::getFPSCounter()
{
return &m_fpsCounter;
}

void VideoBuffer::swap()
{
AVFrame *tmp = m_decodingFrame;
Expand Down
2 changes: 2 additions & 0 deletions QtScrcpy/device/decoder/videobuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ class VideoBuffer
// wake up and avoid any blocking call
void interrupt();

FpsCounter *getFPSCounter();

private:
void swap();

Expand Down
1 change: 1 addition & 0 deletions QtScrcpy/device/device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,7 @@ void Device::initSignals()
m_vb->unLock();
},
Qt::QueuedConnection);
connect(m_vb->getFPSCounter(), &::FpsCounter::updateFPS, m_videoForm, &VideoForm::updateFPS);
}
}

Expand Down
28 changes: 28 additions & 0 deletions QtScrcpy/device/ui/videoform.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include <QDesktopWidget>
#include <QFileInfo>
#include <QLabel>
#include <QMessageBox>
#include <QMimeData>
#include <QMouseEvent>
Expand Down Expand Up @@ -68,6 +69,16 @@ void VideoForm::initUI()
ui->keepRadioWidget->setWidget(m_videoWidget);
ui->keepRadioWidget->setWidthHeightRadio(m_widthHeightRatio);

m_fpsLabel = new QLabel(m_videoWidget);
QFont ft;
ft.setPointSize(15);
ft.setWeight(QFont::Light);
ft.setBold(true);
m_fpsLabel->setFont(ft);
m_fpsLabel->move(5, 15);
m_fpsLabel->setMinimumWidth(100);
m_fpsLabel->setStyleSheet(R"(QLabel {color: #00FF00;})");

setMouseTracking(true);
m_videoWidget->setMouseTracking(true);
ui->keepRadioWidget->setMouseTracking(true);
Expand Down Expand Up @@ -115,6 +126,14 @@ void VideoForm::removeBlackRect()
resize(ui->keepRadioWidget->goodSize());
}

void VideoForm::showFPS(bool show)
{
if (!m_fpsLabel) {
return;
}
m_fpsLabel->setVisible(show);
}

void VideoForm::updateRender(const AVFrame *frame)
{
if (m_videoWidget->isHidden()) {
Expand Down Expand Up @@ -429,6 +448,15 @@ void VideoForm::onSwitchFullScreen()
}
}

void VideoForm::updateFPS(quint32 fps)
{
qDebug() << "FPS:" << fps;
if (!m_fpsLabel) {
return;
}
m_fpsLabel->setText(QString("FPS:%1").arg(fps));
}

void VideoForm::staysOnTop(bool top)
{
bool needShow = false;
Expand Down
4 changes: 4 additions & 0 deletions QtScrcpy/device/ui/videoform.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class ToolForm;
class Device;
class FileHandler;
class QYUVOpenGLWidget;
class QLabel;
class VideoForm : public QWidget
{
Q_OBJECT
Expand All @@ -29,9 +30,11 @@ class VideoForm : public QWidget
const QSize &frameSize();
void resizeSquare();
void removeBlackRect();
void showFPS(bool show);

public slots:
void onSwitchFullScreen();
void updateFPS(quint32 fps);

private:
void updateStyleSheet(bool vertical);
Expand Down Expand Up @@ -68,6 +71,7 @@ public slots:
QPointer<ToolForm> m_toolForm;
QPointer<QWidget> m_loadingWidget;
QPointer<QYUVOpenGLWidget> m_videoWidget;
QPointer<QLabel> m_fpsLabel;

//inside member
QSize m_frameSize;
Expand Down
15 changes: 15 additions & 0 deletions QtScrcpy/devicemanage/devicemanage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,21 @@ bool DeviceManage::staysOnTop(const QString &serial)
return true;
}

void DeviceManage::showFPS(const QString &serial, bool show)
{
if (!serial.isEmpty() && m_devices.contains(serial)) {
auto it = m_devices.find(serial);
if (!it->data()) {
return;
}
if (!it->data()->getVideoForm()) {
return;
}
it->data()->getVideoForm()->showFPS(show);
}
return;
}

bool DeviceManage::disconnectDevice(const QString &serial)
{
bool ret = false;
Expand Down
1 change: 1 addition & 0 deletions QtScrcpy/devicemanage/devicemanage.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class DeviceManage : public QObject
bool connectDevice(Device::DeviceParams params);
void updateScript(QString script);
bool staysOnTop(const QString &serial);
void showFPS(const QString &serial, bool show);

bool disconnectDevice(const QString &serial);
void disconnectAllDevice();
Expand Down
1 change: 1 addition & 0 deletions QtScrcpy/dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ void Dialog::on_startServerBtn_clicked()
if (ui->alwaysTopCheck->isChecked()) {
m_deviceManage.staysOnTop(params.serial);
}
m_deviceManage.showFPS(params.serial, ui->fpsCheck->isChecked());
}

void Dialog::on_stopServerBtn_clicked()
Expand Down
49 changes: 28 additions & 21 deletions QtScrcpy/dialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -208,10 +208,23 @@
<property name="bottomMargin">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QCheckBox" name="recordScreenCheck">
<item row="1" column="1">
<widget class="QCheckBox" name="closeScreenCheck">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>record screen</string>
<string>screen-off</string>
</property>
</widget>
</item>
<item row="1" column="3">
<widget class="QCheckBox" name="framelessCheck">
<property name="text">
<string>frameless</string>
</property>
</widget>
</item>
Expand All @@ -231,16 +244,19 @@
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QCheckBox" name="closeScreenCheck">
<item row="0" column="1">
<widget class="QCheckBox" name="notDisplayCheck">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>screen-off</string>
<string>background record</string>
</property>
<property name="checkable">
<bool>false</bool>
</property>
</widget>
</item>
Expand All @@ -260,26 +276,17 @@
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QCheckBox" name="notDisplayCheck">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<item row="0" column="0">
<widget class="QCheckBox" name="recordScreenCheck">
<property name="text">
<string>background record</string>
</property>
<property name="checkable">
<bool>false</bool>
<string>record screen</string>
</property>
</widget>
</item>
<item row="1" column="3">
<widget class="QCheckBox" name="framelessCheck">
<item row="0" column="4">
<widget class="QCheckBox" name="fpsCheck">
<property name="text">
<string>frameless</string>
<string>show fps</string>
</property>
</widget>
</item>
Expand Down
Binary file modified QtScrcpy/res/i18n/QtScrcpy_en.qm
Binary file not shown.
Loading

0 comments on commit 06e77ad

Please sign in to comment.