From 8e636b144ec1b5c7b3a65c3c0782a51e3e4624d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C4=81rlis=20Se=C5=86ko?= Date: Sat, 12 Jun 2021 12:45:13 +0300 Subject: [PATCH] Proof of concept for windowed mode. --- src/core/controller.cpp | 3 ++- src/widgets/capture/capturewidget.cpp | 12 ++++++++++-- src/widgets/capture/capturewidget.h | 5 +++++ 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/core/controller.cpp b/src/core/controller.cpp index ffe0ad5282..2ffa5be4eb 100644 --- a/src/core/controller.cpp +++ b/src/core/controller.cpp @@ -315,7 +315,8 @@ void Controller::startVisualCapture(const uint id, m_captureWindow->activateWindow(); m_captureWindow->raise(); #else - m_captureWindow->showFullScreen(); + //m_captureWindow->showFullScreen(); + m_captureWindow->showMaximized(); // m_captureWindow->show(); // For CaptureWidget Debugging under Linux #endif if (!m_appLatestUrl.isEmpty() && diff --git a/src/widgets/capture/capturewidget.cpp b/src/widgets/capture/capturewidget.cpp index e4b8ed3a52..69b9259894 100644 --- a/src/widgets/capture/capturewidget.cpp +++ b/src/widgets/capture/capturewidget.cpp @@ -68,6 +68,7 @@ CaptureWidget::CaptureWidget(uint id, , m_selection(nullptr) , m_existingObjectIsChanged(false) , m_startMove(false) + , m_middleClickDrag(false) { m_undoStack.setUndoLimit(ConfigHandler().undoLimit()); @@ -130,9 +131,9 @@ CaptureWidget::CaptureWidget(uint id, resize(currentScreen->size()); #else // Comment For CaptureWidget Debugging under Linux - setWindowFlags(Qt::BypassWindowManagerHint | Qt::WindowStaysOnTopHint | + /*setWindowFlags(Qt::BypassWindowManagerHint | Qt::WindowStaysOnTopHint | Qt::FramelessWindowHint | Qt::Tool); - resize(pixmap().size()); + resize(pixmap().size());*/ #endif } // Create buttons @@ -342,6 +343,7 @@ void CaptureWidget::paintEvent(QPaintEvent* paintEvent) { Q_UNUSED(paintEvent) QPainter painter(this); + painter.translate(m_viewOffset); painter.drawPixmap(0, 0, m_context.screenshot); if (m_activeTool && m_mouseIsClicked) { @@ -502,8 +504,13 @@ void CaptureWidget::mousePressEvent(QMouseEvent* e) m_grabbing = true; } } + } else if (e->button() == Qt::MiddleButton) { + m_middleClickDrag = true; + m_dragStartPoint = e->pos(); + m_initialOffset = m_viewOffset; } + // Commit current tool if it has edit widget and mouse click is outside // of it if (m_toolWidget && !m_toolWidget->geometry().contains(e->pos())) { @@ -744,6 +751,7 @@ void CaptureWidget::mouseReleaseEvent(QMouseEvent* e) m_activeToolIsMoved = false; m_newSelection = false; m_grabbing = false; + m_middleClickDrag = false; updateCursor(); } diff --git a/src/widgets/capture/capturewidget.h b/src/widgets/capture/capturewidget.h index 8eaad97004..997853019d 100644 --- a/src/widgets/capture/capturewidget.h +++ b/src/widgets/capture/capturewidget.h @@ -21,6 +21,7 @@ #include #include #include +#include class QPaintEvent; class QResizeEvent; @@ -195,4 +196,8 @@ private slots: // For start moving after more than X offset QPoint m_startMovePos; bool m_startMove; + + QPoint m_viewOffset; + QPoint m_initialOffset; + bool m_middleClickDrag; };