diff --git a/colorpicker/colorpickerscene.cpp b/colorpicker/colorpickerscene.cpp index 514c130..840ace5 100644 --- a/colorpicker/colorpickerscene.cpp +++ b/colorpicker/colorpickerscene.cpp @@ -32,12 +32,13 @@ ColorPickerScene::ColorPickerScene(QPixmap pixmap, QWidget *parentWidget) color = pItem->pixmap().toImage().pixelColor(QCursor::pos()); text->setPlainText(color.name()); ellipse->setBrush(color); + image = pixmap.toImage(); show(); } void ColorPickerScene::mouseMoveEvent(QGraphicsSceneMouseEvent *event) { - color = pItem->pixmap().toImage().pixelColor(event->scenePos().toPoint()); + color = image.pixelColor(event->scenePos().toPoint()); text->setPlainText(color.name()); ellipse->setBrush(color); @@ -61,9 +62,6 @@ void ColorPickerScene::mouseMoveEvent(QGraphicsSceneMouseEvent *event) { ellipse->setRect(QRectF(scopePoint, QSize(20, 20))); text->setPos(resPoint); textBackground->setPos(text->pos()); - // How does this work? I have no clue.... - // I mean.. It kinda makes sense when you look through it carefully - // But it's still a mess. } void ColorPickerScene::keyPressEvent(QKeyEvent *event) { diff --git a/colorpicker/colorpickerscene.hpp b/colorpicker/colorpickerscene.hpp index eb2cf00..e2e9c55 100644 --- a/colorpicker/colorpickerscene.hpp +++ b/colorpicker/colorpickerscene.hpp @@ -17,10 +17,11 @@ public: void keyPressEvent(QKeyEvent *event) override; void mouseReleaseEvent(QGraphicsSceneMouseEvent *) override; static void showPicker() { - ColorPickerScene(screenshotutil::fullscreen(), 0); + new ColorPickerScene(screenshotutil::fullscreen(), 0); } private: + QImage image; QColor color; QGraphicsEllipseItem *ellipse = 0; QGraphicsPixmapItem *pItem = 0; diff --git a/cropeditor/cropscene.cpp b/cropeditor/cropscene.cpp index 876a96f..c0765a2 100644 --- a/cropeditor/cropscene.cpp +++ b/cropeditor/cropscene.cpp @@ -211,7 +211,7 @@ void CropScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *e) { if (drawingSelection) if (!drawingSelection->init(this)) setDrawingSelection("None", [] { return nullptr; }); } else if (settings::settings().value("quickMode", false).toBool()) - done(); + done(true); prevButtons = Qt::NoButton; } @@ -257,7 +257,8 @@ void CropScene::contextMenuEvent(QGraphicsSceneContextMenuEvent *e) { } void CropScene::keyReleaseEvent(QKeyEvent *event) { - if (event->key() == Qt::Key_Return || event->key() == Qt::Key_Enter || event->key() == Qt::Key_Escape) done(); + if (event->key() == Qt::Key_Return || event->key() == Qt::Key_Enter || event->key() == Qt::Key_Escape) + done(event->key() != Qt::Key_Escape); } void CropScene::updateMag(QPointF scenePos) { @@ -311,8 +312,8 @@ void CropScene::initMagnifierGrid() { } } -void CropScene::done() { - if (rect) { +void CropScene::done(bool notEsc) { + if (notEsc && rect) { rect->setPen(QPen(Qt::NoPen)); magnifier->setVisible(false); magnifierBox->setVisible(false); diff --git a/cropeditor/cropscene.hpp b/cropeditor/cropscene.hpp index cb04c74..0f93daa 100644 --- a/cropeditor/cropscene.hpp +++ b/cropeditor/cropscene.hpp @@ -54,7 +54,7 @@ private: void updateMag(QPointF scenePos); void initMagnifierGrid(); void addDrawingAction(QMenu &menu, QString name, std::function item); - void done(); + void done(bool notEsc); bool fullscreen; std::function drawingSelectionMaker; QFlags prevButtons; diff --git a/mainwindow.ui b/mainwindow.ui index d68b223..699f6df 100644 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -80,7 +80,7 @@ - Recording + &Recording diff --git a/screenshotutil.cpp b/screenshotutil.cpp index 8e04679..e5aa697 100644 --- a/screenshotutil.cpp +++ b/screenshotutil.cpp @@ -2,6 +2,7 @@ #include #include +#include #include #include #include @@ -10,9 +11,9 @@ QPixmap screenshotutil::fullscreen(bool cursor) { int height = 0, width = 0; for (QScreen *screen : QApplication::screens()) { - width += screen->size().width(); - int h = screen->size().height(); - height = h > height ? h : height; + QRect geo = screen->geometry(); + width = qMax(geo.right() + geo.width(), width); + height = qMax(geo.bottom() + geo.height(), height); } QPixmap image(width, height); image.fill(Qt::transparent); @@ -20,7 +21,10 @@ QPixmap screenshotutil::fullscreen(bool cursor) { width = 0; for (QScreen *screen : QApplication::screens()) { QPixmap currentScreen = window(0, screen); - painter.drawPixmap(width, 0, currentScreen); + // Hack for https://bugreports.qt.io/browse/QTBUG-58110 + QStringList qVer = QString(qVersion()).split('.'); + if (qVer.at(0).toInt() == 5 && qVer.at(1).toInt() < 9) currentScreen = currentScreen.copy(screen->geometry()); + painter.drawPixmap(screen->geometry().topLeft(), currentScreen); width += screen->size().width(); } #ifdef PLATFORM_CAPABILITY_CURSOR @@ -28,8 +32,8 @@ QPixmap screenshotutil::fullscreen(bool cursor) { auto cursorData = PlatformBackend::inst().getCursor(); painter.drawPixmap(QCursor::pos() - std::get<0>(cursorData), std::get<1>(cursorData)); } - painter.end(); #endif + painter.end(); return image; }