resolving merge conflicts
This commit is contained in:
@@ -115,27 +115,32 @@ void CaptureToolButton::setColor(const QColor& c)
|
||||
|
||||
QColor CaptureToolButton::m_mainColor = ConfigHandler().uiMainColorValue();
|
||||
|
||||
static std::map<CaptureToolButton::ButtonType, int> buttonTypeOrder{
|
||||
static std::map<CaptureToolButton::ButtonType, int> buttonTypeOrder
|
||||
{
|
||||
{ CaptureToolButton::TYPE_PENCIL, 0 },
|
||||
{ CaptureToolButton::TYPE_DRAWER, 1 },
|
||||
{ CaptureToolButton::TYPE_ARROW, 2 },
|
||||
{ CaptureToolButton::TYPE_SELECTION, 3 },
|
||||
{ CaptureToolButton::TYPE_RECTANGLE, 4 },
|
||||
{ CaptureToolButton::TYPE_CIRCLE, 5 },
|
||||
{ CaptureToolButton::TYPE_MARKER, 6 },
|
||||
{ CaptureToolButton::TYPE_TEXT, 7 },
|
||||
{ CaptureToolButton::TYPE_PIXELATE, 8 },
|
||||
{ CaptureToolButton::TYPE_CIRCLECOUNT, 9 },
|
||||
{ CaptureToolButton::TYPE_SELECTIONINDICATOR, 10 },
|
||||
{ CaptureToolButton::TYPE_MOVESELECTION, 11 },
|
||||
{ CaptureToolButton::TYPE_UNDO, 12 },
|
||||
{ CaptureToolButton::TYPE_REDO, 13 },
|
||||
{ CaptureToolButton::TYPE_COPY, 14 },
|
||||
{ CaptureToolButton::TYPE_SAVE, 15 },
|
||||
{ CaptureToolButton::TYPE_EXIT, 16 },
|
||||
{ CaptureToolButton::TYPE_IMAGEUPLOADER, 17 },
|
||||
{ CaptureToolButton::TYPE_OPEN_APP, 18 },
|
||||
{ CaptureToolButton::TYPE_PIN, 19 },
|
||||
{ CaptureToolButton::TYPE_DRAWER, 1 },
|
||||
{ CaptureToolButton::TYPE_ARROW, 2 },
|
||||
{ CaptureToolButton::TYPE_SELECTION, 3 },
|
||||
{ CaptureToolButton::TYPE_RECTANGLE, 4 },
|
||||
{ CaptureToolButton::TYPE_CIRCLE, 5 },
|
||||
{ CaptureToolButton::TYPE_MARKER, 6 },
|
||||
{ CaptureToolButton::TYPE_TEXT, 7 },
|
||||
{ CaptureToolButton::TYPE_PIXELATE, 8 },
|
||||
{ CaptureToolButton::TYPE_CIRCLECOUNT, 9 },
|
||||
{ CaptureToolButton::TYPE_SELECTIONINDICATOR, 10 },
|
||||
{ CaptureToolButton::TYPE_MOVESELECTION, 11 },
|
||||
{ CaptureToolButton::TYPE_UNDO, 12 },
|
||||
{ CaptureToolButton::TYPE_REDO, 13 },
|
||||
{ CaptureToolButton::TYPE_COPY, 14 },
|
||||
{ CaptureToolButton::TYPE_SAVE, 15 },
|
||||
{ CaptureToolButton::TYPE_IMAGEUPLOADER, 16 },
|
||||
#if not(defined(Q_OS_MAC) || defined(Q_OS_MAC64) || defined(Q_OS_MACOS) || \
|
||||
defined(Q_OS_MACX))
|
||||
{ CaptureToolButton::TYPE_OPEN_APP, 17 },
|
||||
{ CaptureToolButton::TYPE_EXIT, 18 }, { CaptureToolButton::TYPE_PIN, 19 },
|
||||
#else
|
||||
{ CaptureToolButton::TYPE_EXIT, 17 }, { CaptureToolButton::TYPE_PIN, 18 },
|
||||
#endif
|
||||
};
|
||||
|
||||
int CaptureToolButton::getPriorityByButton(CaptureToolButton::ButtonType b)
|
||||
@@ -164,7 +169,10 @@ QVector<CaptureToolButton::ButtonType>
|
||||
CaptureToolButton::TYPE_SAVE,
|
||||
CaptureToolButton::TYPE_EXIT,
|
||||
CaptureToolButton::TYPE_IMAGEUPLOADER,
|
||||
#if not(defined(Q_OS_MAC) || defined(Q_OS_MAC64) || defined(Q_OS_MACOS) || \
|
||||
defined(Q_OS_MACX))
|
||||
CaptureToolButton::TYPE_OPEN_APP,
|
||||
#endif
|
||||
CaptureToolButton::TYPE_PIN,
|
||||
CaptureToolButton::TYPE_CIRCLECOUNT,
|
||||
};
|
||||
|
||||
@@ -53,8 +53,7 @@ public:
|
||||
TYPE_REDO = 16,
|
||||
TYPE_PIN = 17,
|
||||
TYPE_TEXT = 18,
|
||||
TYPE_CIRCLECOUNT = 19,
|
||||
|
||||
TYPE_CIRCLECOUNT = 19
|
||||
};
|
||||
Q_ENUM(ButtonType)
|
||||
|
||||
|
||||
@@ -36,7 +36,9 @@
|
||||
#include "src/widgets/capture/notifierbox.h"
|
||||
#include "src/widgets/orientablepushbutton.h"
|
||||
#include "src/widgets/panel/sidepanelwidget.h"
|
||||
#include "src/widgets/updatenotificationwidget.h"
|
||||
#include <QApplication>
|
||||
#include <QDateTime>
|
||||
#include <QDesktopWidget>
|
||||
#include <QGuiApplication>
|
||||
#include <QPaintEvent>
|
||||
@@ -70,6 +72,8 @@ CaptureWidget::CaptureWidget(const uint id,
|
||||
, m_toolWidget(nullptr)
|
||||
, m_mouseOverHandle(SelectionWidget::NO_SIDE)
|
||||
, m_id(id)
|
||||
, m_lastMouseWheel(0)
|
||||
, m_updateNotificationWidget(nullptr)
|
||||
{
|
||||
// Base config of the widget
|
||||
m_eventFilter = new HoverEventFilter(this);
|
||||
@@ -88,7 +92,8 @@ CaptureWidget::CaptureWidget(const uint id,
|
||||
initContext(savePath, fullScreen);
|
||||
initShortcuts();
|
||||
m_context.circleCount = 1;
|
||||
#ifdef Q_OS_WIN
|
||||
#if (defined(Q_OS_WIN) || defined(Q_OS_MAC) || defined(Q_OS_MAC64) || \
|
||||
defined(Q_OS_MACOS) || defined(Q_OS_MACX))
|
||||
// Top left of the whole set of screens
|
||||
QPoint topLeft(0, 0);
|
||||
#endif
|
||||
@@ -102,7 +107,7 @@ CaptureWidget::CaptureWidget(const uint id,
|
||||
}
|
||||
m_context.origScreenshot = m_context.screenshot;
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
#if defined(Q_OS_WIN)
|
||||
setWindowFlags(Qt::WindowStaysOnTopHint | Qt::FramelessWindowHint |
|
||||
Qt::Popup);
|
||||
|
||||
@@ -117,11 +122,24 @@ CaptureWidget::CaptureWidget(const uint id,
|
||||
}
|
||||
}
|
||||
move(topLeft);
|
||||
resize(pixmap().size());
|
||||
#elif (defined(Q_OS_MAC) || defined(Q_OS_MAC64) || defined(Q_OS_MACOS) || \
|
||||
defined(Q_OS_MACX))
|
||||
// Emulate fullscreen mode
|
||||
// setWindowFlags(Qt::WindowStaysOnTopHint |
|
||||
// Qt::BypassWindowManagerHint |
|
||||
// Qt::FramelessWindowHint |
|
||||
// Qt::NoDropShadowWindowHint | Qt::ToolTip |
|
||||
// Qt::Popup
|
||||
// );
|
||||
QScreen* currentScreen = QGuiApplication::screenAt(QCursor::pos());
|
||||
move(currentScreen->geometry().x(), currentScreen->geometry().y());
|
||||
resize(currentScreen->size());
|
||||
#else
|
||||
setWindowFlags(Qt::BypassWindowManagerHint | Qt::WindowStaysOnTopHint |
|
||||
Qt::FramelessWindowHint | Qt::Tool);
|
||||
#endif
|
||||
resize(pixmap().size());
|
||||
#endif
|
||||
}
|
||||
// Create buttons
|
||||
m_buttonHandler = new ButtonHandler(this);
|
||||
@@ -132,7 +150,7 @@ CaptureWidget::CaptureWidget(const uint id,
|
||||
QRect r = screen->geometry();
|
||||
r.moveTo(r.x() / screen->devicePixelRatio(),
|
||||
r.y() / screen->devicePixelRatio());
|
||||
#ifdef Q_OS_WIN
|
||||
#if defined(Q_OS_WIN)
|
||||
r.moveTo(r.topLeft() - topLeft);
|
||||
#endif
|
||||
areas.append(r);
|
||||
@@ -304,7 +322,19 @@ void CaptureWidget::paintEvent(QPaintEvent*)
|
||||
painter.setClipRect(rect());
|
||||
|
||||
if (m_showInitialMsg) {
|
||||
#if (defined(Q_OS_MAC) || defined(Q_OS_MAC64) || defined(Q_OS_MACOS) || \
|
||||
defined(Q_OS_MACX))
|
||||
QRect helpRect;
|
||||
QScreen* currentScreen = QGuiApplication::screenAt(QCursor::pos());
|
||||
if (currentScreen) {
|
||||
helpRect = currentScreen->geometry();
|
||||
} else {
|
||||
helpRect = QGuiApplication::primaryScreen()->geometry();
|
||||
}
|
||||
#else
|
||||
QRect helpRect = QGuiApplication::primaryScreen()->geometry();
|
||||
#endif
|
||||
|
||||
helpRect.moveTo(mapFromGlobal(helpRect.topLeft()));
|
||||
|
||||
QString helpTxt =
|
||||
@@ -606,7 +636,36 @@ void CaptureWidget::keyReleaseEvent(QKeyEvent* e)
|
||||
|
||||
void CaptureWidget::wheelEvent(QWheelEvent* e)
|
||||
{
|
||||
m_context.thickness += e->angleDelta().y() / 120;
|
||||
/* Mouse scroll usually gives value 120, not more or less, just how many
|
||||
* times.
|
||||
* Touchpad gives the value 2 or more (usually 2-8), it doesn't give
|
||||
* too big values like mouse wheel on normal scrolling, so it is almost
|
||||
* impossible to scroll. It's easier to calculate number of requests and do
|
||||
* not accept events faster that one in 200ms.
|
||||
* */
|
||||
int thicknessOffset = 0;
|
||||
if (e->angleDelta().y() >= 60) {
|
||||
// mouse scroll (wheel) increment
|
||||
thicknessOffset = 1;
|
||||
} else if (e->angleDelta().y() <= -60) {
|
||||
// mouse scroll (wheel) decrement
|
||||
thicknessOffset = -1;
|
||||
} else {
|
||||
// touchpad scroll
|
||||
qint64 current = QDateTime::currentMSecsSinceEpoch();
|
||||
if ((current - m_lastMouseWheel) > 200) {
|
||||
if (e->angleDelta().y() > 0) {
|
||||
thicknessOffset = 1;
|
||||
} else if (e->angleDelta().y() < 0) {
|
||||
thicknessOffset = -1;
|
||||
}
|
||||
m_lastMouseWheel = current;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
m_context.thickness += thicknessOffset;
|
||||
m_context.thickness = qBound(0, m_context.thickness, 100);
|
||||
QPoint topLeft =
|
||||
qApp->desktop()
|
||||
@@ -681,10 +740,19 @@ void CaptureWidget::initPanel()
|
||||
}
|
||||
|
||||
m_panel = new UtilityPanel(this);
|
||||
m_panel->hide();
|
||||
makeChild(m_panel);
|
||||
#if (defined(Q_OS_MAC) || defined(Q_OS_MAC64) || defined(Q_OS_MACOS) || \
|
||||
defined(Q_OS_MACX))
|
||||
QScreen* currentScreen = QGuiApplication::screenAt(QCursor::pos());
|
||||
panelRect.moveTo(mapFromGlobal(panelRect.topLeft()));
|
||||
m_panel->setFixedWidth(m_colorPicker->width() * 1.5);
|
||||
m_panel->setFixedHeight(currentScreen->geometry().height());
|
||||
#else
|
||||
panelRect.moveTo(mapFromGlobal(panelRect.topLeft()));
|
||||
panelRect.setWidth(m_colorPicker->width() * 1.5);
|
||||
m_panel->setGeometry(panelRect);
|
||||
#endif
|
||||
|
||||
SidePanelWidget* sidePanel = new SidePanelWidget(&m_context.screenshot);
|
||||
connect(sidePanel,
|
||||
@@ -711,6 +779,26 @@ void CaptureWidget::initPanel()
|
||||
m_panel->pushWidget(new QUndoView(&m_undoStack, this));
|
||||
}
|
||||
|
||||
void CaptureWidget::showAppUpdateNotification(const QString& appLatestVersion,
|
||||
const QString& appLatestUrl)
|
||||
{
|
||||
if (nullptr == m_updateNotificationWidget) {
|
||||
m_updateNotificationWidget =
|
||||
new UpdateNotificationWidget(this, appLatestVersion, appLatestUrl);
|
||||
}
|
||||
#if (defined(Q_OS_MAC) || defined(Q_OS_MAC64) || defined(Q_OS_MACOS) || \
|
||||
defined(Q_OS_MACX))
|
||||
int ax = (width() - m_updateNotificationWidget->width()) / 2;
|
||||
#else
|
||||
QRect helpRect = QGuiApplication::primaryScreen()->geometry();
|
||||
int ax = helpRect.left() +
|
||||
((helpRect.width() - m_updateNotificationWidget->width()) / 2);
|
||||
#endif
|
||||
m_updateNotificationWidget->move(ax, 0);
|
||||
makeChild(m_updateNotificationWidget);
|
||||
m_updateNotificationWidget->show();
|
||||
}
|
||||
|
||||
void CaptureWidget::initSelection()
|
||||
{
|
||||
m_selection = new SelectionWidget(m_uiColor, this);
|
||||
@@ -1101,6 +1189,10 @@ void CaptureWidget::copyScreenshot()
|
||||
|
||||
void CaptureWidget::saveScreenshot()
|
||||
{
|
||||
#if (defined(Q_OS_MAC) || defined(Q_OS_MAC64) || defined(Q_OS_MACOS) || \
|
||||
defined(Q_OS_MACX))
|
||||
showNormal();
|
||||
#endif
|
||||
m_captureDone = true;
|
||||
if (m_activeTool != nullptr) {
|
||||
QPainter painter(&m_context.screenshot);
|
||||
|
||||
@@ -44,6 +44,7 @@ class QNetworkReply;
|
||||
class ColorPicker;
|
||||
class NotifierBox;
|
||||
class HoverEventFilter;
|
||||
class UpdateNotificationWidget;
|
||||
|
||||
class CaptureWidget : public QWidget
|
||||
{
|
||||
@@ -58,6 +59,8 @@ public:
|
||||
|
||||
void updateButtons();
|
||||
QPixmap pixmap();
|
||||
void showAppUpdateNotification(const QString& appLatestVersion,
|
||||
const QString& appLatestUrl);
|
||||
|
||||
public slots:
|
||||
bool commitCurrentTool();
|
||||
@@ -149,6 +152,8 @@ private:
|
||||
QRect extendedRect(QRect* r) const;
|
||||
|
||||
private:
|
||||
UpdateNotificationWidget* m_updateNotificationWidget;
|
||||
quint64 m_lastMouseWheel;
|
||||
QUndoStack m_undoStack;
|
||||
QPointer<CaptureToolButton> m_sizeIndButton;
|
||||
// Last pressed button
|
||||
|
||||
Reference in New Issue
Block a user