mirror of
https://github.com/barry-ran/QtScrcpy.git
synced 2025-08-03 14:18:45 +00:00
feat: remember video rect
This commit is contained in:
parent
dd26218ce4
commit
d25a6b648a
5 changed files with 48 additions and 0 deletions
|
@ -71,6 +71,7 @@ Device::~Device()
|
||||||
delete m_vb;
|
delete m_vb;
|
||||||
}
|
}
|
||||||
if (m_videoForm) {
|
if (m_videoForm) {
|
||||||
|
m_videoForm->close();
|
||||||
delete m_videoForm;
|
delete m_videoForm;
|
||||||
}
|
}
|
||||||
emit deviceDisconnect(m_params.serial);
|
emit deviceDisconnect(m_params.serial);
|
||||||
|
@ -218,6 +219,11 @@ void Device::initSignals()
|
||||||
if (m_videoForm) {
|
if (m_videoForm) {
|
||||||
m_videoForm->setWindowTitle(deviceName);
|
m_videoForm->setWindowTitle(deviceName);
|
||||||
m_videoForm->updateShowSize(size);
|
m_videoForm->updateShowSize(size);
|
||||||
|
|
||||||
|
QRect rc = Config::getInstance().getRect(getSerial());
|
||||||
|
if (rc.isValid()) {
|
||||||
|
m_videoForm->setGeometry(rc);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// init recorder
|
// init recorder
|
||||||
|
|
|
@ -430,6 +430,15 @@ void VideoForm::resizeEvent(QResizeEvent *event)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void VideoForm::closeEvent(QCloseEvent *event)
|
||||||
|
{
|
||||||
|
Q_UNUSED(event)
|
||||||
|
if (!m_device) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Config::getInstance().setRect(m_device->getSerial(), geometry());
|
||||||
|
}
|
||||||
|
|
||||||
void VideoForm::dragEnterEvent(QDragEnterEvent *event)
|
void VideoForm::dragEnterEvent(QDragEnterEvent *event)
|
||||||
{
|
{
|
||||||
event->acceptProposedAction();
|
event->acceptProposedAction();
|
||||||
|
|
|
@ -49,6 +49,7 @@ protected:
|
||||||
void paintEvent(QPaintEvent *);
|
void paintEvent(QPaintEvent *);
|
||||||
void showEvent(QShowEvent *event);
|
void showEvent(QShowEvent *event);
|
||||||
void resizeEvent(QResizeEvent *event);
|
void resizeEvent(QResizeEvent *event);
|
||||||
|
void closeEvent(QCloseEvent *event);
|
||||||
|
|
||||||
void dragEnterEvent(QDragEnterEvent *event);
|
void dragEnterEvent(QDragEnterEvent *event);
|
||||||
void dragMoveEvent(QDragMoveEvent *event);
|
void dragMoveEvent(QDragMoveEvent *event);
|
||||||
|
|
|
@ -44,6 +44,12 @@
|
||||||
#define COMMON_RECORD_FORMAT_INDEX_KEY "RecordFormatIndex"
|
#define COMMON_RECORD_FORMAT_INDEX_KEY "RecordFormatIndex"
|
||||||
#define COMMON_RECORD_FORMAT_INDEX_DEF 0
|
#define COMMON_RECORD_FORMAT_INDEX_DEF 0
|
||||||
|
|
||||||
|
#define SERIAL_WINDOW_RECT_KEY_X "WindowRectX"
|
||||||
|
#define SERIAL_WINDOW_RECT_KEY_Y "WindowRectY"
|
||||||
|
#define SERIAL_WINDOW_RECT_KEY_W "WindowRectW"
|
||||||
|
#define SERIAL_WINDOW_RECT_KEY_H "WindowRectH"
|
||||||
|
#define SERIAL_WINDOW_RECT_KEY_DEF -1
|
||||||
|
|
||||||
// 最大尺寸 录制格式
|
// 最大尺寸 录制格式
|
||||||
|
|
||||||
QString Config::s_configPath = "";
|
QString Config::s_configPath = "";
|
||||||
|
@ -140,6 +146,29 @@ void Config::setRecordFormatIndex(int recordFormatIndex)
|
||||||
m_userData->endGroup();
|
m_userData->endGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Config::setRect(const QString &serial, const QRect &rc)
|
||||||
|
{
|
||||||
|
m_userData->beginGroup(serial);
|
||||||
|
m_userData->setValue(SERIAL_WINDOW_RECT_KEY_X, rc.left());
|
||||||
|
m_userData->setValue(SERIAL_WINDOW_RECT_KEY_Y, rc.top());
|
||||||
|
m_userData->setValue(SERIAL_WINDOW_RECT_KEY_W, rc.width());
|
||||||
|
m_userData->setValue(SERIAL_WINDOW_RECT_KEY_H, rc.height());
|
||||||
|
m_userData->endGroup();
|
||||||
|
m_userData->sync();
|
||||||
|
}
|
||||||
|
|
||||||
|
QRect Config::getRect(const QString &serial)
|
||||||
|
{
|
||||||
|
QRect rc;
|
||||||
|
m_userData->beginGroup(serial);
|
||||||
|
rc.setX(m_userData->value(SERIAL_WINDOW_RECT_KEY_X, SERIAL_WINDOW_RECT_KEY_DEF).toInt());
|
||||||
|
rc.setY(m_userData->value(SERIAL_WINDOW_RECT_KEY_Y, SERIAL_WINDOW_RECT_KEY_DEF).toInt());
|
||||||
|
rc.setWidth(m_userData->value(SERIAL_WINDOW_RECT_KEY_W, SERIAL_WINDOW_RECT_KEY_DEF).toInt());
|
||||||
|
rc.setHeight(m_userData->value(SERIAL_WINDOW_RECT_KEY_H, SERIAL_WINDOW_RECT_KEY_DEF).toInt());
|
||||||
|
m_userData->endGroup();
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
QString Config::getServerVersion()
|
QString Config::getServerVersion()
|
||||||
{
|
{
|
||||||
QString server;
|
QString server;
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QPointer>
|
#include <QPointer>
|
||||||
|
#include <QRect>
|
||||||
|
|
||||||
class QSettings;
|
class QSettings;
|
||||||
class Config : public QObject
|
class Config : public QObject
|
||||||
|
@ -29,6 +30,8 @@ public:
|
||||||
void setMaxSizeIndex(int maxSizeIndex);
|
void setMaxSizeIndex(int maxSizeIndex);
|
||||||
int getRecordFormatIndex();
|
int getRecordFormatIndex();
|
||||||
void setRecordFormatIndex(int recordFormatIndex);
|
void setRecordFormatIndex(int recordFormatIndex);
|
||||||
|
void setRect(const QString &serial, const QRect &rc);
|
||||||
|
QRect getRect(const QString &serial);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
explicit Config(QObject *parent = nullptr);
|
explicit Config(QObject *parent = nullptr);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue