Skip to content

Commit

Permalink
Add lastRectArea to cli #150
Browse files Browse the repository at this point in the history
  • Loading branch information
DamirPorobic committed Sep 25, 2019
1 parent 8378d18 commit 2e2f931
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/backend/KsnipCommandLine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ KsnipCommandLine::KsnipCommandLine(const QCoreApplication &app, const QList<Capt
KsnipCommandLine::~KsnipCommandLine()
{
delete mRectAreaOption;
delete mLastRectAreaOption;
delete mFullScreenOption;
delete mCurrentScreenOption;
delete mActiveWindowOption;
Expand All @@ -48,8 +49,11 @@ void KsnipCommandLine::addImageGrabberOptions(const QList<CaptureModes> &capture
if (captureModes.contains(CaptureModes::RectArea)) {
mRectAreaOption = addOption(QStringLiteral("r"), QStringLiteral("rectarea"), QStringLiteral("Select a rectangular area from where to take a screenshot."));
}
if (captureModes.contains(CaptureModes::LastRectArea)) {
mLastRectAreaOption = addOption(QStringLiteral("l"), QStringLiteral("lastrectarea"), QStringLiteral("Take a screenshot using last selected rectangular area."));
}
if (captureModes.contains(CaptureModes::FullScreen)) {
mFullScreenOption = addOption(QStringLiteral("f"), QStringLiteral("fullscreen"), QStringLiteral("\"Capture the fullscreen including all monitors."));
mFullScreenOption = addOption(QStringLiteral("f"), QStringLiteral("fullscreen"), QStringLiteral("Capture the fullscreen including all monitors."));
}
if (captureModes.contains(CaptureModes::CurrentScreen)) {
mCurrentScreenOption = addOption(QStringLiteral("m"), QStringLiteral("current"), QStringLiteral("Capture the screen (monitor) where the mouse cursor is currently located."));
Expand Down Expand Up @@ -99,6 +103,11 @@ bool KsnipCommandLine::isRectAreaSet() const
return mRectAreaOption != nullptr && isSet(*mRectAreaOption);
}

bool KsnipCommandLine::isLastRectAreaSet() const
{
return mLastRectAreaOption != nullptr && isSet(*mLastRectAreaOption);
}

bool KsnipCommandLine::isFullScreenSet() const
{
return mFullScreenOption != nullptr && isSet(*mFullScreenOption);
Expand Down Expand Up @@ -162,7 +171,7 @@ QString KsnipCommandLine::image() const

bool KsnipCommandLine::isCaptureModeSet() const
{
return isRectAreaSet() || isFullScreenSet() || isCurrentScreenSet() || isActiveWindowSet() || isWindowsUnderCursorSet();
return isRectAreaSet() || isLastRectAreaSet() || isFullScreenSet() || isCurrentScreenSet() || isActiveWindowSet() || isWindowsUnderCursorSet();
}

CaptureModes KsnipCommandLine::captureMode() const
Expand All @@ -175,6 +184,8 @@ CaptureModes KsnipCommandLine::captureMode() const
return CaptureModes::ActiveWindow;
} else if (isWindowsUnderCursorSet()) {
return CaptureModes::WindowUnderCursor;
} else if (isLastRectAreaSet()) {
return CaptureModes::LastRectArea;
} else {
return CaptureModes::RectArea;
}
Expand Down
2 changes: 2 additions & 0 deletions src/backend/KsnipCommandLine.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class KsnipCommandLine : public QCommandLineParser
KsnipCommandLine(const QCoreApplication &app, const QList<CaptureModes> &captureModes);
~KsnipCommandLine();
bool isRectAreaSet() const;
bool isLastRectAreaSet() const;
bool isFullScreenSet() const;
bool isCurrentScreenSet() const;
bool isActiveWindowSet() const;
Expand All @@ -49,6 +50,7 @@ class KsnipCommandLine : public QCommandLineParser

private:
QCommandLineOption *mRectAreaOption = nullptr;
QCommandLineOption *mLastRectAreaOption = nullptr;
QCommandLineOption *mFullScreenOption = nullptr;
QCommandLineOption *mCurrentScreenOption = nullptr;
QCommandLineOption *mActiveWindowOption = nullptr;
Expand Down

0 comments on commit 2e2f931

Please sign in to comment.