From a3dbf3aaea6f4e07256048ec21b77bfa4de6ff02 Mon Sep 17 00:00:00 2001 From: Alf Gaida Date: Fri, 20 Nov 2015 00:23:48 +0100 Subject: [PATCH] Cherry-picking upstream version 1.95-20151117. --- debian/changelog | 7 +++ debian/control | 1 + src/core/config.cpp | 86 ++++++++++++++++++++++++++++++----- src/core/config.h | 12 +++-- src/core/core.cpp | 12 ++--- src/core/core.h | 7 +++ src/core/main.cpp | 2 +- src/core/ui/configwidget.cpp | 2 + src/core/ui/configwidget.ui | 87 ++++++++++++++++++++++++++++++++---- src/core/ui/mainwindow.cpp | 4 +- 10 files changed, 187 insertions(+), 33 deletions(-) diff --git a/debian/changelog b/debian/changelog index 3be89a6..8b11739 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +screengrab (1.95+20151117-1) experimental; urgency=medium + + * Cherry-picking upstream version 1.95+20151117. + * Added libxcb-xfixes0-dev as build dependency + + -- Alf Gaida Fri, 20 Nov 2015 00:23:43 +0100 + screengrab (1.95+20150929-1) experimental; urgency=medium [Alf Gaida ] diff --git a/debian/control b/debian/control index eb1e0c4..b5c5acd 100644 --- a/debian/control +++ b/debian/control @@ -12,6 +12,7 @@ Build-Depends: debhelper (>= 9), libqt5x11extras5-dev, libqt5xdg-dev (>= 1.3.0), libx11-dev, + libxcb-xfixes0-dev, pkg-config, qttools5-dev, qttools5-dev-tools diff --git a/src/core/config.cpp b/src/core/config.cpp index 774fc52..e35e9c1 100644 --- a/src/core/config.cpp +++ b/src/core/config.cpp @@ -35,6 +35,8 @@ #define KEY_SAVEFORMAT "defImgFormat" #define KEY_DELAY_DEF "defDelay" #define KEY_DELAY "delay" +#define KEY_SCREENSHOT_TYPE_DEF "defScreenshotType" +#define KEY_SCREENSHOT_TYPE "screenshotType" #define KEY_IMG_QUALITY "imageQuality" #define KEY_FILENAMEDATE "insDateTimeInFilename" #define KEY_DATETIME_TPL "templateDateTime" @@ -51,11 +53,60 @@ #define KEY_ZOOMBOX "zoomAroundMouse" #define KEY_TIME_NOTIFY "timeTrayMessages" #define KEY_ALLOW_COPIES "AllowCopies" -#define KEY_TYPE_SCREEN "typeScreenDefault" #define KEY_ENABLE_EXT_VIEWER "enbaleExternalView" #define KEY_NODECOR "noDecorations" #define KEY_INCLUDE_CURSOR "includeCursor" + +static const QLatin1String FullScreen("FullScreen"); +static const QLatin1String Window("Window"); +static const QLatin1String Area("Area"); +static const QLatin1String PreviousSelection("PreviousSelection"); + +static QString screenshotTypeToString(int v); +static int screenshotTypeFromString(const QString& str); + +static QString screenshotTypeToString(int v) +{ + QString r; + + switch(v) { + case Core::FullScreen: + r = FullScreen; + break; + case Core::Window: + r = Window; + break; + case Core::Area: + r = Area; + break; + case Core::PreviousSelection: + r = PreviousSelection; + break; + default: + r = FullScreen; + } + return r; +} + +static int screenshotTypeFromString(const QString& str) +{ + int r; + + if (str == FullScreen) + r = Core::FullScreen; + else if (str == Window) + r = Core::Window; + else if (str == Area) + r = Core::Area; + else if (str == PreviousSelection) + r = Core::PreviousSelection; + else + r = Core::FullScreen; // Default + + return r; +} + Config* Config::ptrInstance = 0; // constructor @@ -242,6 +293,26 @@ void Config::setDelay(quint8 sec) setValue(KEY_DELAY, sec); } +int Config::getDefScreenshotType() +{ + return (value(QLatin1String(KEY_SCREENSHOT_TYPE_DEF)).toInt()); +} + +void Config::setDefScreenshotType(const int type) +{ + setValue(QLatin1String(KEY_SCREENSHOT_TYPE_DEF), type); +} + +int Config::getScreenshotType() +{ + return (value(QLatin1String(KEY_SCREENSHOT_TYPE)).toInt()); +} + +void Config::setScreenshotType(const int type) +{ + setValue(QLatin1String(KEY_SCREENSHOT_TYPE), type); +} + quint8 Config::getAutoCopyFilenameOnSaving() { return value(KEY_FILENAME_TO_CLB).toInt(); @@ -283,16 +354,6 @@ void Config::setCloseInTray(bool val) setValue(KEY_CLOSE_INTRAY, val); } -int Config::getTypeScreen() -{ - return value(KEY_TYPE_SCREEN).toInt(); -} - -void Config::setTypeScreen(quint8 type) -{ - setValue(KEY_TYPE_SCREEN, type); -} - quint8 Config::getTimeTrayMess() { return value(KEY_TIME_NOTIFY).toInt(); @@ -412,6 +473,7 @@ void Config::loadSettings() setSaveFileName(_settings->value(KEY_SAVENAME,DEF_SAVE_NAME).toString()); setSaveFormat(_settings->value(KEY_SAVEFORMAT, DEF_SAVE_FORMAT).toString()); setDefDelay(_settings->value(KEY_DELAY, DEF_DELAY).toInt()); + setDefScreenshotType(screenshotTypeFromString(_settings->value(QLatin1String(KEY_SCREENSHOT_TYPE_DEF)).toString())); setAutoCopyFilenameOnSaving(_settings->value(KEY_FILENAME_TO_CLB, DEF_FILENAME_TO_CLB).toInt()); setDateTimeInFilename(_settings->value(KEY_FILENAMEDATE, DEF_DATETIME_FILENAME).toBool()); setDateTimeTpl(_settings->value(KEY_DATETIME_TPL, DEF_DATETIME_TPL).toString()); @@ -450,6 +512,7 @@ void Config::saveSettings() _settings->setValue(KEY_SAVENAME, getSaveFileName()); _settings->setValue(KEY_SAVEFORMAT, getSaveFormat()); _settings->setValue(KEY_DELAY, getDefDelay()); + _settings->setValue(QLatin1String(KEY_SCREENSHOT_TYPE_DEF), screenshotTypeToString(getDefScreenshotType())); _settings->setValue(KEY_FILENAME_TO_CLB, getAutoCopyFilenameOnSaving()); _settings->setValue(KEY_FILENAMEDATE, getDateTimeInFilename()); _settings->setValue(KEY_DATETIME_TPL, getDateTimeTpl()); @@ -486,6 +549,7 @@ void Config::setDefaultSettings() setSaveFileName(DEF_SAVE_NAME); setSaveFormat(DEF_SAVE_FORMAT); setDefDelay(DEF_DELAY); + setScreenshotType(Core::FullScreen); setImageQuality(DEF_IMG_QUALITY); setDateTimeInFilename(DEF_DATETIME_FILENAME); setDateTimeTpl(DEF_DATETIME_TPL); diff --git a/src/core/config.h b/src/core/config.h index 6740dc8..6088514 100644 --- a/src/core/config.h +++ b/src/core/config.h @@ -144,6 +144,14 @@ public: quint8 getDelay(); void setDelay(quint8 sec); + // configured default screenshot type + int getDefScreenshotType(); + void setDefScreenshotType(const int type); + + // current screenshot type + int getScreenshotType(); + void setScreenshotType(const int type); + quint8 getAutoCopyFilenameOnSaving(); void setAutoCopyFilenameOnSaving(quint8 val); @@ -159,10 +167,6 @@ public: bool getCloseInTray(); void setCloseInTray(bool val); - // type of screen - int getTypeScreen(); - void setTypeScreen(quint8 type); - // tume of tray messages quint8 getTimeTrayMess(); void setTimeTrayMess(int src); diff --git a/src/core/core.cpp b/src/core/core.cpp index ca5c4e6..2cee298 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp @@ -183,9 +183,9 @@ void Core::screenShot(bool first) if (_firstScreen) _conf->updateLastSaveDate(); - switch(_conf->getTypeScreen()) + switch(_conf->getScreenshotType()) { - case 0: + case Core::FullScreen: { const QList screens = qApp->screens(); const QDesktopWidget *desktop = QApplication::desktop(); @@ -197,20 +197,20 @@ void Core::screenShot(bool first) _wnd->updatePixmap(_pixelMap); break; } - case 1: + case Core::Window: { getActiveWindow(); checkAutoSave(first); _wnd->updatePixmap(_pixelMap); break; } - case 2: + case Core::Area: { _selector = new RegionSelect(_conf); connect(_selector, &RegionSelect::processDone, this, &Core::regionGrabbed); break; } - case 3: + case Core::PreviousSelection: { _selector = new RegionSelect(_conf, _lastSelectedArea); connect(_selector, &RegionSelect::processDone, this, &Core::regionGrabbed); @@ -517,7 +517,7 @@ void Core::processCmdLineOpts(const QStringList& arguments) // Check commandline parameters and set screenshot type for (int i=0; i < _screenTypeOpts.count(); ++i) if (_cmdLine.isSet(_screenTypeOpts.at(i))) - _conf->setTypeScreen(i); + _conf->setScreenshotType(i); #ifdef SG_EXT_UPLOADS /// FIXMA - In module interface need add the mthod for geting module cmdLine options diff --git a/src/core/core.h b/src/core/core.h index 041b980..c50312f 100644 --- a/src/core/core.h +++ b/src/core/core.h @@ -71,6 +71,13 @@ public Q_SLOTS: void autoSave(); public: + enum ScreenshotType { + FullScreen = 0, + Window, + Area, + PreviousSelection + }; + static Core* instance(); ~Core(); diff --git a/src/core/main.cpp b/src/core/main.cpp index 8b45656..7f2fe3a 100644 --- a/src/core/main.cpp +++ b/src/core/main.cpp @@ -34,7 +34,7 @@ int main(int argc, char *argv[]) if (!ScreenGrab->config()->getAllowMultipleInstance() && scr.isRunning()) { - QString type = QString::number(ScreenGrab->config()->getTypeScreen()); + QString type = QString::number(ScreenGrab->config()->getDefScreenshotType()); scr.sendMessage("screengrab --type=" + type); return 0; } diff --git a/src/core/ui/configwidget.cpp b/src/core/ui/configwidget.cpp index 3fb63b7..3662440 100644 --- a/src/core/ui/configwidget.cpp +++ b/src/core/ui/configwidget.cpp @@ -154,6 +154,7 @@ void ConfigDialog::loadSettings() _ui->cbxFormat->setCurrentIndex(conf->getDefaultFormatID()); _ui->defDelay->setValue(conf->getDefDelay()); + _ui->cbxTypeScr->setCurrentIndex(conf->getDefScreenshotType()); _ui->checkIncDate->setChecked(conf->getDateTimeInFilename()); _ui->editDateTmeTpl->setText(conf->getDateTimeTpl()); _ui->cbxCopyFileName->setCurrentIndex(conf->getAutoCopyFilenameOnSaving()); @@ -252,6 +253,7 @@ void ConfigDialog::saveSettings() conf->setSaveFileName(_ui->editFileName->text()); conf->setSaveFormat(_ui->cbxFormat->currentText()); conf->setDefDelay(_ui->defDelay->value()); + conf->setDefScreenshotType(_ui->cbxTypeScr->currentIndex()); conf->setDateTimeInFilename(_ui->checkIncDate->isChecked()); conf->setDateTimeTpl(_ui->editDateTmeTpl->text()); conf->setAutoCopyFilenameOnSaving(_ui->cbxCopyFileName->currentIndex()); diff --git a/src/core/ui/configwidget.ui b/src/core/ui/configwidget.ui index 181a70b..f7bf62b 100644 --- a/src/core/ui/configwidget.ui +++ b/src/core/ui/configwidget.ui @@ -6,8 +6,8 @@ 0 0 - 634 - 294 + 770 + 335 @@ -280,8 +280,8 @@ Screenshot - - + + @@ -331,14 +331,83 @@ - + + + + + + + 0 + 0 + + + + Qt::LeftToRight + + + Type: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + true + + + Type of screenshot + + + 0 + + + + Full screen + + + + + Window + + + + + Screen area + + + + + Previous selection + + + + + + + + Qt::Horizontal + + + + 118 + 28 + + + + + + + Image quality - + @@ -368,21 +437,21 @@ - + Include mouse pointer - + Zoom area around mouse in selection mode - + Qt::Vertical diff --git a/src/core/ui/mainwindow.cpp b/src/core/ui/mainwindow.cpp index 13bed8e..b8442d0 100644 --- a/src/core/ui/mainwindow.cpp +++ b/src/core/ui/mainwindow.cpp @@ -399,7 +399,7 @@ void MainWindow::delayBoxChange(int delay) void MainWindow::typeScreenShotChange(int type) { - _conf->setTypeScreen(type); + _conf->setScreenshotType(type); } void MainWindow::checkIncludeCursor(bool include) @@ -410,8 +410,8 @@ void MainWindow::checkIncludeCursor(bool include) // updating UI from configdata void MainWindow::updateUI() { - _ui->cbxTypeScr->setCurrentIndex(_conf->getTypeScreen()); _ui->delayBox->setValue(_conf->getDelay()); + _ui->cbxTypeScr->setCurrentIndex(_conf->getDefScreenshotType()); _ui->checkIncludeCursor->setChecked(_conf->getIncludeCursor()); updateShortcuts();