mirror of
https://github.com/barry-ran/QtScrcpy.git
synced 2025-04-20 11:35:56 +00:00
feat: add qml main window
This commit is contained in:
parent
790ac38224
commit
094e592dda
7 changed files with 64 additions and 7 deletions
|
@ -4,7 +4,7 @@
|
|||
#
|
||||
#-------------------------------------------------
|
||||
|
||||
QT += core gui
|
||||
QT += core gui quick
|
||||
QT += network
|
||||
|
||||
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include <QApplication>
|
||||
#include <QDebug>
|
||||
#include <QFile>
|
||||
#include <QQmlApplicationEngine>
|
||||
#include <QSurfaceFormat>
|
||||
#include <QTcpServer>
|
||||
#include <QTcpSocket>
|
||||
|
@ -71,18 +72,19 @@ int main(int argc, char *argv[])
|
|||
|
||||
g_oldMessageHandler = qInstallMessageHandler(myMessageOutput);
|
||||
Stream::init();
|
||||
QApplication a(argc, argv);
|
||||
QApplication app(argc, argv);
|
||||
QQmlApplicationEngine engine("qrc:/qml/MainWindow.qml");
|
||||
|
||||
// windows下通过qmake VERSION变量或者rc设置版本号和应用名称后,这里可以直接拿到
|
||||
// mac下拿到的是CFBundleVersion的值
|
||||
qDebug() << a.applicationVersion();
|
||||
qDebug() << a.applicationName();
|
||||
qDebug() << app.applicationVersion();
|
||||
qDebug() << app.applicationName();
|
||||
|
||||
//update version
|
||||
QStringList versionList = QCoreApplication::applicationVersion().split(".");
|
||||
if (versionList.size() >= 3) {
|
||||
QString version = versionList[0] + "." + versionList[1] + "." + versionList[2];
|
||||
a.setApplicationVersion(version);
|
||||
app.setApplicationVersion(version);
|
||||
}
|
||||
|
||||
installTranslator();
|
||||
|
@ -100,9 +102,11 @@ int main(int argc, char *argv[])
|
|||
file.close();
|
||||
}
|
||||
|
||||
/*
|
||||
g_mainDlg = new Dialog;
|
||||
g_mainDlg->setWindowTitle(Config::getInstance().getTitle());
|
||||
g_mainDlg->show();
|
||||
*/
|
||||
|
||||
qInfo(
|
||||
"%s",
|
||||
|
@ -112,7 +116,7 @@ int main(int argc, char *argv[])
|
|||
.data());
|
||||
qInfo() << QString("QtScrcpy %1 <https://github.com/barry-ran/QtScrcpy>").arg(QCoreApplication::applicationVersion()).toUtf8();
|
||||
|
||||
int ret = a.exec();
|
||||
int ret = app.exec();
|
||||
|
||||
#if defined(Q_OS_WIN32) || defined(Q_OS_OSX)
|
||||
MouseTap::getInstance()->quitMouseEventTap();
|
||||
|
|
BIN
QtScrcpy/res/image/mainwindow/bg.png
Normal file
BIN
QtScrcpy/res/image/mainwindow/bg.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 93 KiB |
BIN
QtScrcpy/res/image/mainwindow/bg@2x.png
Normal file
BIN
QtScrcpy/res/image/mainwindow/bg@2x.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 334 KiB |
BIN
QtScrcpy/res/image/mainwindow/bg@3x.png
Normal file
BIN
QtScrcpy/res/image/mainwindow/bg@3x.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 645 KiB |
49
QtScrcpy/res/qml/MainWindow.qml
Normal file
49
QtScrcpy/res/qml/MainWindow.qml
Normal file
|
@ -0,0 +1,49 @@
|
|||
import QtQuick 2.12
|
||||
import QtQuick.Window 2.12
|
||||
|
||||
Window {
|
||||
id: window
|
||||
visible: true
|
||||
flags: Qt.Window |Qt.FramelessWindowHint
|
||||
width: 800
|
||||
height: 600
|
||||
color: "transparent"
|
||||
|
||||
// bg
|
||||
Image {
|
||||
id: background
|
||||
//anchors { top: parent.top; bottom: parent.bottom }
|
||||
anchors.fill: parent
|
||||
source: "qrc:/image/mainwindow/bg.png"
|
||||
fillMode: Image.PreserveAspectCrop
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.top: parent.top
|
||||
height: 30
|
||||
color: "red"
|
||||
|
||||
DragHandler {
|
||||
grabPermissions: TapHandler.CanTakeOverFromAnything
|
||||
onActiveChanged: if (active) { window.startSystemMove(); }
|
||||
}
|
||||
}
|
||||
|
||||
DragHandler {
|
||||
id: resizeHandler
|
||||
grabPermissions: TapHandler.TakeOverForbidden
|
||||
target: null
|
||||
onActiveChanged:
|
||||
if (active) {
|
||||
const p = resizeHandler.centroid.position;
|
||||
let e = 0;
|
||||
if (p.x / width < 0.10) { e |= Qt.LeftEdge }
|
||||
if (p.x / width > 0.90) { e |= Qt.RightEdge }
|
||||
if (p.y / height > 0.90) { e |= Qt.BottomEdge }
|
||||
console.log("RESIZING", e);
|
||||
window.startSystemResize(e);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -2,7 +2,7 @@
|
|||
<qresource prefix="/">
|
||||
<file>font/fontawesome-webfont.ttf</file>
|
||||
<file>image/videoform/phone-h.png</file>
|
||||
<file>image/videoform/phone-v.png</file>
|
||||
<file>image/videoform/phone-v.png</file>
|
||||
<file>qss/psblack.css</file>
|
||||
<file>qss/psblack/add_bottom.png</file>
|
||||
<file>qss/psblack/add_left.png</file>
|
||||
|
@ -24,5 +24,9 @@
|
|||
<file>qss/psblack/radiobutton_unchecked_disable.png</file>
|
||||
<file>i18n/QtScrcpy_en.qm</file>
|
||||
<file>i18n/QtScrcpy_zh.qm</file>
|
||||
<file>qml/MainWindow.qml</file>
|
||||
<file>image/mainwindow/bg.png</file>
|
||||
<file>image/mainwindow/bg@2x.png</file>
|
||||
<file>image/mainwindow/bg@3x.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
|
Loading…
Add table
Reference in a new issue