diff options
author | Ken Moore <ken@ixsystems.com> | 2016-11-22 14:40:13 -0500 |
---|---|---|
committer | Ken Moore <ken@ixsystems.com> | 2016-11-22 14:40:13 -0500 |
commit | 61ec083ea62121a9eba88c4bd46f10be9b367f81 (patch) | |
tree | 69ffaca31581a21019ed6d88a7fdcd8189f35641 /src-qt5/desktop-utils/lumina-screenshot | |
parent | Oops - NOW the desktop/panel settings-reload will work. (diff) | |
download | lumina-61ec083ea62121a9eba88c4bd46f10be9b367f81.tar.gz lumina-61ec083ea62121a9eba88c4bd46f10be9b367f81.tar.bz2 lumina-61ec083ea62121a9eba88c4bd46f10be9b367f81.zip |
Add better error notifications when saving screenshots.
Diffstat (limited to 'src-qt5/desktop-utils/lumina-screenshot')
-rw-r--r-- | src-qt5/desktop-utils/lumina-screenshot/MainUI.cpp | 26 | ||||
-rw-r--r-- | src-qt5/desktop-utils/lumina-screenshot/MainUI.h | 3 |
2 files changed, 23 insertions, 6 deletions
diff --git a/src-qt5/desktop-utils/lumina-screenshot/MainUI.cpp b/src-qt5/desktop-utils/lumina-screenshot/MainUI.cpp index 83940c93..16e7c77b 100644 --- a/src-qt5/desktop-utils/lumina-screenshot/MainUI.cpp +++ b/src-qt5/desktop-utils/lumina-screenshot/MainUI.cpp @@ -8,6 +8,8 @@ #include "ui_MainUI.h" #include <LuminaX11.h> +#include <QMessageBox> + MainUI::MainUI() : QMainWindow(), ui(new Ui::MainUI){ ui->setupUi(this); //load the designer file @@ -48,6 +50,7 @@ MainUI::MainUI() : QMainWindow(), ui(new Ui::MainUI){ this->show(); IMG->setDefaultSize(ui->scrollArea->maximumViewportSize()); IMG->LoadImage( QApplication::screens().at(0)->grabWindow(QApplication::desktop()->winId()).toImage() ); //initial screenshot + lastScreenShot = QDateTime::currentDateTime(); //ui->label_screenshot->setPixmap( cpic.scaled(ui->label_screenshot->size(), Qt::KeepAspectRatio, Qt::SmoothTransformation) ); } @@ -69,26 +72,36 @@ void MainUI::setupIcons(){ //ui->actionEdit->setIcon( LXDG::findIcon("applications-graphics","") ); } +void MainUI::showSaveError(QString path){ + QMessageBox::warning(this, tr("Could not save screenshot"), tr("The screenshot could not be saved. Please check directory permissions or pick a different directory")+"\n\n"+path); +} //============== // PRIVATE SLOTS //============== void MainUI::saveScreenshot(){ if(mousegrabbed){ return; } - QString filepath = QFileDialog::getSaveFileName(this, tr("Save Screenshot"), ppath, tr("PNG Files (*.png);;AllFiles (*)") ); + QString filepath = QFileDialog::getSaveFileName(this, tr("Save Screenshot"), ppath+"/"+QString( "Screenshot-%1.png" ).arg( lastScreenShot.toString("yyyy-MM-dd-hh-mm-ss")), tr("PNG Files (*.png);;AllFiles (*)") ); if(filepath.isEmpty()){ return; } if(!filepath.endsWith(".png")){ filepath.append(".png"); } - IMG->image().save(filepath, "png"); - ppath = filepath; + if( !IMG->image().save(filepath, "png") ){ + showSaveError(filepath); + }else{ + ppath = filepath.section("/",0,-2); //just the directory + } } + void MainUI::quicksave(){ if(mousegrabbed){ return; } QString savedir = QDir::homePath()+"/"; if(QFile::exists(savedir + "Pictures/")){ savedir.append("Pictures/"); } else if(QFile::exists(savedir + "Images/")){ savedir.append("Images/"); } - QString path = savedir + QString( "Screenshot-%1.png" ).arg( QDateTime::currentDateTime().toString("yyyy-MM-dd-hh-mm-ss") ); - IMG->image().save(path, "png"); - QProcess::startDetached("lumina-open \""+path+"\""); + QString path = savedir + QString( "Screenshot-%1.png" ).arg( lastScreenShot.toString("yyyy-MM-dd-hh-mm-ss") ); + if(IMG->image().save(path, "png") ){ + QProcess::startDetached("lumina-open \""+path+"\""); + }else{ + showSaveError(path); + } } void MainUI::startScreenshot(){ @@ -145,6 +158,7 @@ void MainUI::getPixmap(){ this->show(); this->setGeometry(lastgeom); ui->tabWidget->setCurrentWidget(ui->tab_view); //view it right now + lastScreenShot = QDateTime::currentDateTime(); //Now display the pixmap on the label as well IMG->LoadImage( cpic.toImage() ); } diff --git a/src-qt5/desktop-utils/lumina-screenshot/MainUI.h b/src-qt5/desktop-utils/lumina-screenshot/MainUI.h index 00b3f8ac..69c9bf26 100644 --- a/src-qt5/desktop-utils/lumina-screenshot/MainUI.h +++ b/src-qt5/desktop-utils/lumina-screenshot/MainUI.h @@ -49,6 +49,9 @@ private: //Image Editor widget ImageEditor *IMG; + QDateTime lastScreenShot; + + void showSaveError(QString path); private slots: //Button Slots |