Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Commit

Permalink
Invoke screensot tool (Ctrl+Alt+S) on the screen where the mouse curs…
Browse files Browse the repository at this point in the history
…or is located
  • Loading branch information
Dmitry Baryshev committed Sep 23, 2020
1 parent 638cf00 commit 378382b
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 11 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ Trader's Home Task (THT) helps you preparing for a working day on the U.S. stock

See [HOWTO](HOWTO.md) and [README](README.md) for more.

## 2.4.1
- Invoke screensot tool (Ctrl+Alt+S) on the screen where the mouse cursor is located

## 2.4.0
- Updated links in the About dialog
- Updated the tickers database
Expand Down
2 changes: 1 addition & 1 deletion THT-version.tag
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.4.0
2.4.1
2 changes: 1 addition & 1 deletion dist/tht.iss
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#define MyAppName "Trader's Home Task"
#define MyAppPublisher "Dmitry Baryshev"
#define MyAppURL "https://github.com/smoked-herring/tht"
#define MyAppVersion "2.4.0"
#define MyAppVersion "2.4.1"

[Setup]
AppId={{16AE5DDE-D073-4F5F-ABC3-11DD9FBF58E3}
Expand Down
23 changes: 15 additions & 8 deletions regionselect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,17 @@ RegionSelect::RegionSelect(KeyboardInteraction _ki, QWidget *parent) :
setWindowState(Qt::WindowFullScreen);
setCursor(Qt::CrossCursor);

QRect rc = QApplication::desktop()->screenGeometry(QCursor::pos());

sizeDesktop = rc.size();
resize(sizeDesktop);
screenRect = QApplication::desktop()->screenGeometry(QCursor::pos());
setGeometry(screenRect);

desktopPixmapBkg = QPixmap::grabWindow(QApplication::desktop()->winId(),
rc.x(), rc.y(), rc.width(), rc.height());
screenRect.x(),
screenRect.y(),
screenRect.width(),
screenRect.height());

desktopPixmapClr = desktopPixmapBkg;

move(rc.topLeft());
drawBackGround();
}

Expand All @@ -60,16 +60,23 @@ RegionSelect::~RegionSelect()
bool RegionSelect::event(QEvent *event)
{
if(ki == UseKeyboard && event->type() == QEvent::KeyPress)
{
event->accept();
reject();
}
else if(event->type() == QEvent::MouseButtonRelease)
{
event->accept();

QMouseEvent *mouseEvent = static_cast<QMouseEvent*> (event);

if(mouseEvent->button() == Qt::LeftButton)
accept();
}
else if(event->type() == QEvent::MouseButtonPress)
{
event->accept();

QMouseEvent *mouseEvent = static_cast<QMouseEvent*> (event);

if(mouseEvent->button() != Qt::LeftButton)
Expand Down Expand Up @@ -110,9 +117,9 @@ void RegionSelect::drawBackGround()
painter.setBrush(QBrush(QColor(0, 0, 0, 85), Qt::SolidPattern));

// draw rect of desktop size in poainter
painter.drawRect(QApplication::desktop()->rect());
painter.drawRect(rect());

QRect txtRect = QApplication::desktop()->screenGeometry(QApplication::desktop()->primaryScreen());
QRect txtRect = rect();
QString txtTip = ki == UseKeyboard
//: Appeal to the user
? tr("Using the mouse, select the rectangle, or click\nany keyboard button or right/middle mouse button to cancel.")
Expand Down
3 changes: 2 additions & 1 deletion regionselect.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,14 @@ class RegionSelect : public QDialog
KeyboardInteraction ki;

QRect selectRect;
QSize sizeDesktop;

QPoint selStartPoint;
QPoint selEndPoint;

QPixmap desktopPixmapBkg;
QPixmap desktopPixmapClr;

QRect screenRect;
};

#endif // REGIONSELECT_H

0 comments on commit 378382b

Please sign in to comment.