aboutsummaryrefslogtreecommitdiff
path: root/src-qt5/desktop-utils/lumina-screenshot
diff options
context:
space:
mode:
Diffstat (limited to 'src-qt5/desktop-utils/lumina-screenshot')
-rw-r--r--src-qt5/desktop-utils/lumina-screenshot/MainUI.cpp50
-rw-r--r--src-qt5/desktop-utils/lumina-screenshot/MainUI.h3
-rw-r--r--src-qt5/desktop-utils/lumina-screenshot/MainUI.ui58
-rw-r--r--src-qt5/desktop-utils/lumina-screenshot/i18n/l-screenshot_de.ts10
4 files changed, 97 insertions, 24 deletions
diff --git a/src-qt5/desktop-utils/lumina-screenshot/MainUI.cpp b/src-qt5/desktop-utils/lumina-screenshot/MainUI.cpp
index 40c9857b..25f4cc62 100644
--- a/src-qt5/desktop-utils/lumina-screenshot/MainUI.cpp
+++ b/src-qt5/desktop-utils/lumina-screenshot/MainUI.cpp
@@ -9,12 +9,15 @@
#include <LuminaX11.h>
#include <QMessageBox>
+#include <QClipboard>
-
-MainUI::MainUI() : QMainWindow(), ui(new Ui::MainUI){
+MainUI::MainUI()
+ : QMainWindow(), ui(new Ui::MainUI),
+ mousegrabbed(false),
+ picSaved(false),
+ closeOnSave(false)
+{
ui->setupUi(this); //load the designer file
- mousegrabbed = false;
- picSaved = false;
XCB = new LXCB();
IMG = new ImageEditor(this);
ui->scrollArea->setWidget(IMG);
@@ -30,7 +33,8 @@ MainUI::MainUI() : QMainWindow(), ui(new Ui::MainUI){
scaleTimer->setSingleShot(true);
scaleTimer->setInterval(200); //~1/5 second
tabbar = new QTabBar(this);
- ui->tabLayout->insertWidget(0,tabbar);
+ tabbar->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred);
+ ui->tabLayout->insertWidget(0,tabbar, Qt::AlignLeft | Qt::AlignBottom);
tabbar->addTab(LXDG::findIcon("view-preview",""), tr("View"));
tabbar->addTab(LXDG::findIcon("preferences-other",""), tr("Settings"));
ui->stackedWidget->setCurrentWidget(ui->page_current);
@@ -47,6 +51,7 @@ MainUI::MainUI() : QMainWindow(), ui(new Ui::MainUI){
//connect(ui->push_snap, SIGNAL(clicked()), this, SLOT(startScreenshot()) );
connect(ui->actionTake_Screenshot, SIGNAL(triggered()), this, SLOT(startScreenshot()) );
connect(ui->tool_crop, SIGNAL(clicked()), IMG, SLOT(cropImage()) );
+ connect(ui->tool_copy_to_clipboard, SIGNAL(clicked()), this, SLOT(copyToClipboard()) );
connect(IMG, SIGNAL(selectionChanged(bool)), this, SLOT(imgselchanged(bool)) );
connect(IMG, SIGNAL(scaleFactorChanged(int)), this, SLOT(imgScalingChanged(int)) );
connect(ui->slider_zoom, SIGNAL(valueChanged(int)), this, SLOT(sliderChanged()) );
@@ -74,16 +79,14 @@ MainUI::~MainUI(){}
void MainUI::setupIcons(){
//Setup the icons
- //ui->tool_save->setIcon( LXDG::findIcon("document-save","") );
ui->tool_quicksave->setIcon( LXDG::findIcon("document-edit","") );
ui->actionSave_As->setIcon( LXDG::findIcon("document-save-as","") );
ui->actionQuick_Save->setIcon( LXDG::findIcon("document-save","") );
ui->actionClose->setIcon( LXDG::findIcon("application-exit","") );
- //ui->push_snap->setIcon( LXDG::findIcon("camera-web","") );
+ ui->tool_copy_to_clipboard->setIcon( LXDG::findIcon("insert-image","") );
ui->actionTake_Screenshot->setIcon( LXDG::findIcon("camera-web","") );
ui->tool_crop->setIcon( LXDG::findIcon("transform-crop","") );
ui->tool_resize->setIcon( LXDG::findIcon("transform-scale","") );
- //ui->actionEdit->setIcon( LXDG::findIcon("applications-graphics","") );
this->setWindowIcon( LXDG::findIcon("camera-web","") );
}
@@ -96,13 +99,22 @@ void MainUI::showSaveError(QString path){
void MainUI::saveScreenshot(){
if(mousegrabbed){ return; }
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.isEmpty()){
+ closeOnSave = false;
+ return;
+ }
if(!filepath.endsWith(".png")){ filepath.append(".png"); }
if( !IMG->image().save(filepath, "png") ){
+ closeOnSave = false;
showSaveError(filepath);
}else{
picSaved = true;
ppath = filepath.section("/",0,-2); //just the directory
+ if (closeOnSave) {
+ // We came here from close, now we need to close *after* handling
+ // the current screen event.
+ QTimer::singleShot(0, this, SLOT(close()));
+ }
}
}
@@ -121,6 +133,12 @@ void MainUI::quicksave(){
}
}
+void MainUI::copyToClipboard(){
+ qDebug() << "Copy Image to clipboard";
+ QClipboard *clipboard = QApplication::clipboard();
+ clipboard->setImage(IMG->image());
+ qDebug() << " - Success:" << !clipboard->image().isNull();
+}
void MainUI::startScreenshot(){
if(mousegrabbed){ return; }
@@ -243,8 +261,18 @@ 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
+ const int messageRet = QMessageBox::warning(this, tr("Unsaved Screenshot"),
+ tr("The current screenshot has not been saved yet. Do you want to save or discard your changes?"),
+ QMessageBox::Discard | QMessageBox::Save |QMessageBox::Cancel, QMessageBox::Cancel);
+ switch (messageRet) {
+ case QMessageBox::Discard:
+ // Just close, we don't care about the file.
+ break;
+ case QMessageBox::Save:
+ closeOnSave = true;
+ saveScreenshot();
+ // fall through
+ case QMessageBox::Cancel:
ev->ignore();
return;
}
diff --git a/src-qt5/desktop-utils/lumina-screenshot/MainUI.h b/src-qt5/desktop-utils/lumina-screenshot/MainUI.h
index 396bfafe..4a18ef74 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, picSaved;
+ bool mousegrabbed, picSaved, closeOnSave;
QRect lastgeom;
QString ppath; //previous file path
WId cwin; //current window to screenshot
@@ -63,6 +63,7 @@ private slots:
}
void saveScreenshot();
void quicksave();
+ void copyToClipboard();
void startScreenshot();
diff --git a/src-qt5/desktop-utils/lumina-screenshot/MainUI.ui b/src-qt5/desktop-utils/lumina-screenshot/MainUI.ui
index cddee009..f4230ff6 100644
--- a/src-qt5/desktop-utils/lumina-screenshot/MainUI.ui
+++ b/src-qt5/desktop-utils/lumina-screenshot/MainUI.ui
@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
- <width>386</width>
- <height>288</height>
+ <width>480</width>
+ <height>318</height>
</rect>
</property>
<property name="sizePolicy">
@@ -54,7 +54,7 @@
<item>
<widget class="QFrame" name="frame_modify">
<property name="frameShape">
- <enum>QFrame::NoFrame</enum>
+ <enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
@@ -83,12 +83,44 @@
<verstretch>0</verstretch>
</sizepolicy>
</property>
+ <property name="statusTip">
+ <string>Open screenshot with an application</string>
+ </property>
<property name="text">
- <string>Open With...</string>
+ <string>Open</string>
</property>
<property name="toolButtonStyle">
<enum>Qt::ToolButtonTextBesideIcon</enum>
</property>
+ <property name="autoRaise">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QToolButton" name="tool_copy_to_clipboard">
+ <property name="statusTip">
+ <string>Copy screenshot to clipboard</string>
+ </property>
+ <property name="text">
+ <string>Copy</string>
+ </property>
+ <property name="shortcut">
+ <string>Ctrl+C</string>
+ </property>
+ <property name="toolButtonStyle">
+ <enum>Qt::ToolButtonTextBesideIcon</enum>
+ </property>
+ <property name="autoRaise">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="Line" name="line">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
</widget>
</item>
<item>
@@ -99,12 +131,18 @@
<verstretch>0</verstretch>
</sizepolicy>
</property>
+ <property name="statusTip">
+ <string>Resize screenshot to selection</string>
+ </property>
<property name="text">
<string>Resize</string>
</property>
<property name="toolButtonStyle">
<enum>Qt::ToolButtonTextBesideIcon</enum>
</property>
+ <property name="autoRaise">
+ <bool>true</bool>
+ </property>
</widget>
</item>
<item>
@@ -115,12 +153,18 @@
<verstretch>0</verstretch>
</sizepolicy>
</property>
+ <property name="statusTip">
+ <string>Crop screenshot to selection</string>
+ </property>
<property name="text">
<string>&amp;Crop</string>
</property>
<property name="toolButtonStyle">
<enum>Qt::ToolButtonTextBesideIcon</enum>
</property>
+ <property name="autoRaise">
+ <bool>true</bool>
+ </property>
</widget>
</item>
</layout>
@@ -210,8 +254,8 @@
<rect>
<x>0</x>
<y>0</y>
- <width>344</width>
- <height>216</height>
+ <width>439</width>
+ <height>230</height>
</rect>
</property>
</widget>
@@ -463,9 +507,9 @@
</attribute>
<addaction name="actionTake_Screenshot"/>
<addaction name="actionSave_As"/>
- <addaction name="actionQuick_Save"/>
<addaction name="actionClose"/>
</widget>
+ <widget class="QStatusBar" name="statusBar"/>
<action name="actionTake_Screenshot">
<property name="text">
<string>Capture</string>
diff --git a/src-qt5/desktop-utils/lumina-screenshot/i18n/l-screenshot_de.ts b/src-qt5/desktop-utils/lumina-screenshot/i18n/l-screenshot_de.ts
index ab4efacf..5888f671 100644
--- a/src-qt5/desktop-utils/lumina-screenshot/i18n/l-screenshot_de.ts
+++ b/src-qt5/desktop-utils/lumina-screenshot/i18n/l-screenshot_de.ts
@@ -50,17 +50,17 @@
<message>
<location filename="../MainUI.ui" line="70"/>
<source> Sec Delay</source>
- <translation type="unfinished"></translation>
+ <translation> Sek. Verzögerung</translation>
</message>
<message>
<location filename="../MainUI.ui" line="183"/>
<source>Capture</source>
- <translation type="unfinished"></translation>
+ <translation>Aufnehmen</translation>
</message>
<message>
<location filename="../MainUI.ui" line="212"/>
<source>Edit</source>
- <translation type="unfinished"></translation>
+ <translation>Bearbeiten</translation>
</message>
<message>
<location filename="../MainUI.ui" line="362"/>
@@ -100,12 +100,12 @@
<message>
<location filename="../MainUI.cpp" line="79"/>
<source>Could not save screenshot</source>
- <translation type="unfinished"></translation>
+ <translation>Bildschirmfoto konnte nicht gespeichert werden</translation>
</message>
<message>
<location filename="../MainUI.cpp" line="79"/>
<source>The screenshot could not be saved. Please check directory permissions or pick a different directory</source>
- <translation type="unfinished"></translation>
+ <translation>Das Bildschirmfoto konnte nicht gespeichert werden. Bitte überprüfen Sie die Verzeichnisberechtigungen oder wählen Sie ein anderes Verzeichnis aus</translation>
</message>
<message>
<location filename="../MainUI.cpp" line="86"/>
bgstack15