diff --git a/CMakeLists.txt b/CMakeLists.txt index a268205..e1683ca 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,10 +19,6 @@ elseif (APPLE) set(CMAKE_PREFIX_PATH "/opt/homebrew/opt/qt") include_directories("/opt/homebrew/opt/tesseract/include") 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 () find_package(Qt6 REQUIRED COMPONENTS @@ -50,15 +46,15 @@ file(GLOB_RECURSE MODELS_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/models/*.h" ) -if (WIN32) - add_executable(ARCDesktopProject - main.cpp - ${VIEW_SOURCES} - ${SERVICES_SOURCES} - ${DB_SOURCES} - ${MODELS_SOURCES} - ) +add_executable(ARCDesktopProject + main.cpp + ${VIEW_SOURCES} + ${SERVICES_SOURCES} + ${DB_SOURCES} + ${MODELS_SOURCES} +) +if (WIN32) target_link_libraries(ARCDesktopProject Qt6::Widgets Qt6::Sql @@ -71,15 +67,6 @@ if (WIN32) file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/rus.traineddata" DESTINATION "${CMAKE_BINARY_DIR}") elseif (APPLE) - add_executable(ARCDesktopProject - main.cpp - ${VIEW_SOURCES} - ${SERVICES_SOURCES} - ${DB_SOURCES} - ${MODELS_SOURCES} - ${SCRCPY} - ) - target_link_libraries(ARCDesktopProject Qt6::Widgets Qt6::Sql diff --git a/database/app_data.db b/database/app_data.db index e65c406..94a52d1 100644 Binary files a/database/app_data.db and b/database/app_data.db differ diff --git a/services/DeviceScreener.cpp b/services/DeviceScreener.cpp index 9c1053a..e618d38 100644 --- a/services/DeviceScreener.cpp +++ b/services/DeviceScreener.cpp @@ -15,12 +15,12 @@ DeviceScreener::DeviceScreener(QObject *parent) : QObject(parent) { DeviceScreener::~DeviceScreener() = default; void DeviceScreener::start() { - qDebug() << "Worker started in thread:" << QThread::currentThread(); + // qDebug() << "Worker started in thread:" << QThread::currentThread(); while (m_running) { QList> devices = readAdbDevices(); QStringList onlineIds; for (const auto&[id, status] : devices) { - qDebug() << "Id:" << id << ", Status:" << status; + // qDebug() << "Id:" << id << ", Status:" << status; DeviceInfo device; device.id = id; @@ -32,9 +32,9 @@ void DeviceScreener::start() { } device.status = status; 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); } emit finished(); diff --git a/views/AccountWindow.cpp b/views/AccountWindow.cpp index 0a64189..6f80ca9 100644 --- a/views/AccountWindow.cpp +++ b/views/AccountWindow.cpp @@ -93,7 +93,7 @@ void AccountWindow::onItemDoubleClicked(QTableWidgetItem *item) { int column = item->column(); if (column == 0) { int accountId = item->data(Qt::UserRole).toInt(); - qDebug() << accountId; + // qDebug() << accountId; TransactionWindow *detailWindow = new TransactionWindow(accountId, this); detailWindow->exec(); // Ожидаем закрытия окна } diff --git a/views/DeviceWidget.cpp b/views/DeviceWidget.cpp index 0ecc584..5e73e5e 100644 --- a/views/DeviceWidget.cpp +++ b/views/DeviceWidget.cpp @@ -14,7 +14,7 @@ DeviceWidget::DeviceWidget(const DeviceInfo &device, QWidget *parent): QWidget(p img.loadFromData(device.image, "JPG"); 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->setAlignment(Qt::AlignCenter); layout->addWidget(imageLabel); diff --git a/views/scrcpy/ScrcpyWindow.cpp b/views/scrcpy/ScrcpyWindow.cpp index 023b2d0..8aadcd3 100644 --- a/views/scrcpy/ScrcpyWindow.cpp +++ b/views/scrcpy/ScrcpyWindow.cpp @@ -4,6 +4,7 @@ #include #include #include +#include #ifdef Q_OS_WIN #include @@ -21,15 +22,15 @@ ScrcpyWindow::~ScrcpyWindow() { void ScrcpyWindow::closeEvent(QCloseEvent *event) { qDebug() << "closeEvent triggered"; - stopScrcpy(); - event->accept(); + stopScrcpy(); + event->accept(); } void ScrcpyWindow::startScrcpy() { int deviceWidth = 720; int deviceHeight = 1600; - QScreen* screen = QGuiApplication::primaryScreen(); + QScreen *screen = QGuiApplication::primaryScreen(); int screenHeight = screen->availableGeometry().height(); int screenWidth = screen->availableGeometry().width(); @@ -40,29 +41,20 @@ void ScrcpyWindow::startScrcpy() { int windowWidth = static_cast(deviceWidth * scale); int windowHeight = static_cast(deviceHeight * scale); - qDebug() << "windowWidth:" << windowWidth; - qDebug() << "windowHeight:" << windowHeight; - // Устанавливаем размер вашего окна setFixedSize(windowWidth + 100, windowHeight); // setWindowFlags(windowFlags() | Qt::MSWindowsFixedSizeDialogHint); - // QString("--window-width=%1").arg(windowWidth), QString("--window-height=%1").arg(windowHeight) 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(); } 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; m_process = nullptr; + #ifdef Q_OS_WIN HWND hwndScrcpy = FindWindowW(nullptr, L"scrcpy"); if (hwndScrcpy) { @@ -71,6 +63,7 @@ void ScrcpyWindow::stopScrcpy() { #endif } +#ifdef Q_OS_WIN LRESULT CALLBACK wndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { OutputDebugString(L"WM_CLOSE received\n"); @@ -120,8 +113,6 @@ LRESULT CALLBACK wndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { } void ScrcpyWindow::embedPlatformSpecific() { -#ifdef Q_OS_WIN - HWND hwndScrcpy = FindWindowW(nullptr, L"scrcpy"); int attempts = 0; @@ -174,15 +165,5 @@ void ScrcpyWindow::embedPlatformSpecific() { // LONG_PTR prevWndProc = GetWindowLongPtr(hwndTarget, GWLP_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 -} \ No newline at end of file diff --git a/views/scrcpy/ScrcpyWindow_mac.mm b/views/scrcpy/ScrcpyWindow_mac.mm deleted file mode 100644 index e7da188..0000000 --- a/views/scrcpy/ScrcpyWindow_mac.mm +++ /dev/null @@ -1,61 +0,0 @@ -#import -#import -#import -#include -#include - -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]; -}