1
0
forked from BRT/arc

Remove macOS-specific Scrcpy embedding and cleanup debug logs

Removed Scrcpy embedding code and related configurations for macOS. Commented out excessive debug logging in multiple files to reduce console noise. Simplified CMakeLists.txt by unifying platform-specific sections for improved build system clarity.
This commit is contained in:
slava 2025-04-26 15:16:42 +07:00
parent 675fa7ca5f
commit c3fed927fc
7 changed files with 23 additions and 116 deletions

View File

@ -19,10 +19,6 @@ elseif (APPLE)
set(CMAKE_PREFIX_PATH "/opt/homebrew/opt/qt") set(CMAKE_PREFIX_PATH "/opt/homebrew/opt/qt")
include_directories("/opt/homebrew/opt/tesseract/include") include_directories("/opt/homebrew/opt/tesseract/include")
link_directories("/opt/homebrew/opt/tesseract/lib") link_directories("/opt/homebrew/opt/tesseract/lib")
set(CMAKE_CXX_STANDARD 17) # или 20, если нужно
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ObjC++")
set(SCRCPY ${CMAKE_CURRENT_SOURCE_DIR}/views/scrcpy/ScrcpyWindow_mac.mm)
endif () endif ()
find_package(Qt6 REQUIRED COMPONENTS find_package(Qt6 REQUIRED COMPONENTS
@ -50,15 +46,15 @@ file(GLOB_RECURSE MODELS_SOURCES
"${CMAKE_CURRENT_SOURCE_DIR}/models/*.h" "${CMAKE_CURRENT_SOURCE_DIR}/models/*.h"
) )
if (WIN32) add_executable(ARCDesktopProject
add_executable(ARCDesktopProject
main.cpp main.cpp
${VIEW_SOURCES} ${VIEW_SOURCES}
${SERVICES_SOURCES} ${SERVICES_SOURCES}
${DB_SOURCES} ${DB_SOURCES}
${MODELS_SOURCES} ${MODELS_SOURCES}
) )
if (WIN32)
target_link_libraries(ARCDesktopProject target_link_libraries(ARCDesktopProject
Qt6::Widgets Qt6::Widgets
Qt6::Sql Qt6::Sql
@ -71,15 +67,6 @@ if (WIN32)
file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/rus.traineddata" DESTINATION "${CMAKE_BINARY_DIR}") file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/rus.traineddata" DESTINATION "${CMAKE_BINARY_DIR}")
elseif (APPLE) elseif (APPLE)
add_executable(ARCDesktopProject
main.cpp
${VIEW_SOURCES}
${SERVICES_SOURCES}
${DB_SOURCES}
${MODELS_SOURCES}
${SCRCPY}
)
target_link_libraries(ARCDesktopProject target_link_libraries(ARCDesktopProject
Qt6::Widgets Qt6::Widgets
Qt6::Sql Qt6::Sql

Binary file not shown.

View File

@ -15,12 +15,12 @@ DeviceScreener::DeviceScreener(QObject *parent) : QObject(parent) {
DeviceScreener::~DeviceScreener() = default; DeviceScreener::~DeviceScreener() = default;
void DeviceScreener::start() { void DeviceScreener::start() {
qDebug() << "Worker started in thread:" << QThread::currentThread(); // qDebug() << "Worker started in thread:" << QThread::currentThread();
while (m_running) { while (m_running) {
QList<QPair<QString, QString>> devices = readAdbDevices(); QList<QPair<QString, QString>> devices = readAdbDevices();
QStringList onlineIds; QStringList onlineIds;
for (const auto&[id, status] : devices) { for (const auto&[id, status] : devices) {
qDebug() << "Id:" << id << ", Status:" << status; // qDebug() << "Id:" << id << ", Status:" << status;
DeviceInfo device; DeviceInfo device;
device.id = id; device.id = id;
@ -32,9 +32,9 @@ void DeviceScreener::start() {
} }
device.status = status; device.status = status;
device.updateTime = QDateTime::currentDateTime(); device.updateTime = QDateTime::currentDateTime();
qDebug() << "Update device: " << DeviceDAO::upsertDevice(device); // qDebug() << "Update device: " << DeviceDAO::upsertDevice(device);
} }
qDebug() << "All devices offline: " << DeviceDAO::markDevicesOfflineExcept(onlineIds); // qDebug() << "All devices offline: " << DeviceDAO::markDevicesOfflineExcept(onlineIds);
QThread::sleep(3); QThread::sleep(3);
} }
emit finished(); emit finished();

View File

@ -93,7 +93,7 @@ void AccountWindow::onItemDoubleClicked(QTableWidgetItem *item) {
int column = item->column(); int column = item->column();
if (column == 0) { if (column == 0) {
int accountId = item->data(Qt::UserRole).toInt(); int accountId = item->data(Qt::UserRole).toInt();
qDebug() << accountId; // qDebug() << accountId;
TransactionWindow *detailWindow = new TransactionWindow(accountId, this); TransactionWindow *detailWindow = new TransactionWindow(accountId, this);
detailWindow->exec(); // Ожидаем закрытия окна detailWindow->exec(); // Ожидаем закрытия окна
} }

View File

@ -14,7 +14,7 @@ DeviceWidget::DeviceWidget(const DeviceInfo &device, QWidget *parent): QWidget(p
img.loadFromData(device.image, "JPG"); img.loadFromData(device.image, "JPG");
auto *imageLabel = new QLabel(this); auto *imageLabel = new QLabel(this);
qDebug() << "imageLabel" << img.width() ; // qDebug() << "imageLabel" << img.width() ;
imageLabel->setPixmap(QPixmap::fromImage(img).scaled(200, 350, Qt::KeepAspectRatio, Qt::SmoothTransformation)); imageLabel->setPixmap(QPixmap::fromImage(img).scaled(200, 350, Qt::KeepAspectRatio, Qt::SmoothTransformation));
imageLabel->setAlignment(Qt::AlignCenter); imageLabel->setAlignment(Qt::AlignCenter);
layout->addWidget(imageLabel); layout->addWidget(imageLabel);

View File

@ -4,6 +4,7 @@
#include <QGuiApplication> #include <QGuiApplication>
#include <QTimer> #include <QTimer>
#include <QCloseEvent> #include <QCloseEvent>
#include <QThread>
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
#include <windows.h> #include <windows.h>
@ -29,7 +30,7 @@ void ScrcpyWindow::startScrcpy() {
int deviceWidth = 720; int deviceWidth = 720;
int deviceHeight = 1600; int deviceHeight = 1600;
QScreen* screen = QGuiApplication::primaryScreen(); QScreen *screen = QGuiApplication::primaryScreen();
int screenHeight = screen->availableGeometry().height(); int screenHeight = screen->availableGeometry().height();
int screenWidth = screen->availableGeometry().width(); int screenWidth = screen->availableGeometry().width();
@ -40,29 +41,20 @@ void ScrcpyWindow::startScrcpy() {
int windowWidth = static_cast<int>(deviceWidth * scale); int windowWidth = static_cast<int>(deviceWidth * scale);
int windowHeight = static_cast<int>(deviceHeight * scale); int windowHeight = static_cast<int>(deviceHeight * scale);
qDebug() << "windowWidth:" << windowWidth;
qDebug() << "windowHeight:" << windowHeight;
// Устанавливаем размер вашего окна
setFixedSize(windowWidth + 100, windowHeight); setFixedSize(windowWidth + 100, windowHeight);
// setWindowFlags(windowFlags() | Qt::MSWindowsFixedSizeDialogHint); // setWindowFlags(windowFlags() | Qt::MSWindowsFixedSizeDialogHint);
// QString("--window-width=%1").arg(windowWidth), QString("--window-height=%1").arg(windowHeight)
m_process = new QProcess(this); m_process = new QProcess(this);
m_process->start("scrcpy", { "--window-title", "scrcpy", "--always-on-top"}); m_process->start("scrcpy", {"--window-title", "scrcpy", "--always-on-top", "--window-borderless"});
// Подождём немного, чтобы окно scrcpy запустилось
// QTimer::singleShot(2000, this, &ScrcpyWindow::);
embedPlatformSpecific(); embedPlatformSpecific();
} }
void ScrcpyWindow::stopScrcpy() { void ScrcpyWindow::stopScrcpy() {
// m_process->terminate();
// if (!m_process->waitForFinished(3000)) {
// qDebug() << "Process did not finish in time, killing it";
m_process->kill(); // Принудительное завершение процесса m_process->kill(); // Принудительное завершение процесса
// }
delete m_process; delete m_process;
m_process = nullptr; m_process = nullptr;
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
HWND hwndScrcpy = FindWindowW(nullptr, L"scrcpy"); HWND hwndScrcpy = FindWindowW(nullptr, L"scrcpy");
if (hwndScrcpy) { if (hwndScrcpy) {
@ -71,6 +63,7 @@ void ScrcpyWindow::stopScrcpy() {
#endif #endif
} }
#ifdef Q_OS_WIN
LRESULT CALLBACK wndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { LRESULT CALLBACK wndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {
OutputDebugString(L"WM_CLOSE received\n"); OutputDebugString(L"WM_CLOSE received\n");
@ -120,8 +113,6 @@ LRESULT CALLBACK wndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {
} }
void ScrcpyWindow::embedPlatformSpecific() { void ScrcpyWindow::embedPlatformSpecific() {
#ifdef Q_OS_WIN
HWND hwndScrcpy = FindWindowW(nullptr, L"scrcpy"); HWND hwndScrcpy = FindWindowW(nullptr, L"scrcpy");
int attempts = 0; int attempts = 0;
@ -174,15 +165,5 @@ void ScrcpyWindow::embedPlatformSpecific() {
// LONG_PTR prevWndProc = GetWindowLongPtr(hwndTarget, GWLP_WNDPROC); // LONG_PTR prevWndProc = GetWindowLongPtr(hwndTarget, GWLP_WNDPROC);
// SetWindowLongPtr(hwndTarget, GWLP_WNDPROC, (LONG_PTR)wndProc); // SetWindowLongPtr(hwndTarget, GWLP_WNDPROC, (LONG_PTR)wndProc);
#elif defined(Q_OS_MAC)
extern void embedScrcpyMac(QWidget *container);
embedScrcpyMac(this);
#else
qDebug() << "Scrcpy embedding not implemented for this OS.";
#endif
} }
#endif

View File

@ -1,61 +0,0 @@
#import <Cocoa/Cocoa.h>
#import <QtCore/QDebug>
#import <ApplicationServices/ApplicationServices.h>
#include <QWidget>
#include <QWindow>
void listAllWindows() {
CFArrayRef windowList = CGWindowListCopyWindowInfo(kCGWindowListOptionOnScreenOnly, kCGNullWindowID);
for (NSDictionary *entry in (__bridge NSArray *)windowList) {
NSString *name = entry[(NSString *)kCGWindowName];
NSString *owner = entry[(NSString *)kCGWindowOwnerName];
NSNumber *windowNumber = entry[(NSString *)kCGWindowNumber];
if (name.length > 0) {
qDebug() << "Window:" << owner.UTF8String << "-" << name.UTF8String
<< "ID:" << windowNumber.intValue;
}
}
CFRelease(windowList);
}
void embedScrcpyMac(QWidget *container) {
// Получаем список окон
NSArray *windows = [NSApp windows];
NSWindow *scrcpyWindow = nil;
listAllWindows();
for (NSWindow *window in windows) {
NSString *title = [window title];
qDebug() << "Found window title:" << title.UTF8String;
if ([[window title] isEqualToString:@"scrcpy"]) {
scrcpyWindow = window;
break;
}
}
if (!scrcpyWindow) {
qDebug() << "scrcpy window not found";
return;
}
// Убираем заголовок и рамку
[scrcpyWindow setStyleMask:NSWindowStyleMaskBorderless];
// Получаем координаты окна Qt
NSView *nativeView = (NSView *)container->winId();
NSWindow *qtWindow = [nativeView window];
NSRect frame = [qtWindow frame];
// Задаём новый размер и позицию для окна scrcpy
CGFloat width = frame.size.width;
CGFloat height = frame.size.height;
CGFloat x = frame.origin.x;
CGFloat y = frame.origin.y;
[scrcpyWindow setFrame:NSMakeRect(x, y, width, height) display:YES];
[scrcpyWindow orderFront:nil];
}