diff --git a/CMakeLists.txt b/CMakeLists.txt index 53de829..0a049cc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,122 +1,118 @@ # KDE Application Version, managed by release script set(KDE_APPLICATIONS_VERSION_MAJOR "18") set(KDE_APPLICATIONS_VERSION_MINOR "11") set(KDE_APPLICATIONS_VERSION_MICRO "70") set(KDE_APPLICATIONS_VERSION "${KDE_APPLICATIONS_VERSION_MAJOR}.${KDE_APPLICATIONS_VERSION_MINOR}.${KDE_APPLICATIONS_VERSION_MICRO}") set(SPECTACLE_VERSION ${KDE_APPLICATIONS_VERSION}) # minimum requirements cmake_minimum_required (VERSION 3.0 FATAL_ERROR) # Spectacle project project(Spectacle VERSION ${SPECTACLE_VERSION}) set(QT_MIN_VERSION "5.6.0") set(KF5_MIN_VERSION "5.29.0") set(PLASMA_MIN_VERSION "5.4.0") find_package(ECM ${KF5_MIN_VERSION} REQUIRED NO_MODULE) set( CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules ${CMAKE_MODULE_PATH} ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR} ) # set up kf5 include(KDEInstallDirs) include(KDECMakeSettings) include(KDECompilerSettings NO_POLICY_SCOPE) include(ECMInstallIcons) include(ECMSetupVersion) include(FeatureSummary) find_package( Qt5 ${QT_MIN_VERSION} CONFIG REQUIRED Core Concurrent Widgets DBus PrintSupport Quick ) find_package( KF5 ${KF5_MIN_VERSION} REQUIRED CoreAddons WidgetsAddons DBusAddons Notifications Config I18n KIO XmlGui WindowSystem DocTools Declarative NewStuff ) add_definitions(-DQT_NO_URL_CAST_FROM_STRING) add_definitions(-DQT_USE_QSTRINGBUILDER) add_definitions(-DQT_NO_CAST_FROM_ASCII) add_definitions(-DQT_NO_CAST_TO_ASCII) add_definitions(-DQT_NO_NARROWING_CONVERSIONS_IN_CONNECT) # optional components find_package(KF5Kipi) if (KF5Kipi_FOUND) set(KIPI_FOUND 1) endif () find_package(KDEExperimentalPurpose) if (KDEExperimentalPurpose_FOUND) set(PURPOSE_FOUND 1) endif() find_package(XCB COMPONENTS XFIXES IMAGE UTIL CURSOR) set(XCB_COMPONENTS_ERRORS FALSE) if (XCB_FOUND) find_package(Qt5X11Extras ${QT_MIN_VERSION} REQUIRED) endif() set(XCB_COMPONENTS_FOUND TRUE) if(NOT XCB_XFIXES_FOUND) set(XCB_COMPONENTS_ERRORS "${XCB_COMPONENTS_ERRORS} XCB-XFIXES ") set(XCB_COMPONENTS_FOUND FALSE) endif() if(NOT XCB_IMAGE_FOUND) set(XCB_COMPONENTS_ERRORS "${XCB_COMPONENTS_ERRORS} XCB-IMAGE ") set(XCB_COMPONENTS_FOUND FALSE) endif() if(NOT XCB_UTIL_FOUND) set(XCB_COMPONENTS_ERRORS "${XCB_COMPONENTS_ERRORS} XCB-UTIL ") set(XCB_COMPONENTS_FOUND FALSE) endif() if(NOT XCB_CURSOR_FOUND) set(XCB_COMPONENTS_ERRORS "${XCB_COMPONENTS_ERRORS} XCB-CURSOR ") set(XCB_COMPONENTS_FOUND FALSE) endif() # fail build if none of the platform backends can be found if (NOT XCB_FOUND OR NOT XCB_COMPONENTS_FOUND) message(FATAL_ERROR "No suitable backend platform was found. Currenty supported platforms are: XCB Components Required: ${XCB_COMPONENTS_ERRORS}") endif() -if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") - add_definitions("-Wno-mismatched-tags") -endif() - # hand off to subdirectories add_subdirectory(src) add_subdirectory(dbus) add_subdirectory(desktop) add_subdirectory(icons) add_subdirectory(doc) # summaries feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES) diff --git a/doc/index.docbook b/doc/index.docbook index 0331d5f..0598ef5 100644 --- a/doc/index.docbook +++ b/doc/index.docbook @@ -1,367 +1,367 @@ Spectacle"> ]> The &spectacle; Handbook &Boudhayan.Gupta; &Boudhayan.Gupta.mail; &Boudhayan.Gupta; &Boudhayan.Gupta.mail; 1997-2000&Richard.J.Moore; 2000&Matthias.Ettrich; 2015&Boudhayan.Gupta; &FDLNotice; 2018-07-17 Applications 18.08 &spectacle; is a simple application for capturing desktop screenshots. It can capture images of the entire desktop, a single monitor, the currently active window, the window currently under the mouse, or a rectangular region of the screen. The images can then be printed, sent to other applications for manipulation, or quickly be saved as-is. KDE spectacle kdegraphics screenshot screen capture screen grab Introduction &spectacle; is a simple application for capturing desktop screenshots. It can capture images of the entire desktop, a single monitor, the currently active window, the window currently under the mouse, or a rectangular region of the screen. The images can then be printed, sent to other applications for manipulation, or quickly be saved as-is. Please report any problems or feature requests to the &kde; Bug Tracking System. Starting &spectacle; &spectacle; can be started in a variety of ways, as described below: In the application launcher menu, &spectacle; can be found at ApplicationsUtilitiesScreenshot Capture Utility &spectacle; Pressing the Print button on the keyboard will immediately launch &spectacle;. Additionally, three more keyboard shortcuts are available to take screenshots and save them in your default save folder without showing the &GUI;: MetaPrint will take a screenshot of the active window &Shift;Print will take a screenshot of your entire desktop, &ie; all monitors Meta&Shift;Print will take a rectangular region screenshot You can configure the default save location and filename by starting &spectacle; normally and clicking on the Configure... button, then navigating to the Save section. The mini command line &krunner; (invoked with &Alt;F2) may also be used to start &spectacle;. &spectacle; can be started from the command-line. &spectacle; has an extensive set of command-line options, including a background mode which can be used to script the capture of screenshots without showing the &GUI; or requiring user interaction. To start &spectacle; from the command prompt, type in: % spectacle & To view the full list of command-line options and their explanation, type in: % spectacle --help Using &spectacle; Once &spectacle; starts, you will see a window like the following: &spectacle; Main Window &spectacle; grabs an image of your entire desktop immediately after it is started, but before it displays itself on screen. This allows you to quickly create full-desktop screenshot images. The snapshot taken by &spectacle; is displayed in the preview window, which is located on the left-hand side of the &spectacle; application window. The image can be saved to a location of your choice by clicking on the Save As button or typing &Ctrl;&Shift;S. This opens the standard save dialog, where you can choose the filename, the folder location, and the format that your screenshot will be saved in. You may edit the filename to anything you wish, including the name of a previously saved screenshot. To save a screenshot to the default location, click on the arrow portion of the Save As... button and press the Save (&Ctrl;S) button. The new save mode will be remembered for next time. The default save location and filename can be configured, as described later. To quickly save the image and quit &spectacle;, click on the checkbox beside Quit after Save or Copy, then click the arrow portion of the Save As... button and press the Save (&Ctrl;S) item. This saves the image as a PNG file in your default Pictures folder, and exits the application immediately. As above, this new save mode will be remembered. Taking A Screenshot When you open &spectacle;, it immediately takes a screenshot of the whole screen as a convenience and shows a preview of it in the main window. You can save this screenshot using the buttons on the bottom of the window, or take a new one using the controls to the right of the preview. To discard the current screenshot and take another screenshot, press the Take a New Screenshot (&Ctrl;N) button. You may configure certain options on the right hand side of the application window before taking a new screenshot. These options allow you to select the area of the screen that is to be captured, set a delay before capturing the image, and configure whether the mouse cursor and/or the window decorations should be captured along with the screenshot. Capture Mode The capture mode settings allow you to set the area of the screen that should be captured, and whether there should be a delay between pressing the Take a New Screenshot (&Ctrl;N) button and taking the screenshot. You may also enable the On Click checkbox, which disables the delay function and only takes the screenshot after you click anywhere on the screen after clicking the Take a New Screenshot (&Ctrl;N) button. The Area combo-box allows you to set the area of the screen that should be captured. There are five options to select from, as described below. The Full Screen (All Monitors) option takes a screenshot of your entire desktop, spread across all the outputs, including all the monitors, projectors etc. The Current Screen option takes a screenshot of the output that currently contains the mouse pointer. The Active Window option takes a screenshot of the window that currently has focus. It is advisable to use a delay with this mode, to give you time to select and activate a window before the screenshot is taken. The Window Under Cursor option takes a screenshot of the window that is under the mouse cursor. If the cursor is on top of a popup menu, &spectacle; tries to take a screenshot of the menu as well as its parent window. While this works most of the time, in certain cases it may fail to obtain information about the parent window. In this case, &spectacle; falls back to old way of capturing the image automatically, and captures an image of only the popup menu. You can also force the old way of capturing the image by checking the Capture the current pop-up only checkbox under Options The Rectangular Region option allows you to select a rectangular region of your desktop with your mouse. This region may be spread across different outputs. This mode does not immediately take a screenshot but allows you to draw a rectangle on your screen, which can be moved and resized as needed. Once the desired selection rectangle has been drawn, double-clicking anywhere on the screen, or pressing the &Enter; button on the keyboard will capture the screenshot. - You can use the arrow keys to move and adjust the rectangle. Pressing the arrow keys will move the rectangle. Holding the Shift key while pressing the arrow keys will move the rectangle slowly, for fine-tuning your selection. Holding the Alt key while pressing the arrow keys will adjust the size of the rectangle. + You can use the arrow keys to move and adjust the rectangle. Pressing the arrow keys will move the rectangle. Holding the &Shift; key while pressing the arrow keys will move the rectangle slowly, for fine-tuning your selection. Holding the &Alt; key while pressing the arrow keys will adjust the size of the rectangle. The Delay spin-box allows you to set the delay between pressing the Take a New Screenshot (&Ctrl;N) button and taking the screenshot. This delay can be set in increments of 1 seconds using the spinbox buttons or the keyboard. Enabling the On Click checkbox overrides the delay. When this checkbox is enabled, pressing the Take a New Screenshot (&Ctrl;N) button hides the &spectacle; window and changes the mouse cursor to a crosshair. The screenshot is captured when the mouse is left-clicked, or aborted if any other mouse buttons are clicked. Note that you cannot interact with the desktop using the mouse while the cursor is a crosshair, but you can use the keyboard. Options The Options settings allow you to select whether the mouse cursor should be included in the screenshots, and whether to capture window decorations along with the image of a single application window. In Window Under Cursor mode, it also allows you to select if &spectacle; shall only capture the image of the current popup menu under the cursor, or also include the parent window. Finally, Quit after Save or Copy will quit &spectacle; after any save or copy operations. Enabling the Include mouse pointer checkbox includes an image of the mouse pointer in the screenshot. The Include window titlebar and borders option is only enabled when either the Active Window mode or the Window Under Cursor mode is selected in the Area combo-box. Checking this option includes the window borders and decoration in the screenshot, while unchecking it gives an image of only the window contents. The Capture the current pop-up only option is only enabled when the Window Under Cursor mode is selected in the Area combo-box. Checking this option captures only the popup menu under the cursor, without its parent window. The Quit after Save or Copy option will quit &spectacle; after any saving or copying operations. Note that a copied screenshot will only be retained if you are running a clipboard manager that accepts images. KDE Klipper can be configured in this manner by right-clicking on its icon, selecting Configure Clipboard..., and unchecking Ignore images. Additional Functionality Buttons There are some buttons located at the bottom of the &spectacle; window. Their functions are described below: Help Gives you the common menu items described in the Help Menu of the &kde; Fundamentals. Configure... Gives you access to &spectacle;'s Configure window where you can change the capture settings and default save location and filename. Tools Opens a drop-down menu which offers various tools: Open Screenshots Folder will highlight the last saved screenshot in the default file manager Access to the Print dialog A range of external programs for Screen Recording Export Opens a drop-down menu that will allow you to directly open the screenshot with all programs that are associated with the PNG (Portable Network Graphics) &MIME; type. Depending on what programs are installed, you will be able to open and edit the snapshot in your graphics applications or viewers. Furthermore, if you have the KIPI Plugins installed, you will be able to email your screenshots and export them directly to some social networks and websites. Copy To Clipboard Copies the current screenshot to the clipboard. You can also use the &Ctrl;C keyboard shortcut for this. Save As Saves the screenshot as a PNG image in your default Pictures folder and immediately exits the application. Configure Use the Configure... button to open the configuration dialog. General General Copy file location to clipboard after saving When a screenshot is saved, copy the location at which the file was saved to the clipboard. You can then paste it anywhere that accepts text input. Note that you must be running a clipboard manager in order to keep the path in the clipboard after &spectacle; quits. Use light background Use a light background color to mask the cropped-out area in the rectangular region selector. This may make dark cursors easier to see. Remember selected area By default, &spectacle; does not show an initial selection when you take a screenshot of a rectangular region. Enable this option to remember the last selected region of the screen, and set it as the initial selection when you use the rectangular region selector the next time. Save When you use the Save function, &spectacle; saves the image with a default filename, in your Pictures folder (which is inside your home folder). The default filename includes the date and time when the image was taken. The Save page allows you to set the default save location and filename. Clicking this option brings up a dialog box like the following: Save Default Save Location In the Location text box set the folder where you'd like to save your screenshots when you press Save. Default Save Filename Set a default filename for saved screenshots. You can use the following placeholders in the filename, which will be replaced with actual text when the file is saved: %Y: Year (4 digit) %y: Year (2 digit) %M: Month %D: Day %H: Hour %m: Minute %S: Second %T: Window title If a file with this name already exists, a serial number will be appended to the filename. For example, if the filename is Screenshot, and Screenshot.png already exists, the image will be saved as Screenshot-1.png. Typing an extension into the filename will automatically set the image format correctly and remove the extension from the filename field. Drag and Drop A captured image can be dragged to another application or document. If the application is able to handle images, a copy of the full image is inserted there. If you drag a screenshot into a file manager window, a dialog pops up where you can edit the filename and select the image format and the file will be inserted into the actual folder. If you drag the screenshot to a text box, the path to the temporary saved file is inserted. This is useful for example to upload a screenshot through web forms or to attach screenshots into bug reports on the &kde; bugtracker. This works with all clients that do not pick up the image data, but only look for a &URL; in the dragged mimedata. Credits and License Program copyright © 2015 &Boudhayan.Gupta; &Boudhayan.Gupta.mail;. Portions of the code are based directly on code from the &ksnapshot; project. Copyright © 1997-2011 The &ksnapshot; Developers. Detailed copyright assignment notices are available in the headers in the source code. Portions of the code are based directly on code from the &kwin; project. Copyright © 2008, 2013 The &kwin; Developers. Detailed copyright assignment notices are available in the headers in the source code. Documentation based on the original &ksnapshot; documentation: Copyright © 1997-2000 &Richard.J.Moore; &Richard.J.Moore.mail; Copyright © 2000 &Matthias.Ettrich; &Matthias.Ettrich.mail; &underFDL; &underGPL; &documentation.index; diff --git a/src/QuickEditor/QuickEditor.cpp b/src/QuickEditor/QuickEditor.cpp index 91e3d5d..7ba7a53 100644 --- a/src/QuickEditor/QuickEditor.cpp +++ b/src/QuickEditor/QuickEditor.cpp @@ -1,150 +1,151 @@ /* * Copyright (C) 2016 Boudhayan Gupta * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #include "QuickEditor.h" #include "SpectacleConfig.h" #include #include #include #include #include #include #include #include struct QuickEditor::ImageStore : public QQuickImageProvider { ImageStore(const QPixmap &pixmap) : QQuickImageProvider(QQuickImageProvider::Pixmap), mPixmap(pixmap) {} QPixmap requestPixmap(const QString &id, QSize *size, const QSize &requestedSize) Q_DECL_OVERRIDE { Q_UNUSED(id); if (size) { *size = mPixmap.size(); } if (requestedSize.isEmpty()) { return mPixmap; } return mPixmap.scaled(requestedSize, Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation); } QPixmap mPixmap; }; -struct QuickEditor::QuickEditorPrivate +class QuickEditor::QuickEditorPrivate { +public: KDeclarative::KDeclarative *mDecl; QQuickView *mQuickView; QQmlEngine *mQmlEngine; QRect mGrabRect; QSharedPointer mCurrentGrabResult; }; QuickEditor::QuickEditor(const QPixmap &pixmap, QObject *parent) : QObject(parent), mImageStore(new ImageStore(pixmap)), d_ptr(new QuickEditorPrivate) { Q_D(QuickEditor); d->mQmlEngine = new QQmlEngine(); d->mDecl = new KDeclarative::KDeclarative; d->mDecl->setDeclarativeEngine(d->mQmlEngine); #if KDECLARATIVE_VERSION >= QT_VERSION_CHECK(5, 45, 0) d->mDecl->setupEngine(d->mQmlEngine); d->mDecl->setupContext(); #else d->mDecl->setupBindings(); #endif d->mQmlEngine->addImageProvider(QStringLiteral("snapshot"), mImageStore); d->mQuickView = new QQuickView(d->mQmlEngine, nullptr); d->mQuickView->setClearBeforeRendering(false); d->mQuickView->setSource(QUrl(QStringLiteral("qrc:///QuickEditor/EditorRoot.qml"))); d->mQuickView->setFlags(Qt::BypassWindowManagerHint | Qt::WindowStaysOnTopHint | Qt::FramelessWindowHint | Qt::Tool); d->mQuickView->setGeometry(0, 0, pixmap.width(), pixmap.height()); d->mQuickView->showFullScreen(); // connect up the signals QQuickItem *rootItem = d->mQuickView->rootObject(); connect(rootItem, SIGNAL(acceptImage(int, int, int, int)), this, SLOT(acceptImageHandler(int, int, int, int))); connect(rootItem, SIGNAL(cancelImage()), this, SIGNAL(grabCancelled())); // set up initial config SpectacleConfig *config = SpectacleConfig::instance(); if (config->rememberLastRectangularRegion()) { auto pixelRatio = d->mQuickView->devicePixelRatio(); QRect cropRegion = config->cropRegion(); if (!cropRegion.isEmpty()) { QMetaObject::invokeMethod( rootItem, "setInitialSelection", Q_ARG(QVariant, cropRegion.x() / pixelRatio), Q_ARG(QVariant, cropRegion.y() / pixelRatio), Q_ARG(QVariant, cropRegion.width() / pixelRatio), Q_ARG(QVariant, cropRegion.height() / pixelRatio) ); } } rootItem->setProperty("showMagnifier", config->showMagnifierChecked()); if (config->useLightRegionMaskColour()) { rootItem->setProperty("maskColour", QColor(255, 255, 255, 100)); } } QuickEditor::~QuickEditor() { Q_D(QuickEditor); delete d->mQuickView; delete d->mDecl; delete d->mQmlEngine; delete d_ptr; } void QuickEditor::acceptImageHandler(int x, int y, int width, int height) { Q_D(QuickEditor); if ((x == -1) && (y == -1) && (width == -1) && (height == -1)) { SpectacleConfig::instance()->setCropRegion(QRect()); emit grabCancelled(); return; } auto pixelRatio = d->mQuickView->devicePixelRatio(); d->mGrabRect = QRect(x * pixelRatio, y * pixelRatio, width * pixelRatio, height * pixelRatio); SpectacleConfig::instance()->setCropRegion(d->mGrabRect); d->mQuickView->hide(); emit grabDone(mImageStore->mPixmap.copy(d->mGrabRect), d->mGrabRect); } diff --git a/src/QuickEditor/QuickEditor.h b/src/QuickEditor/QuickEditor.h index 0a57fa7..9544b8e 100644 --- a/src/QuickEditor/QuickEditor.h +++ b/src/QuickEditor/QuickEditor.h @@ -1,53 +1,53 @@ /* * Copyright (C) 2016 Boudhayan Gupta * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #ifndef QUICKEDITOR_H #define QUICKEDITOR_H #include class QuickEditor : public QObject { Q_OBJECT public: explicit QuickEditor(const QPixmap &pixmap, QObject *parent = nullptr); virtual ~QuickEditor(); signals: void grabDone(const QPixmap &pixmap, const QRect &cropRegion); void grabCancelled(); private slots: void acceptImageHandler(int x, int y, int width, int height); private: struct ImageStore; ImageStore *mImageStore; - struct QuickEditorPrivate; - Q_DECLARE_PRIVATE(QuickEditor); + class QuickEditorPrivate; + Q_DECLARE_PRIVATE(QuickEditor) QuickEditorPrivate *d_ptr; }; #endif // QUICKEDITOR_H