66#include < iostream>
77
88#include " ScreenShot.h"
9+ #include " DrawingWidget.h"
10+
11+ extern DrawingWidget *drawing;
12+
913
1014#define _ (String ) gettext(String)
1115
@@ -18,21 +22,26 @@ void takeScreenshot(){
1822 QDateTime time = QDateTime::currentDateTime ();
1923 QString imgname = pics + " /" + time.toString (" yyyy-MM-dd_hh-mm-ss" ) + " .png" ;
2024 int status = 1 ;
21- // detect X11
22- if (!getenv (" WAYLAND_DISPLAY" )){
23- QScreen *screen = QGuiApplication::primaryScreen ();
24- QPixmap pixmap = screen->grabWindow (0 );
25- QFile file (imgname);
26- file.open (QIODevice::WriteOnly);
27- pixmap.save (&file, " PNG" );
25+ if (drawing->penMode == SELECTION) {
26+ drawing->cropWidget ->image .save (imgname);
2827 status = 0 ;
29- } else {
30- std::string spectacle (which ((char *)" spectacle" ));
31- std::string grim (which ((char *)" grim" ));
32- if (strlen (spectacle.c_str ()) != 0 ){
33- status = system ((" QT_QPA_PLATFORM='wayland' " +spectacle+" -fbnmo " +imgname.toStdString ()).c_str ());
34- } else if (strlen (grim.c_str ()) != 0 ){
35- status = system ((grim+" -t png " +imgname.toStdString ()).c_str ());
28+ } else if (drawing->penMode == DRAW) {
29+ // detect X11
30+ if (!getenv (" WAYLAND_DISPLAY" )){
31+ QScreen *screen = QGuiApplication::primaryScreen ();
32+ QPixmap pixmap = screen->grabWindow (0 );
33+ QFile file (imgname);
34+ file.open (QIODevice::WriteOnly);
35+ pixmap.save (&file, " PNG" );
36+ status = 0 ;
37+ } else {
38+ std::string spectacle (which ((char *)" spectacle" ));
39+ std::string grim (which ((char *)" grim" ));
40+ if (strlen (spectacle.c_str ()) != 0 ){
41+ status = system ((" QT_QPA_PLATFORM='wayland' " +spectacle+" -fbnmo " +imgname.toStdString ()).c_str ());
42+ } else if (strlen (grim.c_str ()) != 0 ){
43+ status = system ((grim+" -t png " +imgname.toStdString ()).c_str ());
44+ }
3645 }
3746 }
3847 // show message
0 commit comments