Skip to content

Commit

Permalink
Proof of concept for windowed mode.
Browse files Browse the repository at this point in the history
  • Loading branch information
karliss committed Jun 12, 2021
1 parent 8f6b6b0 commit 8e636b1
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/core/controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() &&
Expand Down
12 changes: 10 additions & 2 deletions src/widgets/capture/capturewidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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())) {
Expand Down Expand Up @@ -744,6 +751,7 @@ void CaptureWidget::mouseReleaseEvent(QMouseEvent* e)
m_activeToolIsMoved = false;
m_newSelection = false;
m_grabbing = false;
m_middleClickDrag = false;

updateCursor();
}
Expand Down
5 changes: 5 additions & 0 deletions src/widgets/capture/capturewidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <QPointer>
#include <QUndoStack>
#include <QWidget>
#include <qpoint.h>

class QPaintEvent;
class QResizeEvent;
Expand Down Expand Up @@ -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;
};

0 comments on commit 8e636b1

Please sign in to comment.