Skip to content

Commit 5354ae0

Browse files
authored
feat: Option to show/hide the toolbar when connecting a device. (#1042)
* Option to show/hide the toolbar when connecting a device. * Modify the code as required.
1 parent 076f9ba commit 5354ae0

File tree

10 files changed

+65
-37
lines changed

10 files changed

+65
-37
lines changed

QtScrcpy/res/i18n/en_US.qm

71 Bytes
Binary file not shown.

QtScrcpy/res/i18n/en_US.ts

+8-4
Original file line numberDiff line numberDiff line change
@@ -135,10 +135,6 @@
135135
<source>Start Config</source>
136136
<translation>Start Config</translation>
137137
</message>
138-
<message>
139-
<source>record save path:</source>
140-
<translation>record save path:</translation>
141-
</message>
142138
<message>
143139
<source>select path</source>
144140
<translation>select path</translation>
@@ -297,5 +293,13 @@
297293
<source>auto update</source>
298294
<translation>auto update</translation>
299295
</message>
296+
<message>
297+
<source>show toolbar</source>
298+
<translation>show toolbar</translation>
299+
</message>
300+
<message>
301+
<source>record save path:</source>
302+
<translation>record save path:</translation>
303+
</message>
300304
</context>
301305
</TS>

QtScrcpy/res/i18n/zh_CN.qm

55 Bytes
Binary file not shown.

QtScrcpy/res/i18n/zh_CN.ts

+8-4
Original file line numberDiff line numberDiff line change
@@ -135,10 +135,6 @@
135135
<source>Start Config</source>
136136
<translation>启动配置</translation>
137137
</message>
138-
<message>
139-
<source>record save path:</source>
140-
<translation>录像保存路径:</translation>
141-
</message>
142138
<message>
143139
<source>select path</source>
144140
<translation>选择路径</translation>
@@ -297,5 +293,13 @@
297293
<source>auto update</source>
298294
<translation>自动刷新</translation>
299295
</message>
296+
<message>
297+
<source>show toolbar</source>
298+
<translation>显示工具栏</translation>
299+
</message>
300+
<message>
301+
<source>record save path:</source>
302+
<translation>录像保存路径</translation>
303+
</message>
300304
</context>
301305
</TS>

QtScrcpy/ui/dialog.cpp

+6-2
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ void Dialog::updateBootConfig(bool toView)
195195
ui->stayAwakeCheck->setChecked(config.keepAlive);
196196
ui->useSingleModeCheck->setChecked(config.simpleMode);
197197
ui->autoUpdatecheckBox->setChecked(config.autoUpdateDevice);
198+
ui->showToolbar->setChecked(config.showToolbar);
198199
} else {
199200
UserBootConfig config;
200201

@@ -213,6 +214,8 @@ void Dialog::updateBootConfig(bool toView)
213214
config.keepAlive = ui->stayAwakeCheck->isChecked();
214215
config.simpleMode = ui->useSingleModeCheck->isChecked();
215216
config.autoUpdateDevice = ui->autoUpdatecheckBox->isChecked();
217+
config.showToolbar = ui->showToolbar->isChecked();
218+
216219
Config::getInstance().setUserBootConfig(config);
217220
}
218221
}
@@ -447,14 +450,15 @@ void Dialog::onDeviceConnected(bool success, const QString &serial, const QStrin
447450
if (!success) {
448451
return;
449452
}
450-
451-
auto videoForm = new VideoForm(ui->framelessCheck->isChecked(), Config::getInstance().getSkin());
453+
auto videoForm = new VideoForm(ui->framelessCheck->isChecked(), Config::getInstance().getSkin(), ui->showToolbar->isChecked());
452454
videoForm->setSerial(serial);
453455

454456
qsc::IDeviceManage::getInstance().getDevice(serial)->setUserData(static_cast<void*>(videoForm));
455457
qsc::IDeviceManage::getInstance().getDevice(serial)->registerDeviceObserver(videoForm);
456458

459+
457460
videoForm->showFPS(ui->fpsCheck->isChecked());
461+
458462
if (ui->alwaysTopCheck->isChecked()) {
459463
videoForm->staysOnTop();
460464
}

QtScrcpy/ui/dialog.ui

+28-21
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<x>0</x>
88
<y>0</y>
99
<width>1293</width>
10-
<height>454</height>
10+
<height>502</height>
1111
</rect>
1212
</property>
1313
<property name="windowTitle">
@@ -255,7 +255,7 @@
255255
</sizepolicy>
256256
</property>
257257
<property name="focusPolicy">
258-
<enum>Qt::ClickFocus</enum>
258+
<enum>Qt::FocusPolicy::ClickFocus</enum>
259259
</property>
260260
<property name="documentTitle">
261261
<string/>
@@ -626,29 +626,32 @@
626626
<property name="bottomMargin">
627627
<number>0</number>
628628
</property>
629-
<item row="1" column="1">
630-
<widget class="QCheckBox" name="closeScreenCheck">
629+
<item row="0" column="4">
630+
<widget class="QCheckBox" name="fpsCheck">
631631
<property name="sizePolicy">
632632
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
633633
<horstretch>0</horstretch>
634634
<verstretch>0</verstretch>
635635
</sizepolicy>
636636
</property>
637637
<property name="text">
638-
<string>screen-off</string>
638+
<string>show fps</string>
639639
</property>
640640
</widget>
641641
</item>
642-
<item row="1" column="3">
643-
<widget class="QCheckBox" name="framelessCheck">
642+
<item row="0" column="1">
643+
<widget class="QCheckBox" name="notDisplayCheck">
644644
<property name="sizePolicy">
645645
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
646646
<horstretch>0</horstretch>
647647
<verstretch>0</verstretch>
648648
</sizepolicy>
649649
</property>
650650
<property name="text">
651-
<string>frameless</string>
651+
<string>background record</string>
652+
</property>
653+
<property name="checkable">
654+
<bool>false</bool>
652655
</property>
653656
</widget>
654657
</item>
@@ -668,19 +671,16 @@
668671
</property>
669672
</widget>
670673
</item>
671-
<item row="0" column="1">
672-
<widget class="QCheckBox" name="notDisplayCheck">
674+
<item row="0" column="0">
675+
<widget class="QCheckBox" name="recordScreenCheck">
673676
<property name="sizePolicy">
674677
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
675678
<horstretch>0</horstretch>
676679
<verstretch>0</verstretch>
677680
</sizepolicy>
678681
</property>
679682
<property name="text">
680-
<string>background record</string>
681-
</property>
682-
<property name="checkable">
683-
<bool>false</bool>
683+
<string>record screen</string>
684684
</property>
685685
</widget>
686686
</item>
@@ -700,29 +700,29 @@
700700
</property>
701701
</widget>
702702
</item>
703-
<item row="0" column="0">
704-
<widget class="QCheckBox" name="recordScreenCheck">
703+
<item row="1" column="1">
704+
<widget class="QCheckBox" name="closeScreenCheck">
705705
<property name="sizePolicy">
706706
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
707707
<horstretch>0</horstretch>
708708
<verstretch>0</verstretch>
709709
</sizepolicy>
710710
</property>
711711
<property name="text">
712-
<string>record screen</string>
712+
<string>screen-off</string>
713713
</property>
714714
</widget>
715715
</item>
716-
<item row="0" column="4">
717-
<widget class="QCheckBox" name="fpsCheck">
716+
<item row="1" column="3">
717+
<widget class="QCheckBox" name="framelessCheck">
718718
<property name="sizePolicy">
719719
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
720720
<horstretch>0</horstretch>
721721
<verstretch>0</verstretch>
722722
</sizepolicy>
723723
</property>
724724
<property name="text">
725-
<string>show fps</string>
725+
<string>frameless</string>
726726
</property>
727727
</widget>
728728
</item>
@@ -739,6 +739,13 @@
739739
</property>
740740
</widget>
741741
</item>
742+
<item row="2" column="0">
743+
<widget class="QCheckBox" name="showToolbar">
744+
<property name="text">
745+
<string>show toolbar</string>
746+
</property>
747+
</widget>
748+
</item>
742749
</layout>
743750
</widget>
744751
</item>
@@ -1146,7 +1153,7 @@
11461153
</sizepolicy>
11471154
</property>
11481155
<property name="orientation">
1149-
<enum>Qt::Vertical</enum>
1156+
<enum>Qt::Orientation::Vertical</enum>
11501157
</property>
11511158
<property name="sizeHint" stdset="0">
11521159
<size>

QtScrcpy/ui/videoform.cpp

+5-4
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,14 @@
2121
#include "ui_videoform.h"
2222
#include "videoform.h"
2323

24-
VideoForm::VideoForm(bool framelessWindow, bool skin, QWidget *parent) : QWidget(parent), ui(new Ui::videoForm), m_skin(skin)
24+
VideoForm::VideoForm(bool framelessWindow, bool skin, bool showToolbar, QWidget *parent) : QWidget(parent), ui(new Ui::videoForm), m_skin(skin)
2525
{
2626
ui->setupUi(this);
2727
initUI();
2828
installShortcut();
2929
updateShowSize(size());
3030
bool vertical = size().height() > size().width();
31+
this->show_toolbar = showToolbar;
3132
if (m_skin) {
3233
updateStyleSheet(vertical);
3334
}
@@ -479,7 +480,7 @@ void VideoForm::switchFullScreen()
479480
if (m_skin) {
480481
updateStyleSheet(m_frameSize.height() > m_frameSize.width());
481482
}
482-
showToolForm(true);
483+
showToolForm(this->show_toolbar);
483484
#ifdef Q_OS_WIN32
484485
::SetThreadExecutionState(ES_CONTINUOUS);
485486
#endif
@@ -721,9 +722,9 @@ void VideoForm::paintEvent(QPaintEvent *paint)
721722
void VideoForm::showEvent(QShowEvent *event)
722723
{
723724
Q_UNUSED(event)
724-
if (!isFullScreen()) {
725+
if (!isFullScreen() && this->show_toolbar) {
725726
QTimer::singleShot(500, this, [this](){
726-
showToolForm();
727+
showToolForm(this->show_toolbar);
727728
});
728729
}
729730
}

QtScrcpy/ui/videoform.h

+4-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class VideoForm : public QWidget, public qsc::DeviceObserver
1919
{
2020
Q_OBJECT
2121
public:
22-
explicit VideoForm(bool framelessWindow = false, bool skin = true, QWidget *parent = 0);
22+
explicit VideoForm(bool framelessWindow = false, bool skin = true, bool showToolBar = true, QWidget *parent = 0);
2323
~VideoForm();
2424

2525
void staysOnTop(bool top = true);
@@ -32,7 +32,6 @@ class VideoForm : public QWidget, public qsc::DeviceObserver
3232
void removeBlackRect();
3333
void showFPS(bool show);
3434
void switchFullScreen();
35-
3635
bool isHost();
3736

3837
private:
@@ -85,6 +84,9 @@ class VideoForm : public QWidget, public qsc::DeviceObserver
8584
bool m_skin = true;
8685
QPoint m_fullScreenBeforePos;
8786
QString m_serial;
87+
88+
//Whether to display the toolbar when connecting a device.
89+
bool show_toolbar = true;
8890
};
8991

9092
#endif // VIDEOFORM_H

QtScrcpy/util/config.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,9 @@
9696
#define COMMON_TRAY_MESSAGE_SHOWN_KEY "TrayMessageShown"
9797
#define COMMON_TRAY_MESSAGE_SHOWN_DEF false
9898

99+
#define COMMON_SHOW_TOOLBAR_KEY "showToolbar"
100+
#define COMMON_SHOW_TOOLBAR_DEF true
101+
99102
// device config
100103
#define SERIAL_WINDOW_RECT_KEY_X "WindowRectX"
101104
#define SERIAL_WINDOW_RECT_KEY_Y "WindowRectY"
@@ -163,6 +166,7 @@ void Config::setUserBootConfig(const UserBootConfig &config)
163166
m_userData->setValue(COMMON_KEEP_ALIVE_KEY, config.keepAlive);
164167
m_userData->setValue(COMMON_SIMPLE_MODE_KEY, config.simpleMode);
165168
m_userData->setValue(COMMON_AUTO_UPDATE_DEVICE_KEY, config.autoUpdateDevice);
169+
m_userData->setValue(COMMON_SHOW_TOOLBAR_KEY, config.showToolbar);
166170
m_userData->endGroup();
167171
m_userData->sync();
168172
}
@@ -186,6 +190,7 @@ UserBootConfig Config::getUserBootConfig()
186190
config.keepAlive = m_userData->value(COMMON_KEEP_ALIVE_KEY, COMMON_KEEP_ALIVE_DEF).toBool();
187191
config.simpleMode = m_userData->value(COMMON_SIMPLE_MODE_KEY, COMMON_SIMPLE_MODE_DEF).toBool();
188192
config.autoUpdateDevice = m_userData->value(COMMON_AUTO_UPDATE_DEVICE_KEY, COMMON_AUTO_UPDATE_DEVICE_DEF).toBool();
193+
config.showToolbar =m_userData->value(COMMON_SHOW_TOOLBAR_KEY,COMMON_SHOW_TOOLBAR_DEF).toBool();
189194
m_userData->endGroup();
190195
return config;
191196
}

QtScrcpy/util/config.h

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ struct UserBootConfig
2222
bool keepAlive = false;
2323
bool simpleMode = false;
2424
bool autoUpdateDevice = true;
25+
bool showToolbar = true;
2526
};
2627

2728
class QSettings;

0 commit comments

Comments
 (0)