diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a0cd4a2..71d22ed 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,106 +1,106 @@ # common - configure file and version definitions configure_file(Config.h.in ${CMAKE_CURRENT_BINARY_DIR}/Config.h) set(CMAKE_AUTORCC 1) # target set( SPECTACLE_SRCS_DEFAULT Main.cpp ExportManager.cpp SpectacleCore.cpp SpectacleConfig.cpp SpectacleDBusAdapter.cpp PlatformBackends/ImageGrabber.cpp PlatformBackends/DummyImageGrabber.cpp PlatformBackends/KWinWaylandImageGrabber.cpp Gui/KSMainWindow.cpp Gui/KSWidget.cpp Gui/KSImageWidget.cpp Gui/ExportMenu.cpp Gui/SmartSpinBox.cpp Gui/SettingsDialog/SettingsDialog.cpp Gui/SettingsDialog/SettingsPage.cpp Gui/SettingsDialog/SaveOptionsPage.cpp Gui/SettingsDialog/GeneralOptionsPage.cpp QuickEditor/QuickEditor.cpp QuickEditor/QmlResources.qrc ) if(XCB_FOUND) set( SPECTACLE_SRCS_X11 PlatformBackends/X11ImageGrabber.cpp ) endif() if(KF5Kipi_FOUND) set( SPECTACLE_SRCS_KIPI KipiInterface/KSGKipiInterface.cpp KipiInterface/KSGKipiInfoShared.cpp KipiInterface/KSGKipiImageCollectionShared.cpp KipiInterface/KSGKipiImageCollectionSelector.cpp ) endif() set( SPECTACLE_SRCS_ALL ${SPECTACLE_SRCS_DEFAULT} ${SPECTACLE_SRCS_KIPI} ${SPECTACLE_SRCS_X11} ) add_executable( spectacle ${SPECTACLE_SRCS_ALL} ) # link libraries target_link_libraries( spectacle Qt5::Concurrent Qt5::DBus Qt5::PrintSupport Qt5::Quick KF5::CoreAddons KF5::DBusAddons KF5::WidgetsAddons KF5::Notifications KF5::ConfigCore KF5::I18n KF5::KIOWidgets KF5::WindowSystem KF5::XmlGui KF5::Declarative KF5::NewStuff ) if(XCB_FOUND) target_link_libraries( spectacle XCB::XFIXES XCB::IMAGE XCB::CURSOR XCB::UTIL Qt5::X11Extras ) endif() if(KF5Kipi_FOUND) target_link_libraries ( spectacle KF5::Kipi ) endif() if(KDEExperimentalPurpose_FOUND) target_link_libraries ( spectacle - KDEExperimental::PurposeWidgets + KF5::PurposeWidgets ) endif() install(TARGETS spectacle ${INSTALL_TARGETS_DEFAULT_ARGS}) diff --git a/src/Gui/SettingsDialog/SettingsDialog.cpp b/src/Gui/SettingsDialog/SettingsDialog.cpp index 104bc72..8b260fb 100644 --- a/src/Gui/SettingsDialog/SettingsDialog.cpp +++ b/src/Gui/SettingsDialog/SettingsDialog.cpp @@ -1,88 +1,88 @@ /* * Copyright (C) 2015 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 "SettingsDialog.h" #include #include #include #include #include #include "SaveOptionsPage.h" #include "GeneralOptionsPage.h" SettingsDialog::SettingsDialog(QWidget *parent) : KPageDialog(parent) { // set up window options and geometry setWindowTitle(i18n("Configure")); setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); resize(500, 470); // init all pages QMetaObject::invokeMethod(this, "initPages", Qt::QueuedConnection); } void SettingsDialog::initPages() { KPageWidgetItem *generalOptions = new KPageWidgetItem(new GeneralOptionsPage(this), i18n("General")); generalOptions->setHeader(i18n("General")); generalOptions->setIcon(QIcon::fromTheme(QStringLiteral("view-preview"))); // This is what Dolphin uses for the icon on its General page... addPage(generalOptions); mPages.insert(generalOptions); KPageWidgetItem *saveOptions = new KPageWidgetItem(new SaveOptionsPage(this), i18n("Save")); saveOptions->setHeader(i18n("Save")); saveOptions->setIcon(QIcon::fromTheme(QStringLiteral("document-save"))); addPage(saveOptions); mPages.insert(saveOptions); connect(this, &SettingsDialog::currentPageChanged, this, &SettingsDialog::onPageChanged); } void SettingsDialog::accept() { Q_FOREACH(auto page, mPages) { SettingsPage *pageWidget = dynamic_cast(page->widget()); if (pageWidget) { pageWidget->saveChanges(); } } - done(QDialog::Accepted); + emit done(QDialog::Accepted); } void SettingsDialog::onPageChanged(KPageWidgetItem *current, KPageWidgetItem *before) { Q_UNUSED(current); SettingsPage *pageWidget = dynamic_cast(before->widget()); if (pageWidget && (pageWidget->changesMade())) { QMessageBox::StandardButton response = QMessageBox::question(this, i18n("Apply Unsaved Changes"), i18n("You have made changes to the settings in this tab. Do you want to apply those changes?")); if (response == QMessageBox::Yes) { pageWidget->saveChanges(); } else { pageWidget->resetChanges(); } } } diff --git a/src/PlatformBackends/ImageGrabber.h b/src/PlatformBackends/ImageGrabber.h index f890558..6eda640 100644 --- a/src/PlatformBackends/ImageGrabber.h +++ b/src/PlatformBackends/ImageGrabber.h @@ -1,98 +1,96 @@ /* * Copyright (C) 2015 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 IMAGEGRABBER_H #define IMAGEGRABBER_H -#include #include #include #include #include #include #include "QuickEditor/QuickEditor.h" class ImageGrabber : public QObject { Q_OBJECT + Q_ENUMS(GrabMode) Q_PROPERTY(QPixmap pixmap READ pixmap NOTIFY pixmapChanged) Q_PROPERTY(bool capturePointer READ capturePointer WRITE setCapturePointer NOTIFY capturePointerChanged) Q_PROPERTY(bool captureDecorations READ captureDecorations WRITE setCaptureDecorations NOTIFY captureDecorationsChanged) Q_PROPERTY(GrabMode grabMode READ grabMode WRITE setGrabMode NOTIFY grabModeChanged) public: enum GrabMode { InvalidChoice = -1, FullScreen = 0, CurrentScreen = 1, ActiveWindow = 2, WindowUnderCursor = 3, TransientWithParent = 4, RectangularRegion = 5 }; - Q_ENUM(GrabMode); - explicit ImageGrabber(QObject *parent = 0); ~ImageGrabber(); QPixmap pixmap() const; bool capturePointer() const; bool captureDecorations() const; GrabMode grabMode() const; virtual bool onClickGrabSupported() const; void setCapturePointer(const bool newCapturePointer); void setCaptureDecorations(const bool newCaptureDecorations); void setGrabMode(const GrabMode newGrabMode); signals: void pixmapChanged(const QPixmap &pixmap); void imageGrabFailed(); void capturePointerChanged(bool capturePointer); void captureDecorationsChanged(bool captureDecorations); void grabModeChanged(GrabMode grabMode); public slots: virtual void doImageGrab(); virtual void doOnClickGrab(); protected: virtual void grabFullScreen() = 0; virtual void grabCurrentScreen() = 0; virtual void grabActiveWindow() = 0; virtual void grabRectangularRegion() = 0; virtual void grabWindowUnderCursor() = 0; virtual void grabTransientWithParent() = 0; virtual QPixmap blendCursorImage(const QPixmap &pixmap, int x, int y, int width, int height) = 0; bool mCapturePointer; bool mCaptureDecorations; GrabMode mGrabMode; QPixmap mPixmap; }; #endif // IMAGEGRABBER_H