diff --git a/src/QuickEditor/QuickEditor.h b/src/QuickEditor/QuickEditor.h --- a/src/QuickEditor/QuickEditor.h +++ b/src/QuickEditor/QuickEditor.h @@ -35,7 +35,7 @@ public: - explicit QuickEditor(const QPixmap &thePixmap, QWidget *parent = nullptr); + explicit QuickEditor(const QPixmap &thePixmap, const QScreen *activeScreen, QWidget *parent = nullptr); virtual ~QuickEditor() = default; private: @@ -128,7 +128,6 @@ bool mReleaseToCapture; bool mRememberRegion; bool mDisableArrowKeys; - QRect mPrimaryScreenGeo; int mbottomHelpLength; Q_SIGNALS: diff --git a/src/QuickEditor/QuickEditor.cpp b/src/QuickEditor/QuickEditor.cpp --- a/src/QuickEditor/QuickEditor.cpp +++ b/src/QuickEditor/QuickEditor.cpp @@ -46,7 +46,7 @@ const int QuickEditor::magPixels = 16; const int QuickEditor::magOffset = 32; -QuickEditor::QuickEditor(const QPixmap& thePixmap, QWidget *parent) : +QuickEditor::QuickEditor(const QPixmap& thePixmap, const QScreen *activeScreen, QWidget *parent) : QWidget(parent), mMaskColor(QColor::fromRgbF(0, 0, 0, 0.15)), mStrokeColor(palette().highlight().color()), @@ -58,6 +58,7 @@ 0.85 )), mLabelForegroundColor(palette().windowText().color()), + mSelection(static_cast(QRect(activeScreen->geometry().topLeft(), QSize(0,0)))), mMidHelpText(i18n("Click and drag to draw a selection rectangle,\nor press Esc to quit")), mMidHelpTextFont(font()), mBottomHelpTextFont(font()), @@ -70,7 +71,6 @@ mReleaseToCapture(SpectacleConfig::instance()->useReleaseToCapture()), mRememberRegion(SpectacleConfig::instance()->alwaysRememberRegion() || SpectacleConfig::instance()->rememberLastRectangularRegion()), mDisableArrowKeys(false), - mPrimaryScreenGeo(QGuiApplication::primaryScreen()->geometry()), mbottomHelpLength(bottomHelpMaxLength) { SpectacleConfig *config = SpectacleConfig::instance(); @@ -115,8 +115,6 @@ } } } - layoutBottomHelpText(); - update(); } @@ -288,7 +286,7 @@ void QuickEditor::mousePressEvent(QMouseEvent* event) { if (event->button() & Qt::LeftButton) { - /* NOTE Workaround for Bug 407843 + /* NOTE Workaround for Bug 407843 * If we show the selection Widget when a right click menu is open we lose focus on X. * When the user clicks we get the mouse back. We can only grab the keyboard if we already * have mouse focus. So just grab it undconditionally here. @@ -490,6 +488,7 @@ } else if (mMagnifierAllowed && (mShowMagnifier ^ mToggleMagnifier)) { drawMagnifier(painter); } + layoutBottomHelpText(); drawBottomHelpText(painter); } else { drawMidHelpText(painter); @@ -516,7 +515,8 @@ contentWidth = qMax(contentWidth, mBottomHelpGridLeftWidth + maxRightWidth + bottomHelpBoxPairSpacing); contentHeight += (i != bottomHelpMaxLength ? bottomHelpBoxMarginBottom : 0); } - mBottomHelpContentPos.setX((mPrimaryScreenGeo.width() - contentWidth) / 2 + mPrimaryScreenGeo.x()); + QRect activeScreenGeo = QGuiApplication::screenAt(mSelection.center().toPoint())->geometry(); + mBottomHelpContentPos.setX((activeScreenGeo.width() - contentWidth) / 2 + activeScreenGeo.x()); mBottomHelpContentPos.setY(height() - contentHeight - 8); mBottomHelpGridLeftWidth += mBottomHelpContentPos.x(); mBottomHelpBorderBox.setRect( @@ -727,7 +727,8 @@ painter.fillRect(geometry(), mMaskColor); painter.setFont(mMidHelpTextFont); QRect textSize = painter.boundingRect(QRect(), Qt::AlignCenter, mMidHelpText); - QPoint pos((mPrimaryScreenGeo.width() - textSize.width()) / 2 + mPrimaryScreenGeo.x(), (height() - textSize.height()) / 2); + QRect activeScreenGeo = QGuiApplication::screenAt(mSelection.center().toPoint())->geometry(); + QPoint pos((activeScreenGeo.width() - textSize.width()) / 2 + activeScreenGeo.x(), (height() - textSize.height()) / 2); painter.setBrush(mLabelBackgroundColor); QPen pen(mLabelForegroundColor); diff --git a/src/SpectacleCore.cpp b/src/SpectacleCore.cpp --- a/src/SpectacleCore.cpp +++ b/src/SpectacleCore.cpp @@ -37,6 +37,7 @@ #include #include #include +#include SpectacleCore::SpectacleCore(StartMode theStartMode, Spectacle::CaptureMode theCaptureMode, @@ -223,7 +224,7 @@ if (lExportManager->captureMode() == Spectacle::CaptureMode::RectangularRegion) { if(!mQuickEditor) { - mQuickEditor = std::make_unique(thePixmap); + mQuickEditor = std::make_unique(thePixmap, mMainWindow->window()->windowHandle()->screen()); connect(mQuickEditor.get(), &QuickEditor::grabDone, this, &SpectacleCore::screenshotUpdated); connect(mQuickEditor.get(), &QuickEditor::grabCancelled, this, &SpectacleCore::screenshotFailed); mQuickEditor->showFullScreen();