@@ -31,17 +31,25 @@ ScreenshotDisplay::ScreenshotDisplay(const QPixmap& pixmap, QWidget* parent, Con
3131 setWindowIcon (QIcon (" resources/icon.png" ));
3232 setAttribute (Qt::WA_QuitOnClose, false );
3333
34- QScreen* screen = QApplication::primaryScreen ();
35- QRect screenGeometry = screen->geometry ();
36- setGeometry (screenGeometry);
34+ QRect totalGeometry;
35+ const auto screens = QGuiApplication::screens ();
36+ for (QScreen* scr : screens) {
37+ totalGeometry = totalGeometry.united (scr->geometry ());
38+ }
39+
40+ if (totalGeometry.x () < 0 || totalGeometry.y () < 0 ) {
41+ totalGeometry.translate (-totalGeometry.x (), -totalGeometry.y ());
42+ }
43+
44+ setGeometry (totalGeometry);
3745
3846 initializeEditor ();
3947 configureShortcuts ();
4048
4149 drawingPixmap.fill (Qt::transparent);
4250 QFontMetrics fm (currentFont);
4351 textBoundingRect = QRect (QPoint (100 , 100 ), fm.size (0 , text));
44- showFullScreen ();
52+ show ();
4553}
4654
4755void ScreenshotDisplay::initializeEditor () {
@@ -56,7 +64,12 @@ void ScreenshotDisplay::initializeEditor() {
5664 });
5765 connect (editor.get (), &Editor::saveRequested, this , &ScreenshotDisplay::onSaveRequested);
5866 connect (editor.get (), &Editor::copyRequested, this , &ScreenshotDisplay::copySelectionToClipboard);
59- connect (editor.get (), &Editor::publishRequested, this , &ScreenshotDisplay::onPublishRequested);
67+ connect (editor.get (), &Editor::publishRequested, this , [this ]() {
68+ onPublishRequested (false );
69+ });
70+ connect (editor.get (), &Editor::searchRequested, this , [this ]() {
71+ onPublishRequested (true );
72+ });
6073 connect (editor.get (), &Editor::closeRequested, this , &ScreenshotDisplay::onCloseRequested);
6174}
6275
@@ -377,7 +390,7 @@ void ScreenshotDisplay::onSaveRequested() {
377390 }
378391}
379392
380- void ScreenshotDisplay::onPublishRequested () {
393+ void ScreenshotDisplay::onPublishRequested (bool searchImage ) {
381394 if (textEdit) {
382395 finalizeTextEdit ();
383396 }
@@ -459,7 +472,7 @@ void ScreenshotDisplay::onPublishRequested() {
459472 qDebug () << " Network Error:" << reply->errorString ();
460473 });
461474
462- connect (reply, &QNetworkReply::finished, this , [reply, file, tempFilePath, this , progressDialog, screenGeometry, loginInfo]() {
475+ connect (reply, &QNetworkReply::finished, this , [reply, file, tempFilePath, this , progressDialog, searchImage, screenGeometry, loginInfo]() {
463476 progressDialog->close ();
464477
465478 if (reply->error () == QNetworkReply::NoError) {
@@ -469,51 +482,58 @@ void ScreenshotDisplay::onPublishRequested() {
469482 QString url = jsonObject[" url" ].toString ();
470483 QString id = QString::number (jsonObject[" id" ].toInt ());
471484 QString link = SCREEN_ME_HOST + " /" + url;
472-
473- QMessageBox msgBox (this );
474- msgBox.setWindowTitle (" Screenshot Uploaded" );
475- msgBox.setText (" Screenshot uploaded successfully ! Link: " + link);
476- QPushButton* copyButton = msgBox.addButton (tr (" Copy" ), QMessageBox::ActionRole);
477- QPushButton* openButton = msgBox.addButton (tr (" Open" ), QMessageBox::ActionRole);
478- msgBox.addButton (QMessageBox::Ok);
479-
480- QCheckBox* privateCheckBox = nullptr ;
481- if (!loginInfo[" token" ].toString ().isEmpty ()) {
482- privateCheckBox = new QCheckBox (" Private" , &msgBox);
483- msgBox.setCheckBox (privateCheckBox);
484-
485- connect (privateCheckBox, &QCheckBox::toggled, this , [id, loginInfo](bool checked) {
486- QNetworkAccessManager* manager = new QNetworkAccessManager ();
487- QUrl url (SCREEN_ME_HOST + " /api/screenshot/" + id);
488- QNetworkRequest request (url);
489-
490- request.setRawHeader (" Authorization" , " Bearer " + loginInfo[" token" ].toString ().toUtf8 ());
491- request.setHeader (QNetworkRequest::ContentTypeHeader, " application/json" );
492-
493- QJsonObject json;
494- json[" privacy" ] = checked ? " private" : " public" ;
495- QJsonDocument doc (json);
496- QByteArray data = doc.toJson ();
497-
498- QNetworkReply* reply = manager->sendCustomRequest (request, " PATCH" , data);
499- connect (reply, &QNetworkReply::finished, reply, &QNetworkReply::deleteLater);
500- });
485+ QString imageUrl = jsonObject[" imageUrl" ].toString ();
486+
487+ if (!searchImage) {
488+ QMessageBox msgBox (this );
489+ msgBox.setWindowTitle (" Screenshot Uploaded" );
490+ msgBox.setText (" Screenshot uploaded successfully ! Link: " + link);
491+ QPushButton* copyButton = msgBox.addButton (tr (" Copy" ), QMessageBox::ActionRole);
492+ QPushButton* openButton = msgBox.addButton (tr (" Open" ), QMessageBox::ActionRole);
493+ msgBox.addButton (QMessageBox::Ok);
494+
495+ QCheckBox* privateCheckBox = nullptr ;
496+ if (!loginInfo[" token" ].toString ().isEmpty ()) {
497+ privateCheckBox = new QCheckBox (" Private" , &msgBox);
498+ msgBox.setCheckBox (privateCheckBox);
499+
500+ connect (privateCheckBox, &QCheckBox::toggled, this , [id, loginInfo](bool checked) {
501+ QNetworkAccessManager* manager = new QNetworkAccessManager ();
502+ QUrl url (SCREEN_ME_HOST + " /api/screenshot/" + id);
503+ QNetworkRequest request (url);
504+
505+ request.setRawHeader (" Authorization" , " Bearer " + loginInfo[" token" ].toString ().toUtf8 ());
506+ request.setHeader (QNetworkRequest::ContentTypeHeader, " application/json" );
507+
508+ QJsonObject json;
509+ json[" privacy" ] = checked ? " private" : " public" ;
510+ QJsonDocument doc (json);
511+ QByteArray data = doc.toJson ();
512+
513+ QNetworkReply* reply = manager->sendCustomRequest (request, " PATCH" , data);
514+ connect (reply, &QNetworkReply::finished, reply, &QNetworkReply::deleteLater);
515+ });
516+ }
517+
518+ connect (copyButton, &QPushButton::clicked, [link]() {
519+ QClipboard* clipboard = QGuiApplication::clipboard ();
520+ clipboard->setText (link);
521+ });
522+
523+ connect (openButton, &QPushButton::clicked, [link]() {
524+ QDesktopServices::openUrl (QUrl (link));
525+ });
526+
527+ // Position the message box at the bottom right of the screen
528+ msgBox.show ();
529+ QSize msgBoxSize = msgBox.sizeHint ();
530+ msgBox.move (screenGeometry.bottomRight () - QPoint (msgBoxSize.width () + 10 , msgBoxSize.height () + 100 ));
531+ msgBox.exec ();
501532 }
502-
503- connect (copyButton, &QPushButton::clicked, [link]() {
504- QClipboard* clipboard = QGuiApplication::clipboard ();
505- clipboard->setText (link);
506- });
507-
508- connect (openButton, &QPushButton::clicked, [link]() {
509- QDesktopServices::openUrl (QUrl (link));
510- });
511-
512- // Position the message box at the bottom right of the screen
513- msgBox.show ();
514- QSize msgBoxSize = msgBox.sizeHint ();
515- msgBox.move (screenGeometry.bottomRight () - QPoint (msgBoxSize.width () + 10 , msgBoxSize.height () + 100 ));
516- msgBox.exec ();
533+ else {
534+ QDesktopServices::openUrl (QUrl (" https://tineye.com/search?url=" + imageUrl));
535+ }
536+
517537 }
518538 else {
519539 QString errorString = reply->errorString ();
0 commit comments