diff options
Diffstat (limited to 'src-qt5')
-rw-r--r-- | src-qt5/desktop-utils/lumina-screenshot/MainUI.cpp | 25 | ||||
-rw-r--r-- | src-qt5/desktop-utils/lumina-screenshot/MainUI.h | 4 | ||||
-rw-r--r-- | src-qt5/desktop-utils/lumina-screenshot/MainUI.ui | 277 |
3 files changed, 193 insertions, 113 deletions
diff --git a/src-qt5/desktop-utils/lumina-screenshot/MainUI.cpp b/src-qt5/desktop-utils/lumina-screenshot/MainUI.cpp index 57314249..40c9857b 100644 --- a/src-qt5/desktop-utils/lumina-screenshot/MainUI.cpp +++ b/src-qt5/desktop-utils/lumina-screenshot/MainUI.cpp @@ -14,6 +14,7 @@ MainUI::MainUI() : QMainWindow(), ui(new Ui::MainUI){ ui->setupUi(this); //load the designer file mousegrabbed = false; + picSaved = false; XCB = new LXCB(); IMG = new ImageEditor(this); ui->scrollArea->setWidget(IMG); @@ -51,7 +52,7 @@ MainUI::MainUI() : QMainWindow(), ui(new Ui::MainUI){ connect(ui->slider_zoom, SIGNAL(valueChanged(int)), this, SLOT(sliderChanged()) ); connect(scaleTimer, SIGNAL(timeout()), this, SLOT(imgScalingChanged()) ); connect(tabbar, SIGNAL(currentChanged(int)), this, SLOT(tabChanged(int)) ); - + connect(ui->check_show_popups, SIGNAL(toggled(bool)), this, SLOT(showPopupsChanged(bool)) ); settings = new QSettings("lumina-desktop", "lumina-screenshot",this); if(settings->value("screenshot-target", "window").toString() == "window") { ui->radio_window->setChecked(true); @@ -59,6 +60,7 @@ MainUI::MainUI() : QMainWindow(), ui(new Ui::MainUI){ ui->radio_all->setChecked(true); } ui->spin_delay->setValue(settings->value("screenshot-delay", 0).toInt()); + ui->check_show_popups->setChecked( settings->value("showPopupWarnings",true).toBool() ); ui->tool_resize->setVisible(false); //not implemented yet this->show(); @@ -99,6 +101,7 @@ void MainUI::saveScreenshot(){ if( !IMG->image().save(filepath, "png") ){ showSaveError(filepath); }else{ + picSaved = true; ppath = filepath.section("/",0,-2); //just the directory } } @@ -111,10 +114,12 @@ void MainUI::quicksave(){ QString path = savedir + QString( "Screenshot-%1.png" ).arg( lastScreenShot.toString("yyyy-MM-dd-hh-mm-ss") ); if(IMG->image().save(path, "png") ){ + picSaved = true; QProcess::startDetached("lumina-open -select \""+path+"\""); }else{ showSaveError(path); } + } void MainUI::startScreenshot(){ @@ -152,6 +157,10 @@ void MainUI::tabChanged(int tab){ ui->frame_modify->setVisible(tab==0); } +void MainUI::showPopupsChanged(bool show){ + settings->setValue("showPopupWarnings", show); +} + bool MainUI::getWindow(){ //Use this function to set cwin cwin = 0; @@ -194,6 +203,7 @@ void MainUI::getPixmap(){ this->setGeometry(lastgeom); lastScreenShot = QDateTime::currentDateTime(); //Now display the pixmap on the label as well + picSaved = false; IMG->LoadImage( cpic.toImage() ); } @@ -228,3 +238,16 @@ void MainUI::mouseReleaseEvent(QMouseEvent *ev){ void MainUI::resizeEvent(QResizeEvent*){ IMG->setDefaultSize( ui->scrollArea->maximumViewportSize() ); } + +void MainUI::closeEvent(QCloseEvent *ev){ + //qDebug() << "Close Event:" << ui->check_show_popups->isChecked() << picSaved; + if(ui->check_show_popups->isChecked() && !picSaved){ + //Ask what to do about the unsaved changed + if(QMessageBox::Yes != QMessageBox::warning(this, tr("Unsaved Screenshot"), tr("The current screenshot has not been saved yet. Do you want to quit anyway?"), QMessageBox::Yes | QMessageBox::No, QMessageBox::No) ){ + //cancelled close of window + ev->ignore(); + return; + } + } + QMainWindow::closeEvent(ev); +} diff --git a/src-qt5/desktop-utils/lumina-screenshot/MainUI.h b/src-qt5/desktop-utils/lumina-screenshot/MainUI.h index cb740d33..396bfafe 100644 --- a/src-qt5/desktop-utils/lumina-screenshot/MainUI.h +++ b/src-qt5/desktop-utils/lumina-screenshot/MainUI.h @@ -41,7 +41,7 @@ public slots: private: Ui::MainUI *ui; - bool mousegrabbed; + bool mousegrabbed, picSaved; QRect lastgeom; QString ppath; //previous file path WId cwin; //current window to screenshot @@ -71,6 +71,7 @@ private slots: void sliderChanged(); void tabChanged(int); + void showPopupsChanged(bool); //Utility functions to perform a screenshot bool getWindow(); //set the "cwin" variable as appropriate @@ -79,6 +80,7 @@ private slots: protected: void mouseReleaseEvent(QMouseEvent *ev); void resizeEvent(QResizeEvent *ev); + void closeEvent( QCloseEvent *ev); }; #endif diff --git a/src-qt5/desktop-utils/lumina-screenshot/MainUI.ui b/src-qt5/desktop-utils/lumina-screenshot/MainUI.ui index 5e3aabb4..cddee009 100644 --- a/src-qt5/desktop-utils/lumina-screenshot/MainUI.ui +++ b/src-qt5/desktop-utils/lumina-screenshot/MainUI.ui @@ -244,121 +244,176 @@ <enum>QLayout::SetMinimumSize</enum> </property> <item> - <layout class="QHBoxLayout" name="horizontalLayout"> - <property name="spacing"> - <number>0</number> + <widget class="QGroupBox" name="groupBox"> + <property name="title"> + <string>Screen Capture Settings</string> </property> - <property name="sizeConstraint"> - <enum>QLayout::SetMinimumSize</enum> - </property> - <item> - <widget class="QRadioButton" name="radio_all"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Minimum" vsizetype="Minimum"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="text"> - <string>Entire Session</string> - </property> - </widget> - </item> - <item> - <widget class="QSpinBox" name="spin_delay"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Minimum" vsizetype="Minimum"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="suffix"> - <string> Sec Delay</string> - </property> - <property name="prefix"> - <string/> - </property> - <property name="maximum"> - <number>20</number> - </property> - </widget> - </item> - </layout> - </item> - <item> - <layout class="QHBoxLayout" name="horizontalLayout_2"> - <property name="spacing"> - <number>0</number> - </property> - <property name="sizeConstraint"> - <enum>QLayout::SetMinimumSize</enum> - </property> - <item> - <widget class="QRadioButton" name="radio_monitor"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Minimum" vsizetype="Minimum"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="text"> - <string>Single Screen</string> - </property> - </widget> - </item> - <item> - <widget class="QSpinBox" name="spin_monitor"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Minimum" vsizetype="Minimum"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="prefix"> - <string notr="true"># </string> - </property> - <property name="minimum"> - <number>1</number> - </property> - </widget> - </item> - </layout> + <layout class="QVBoxLayout" name="verticalLayout"> + <property name="spacing"> + <number>2</number> + </property> + <property name="leftMargin"> + <number>2</number> + </property> + <property name="topMargin"> + <number>2</number> + </property> + <property name="rightMargin"> + <number>2</number> + </property> + <property name="bottomMargin"> + <number>2</number> + </property> + <item> + <layout class="QHBoxLayout" name="horizontalLayout"> + <property name="spacing"> + <number>0</number> + </property> + <property name="sizeConstraint"> + <enum>QLayout::SetMinimumSize</enum> + </property> + <item> + <widget class="QRadioButton" name="radio_all"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Minimum" vsizetype="Minimum"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>Entire Session</string> + </property> + </widget> + </item> + <item> + <widget class="QSpinBox" name="spin_delay"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Minimum" vsizetype="Minimum"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="suffix"> + <string> Sec Delay</string> + </property> + <property name="prefix"> + <string/> + </property> + <property name="maximum"> + <number>20</number> + </property> + </widget> + </item> + </layout> + </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout_2"> + <property name="spacing"> + <number>0</number> + </property> + <property name="sizeConstraint"> + <enum>QLayout::SetMinimumSize</enum> + </property> + <item> + <widget class="QRadioButton" name="radio_monitor"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Minimum" vsizetype="Minimum"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>Single Screen</string> + </property> + </widget> + </item> + <item> + <widget class="QSpinBox" name="spin_monitor"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Minimum" vsizetype="Minimum"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="prefix"> + <string notr="true"># </string> + </property> + <property name="minimum"> + <number>1</number> + </property> + </widget> + </item> + </layout> + </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout_3"> + <property name="spacing"> + <number>0</number> + </property> + <property name="sizeConstraint"> + <enum>QLayout::SetMinimumSize</enum> + </property> + <item> + <widget class="QRadioButton" name="radio_window"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Minimum" vsizetype="Minimum"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>Single Window</string> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="check_frame"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Minimum" vsizetype="Minimum"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>Include Borders</string> + </property> + </widget> + </item> + </layout> + </item> + </layout> + </widget> </item> <item> - <layout class="QHBoxLayout" name="horizontalLayout_3"> - <property name="spacing"> - <number>0</number> + <widget class="QGroupBox" name="groupBox_2"> + <property name="title"> + <string>General Settings</string> </property> - <property name="sizeConstraint"> - <enum>QLayout::SetMinimumSize</enum> - </property> - <item> - <widget class="QRadioButton" name="radio_window"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Minimum" vsizetype="Minimum"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="text"> - <string>Single Window</string> - </property> - </widget> - </item> - <item> - <widget class="QCheckBox" name="check_frame"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Minimum" vsizetype="Minimum"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="text"> - <string>Include Borders</string> - </property> - </widget> - </item> - </layout> + <layout class="QVBoxLayout" name="verticalLayout_7"> + <property name="spacing"> + <number>2</number> + </property> + <property name="leftMargin"> + <number>2</number> + </property> + <property name="topMargin"> + <number>2</number> + </property> + <property name="rightMargin"> + <number>2</number> + </property> + <property name="bottomMargin"> + <number>2</number> + </property> + <item> + <widget class="QCheckBox" name="check_show_popups"> + <property name="text"> + <string>Show popup warnings about unsaved screenshots</string> + </property> + </widget> + </item> + </layout> + </widget> </item> <item> <spacer name="verticalSpacer"> |