feat: Option to show/hide the toolbar when connecting a device. (#1042)
Some checks are pending
MacOS / Build (push) Waiting to run
Ubuntu / Build (push) Waiting to run
Windows / Build (push) Waiting to run

* Option to show/hide the toolbar when connecting a device.

* Modify the code as required.
This commit is contained in:
Fanxing 2024-12-06 16:33:15 +08:00 committed by GitHub
commit 5354ae0173
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 121 additions and 93 deletions

Binary file not shown.

View file

@ -135,10 +135,6 @@
<source>Start Config</source> <source>Start Config</source>
<translation>Start Config</translation> <translation>Start Config</translation>
</message> </message>
<message>
<source>record save path:</source>
<translation>record save path:</translation>
</message>
<message> <message>
<source>select path</source> <source>select path</source>
<translation>select path</translation> <translation>select path</translation>
@ -297,5 +293,13 @@
<source>auto update</source> <source>auto update</source>
<translation>auto update</translation> <translation>auto update</translation>
</message> </message>
<message>
<source>show toolbar</source>
<translation>show toolbar</translation>
</message>
<message>
<source>record save path:</source>
<translation>record save path:</translation>
</message>
</context> </context>
</TS> </TS>

Binary file not shown.

View file

@ -135,10 +135,6 @@
<source>Start Config</source> <source>Start Config</source>
<translation></translation> <translation></translation>
</message> </message>
<message>
<source>record save path:</source>
<translation></translation>
</message>
<message> <message>
<source>select path</source> <source>select path</source>
<translation></translation> <translation></translation>
@ -297,5 +293,13 @@
<source>auto update</source> <source>auto update</source>
<translation></translation> <translation></translation>
</message> </message>
<message>
<source>show toolbar</source>
<translation></translation>
</message>
<message>
<source>record save path:</source>
<translation></translation>
</message>
</context> </context>
</TS> </TS>

View file

@ -195,6 +195,7 @@ void Dialog::updateBootConfig(bool toView)
ui->stayAwakeCheck->setChecked(config.keepAlive); ui->stayAwakeCheck->setChecked(config.keepAlive);
ui->useSingleModeCheck->setChecked(config.simpleMode); ui->useSingleModeCheck->setChecked(config.simpleMode);
ui->autoUpdatecheckBox->setChecked(config.autoUpdateDevice); ui->autoUpdatecheckBox->setChecked(config.autoUpdateDevice);
ui->showToolbar->setChecked(config.showToolbar);
} else { } else {
UserBootConfig config; UserBootConfig config;
@ -213,6 +214,8 @@ void Dialog::updateBootConfig(bool toView)
config.keepAlive = ui->stayAwakeCheck->isChecked(); config.keepAlive = ui->stayAwakeCheck->isChecked();
config.simpleMode = ui->useSingleModeCheck->isChecked(); config.simpleMode = ui->useSingleModeCheck->isChecked();
config.autoUpdateDevice = ui->autoUpdatecheckBox->isChecked(); config.autoUpdateDevice = ui->autoUpdatecheckBox->isChecked();
config.showToolbar = ui->showToolbar->isChecked();
Config::getInstance().setUserBootConfig(config); Config::getInstance().setUserBootConfig(config);
} }
} }
@ -447,14 +450,15 @@ void Dialog::onDeviceConnected(bool success, const QString &serial, const QStrin
if (!success) { if (!success) {
return; return;
} }
auto videoForm = new VideoForm(ui->framelessCheck->isChecked(), Config::getInstance().getSkin(), ui->showToolbar->isChecked());
auto videoForm = new VideoForm(ui->framelessCheck->isChecked(), Config::getInstance().getSkin());
videoForm->setSerial(serial); videoForm->setSerial(serial);
qsc::IDeviceManage::getInstance().getDevice(serial)->setUserData(static_cast<void*>(videoForm)); qsc::IDeviceManage::getInstance().getDevice(serial)->setUserData(static_cast<void*>(videoForm));
qsc::IDeviceManage::getInstance().getDevice(serial)->registerDeviceObserver(videoForm); qsc::IDeviceManage::getInstance().getDevice(serial)->registerDeviceObserver(videoForm);
videoForm->showFPS(ui->fpsCheck->isChecked()); videoForm->showFPS(ui->fpsCheck->isChecked());
if (ui->alwaysTopCheck->isChecked()) { if (ui->alwaysTopCheck->isChecked()) {
videoForm->staysOnTop(); videoForm->staysOnTop();
} }

View file

@ -7,7 +7,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>1293</width> <width>1293</width>
<height>454</height> <height>502</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -255,7 +255,7 @@
</sizepolicy> </sizepolicy>
</property> </property>
<property name="focusPolicy"> <property name="focusPolicy">
<enum>Qt::ClickFocus</enum> <enum>Qt::FocusPolicy::ClickFocus</enum>
</property> </property>
<property name="documentTitle"> <property name="documentTitle">
<string/> <string/>
@ -626,6 +626,80 @@
<property name="bottomMargin"> <property name="bottomMargin">
<number>0</number> <number>0</number>
</property> </property>
<item row="0" column="4">
<widget class="QCheckBox" name="fpsCheck">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>show fps</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QCheckBox" name="notDisplayCheck">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>background record</string>
</property>
<property name="checkable">
<bool>false</bool>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QCheckBox" name="alwaysTopCheck">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>always on top</string>
</property>
<property name="checked">
<bool>false</bool>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QCheckBox" name="recordScreenCheck">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>record screen</string>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QCheckBox" name="useReverseCheck">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>reverse connection</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="1"> <item row="1" column="1">
<widget class="QCheckBox" name="closeScreenCheck"> <widget class="QCheckBox" name="closeScreenCheck">
<property name="sizePolicy"> <property name="sizePolicy">
@ -652,80 +726,6 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="0">
<widget class="QCheckBox" name="alwaysTopCheck">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>always on top</string>
</property>
<property name="checked">
<bool>false</bool>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QCheckBox" name="notDisplayCheck">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>background record</string>
</property>
<property name="checkable">
<bool>false</bool>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QCheckBox" name="useReverseCheck">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>reverse connection</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QCheckBox" name="recordScreenCheck">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>record screen</string>
</property>
</widget>
</item>
<item row="0" column="4">
<widget class="QCheckBox" name="fpsCheck">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>show fps</string>
</property>
</widget>
</item>
<item row="1" column="4"> <item row="1" column="4">
<widget class="QCheckBox" name="stayAwakeCheck"> <widget class="QCheckBox" name="stayAwakeCheck">
<property name="sizePolicy"> <property name="sizePolicy">
@ -739,6 +739,13 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="0">
<widget class="QCheckBox" name="showToolbar">
<property name="text">
<string>show toolbar</string>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
</item> </item>
@ -1146,7 +1153,7 @@
</sizepolicy> </sizepolicy>
</property> </property>
<property name="orientation"> <property name="orientation">
<enum>Qt::Vertical</enum> <enum>Qt::Orientation::Vertical</enum>
</property> </property>
<property name="sizeHint" stdset="0"> <property name="sizeHint" stdset="0">
<size> <size>

View file

@ -21,13 +21,14 @@
#include "ui_videoform.h" #include "ui_videoform.h"
#include "videoform.h" #include "videoform.h"
VideoForm::VideoForm(bool framelessWindow, bool skin, QWidget *parent) : QWidget(parent), ui(new Ui::videoForm), m_skin(skin) VideoForm::VideoForm(bool framelessWindow, bool skin, bool showToolbar, QWidget *parent) : QWidget(parent), ui(new Ui::videoForm), m_skin(skin)
{ {
ui->setupUi(this); ui->setupUi(this);
initUI(); initUI();
installShortcut(); installShortcut();
updateShowSize(size()); updateShowSize(size());
bool vertical = size().height() > size().width(); bool vertical = size().height() > size().width();
this->show_toolbar = showToolbar;
if (m_skin) { if (m_skin) {
updateStyleSheet(vertical); updateStyleSheet(vertical);
} }
@ -479,7 +480,7 @@ void VideoForm::switchFullScreen()
if (m_skin) { if (m_skin) {
updateStyleSheet(m_frameSize.height() > m_frameSize.width()); updateStyleSheet(m_frameSize.height() > m_frameSize.width());
} }
showToolForm(true); showToolForm(this->show_toolbar);
#ifdef Q_OS_WIN32 #ifdef Q_OS_WIN32
::SetThreadExecutionState(ES_CONTINUOUS); ::SetThreadExecutionState(ES_CONTINUOUS);
#endif #endif
@ -721,9 +722,9 @@ void VideoForm::paintEvent(QPaintEvent *paint)
void VideoForm::showEvent(QShowEvent *event) void VideoForm::showEvent(QShowEvent *event)
{ {
Q_UNUSED(event) Q_UNUSED(event)
if (!isFullScreen()) { if (!isFullScreen() && this->show_toolbar) {
QTimer::singleShot(500, this, [this](){ QTimer::singleShot(500, this, [this](){
showToolForm(); showToolForm(this->show_toolbar);
}); });
} }
} }

View file

@ -19,7 +19,7 @@ class VideoForm : public QWidget, public qsc::DeviceObserver
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit VideoForm(bool framelessWindow = false, bool skin = true, QWidget *parent = 0); explicit VideoForm(bool framelessWindow = false, bool skin = true, bool showToolBar = true, QWidget *parent = 0);
~VideoForm(); ~VideoForm();
void staysOnTop(bool top = true); void staysOnTop(bool top = true);
@ -32,7 +32,6 @@ public:
void removeBlackRect(); void removeBlackRect();
void showFPS(bool show); void showFPS(bool show);
void switchFullScreen(); void switchFullScreen();
bool isHost(); bool isHost();
private: private:
@ -85,6 +84,9 @@ private:
bool m_skin = true; bool m_skin = true;
QPoint m_fullScreenBeforePos; QPoint m_fullScreenBeforePos;
QString m_serial; QString m_serial;
//Whether to display the toolbar when connecting a device.
bool show_toolbar = true;
}; };
#endif // VIDEOFORM_H #endif // VIDEOFORM_H

View file

@ -96,6 +96,9 @@
#define COMMON_TRAY_MESSAGE_SHOWN_KEY "TrayMessageShown" #define COMMON_TRAY_MESSAGE_SHOWN_KEY "TrayMessageShown"
#define COMMON_TRAY_MESSAGE_SHOWN_DEF false #define COMMON_TRAY_MESSAGE_SHOWN_DEF false
#define COMMON_SHOW_TOOLBAR_KEY "showToolbar"
#define COMMON_SHOW_TOOLBAR_DEF true
// device config // device config
#define SERIAL_WINDOW_RECT_KEY_X "WindowRectX" #define SERIAL_WINDOW_RECT_KEY_X "WindowRectX"
#define SERIAL_WINDOW_RECT_KEY_Y "WindowRectY" #define SERIAL_WINDOW_RECT_KEY_Y "WindowRectY"
@ -163,6 +166,7 @@ void Config::setUserBootConfig(const UserBootConfig &config)
m_userData->setValue(COMMON_KEEP_ALIVE_KEY, config.keepAlive); m_userData->setValue(COMMON_KEEP_ALIVE_KEY, config.keepAlive);
m_userData->setValue(COMMON_SIMPLE_MODE_KEY, config.simpleMode); m_userData->setValue(COMMON_SIMPLE_MODE_KEY, config.simpleMode);
m_userData->setValue(COMMON_AUTO_UPDATE_DEVICE_KEY, config.autoUpdateDevice); m_userData->setValue(COMMON_AUTO_UPDATE_DEVICE_KEY, config.autoUpdateDevice);
m_userData->setValue(COMMON_SHOW_TOOLBAR_KEY, config.showToolbar);
m_userData->endGroup(); m_userData->endGroup();
m_userData->sync(); m_userData->sync();
} }
@ -186,6 +190,7 @@ UserBootConfig Config::getUserBootConfig()
config.keepAlive = m_userData->value(COMMON_KEEP_ALIVE_KEY, COMMON_KEEP_ALIVE_DEF).toBool(); config.keepAlive = m_userData->value(COMMON_KEEP_ALIVE_KEY, COMMON_KEEP_ALIVE_DEF).toBool();
config.simpleMode = m_userData->value(COMMON_SIMPLE_MODE_KEY, COMMON_SIMPLE_MODE_DEF).toBool(); config.simpleMode = m_userData->value(COMMON_SIMPLE_MODE_KEY, COMMON_SIMPLE_MODE_DEF).toBool();
config.autoUpdateDevice = m_userData->value(COMMON_AUTO_UPDATE_DEVICE_KEY, COMMON_AUTO_UPDATE_DEVICE_DEF).toBool(); config.autoUpdateDevice = m_userData->value(COMMON_AUTO_UPDATE_DEVICE_KEY, COMMON_AUTO_UPDATE_DEVICE_DEF).toBool();
config.showToolbar =m_userData->value(COMMON_SHOW_TOOLBAR_KEY,COMMON_SHOW_TOOLBAR_DEF).toBool();
m_userData->endGroup(); m_userData->endGroup();
return config; return config;
} }

View file

@ -22,6 +22,7 @@ struct UserBootConfig
bool keepAlive = false; bool keepAlive = false;
bool simpleMode = false; bool simpleMode = false;
bool autoUpdateDevice = true; bool autoUpdateDevice = true;
bool showToolbar = true;
}; };
class QSettings; class QSettings;