Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit bda92cdc authored by Nils Rother's avatar Nils Rother Committed by Nate Graham

Add option to auto-accept box selection on mouse release

Summary:
FEATURE: 404829
Adds the option to have spectacle accept the selected region as soon
as the mouse button is released, similar to how other screenshot tools
allow it (eg. scrot -s).

Test Plan:
To enable the option go to
Configure -> General -> Rectangular Region -> Accept region on mouse release
then set the Capture mode to Rectangular Region and take a new screenshot.

{F6657239}

Behaviour should be the following:
  -When selecting a new region, without a previously saved region available,
   click->drag->release should immediately capture the selected region.
  -When a previously saved region is shown, the saved region can be
   manipulated further and saving this region requires manual confirmation
   (Enter/Double LMB).
  -Clicking and dragging outside of the previously saved region
   captures the newly selected region immediately.

Reviewers: #vdg, #spectacle, ngraham

Reviewed By: #vdg, #spectacle, ngraham

Subscribers: ngraham, #spectacle

Tags: #spectacle

Differential Revision: https://phabricator.kde.org/D19525
parent 7e747661
......@@ -73,6 +73,11 @@ GeneralOptionsPage::GeneralOptionsPage(QWidget *parent) :
connect(mShowMagnifier, &QCheckBox::toggled, this, &GeneralOptionsPage::markDirty);
mainLayout->addRow(QString(), mShowMagnifier);
// release mouse-button to capture
mReleaseToCapture = new QCheckBox(i18n("Accept on click-and-release"), this);
connect(mReleaseToCapture, &QCheckBox::toggled, this, &GeneralOptionsPage::markDirty);
mainLayout->addRow(QString(), mReleaseToCapture);
mainLayout->addItem(new QSpacerItem(0, 18, QSizePolicy::Fixed, QSizePolicy::Fixed));
// remember Rectangular Region box
......@@ -107,6 +112,7 @@ void GeneralOptionsPage::saveChanges()
cfgManager->setRememberLastRectangularRegion(mRememberUntilClosed->isChecked() || mRememberAlways->isChecked());
cfgManager->setAlwaysRememberRegion (mRememberAlways->isChecked());
cfgManager->setShowMagnifierChecked(mShowMagnifier->checkState() == Qt::Checked);
cfgManager->setUseReleaseToCaptureChecked(mReleaseToCapture->checkState() == Qt::Checked);
cfgManager->setPrintKeyActionRunning(static_cast<SpectacleConfig::PrintKeyActionRunning>(mPrintKeyActionGroup->checkedId()));
mChangesMade = false;
......@@ -120,6 +126,7 @@ void GeneralOptionsPage::resetChanges()
mRememberUntilClosed->setChecked(cfgManager->rememberLastRectangularRegion());
mRememberAlways->setChecked(cfgManager->alwaysRememberRegion());
mShowMagnifier->setChecked(cfgManager->showMagnifierChecked());
mReleaseToCapture->setChecked(cfgManager->useReleaseToCapture());
mPrintKeyActionGroup->button(cfgManager->printKeyActionRunning())->setChecked(true);
mChangesMade = false;
......
......@@ -50,6 +50,7 @@ class GeneralOptionsPage : public SettingsPage
QRadioButton* mRememberUntilClosed;
QCheckBox *mUseLightBackground;
QCheckBox *mShowMagnifier;
QCheckBox *mReleaseToCapture;
};
#endif // GENERALOPTIONSPAGE_H
This diff is collapsed.
......@@ -75,6 +75,7 @@ private:
void drawMagnifier(QPainter& painter);
void drawMidHelpText(QPainter& painter);
void drawSelectionSizeTooltip(QPainter& painter);
void setBottomHelpText();
void layoutBottomHelpText();
void setMouseCursor(const QPointF& pos);
MouseState mouseLocation(const QPointF& pos);
......@@ -88,7 +89,7 @@ private:
static const int selectionBoxPaddingY;
static const int selectionBoxMarginY;
static const int bottomHelpLength = 5;
static const int bottomHelpMaxLength = 6;
static bool bottomHelpTextPrepared;
static const int bottomHelpBoxPaddingX;
static const int bottomHelpBoxPaddingY;
......@@ -112,7 +113,7 @@ private:
QPointF mInitialTopLeft;
QString mMidHelpText;
QFont mMidHelpTextFont;
std::pair<QStaticText, std::vector<QStaticText>> mBottomHelpText[bottomHelpLength];
std::pair<QStaticText, std::vector<QStaticText>> mBottomHelpText[bottomHelpMaxLength];
QFont mBottomHelpTextFont;
QRect mBottomHelpBorderBox;
QPoint mBottomHelpContentPos;
......@@ -124,7 +125,11 @@ private:
bool mMagnifierAllowed;
bool mShowMagnifier;
bool mToggleMagnifier;
bool mReleaseToCapture;
bool mRememberRegion;
bool mDisableArrowKeys;
QRect mPrimaryScreenGeo;
int mbottomHelpLength;
Q_SIGNALS:
void grabDone(const QPixmap &pixmap);
......
......@@ -178,6 +178,19 @@ void SpectacleConfig::setShowMagnifierChecked(bool enabled)
mGuiConfig.sync();
}
// release mouse-button to capture
bool SpectacleConfig::useReleaseToCapture() const
{
return mGuiConfig.readEntry(QStringLiteral("useReleaseToCapture"), false);
}
void SpectacleConfig::setUseReleaseToCaptureChecked(bool enabled)
{
mGuiConfig.writeEntry(QStringLiteral("useReleaseToCapture"), enabled);
mGuiConfig.sync();
}
// capture delay
qreal SpectacleConfig::captureDelay() const
......
......@@ -93,6 +93,9 @@ class SpectacleConfig : public QObject
bool showMagnifierChecked() const;
void setShowMagnifierChecked(bool enabled);
bool useReleaseToCapture() const;
void setUseReleaseToCaptureChecked(bool enabled);
qreal captureDelay() const;
void setCaptureDelay(qreal delay);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment