1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294
|
/*
* ========================================================================== *
* *
* This file is part of the Openterface Mini KVM App QT version *
* *
* Copyright (C) 2024 <info@openterface.com> *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation version 3. *
* *
* This program is distributed in the hope that it will be useful, but *
* WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
* General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
* *
* ========================================================================== *
*/
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
// Include Qt headers first
#include <QtWidgets>
#include <QtMultimedia>
#include <QtMultimediaWidgets>
// Then include your custom headers
#include "../host/audiomanager.h"
#include "ui/statuswidget.h"
#include "ui/statusevents.h"
#include "ui/videopane.h"
#include "ui/toggleswitch.h"
#include "toolbarmanager.h"
#include "ui/serialportdebugdialog.h"
#include "ui/settingdialog.h"
#include "host/cameramanager.h"
#include "ui/versioninfomanager.h"
#include "statusbarmanager.h"
#include "host/usbcontrol.h"
#include "ui/cameraajust.h"
#include "ui/scripttool.h"
#include "ui/TaskManager.h"
#include "../scripts/semanticAnalyzer.h"
#include "../scripts/AST.h"
#include "server/tcpServer.h"
#include <QAudioInput>
#include <QAudioOutput>
#include <QAudioSource>
#include <QAudioSink>
#include <QAudioDecoder>
#include <QCamera>
#include <QImageCapture>
#include <QMediaCaptureSession>
#include <QMediaDevices>
#include <QMediaMetaData>
#include <QMediaRecorder>
#include <QScopedPointer>
#include <QVideoWidget>
#include <QMainWindow>
#include <QStackedLayout>
#include <QMediaDevices>
#include <QLoggingCategory>
#include <QAudioBuffer>
#include <QLabel>
#include <QLineEdit>
#include <QPushButton>
#include <QComboBox>
#include <QApplication>
#include <QPalette>
#include <QStyle>
#include <QEvent>
#include <QScrollArea>
#include <libusb-1.0/libusb.h>
#include <QMessageBox>
Q_DECLARE_LOGGING_CATEGORY(log_ui_mainwindow)
QT_BEGIN_NAMESPACE
namespace Ui {
class MainWindow;
}
class QActionGroup;
QT_END_NAMESPACE
class MetaDataDialog;
QPixmap recolorSvg(const QString &svgPath, const QColor &color, const QSize &size);
class MainWindow : public QMainWindow, public StatusEventCallback
{
Q_OBJECT
public:
MainWindow();
void calculate_video_position();
void stop();
// Add this line to declare the destructor
~MainWindow() override;
public slots:
void handleSyntaxTree(std::shared_ptr<ASTNode> syntaxTree);
void changeKeyboardLayout(const QString& layout);
void initializeKeyboardLayouts();
private slots:
void initCamera();
void record();
void pause();
void setMuted(bool);
void takeImage(const QString& path = "");
void takeAreaImage(const QString& path, const QRect& captureArea);
void takeImageDefault();
void displayCaptureError(int, QImageCapture::Error, const QString &errorString);
void versionInfo();
void purchaseLink();
void feedbackLink();
void officialLink();
void aboutLink();
void updateLink();
void setTooltip();
void configureSettings();
void debugSerialPort();
void displayCameraError();
void updateCameraActive(bool active);
void setExposureCompensation(int index);
void updateRecordTime();
void processCapturedImage(int requestId, const QImage &img);
void displayViewfinder();
void displayCapturedImage();
void imageSaved(int id, const QString &fileName);
void updateCameras();
void popupMessage(QString message);
void onPortConnected(const QString& port, const int& baudrate) override;
void onLastKeyPressed(const QString& key) override;
void onLastMouseLocation(const QPoint& location, const QString& mouseEvent) override;
void onStatusUpdate(const QString& port) override;
void onSwitchableUsbToggle(const bool isToHost) override;
void onResolutionChange(const int& width, const int& height, const float& fps) override;
void onTargetUsbConnected(const bool isConnected) override;
bool CheckDeviceAccess(uint16_t vid, uint16_t pid);
protected:
void closeEvent(QCloseEvent *event) override;
void resizeEvent(QResizeEvent* event) override;
void moveEvent(QMoveEvent *event) override;
void onActionRelativeTriggered();
void onActionAbsoluteTriggered();
void onActionResetHIDTriggered();
void onActionResetSerialPortTriggered();
void onActionFactoryResetHIDTriggered();
void onActionSwitchToHostTriggered();
void onActionSwitchToTargetTriggered();
void onActionPasteToTarget();
void onActionScreensaver();
void onToggleVirtualKeyboard();
void queryResolutions();
void updateResolutions(int input_width, int input_height, float input_fps, int capture_width, int capture_height, int capture_fps);
void onButtonClicked();
private slots:
void onRepeatingKeystrokeChanged(int index);
void onFunctionKeyPressed(int key);
void onCtrlAltDelPressed();
void onBaudrateMenuTriggered(QAction* action);
void onToggleSwitchStateChanged(int state);
void onZoomIn();
void onZoomOut();
void onZoomReduction();
private slots:
void checkMousePosition();
private slots:
void onVideoSettingsChanged(int width, int height);
void onResolutionsUpdated(int input_width, int input_height, float input_fps, int capture_width, int capture_height, int capture_fps);
protected:
bool eventFilter(QObject *watched, QEvent *event) override;
private:
Ui::MainWindow *ui;
AudioManager *m_audioManager;
VideoPane *videoPane;
double systemScaleFactor;
QColor iconColor;
QScrollArea *scrollArea;
QStackedLayout *stackedLayout;
QLabel *mouseLocationLabel;
QLabel *mouseLabel;
QLabel *keyPressedLabel;
QLabel *keyLabel;
QToolBar *toolbar;
ToolbarManager *toolbarManager; // Moved up in the declaration orde r
TcpServer *tcpServer;
QMediaDevices m_source;
QScopedPointer<QImageCapture> m_imageCapture;
QMediaCaptureSession m_captureSession;
QScopedPointer<QCamera> m_camera;
QScopedPointer<QMediaRecorder> m_mediaRecorder;
bool videoReady = false;
bool m_isCapturingImage = false;
bool m_applicationExiting = false;
bool m_doImageCapture = true;
int video_width = 1920;
int video_height = 1080;
QList<QCameraDevice> m_lastCameraList;
MetaDataDialog *m_metaDataDialog = nullptr;
SettingDialog *settingDialog = nullptr;
SerialPortDebugDialog *serialPortDebugDialog = nullptr;
QWidget *keyboardPanel = nullptr;
QPushButton* createFunctionButton(const QString &text);
void onRepeatingKeystrokeToggled(bool checked);
QComboBox *repeatingKeystrokeComboBox;
void updateBaudrateMenu(int baudrate);
ToggleSwitch *toggleSwitch;
CameraManager *m_cameraManager;
InputHandler *m_inputHandler;
void updateScrollbars();
QPoint lastMousePos;
double factorScale = 1;
QTimer *mouseEdgeTimer; // Add this line
const int edgeThreshold = 50; // Adjust this value as needed
const int edgeDuration = 125; // Reduced duration for more frequent checks
const int maxScrollSpeed = 50; // Maximum scroll speed
VersionInfoManager *m_versionInfoManager;
StatusBarManager *m_statusBarManager;
USBControl *usbControl;
// CameraAdjust *cameraAdjust;
std::unique_ptr<MouseManager> mouseManager;
std::unique_ptr<KeyboardMouse> keyboardMouse;
std::unique_ptr<SemanticAnalyzer> semanticAnalyzer;
TaskManager* taskmanager;
void showScriptTool();
void onToolbarVisibilityChanged(bool visible);
void animateVideoPane();
void centerVideoPane();
void checkInitSize();
void startServer();
};
#endif // MAINWINDOW_H
|