[kde-doc-english] [kscreengenie] /: Give up on QtQuick. The Main Window is now pure QWidgets. Much faster. MUCH

Boudhayan Gupta me at BaloneyGeek.com
Wed Apr 29 17:11:24 UTC 2015


Git commit 4a5cf8d2fc48e87dc8d1a087b93dbda9ad6ef4bb by Boudhayan Gupta.
Committed on 29/04/2015 at 17:11.
Pushed by bgupta into branch 'master'.

Give up on QtQuick. The Main Window is now pure QWidgets. Much faster. MUCH

M  +6    -1    CMakeLists.txt
A  +1    -0    doc/CMakeLists.txt
A  +1    -0    doc/HELP_ME_I_BEG_YOU
A  +49   -0    doc/index.docbook
M  +4    -3    src/CMakeLists.txt
A  +72   -0    src/Gui/KSImageWidget.cpp     [License: LGPL (v2+)]
A  +55   -0    src/Gui/KSImageWidget.h     [License: LGPL (v2+)]
A  +184  -0    src/Gui/KSMainWindow.cpp     [License: LGPL (v2+)]
R  +18   -31   src/Gui/KSMainWindow.h [from: src/KScreenGenieGUI.h - 065% similarity]
R  +13   -11   src/Gui/KSSendToMenu.cpp [from: src/KSGSendToMenu.cpp - 086% similarity]
R  +6    -6    src/Gui/KSSendToMenu.h [from: src/KSGSendToMenu.h - 090% similarity]
A  +185  -0    src/Gui/KSWidget.cpp     [License: LGPL (v2+)]
A  +89   -0    src/Gui/KSWidget.h     [License: LGPL (v2+)]
M  +16   -16   src/KScreenGenie.cpp
M  +2    -5    src/KScreenGenie.h
D  +0    -232  src/KScreenGenieGUI.cpp
D  +0    -305  src/QmlResources/MainForm.qml
M  +0    -1    src/QmlResources/QmlResources.qrc

http://commits.kde.org/kscreengenie/4a5cf8d2fc48e87dc8d1a087b93dbda9ad6ef4bb

diff --git a/CMakeLists.txt b/CMakeLists.txt
index d90ca49..7d7a664 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -40,7 +40,6 @@ find_package(
         Core
         Quick
         Widgets
-        QuickWidgets
         DBus
         PrintSupport
 )
@@ -70,6 +69,12 @@ if (XCB_FOUND)
     find_package(KF5Screen ${PLASMA_MIN_VERSION} REQUIRED)
 endif()
 
+# fail build if none of the platform backends can be found
+
+if (!XCB_FOUND)
+    message(FATAL_ERROR "No suitable backend platform was found. Currenty supported platforms are: XCB")
+endif()
+
 # hand off to subdirectories
 
 add_subdirectory(src)
diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt
new file mode 100644
index 0000000..8d1c8b6
--- /dev/null
+++ b/doc/CMakeLists.txt
@@ -0,0 +1 @@
+ 
diff --git a/doc/HELP_ME_I_BEG_YOU b/doc/HELP_ME_I_BEG_YOU
new file mode 100644
index 0000000..8d1c8b6
--- /dev/null
+++ b/doc/HELP_ME_I_BEG_YOU
@@ -0,0 +1 @@
+ 
diff --git a/doc/index.docbook b/doc/index.docbook
new file mode 100644
index 0000000..2c29fc8
--- /dev/null
+++ b/doc/index.docbook
@@ -0,0 +1,49 @@
+<?xml version="1.0" ?>
+<!DOCTYPE book PUBLIC "-//KDE//DTD DocBook XML V4.2-Based Variant V1.1//EN" "dtd/kdex.dtd" [
+  <!ENTITY kappname "&kscreengenie;">
+  <!ENTITY package "kdegraphics">
+  <!ENTITY % addindex "IGNORE">
+  <!ENTITY % English "INCLUDE">
+]>
+
+<bookinfo>
+<title>The &kscreengenie; Handbook</title>
+
+<authorgroup>
+<author>
+<personname>
+<firstname>Boudhayan</firstname>
+<othername></othername>
+<surname>Gupta</surname>
+</personname>
+<email>me at BaloneyGeek.com</email>
+</author>
+</authorgroup>
+
+<!-- TRANS:ROLES_OF_TRANSLATORS -->
+
+<copyright>
+<year>2015</year>
+<holder>Boudhayan Gupta</holder>
+</copyright>
+<legalnotice>&FDLNotice;</legalnotice>
+
+<date>2015-04-20</date>
+<releaseinfo>1.0.0</releaseinfo>
+
+<!-- Abstract about this handbook -->
+
+<abstract>
+<para>
+&kscreengenie; .
+</para>
+</abstract>
+
+<keywordset>
+<keyword>KDE</keyword>
+<keyword>kdeutils</keyword>
+<keyword>Kapp</keyword>
+<keyword>nothing</keyword>
+<keyword>nothing else</keyword>
+</keywordset>
+</bookinfo> 
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 1875636..f3df857 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -9,10 +9,12 @@ set(
         Main.cpp
         ImageGrabber.cpp
         KScreenGenie.cpp
-        KScreenGenieGUI.cpp
         KSGImageProvider.cpp
         CropScreenshotGrabber.cpp
-        KSGSendToMenu.cpp
+        Gui/KSMainWindow.cpp
+        Gui/KSWidget.cpp
+        Gui/KSImageWidget.cpp
+        Gui/KSSendToMenu.cpp
 )
 qt5_add_resources (KSG_SRCS_RESOURCES QmlResources/QmlResources.qrc)
 
@@ -51,7 +53,6 @@ add_executable(
 target_link_libraries(
     kscreengenie
         Qt5::Quick
-        Qt5::QuickWidgets
         Qt5::DBus
         Qt5::PrintSupport
         KF5::CoreAddons
diff --git a/src/Gui/KSImageWidget.cpp b/src/Gui/KSImageWidget.cpp
new file mode 100644
index 0000000..5e2d51d
--- /dev/null
+++ b/src/Gui/KSImageWidget.cpp
@@ -0,0 +1,72 @@
+/*
+ *  Copyright (C) 2015 Boudhayan Gupta <me at BaloneyGeek.com>
+ *
+ *  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 "KSImageWidget.h"
+
+KSImageWidget::KSImageWidget(QWidget *parent):
+    QLabel(parent)
+{
+    mDSEffect = new QGraphicsDropShadowEffect(this);
+
+    mDSEffect->setBlurRadius(5);
+    mDSEffect->setOffset(0);
+    mDSEffect->setColor(QColor(Qt::black));
+
+    setGraphicsEffect(mDSEffect);
+    setCursor(Qt::OpenHandCursor);
+    setAlignment(Qt::AlignCenter);
+}
+
+void KSImageWidget::setScreenshot(const QPixmap &pixmap)
+{
+    QPixmap pix = pixmap.scaled(size(), Qt::KeepAspectRatio, Qt::SmoothTransformation);
+    setPixmap(pix);
+}
+
+// drag handlers
+
+void KSImageWidget::mousePressEvent(QMouseEvent *event)
+{
+    if (event->button() == Qt::LeftButton) {
+        mDragStartPosition = event->pos();
+        setCursor(Qt::ClosedHandCursor);
+    }
+}
+
+void KSImageWidget::mouseReleaseEvent(QMouseEvent *event)
+{
+    if (event->button() == Qt::LeftButton) {
+        setCursor(Qt::OpenHandCursor);
+    }
+}
+
+void KSImageWidget::mouseMoveEvent(QMouseEvent *event)
+{
+    if (!(event->buttons() & Qt::LeftButton)) {
+        return;
+    }
+
+    if ((event->pos() - mDragStartPosition).manhattanLength() < 10) {
+        return;
+    }
+
+    setCursor(Qt::OpenHandCursor);
+    emit dragInitiated();
+}
+
diff --git a/src/Gui/KSImageWidget.h b/src/Gui/KSImageWidget.h
new file mode 100644
index 0000000..c92e14e
--- /dev/null
+++ b/src/Gui/KSImageWidget.h
@@ -0,0 +1,55 @@
+/*
+ *  Copyright (C) 2015 Boudhayan Gupta <me at BaloneyGeek.com>
+ *
+ *  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 KSIMAGEWIDGET_H
+#define KSIMAGEWIDGET_H
+
+#include <QLabel>
+#include <QColor>
+#include <QMouseEvent>
+#include <QPoint>
+#include <QPixmap>
+#include <QGraphicsDropShadowEffect>
+
+class KSImageWidget : public QLabel
+{
+    Q_OBJECT
+
+    public:
+
+    explicit KSImageWidget(QWidget *parent = 0);
+    void setScreenshot(const QPixmap &pixmap);
+
+    signals:
+
+    void dragInitiated();
+
+    protected:
+
+    void mousePressEvent(QMouseEvent *event);
+    void mouseReleaseEvent(QMouseEvent *event);
+    void mouseMoveEvent(QMouseEvent *event);
+
+    private:
+
+    QGraphicsDropShadowEffect *mDSEffect;
+    QPoint                     mDragStartPosition;
+};
+
+#endif // KSIMAGEWIDGET_H
diff --git a/src/Gui/KSMainWindow.cpp b/src/Gui/KSMainWindow.cpp
new file mode 100644
index 0000000..3ed44df
--- /dev/null
+++ b/src/Gui/KSMainWindow.cpp
@@ -0,0 +1,184 @@
+/*
+ *  Copyright (C) 2015 Boudhayan Gupta <me at BaloneyGeek.com>
+ *
+ *  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 "KSMainWindow.h"
+
+KSMainWindow::KSMainWindow(bool onClickAvailable, QWidget *parent) :
+    QWidget(parent),
+    mDialogButtonBox(nullptr),
+    mSendToButton(nullptr),
+    mPrintButton(nullptr),
+    mSendToMenu(new KSSendToMenu),
+    mOnClickAvailable(onClickAvailable)
+{
+    QMetaObject::invokeMethod(this, "init", Qt::QueuedConnection);
+}
+
+KSMainWindow::~KSMainWindow()
+{}
+
+// GUI init
+
+void KSMainWindow::init()
+{
+    KSharedConfigPtr config = KSharedConfig::openConfig("kscreengenierc");
+    KConfigGroup guiConfig(config, "GuiConfig");
+
+    // window properties
+
+    setWindowTitle(i18nc("Untitled Screenshot", "Untitled"));
+    setFixedSize(800, 370);
+
+    QPoint location = guiConfig.readEntry("window-position", QPoint(50, 50));
+    move(location);
+
+    // the KSGWidget
+
+    mKSWidget = new KSWidget(this);
+
+    connect(mKSWidget, &KSWidget::newScreenshotRequest, this, &KSMainWindow::captureScreenshot);
+    connect(mKSWidget, &KSWidget::checkboxStatesChanged, this, &KSMainWindow::saveCheckboxStatesConfig);
+    connect(mKSWidget, &KSWidget::captureModeChanged, this, &KSMainWindow::saveCaptureModeConfig);
+    connect(mKSWidget, &KSWidget::dragInitiated, this, &KSMainWindow::dragAndDropRequest);
+
+    // the Button Bar
+
+    mDialogButtonBox = new QDialogButtonBox(this);
+    mDialogButtonBox->setStandardButtons(QDialogButtonBox::Help | QDialogButtonBox::Discard | QDialogButtonBox::Apply | QDialogButtonBox::Save);
+
+    mSendToButton = new QPushButton;
+    KGuiItem::assign(mSendToButton, KGuiItem(i18n("Send To...")));
+    mDialogButtonBox->addButton(mSendToButton, QDialogButtonBox::ActionRole);
+
+    mPrintButton = new QPushButton;
+    KGuiItem::assign(mPrintButton, KStandardGuiItem::print());
+    connect(mPrintButton, &QPushButton::clicked, this, &KSMainWindow::showPrintDialog);
+    mDialogButtonBox->addButton(mPrintButton, QDialogButtonBox::ActionRole);
+
+    connect(mDialogButtonBox->button(QDialogButtonBox::Discard), &QPushButton::clicked, qApp, &QApplication::quit);
+    connect(mDialogButtonBox->button(QDialogButtonBox::Save), &QPushButton::clicked, this, &KSMainWindow::saveAsClicked);
+    KGuiItem::assign(mDialogButtonBox->button(QDialogButtonBox::Save), KStandardGuiItem::saveAs());
+
+    connect(mDialogButtonBox->button(QDialogButtonBox::Apply), &QPushButton::clicked, this, &KSMainWindow::saveAndExit);
+    KGuiItem::assign(mDialogButtonBox->button(QDialogButtonBox::Apply), KStandardGuiItem::save());
+    mDialogButtonBox->button(QDialogButtonBox::Apply)->setText(i18n("Save && Exit"));
+    mDialogButtonBox->button(QDialogButtonBox::Apply)->setToolTip(i18n("Quicksave screenshot in your Pictures directory and exit"));
+
+    KHelpMenu *helpMenu = new KHelpMenu(this, KAboutData::applicationData(), true);
+    mDialogButtonBox->button(QDialogButtonBox::Help)->setMenu(helpMenu->menu());
+
+    // layouts
+
+    mDivider = new QFrame(this);
+    mDivider->setFrameShape(QFrame::HLine);
+    mDivider->setLineWidth(2);
+
+    QVBoxLayout *layout = new QVBoxLayout(this);
+    layout->addWidget(mKSWidget);
+    layout->addWidget(mDivider);
+    layout->addWidget(mDialogButtonBox);
+
+    // populate our send-to actions
+
+    connect(mSendToMenu, &KSSendToMenu::sendToServiceRequest, this, &KSMainWindow::sendToKServiceRequest);
+    connect(mSendToMenu, &KSSendToMenu::sendToClipboardRequest, this, &KSMainWindow::sendToClipboardRequest);
+    connect(mSendToMenu, &KSSendToMenu::sendToOpenWithRequest, this, &KSMainWindow::sendToOpenWithRequest);
+
+    mSendToButton->setMenu(mSendToMenu->menu());
+
+    // read in the checkbox states and capture mode index
+
+    bool capturePointer = guiConfig.readEntry("includePointer", true);
+    bool captureDecorations = guiConfig.readEntry("includeDecorations", true);
+    bool captureOnClick = guiConfig.readEntry("waitCaptureOnClick", false);
+    mKSWidget->setCheckboxStates(capturePointer, captureDecorations, captureOnClick);
+
+    int captureModeIndex = guiConfig.readEntry("captureModeIndex", 0);
+    mKSWidget->setCaptureModeIndex(captureModeIndex);
+
+    // disable onClick mode if not available on the platform
+
+    if (!mOnClickAvailable) {
+        mKSWidget->disableOnClick();
+    }
+
+    // done with the init
+}
+
+// overrides
+
+void KSMainWindow::moveEvent(QMoveEvent *event)
+{
+    Q_UNUSED(event);
+
+    KSharedConfigPtr config = KSharedConfig::openConfig("kscreengenierc");
+    KConfigGroup guiConfig(config, "GuiConfig");
+
+    guiConfig.writeEntry("window-position", pos());
+    guiConfig.sync();
+}
+
+// slots
+
+void KSMainWindow::captureScreenshot(ImageGrabber::GrabMode mode, int timeout, bool includePointer, bool includeDecorations)
+{
+    hide();
+    emit newScreenshotRequest(mode, timeout, includePointer, includeDecorations);
+}
+
+void KSMainWindow::setScreenshotAndShow(const QPixmap &pixmap)
+{
+    show();
+    mKSWidget->setScreenshotPixmap(pixmap);
+
+    if (mSendToMenu->menu()->isEmpty()) {
+        mSendToMenu->populateMenu();
+    }
+}
+
+void KSMainWindow::showPrintDialog()
+{
+    QPrinter *printer = new QPrinter(QPrinter::HighResolution);
+    QPrintDialog printDialog(printer, this);
+    if (printDialog.exec() == QDialog::Accepted) {
+        emit printRequest(printer);
+        return;
+    }
+    delete printer;
+}
+
+void KSMainWindow::saveCheckboxStatesConfig(bool includePointer, bool includeDecorations, bool waitCaptureOnClick)
+{
+    KSharedConfigPtr config = KSharedConfig::openConfig("kscreengenierc");
+    KConfigGroup guiConfig(config, "GuiConfig");
+
+    guiConfig.writeEntry("includePointer", includePointer);
+    guiConfig.writeEntry("includeDecorations", includeDecorations);
+    guiConfig.writeEntry("waitCaptureOnClick", waitCaptureOnClick);
+    guiConfig.sync();
+}
+
+void KSMainWindow::saveCaptureModeConfig(int modeIndex)
+{
+    KSharedConfigPtr config = KSharedConfig::openConfig("kscreengenierc");
+    KConfigGroup guiConfig(config, "GuiConfig");
+
+    guiConfig.writeEntry("captureModeIndex", modeIndex);
+    guiConfig.sync();
+}
diff --git a/src/KScreenGenieGUI.h b/src/Gui/KSMainWindow.h
similarity index 65%
rename from src/KScreenGenieGUI.h
rename to src/Gui/KSMainWindow.h
index 5082e3d..1a49f6a 100644
--- a/src/KScreenGenieGUI.h
+++ b/src/Gui/KSMainWindow.h
@@ -17,30 +17,20 @@
  *  Boston, MA 02110-1301, USA.
  */
 
-#ifndef KSCREENGENIEGUI_H
-#define KSCREENGENIEGUI_H
-
-#include <QApplication>
-#include <QDesktopWidget>
-#include <QCursor>
-#include <QMetaObject>
-#include <QVariant>
-#include <QList>
+#ifndef KSMAINWINDOW_H
+#define KSMAINWINDOW_H
+
 #include <QWidget>
 #include <QPrintDialog>
 #include <QPrinter>
-#include <QQuickItem>
-#include <QQuickWidget>
 #include <QVBoxLayout>
 #include <QHBoxLayout>
 #include <QMouseEvent>
 #include <QMoveEvent>
 #include <QPushButton>
 #include <QDialogButtonBox>
-#include <QMenu>
 #include <QPoint>
-#include <QTimer>
-#include <QDebug>
+#include <QFrame>
 #include <QAction>
 
 #include <KLocalizedString>
@@ -50,30 +40,28 @@
 #include <KHelpMenu>
 #include <KGuiItem>
 #include <KStandardGuiItem>
-#include <KDeclarative/QmlObject>
 
 #include "ImageGrabber.h"
-#include "KSGSendToMenu.h"
-#include "KSGImageProvider.h"
+#include "KSWidget.h"
+#include "KSSendToMenu.h"
 
-class KScreenGenieGUI : public QWidget
+class KSMainWindow : public QWidget
 {
     Q_OBJECT
 
     public:
 
-    explicit KScreenGenieGUI(bool onClickAvailable, QWidget *parent = 0);
-    ~KScreenGenieGUI();
+    explicit KSMainWindow(bool onClickAvailable, QWidget *parent = 0);
+    ~KSMainWindow();
 
     void setScreenshotAndShow(const QPixmap &pixmap);
 
     private slots:
 
-    void captureScreenshot(QString captureMode, double captureDelay, bool includePointer, bool includeDecorations);
+    void captureScreenshot(ImageGrabber::GrabMode mode, int timeout, bool includePointer, bool includeDecorations);
     void saveCheckboxStatesConfig(bool includePointer, bool includeDecorations, bool waitCaptureOnClick);
     void saveCaptureModeConfig(int modeIndex);
     void showPrintDialog();
-    void ungrabMouseWorkaround();
     void init();
 
     signals:
@@ -93,14 +81,13 @@ class KScreenGenieGUI : public QWidget
 
     private:
 
-    QQuickWidget            *mQuickWidget;
-    QDialogButtonBox        *mDialogButtonBox;
-    QPushButton             *mSendToButton;
-    QPushButton             *mPrintButton;
-    KSGSendToMenu           *mSendToMenu;
-    KDeclarative::QmlObject *mKQmlObject;
-    KSGImageProvider        *mScreenshotImageProvider;
-    bool                     mOnClickAvailable;
+    KSWidget         *mKSWidget;
+    QFrame           *mDivider;
+    QDialogButtonBox *mDialogButtonBox;
+    QPushButton      *mSendToButton;
+    QPushButton      *mPrintButton;
+    KSSendToMenu     *mSendToMenu;
+    bool              mOnClickAvailable;
 };
 
-#endif // KSCREENGENIEGUI_H
+#endif // KSMAINWINDOW_H
diff --git a/src/KSGSendToMenu.cpp b/src/Gui/KSSendToMenu.cpp
similarity index 86%
rename from src/KSGSendToMenu.cpp
rename to src/Gui/KSSendToMenu.cpp
index 9256568..809392c 100644
--- a/src/KSGSendToMenu.cpp
+++ b/src/Gui/KSSendToMenu.cpp
@@ -23,17 +23,17 @@
  *  Boston, MA 02110-1301, USA.
  */
 
-#include "KSGSendToMenu.h"
+#include "KSSendToMenu.h"
 
-KSGSendToMenu::KSGSendToMenu(QObject *parent) :
+KSSendToMenu::KSSendToMenu(QObject *parent) :
     QObject(parent),
     mMenu(new QMenu)
 {}
 
-KSGSendToMenu::~KSGSendToMenu()
+KSSendToMenu::~KSSendToMenu()
 {}
 
-void KSGSendToMenu::populateMenu()
+void KSSendToMenu::populateMenu()
 {
     populateHardcodedSendToActions();
     mMenu->addSeparator();
@@ -46,14 +46,14 @@ void KSGSendToMenu::populateMenu()
 
 // return menu
 
-QMenu *KSGSendToMenu::menu()
+QMenu *KSSendToMenu::menu()
 {
     return mMenu;
 }
 
 // send-to handlers
 
-void KSGSendToMenu::handleSendToKService()
+void KSSendToMenu::handleSendToKService()
 {
     QAction *action = qobject_cast<QAction *>(QObject::sender());
     if (!(action)) {
@@ -65,13 +65,15 @@ void KSGSendToMenu::handleSendToKService()
     emit sendToServiceRequest(data);
 }
 
-void KSGSendToMenu::populateHardcodedSendToActions()
+// populators
+
+void KSSendToMenu::populateHardcodedSendToActions()
 {
     mMenu->addAction(QIcon::fromTheme("edit-copy"), i18n("Copy To Clipboard"), this, SIGNAL(sendToClipboardRequest()));
     mMenu->addAction(i18n("Other Application"), this, SIGNAL(sendToOpenWithRequest()));
 }
 
-void KSGSendToMenu::populateKServiceSendToActions()
+void KSSendToMenu::populateKServiceSendToActions()
 {
     const KService::List services = KMimeTypeTrader::self()->query("image/png");
 
@@ -80,14 +82,14 @@ void KSGSendToMenu::populateKServiceSendToActions()
 
         QAction *action = new QAction(QIcon::fromTheme(service->icon()), name, nullptr);
         action->setData(QVariant::fromValue(service));
-        connect(action, &QAction::triggered, this, &KSGSendToMenu::handleSendToKService);
+        connect(action, &QAction::triggered, this, &KSSendToMenu::handleSendToKService);
 
         mMenu->addAction(action);
     }
 }
 
 #ifdef KIPI_FOUND
-void KSGSendToMenu::populateKipiSendToActions()
+void KSSendToMenu::populateKipiSendToActions()
 {
     mKipiInterface = new KSGKipiInterface(this);
     KIPI::PluginLoader *loader = new KIPI::PluginLoader;
@@ -118,7 +120,7 @@ void KSGSendToMenu::populateKipiSendToActions()
             if (category == KIPI::ExportPlugin) {
                 exportActions += action;
             } else if (category == KIPI::ImagesPlugin && pluginInfo->library().contains("kipiplugin_sendimages")) {
-                    exportActions += action;
+                exportActions += action;
             }
         }
 
diff --git a/src/KSGSendToMenu.h b/src/Gui/KSSendToMenu.h
similarity index 90%
rename from src/KSGSendToMenu.h
rename to src/Gui/KSSendToMenu.h
index 02682f4..b095fb0 100644
--- a/src/KSGSendToMenu.h
+++ b/src/Gui/KSSendToMenu.h
@@ -17,8 +17,8 @@
  *  Boston, MA 02110-1301, USA.
  */
 
-#ifndef KSGSENDTOMENU_H
-#define KSGSENDTOMENU_H
+#ifndef KSSENDTOMENU_H
+#define KSSENDTOMENU_H
 
 #include <QObject>
 #include <QWidget>
@@ -44,14 +44,14 @@
 #include "KipiInterface/KSGKipiInterface.h"
 #endif
 
-class KSGSendToMenu : public QObject
+class KSSendToMenu : public QObject
 {
     Q_OBJECT
 
     public:
 
-    explicit KSGSendToMenu(QObject *parent = 0);
-    ~KSGSendToMenu();
+    explicit KSSendToMenu(QObject *parent = 0);
+    ~KSSendToMenu();
 
     QMenu *menu();
 
@@ -84,4 +84,4 @@ class KSGSendToMenu : public QObject
 
 Q_DECLARE_METATYPE(KService::Ptr)
 
-#endif // KSGSENDTOMENU_H
+#endif // KSSENDTOMENU_H
diff --git a/src/Gui/KSWidget.cpp b/src/Gui/KSWidget.cpp
new file mode 100644
index 0000000..c9200f9
--- /dev/null
+++ b/src/Gui/KSWidget.cpp
@@ -0,0 +1,185 @@
+/*
+ *  Copyright (C) 2015 Boudhayan Gupta <me at BaloneyGeek.com>
+ *
+ *  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 "KSWidget.h"
+
+KSWidget::KSWidget(QWidget *parent) :
+    QWidget(parent)
+{
+    QFont tempFont;
+
+    // we'll init the widget that holds the image first
+
+    mImageWidget = new KSImageWidget(this);
+    mImageWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
+    connect(mImageWidget, &KSImageWidget::dragInitiated, this, &KSWidget::dragInitiated);
+
+    // the capture mode options first
+
+    mCaptureModeLabel = new QLabel(this);
+    mCaptureModeLabel->setText(i18n("Capture Mode"));
+    tempFont = mCaptureModeLabel->font();
+    tempFont.setPointSize(12);
+    tempFont.setBold(true);
+    mCaptureModeLabel->setFont(tempFont);
+
+    mCaptureArea = new QComboBox(this);
+    mCaptureArea->insertItem(0, i18n("Full Screen (All Monitors)"), ImageGrabber::FullScreen);
+    mCaptureArea->insertItem(1, i18n("Current Screen"), ImageGrabber::CurrentScreen);
+    mCaptureArea->insertItem(2, i18n("Active Window"), ImageGrabber::ActiveWindow);
+    mCaptureArea->insertItem(3, i18n("Rectangular Region"), ImageGrabber::RectangularRegion);
+    mCaptureArea->setMinimumWidth(200);
+    connect(mCaptureArea, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, &KSWidget::captureModeManage);
+
+    mDelayMsec = new QDoubleSpinBox(this);
+    mDelayMsec->setDecimals(1);
+    mDelayMsec->setSingleStep(0.1);
+    mDelayMsec->setMinimum(0.0);
+    mDelayMsec->setMaximum(999.9);
+    mDelayMsec->setSuffix(i18n(" seconds"));
+
+    mCaptureOnClick = new QCheckBox(this);
+    mCaptureOnClick->setText(i18n("On Click"));
+    mCaptureOnClick->setToolTip(i18n("Wait for a mouse click before capturing the screenshot image"));
+    connect(mCaptureOnClick, &QCheckBox::stateChanged, this, &KSWidget::onClickStateChanged);
+    connect(mCaptureOnClick, &QCheckBox::stateChanged, this, &KSWidget::checkboxStatesChangedHandler);
+
+    mDelayLayout = new QHBoxLayout;
+    mDelayLayout->addWidget(mDelayMsec);
+    mDelayLayout->addWidget(mCaptureOnClick);
+
+    mCaptureModeForm = new QFormLayout;
+    mCaptureModeForm->addRow(i18n("Capture Area"), mCaptureArea);
+    mCaptureModeForm->addRow(i18n("Capture Delay"), mDelayLayout);
+    mCaptureModeForm->setContentsMargins(24, 0, 0, 0);
+
+    // the capture options (mouse pointer, window decorations)
+
+    mCaptureOptionsLabel = new QLabel(this);
+    mCaptureOptionsLabel->setText(i18n("Capture Options"));
+    tempFont = mCaptureOptionsLabel->font();
+    tempFont.setPointSize(12);
+    tempFont.setBold(true);
+    mCaptureOptionsLabel->setFont(tempFont);
+
+    mMousePointer = new QCheckBox(this);
+    mMousePointer->setText(i18n("Include mouse pointer"));
+    mMousePointer->setToolTip(i18n("Show the mouse cursor in the screeenshot image"));
+    connect(mMousePointer, &QCheckBox::stateChanged, this, &KSWidget::checkboxStatesChangedHandler);
+
+    mWindowDecorations = new QCheckBox(this);
+    mWindowDecorations->setText(i18n("Include window titlebar and borders"));
+    mWindowDecorations->setToolTip(i18n("Show the window title bar, the minimize/maximize/close buttons, and the window border"));
+    connect(mWindowDecorations, &QCheckBox::stateChanged, this, &KSWidget::checkboxStatesChangedHandler);
+
+    mCaptureOptionsForm = new QVBoxLayout;
+    mCaptureOptionsForm->addWidget(mMousePointer);
+    mCaptureOptionsForm->addWidget(mWindowDecorations);
+    mCaptureOptionsForm->setSpacing(16);
+    mCaptureOptionsForm->setContentsMargins(24, 0, 0, 0);
+
+    // the take new screenshot button
+
+    mTakeScreenshotButton = new QPushButton(this);
+    mTakeScreenshotButton->setText(i18n("Take New Screenshot"));
+    mTakeScreenshotButton->setIcon(QIcon::fromTheme("ksnapshot"));
+    mTakeScreenshotButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
+    mTakeScreenshotButton->setFocus();
+    connect(mTakeScreenshotButton, &QPushButton::clicked, this, &KSWidget::newScreenshotClicked);
+
+    // finally, finish up the layouts
+
+    mRightLayout = new QVBoxLayout;
+    mRightLayout->addWidget(mCaptureModeLabel);
+    mRightLayout->addLayout(mCaptureModeForm);
+    mRightLayout->addWidget(mCaptureOptionsLabel);
+    mRightLayout->addLayout(mCaptureOptionsForm);
+    mRightLayout->addSpacing(10);
+    mRightLayout->addWidget(mTakeScreenshotButton, 1, Qt::AlignHCenter);
+    mRightLayout->setContentsMargins(20, 0, 0, 10);
+
+    mMainLayout = new QGridLayout(this);
+    mMainLayout->addWidget(mImageWidget, 0, 0, 1, 1);
+    mMainLayout->addLayout(mRightLayout, 0, 1, 1, 1);
+    mMainLayout->setColumnMinimumWidth(0, 400);
+    mMainLayout->setColumnMinimumWidth(1, 400);
+}
+
+// public slots
+
+void KSWidget::setScreenshotPixmap(const QPixmap &pixmap)
+{
+    mImageWidget->setScreenshot(pixmap);
+}
+
+void KSWidget::setCheckboxStates(bool capturePointer, bool captureDecorations, bool captureOnClick)
+{
+    mMousePointer->setChecked(capturePointer);
+    mWindowDecorations->setChecked(captureDecorations);
+    mCaptureOnClick->setChecked(captureOnClick);
+}
+
+void KSWidget::setCaptureModeIndex(int index)
+{
+    mCaptureArea->setCurrentIndex(index);
+}
+
+void KSWidget::disableOnClick()
+{
+    mCaptureOnClick->setEnabled(false);
+    mDelayMsec->setEnabled(true);
+}
+
+// private slots
+
+void KSWidget::newScreenshotClicked()
+{
+    int delay = mCaptureOnClick->isChecked() ? -1 : (mDelayMsec->value() * 1000);
+    ImageGrabber::GrabMode mode = static_cast<ImageGrabber::GrabMode>(mCaptureArea->currentData().toInt());
+    emit newScreenshotRequest(mode, delay, mMousePointer->isChecked(), mWindowDecorations->isChecked());
+}
+
+void KSWidget::checkboxStatesChangedHandler(int state)
+{
+    Q_UNUSED(state);
+    emit checkboxStatesChanged(mMousePointer->isChecked(), mWindowDecorations->isChecked(), mCaptureOnClick->isChecked());
+}
+
+void KSWidget::onClickStateChanged(int state)
+{
+    if (state == Qt::Checked) {
+        mDelayMsec->setEnabled(false);
+    } else if (state == Qt::Unchecked) {
+        mDelayMsec->setEnabled(true);
+    }
+}
+
+void KSWidget::captureModeManage(int index)
+{
+    emit captureModeChanged(index);
+
+    ImageGrabber::GrabMode mode = static_cast<ImageGrabber::GrabMode>(mCaptureArea->itemData(index).toInt());
+    switch (mode) {
+    case ImageGrabber::ActiveWindow:
+        mWindowDecorations->setEnabled(true);
+        break;
+    default:
+        mWindowDecorations->setEnabled(false);
+    }
+}
diff --git a/src/Gui/KSWidget.h b/src/Gui/KSWidget.h
new file mode 100644
index 0000000..61fb5a2
--- /dev/null
+++ b/src/Gui/KSWidget.h
@@ -0,0 +1,89 @@
+/*
+ *  Copyright (C) 2015 Boudhayan Gupta <me at BaloneyGeek.com>
+ *
+ *  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 KSWIDGET_H
+#define KSWIDGET_H
+
+#include <QWidget>
+#include <QHBoxLayout>
+#include <QVBoxLayout>
+#include <QGridLayout>
+#include <QFormLayout>
+#include <QLabel>
+#include <QFont>
+#include <QPushButton>
+#include <QCheckBox>
+#include <QDoubleSpinBox>
+#include <QComboBox>
+#include <QVariant>
+#include <QIcon>
+
+#include <KLocalizedString>
+
+#include "ImageGrabber.h"
+#include "KSImageWidget.h"
+
+class KSWidget : public QWidget
+{
+    Q_OBJECT
+
+	public:
+    
+    explicit KSWidget(QWidget *parent = 0);
+
+	signals:
+
+    void dragInitiated();
+    void captureModeChanged(int index);
+    void checkboxStatesChanged(bool capturePointer, bool captureDecorations, bool captureOnClick);
+    void newScreenshotRequest(ImageGrabber::GrabMode mode, int captureDelay, bool capturePointer, bool captureDecorations);
+
+	public slots:
+
+    void setScreenshotPixmap(const QPixmap &pixmap);
+    void setCheckboxStates(bool capturePointer, bool captureDecorations, bool captureOnClick);
+    void setCaptureModeIndex(int index);
+    void disableOnClick();
+
+    private slots:
+
+    void newScreenshotClicked();
+    void checkboxStatesChangedHandler(int state);
+    void onClickStateChanged(int state);
+    void captureModeManage(int index);
+
+	private:
+    
+    QGridLayout    *mMainLayout;
+    QHBoxLayout    *mDelayLayout;
+    QVBoxLayout    *mRightLayout;
+    QFormLayout    *mCaptureModeForm;
+    QVBoxLayout    *mCaptureOptionsForm;
+    KSImageWidget  *mImageWidget;
+    QPushButton    *mTakeScreenshotButton;
+    QComboBox      *mCaptureArea;
+    QDoubleSpinBox *mDelayMsec;
+    QCheckBox      *mCaptureOnClick;
+    QCheckBox      *mMousePointer;
+    QCheckBox      *mWindowDecorations;
+    QLabel         *mCaptureModeLabel;
+    QLabel         *mCaptureOptionsLabel;
+};
+
+#endif // KSWIDGET_H
diff --git a/src/KScreenGenie.cpp b/src/KScreenGenie.cpp
index 66ef9bd..1d10e60 100644
--- a/src/KScreenGenie.cpp
+++ b/src/KScreenGenie.cpp
@@ -37,7 +37,7 @@ KScreenGenie::KScreenGenie(bool backgroundMode, ImageGrabber::GrabMode grabMode,
     mOverwriteOnSave(true),
     mBackgroundSendToClipboard(sendToClipboard),
     mLocalPixmap(QPixmap()),
-    mScreenGenieGUI(nullptr)
+    mMainWindow(nullptr)
 {
     KSharedConfigPtr config = KSharedConfig::openConfig("kscreengenierc");
     KConfigGroup guiConfig(config, "GuiConfig");
@@ -71,24 +71,24 @@ KScreenGenie::KScreenGenie(bool backgroundMode, ImageGrabber::GrabMode grabMode,
     // if we aren't in background mode, this would be a good time to
     // init the gui
 
-    mScreenGenieGUI = new KScreenGenieGUI(mImageGrabber->onClickGrabSupported());
+    mMainWindow = new KSMainWindow(mImageGrabber->onClickGrabSupported());
 
-    connect(mScreenGenieGUI, &KScreenGenieGUI::newScreenshotRequest, this, &KScreenGenie::takeNewScreenshot);
-    connect(mScreenGenieGUI, &KScreenGenieGUI::saveAndExit, this, &KScreenGenie::doAutoSave);
-    connect(mScreenGenieGUI, &KScreenGenieGUI::saveAsClicked, this, &KScreenGenie::doGuiSaveAs);
-    connect(mScreenGenieGUI, &KScreenGenieGUI::sendToKServiceRequest, this, &KScreenGenie::doSendToService);
-    connect(mScreenGenieGUI, &KScreenGenieGUI::sendToOpenWithRequest, this, &KScreenGenie::doSendToOpenWith);
-    connect(mScreenGenieGUI, &KScreenGenieGUI::sendToClipboardRequest, this, &KScreenGenie::doSendToClipboard);
-    connect(mScreenGenieGUI, &KScreenGenieGUI::dragAndDropRequest, this, &KScreenGenie::doStartDragAndDrop);
-    connect(mScreenGenieGUI, &KScreenGenieGUI::printRequest, this, &KScreenGenie::doPrint);
+    connect(mMainWindow, &KSMainWindow::newScreenshotRequest, this, &KScreenGenie::takeNewScreenshot);
+    connect(mMainWindow, &KSMainWindow::saveAndExit, this, &KScreenGenie::doAutoSave);
+    connect(mMainWindow, &KSMainWindow::saveAsClicked, this, &KScreenGenie::doGuiSaveAs);
+    connect(mMainWindow, &KSMainWindow::sendToKServiceRequest, this, &KScreenGenie::doSendToService);
+    connect(mMainWindow, &KSMainWindow::sendToOpenWithRequest, this, &KScreenGenie::doSendToOpenWith);
+    connect(mMainWindow, &KSMainWindow::sendToClipboardRequest, this, &KScreenGenie::doSendToClipboard);
+    connect(mMainWindow, &KSMainWindow::dragAndDropRequest, this, &KScreenGenie::doStartDragAndDrop);
+    connect(mMainWindow, &KSMainWindow::printRequest, this, &KScreenGenie::doPrint);
 
     QMetaObject::invokeMethod(mImageGrabber, "doImageGrab", Qt::QueuedConnection);
 }
 
 KScreenGenie::~KScreenGenie()
 {
-    if (mScreenGenieGUI) {
-        delete mScreenGenieGUI;
+    if (mMainWindow) {
+        delete mMainWindow;
     }
 }
 
@@ -197,7 +197,7 @@ void KScreenGenie::screenshotUpdated(const QPixmap pixmap)
         doTempSaveForKipi();
         qDebug() << "KipiSave";
 #endif
-        mScreenGenieGUI->setScreenshotAndShow(pixmap);
+        mMainWindow->setScreenshotAndShow(pixmap);
     }
 }
 
@@ -290,7 +290,7 @@ void KScreenGenie::doGuiSaveAs()
         }
     }
 
-    QFileDialog dialog(mScreenGenieGUI);
+    QFileDialog dialog(mMainWindow);
     dialog.setAcceptMode(QFileDialog::AcceptSave);
     dialog.setFileMode(QFileDialog::AnyFile);
     dialog.setNameFilters(supportedFilters);
@@ -319,7 +319,7 @@ void KScreenGenie::doSendToService(KService::Ptr service)
     }
 
     tempFileList.append(tempFile);
-    KRun::runService(*service, tempFileList, mScreenGenieGUI, true);
+    KRun::runService(*service, tempFileList, mMainWindow, true);
 }
 
 void KScreenGenie::doSendToOpenWith()
@@ -334,7 +334,7 @@ void KScreenGenie::doSendToOpenWith()
     }
 
     tempFileList.append(tempFile);
-    KRun::displayOpenWithDialog(tempFileList, mScreenGenieGUI, true);
+    KRun::displayOpenWithDialog(tempFileList, mMainWindow, true);
 }
 
 void KScreenGenie::doSendToClipboard()
diff --git a/src/KScreenGenie.h b/src/KScreenGenie.h
index 4ee248c..baa90c6 100644
--- a/src/KScreenGenie.h
+++ b/src/KScreenGenie.h
@@ -56,7 +56,7 @@
 
 #include "ImageGrabber.h"
 #include "X11ImageGrabber.h"
-#include "KScreenGenieGUI.h"
+#include "Gui/KSMainWindow.h"
 #include "Config.h"
 
 class KScreenGenie : public QObject
@@ -117,10 +117,7 @@ class KScreenGenie : public QObject
     QUrl tempFileSave(const QString mimetype = "png");
     bool doSave(const QUrl url);
     bool isFileExists(const QUrl url);
-
-#ifdef KIPI_FOUND
     void doTempSaveForKipi();
-#endif
 
     bool             mBackgroundMode;
     bool             mOverwriteOnSave;
@@ -129,7 +126,7 @@ class KScreenGenie : public QObject
     QString          mFileNameString;
     QUrl             mFileNameUrl;
     ImageGrabber    *mImageGrabber;
-    KScreenGenieGUI *mScreenGenieGUI;
+    KSMainWindow    *mMainWindow;
 };
 
 #endif // KSCREENGENIE_H
diff --git a/src/KScreenGenieGUI.cpp b/src/KScreenGenieGUI.cpp
deleted file mode 100644
index b9629f8..0000000
--- a/src/KScreenGenieGUI.cpp
+++ /dev/null
@@ -1,232 +0,0 @@
-/*
- *  Copyright (C) 2015 Boudhayan Gupta <me at BaloneyGeek.com>
- *
- *  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 "KScreenGenieGUI.h"
-
-KScreenGenieGUI::KScreenGenieGUI(bool onClickAvailable, QWidget *parent) :
-    QWidget(parent),
-    mQuickWidget(nullptr),
-    mDialogButtonBox(nullptr),
-    mSendToButton(nullptr),
-    mPrintButton(nullptr),
-    mSendToMenu(new KSGSendToMenu),
-    mKQmlObject(new KDeclarative::QmlObject),
-    mScreenshotImageProvider(new KSGImageProvider),
-    mOnClickAvailable(onClickAvailable)
-{
-    QMetaObject::invokeMethod(this, "init", Qt::QueuedConnection);
-}
-
-KScreenGenieGUI::~KScreenGenieGUI()
-{
-    if (mQuickWidget) {
-        delete mQuickWidget;
-        delete mKQmlObject;
-    }
-}
-
-// GUI init
-
-void KScreenGenieGUI::init()
-{
-    KSharedConfigPtr config = KSharedConfig::openConfig("kscreengenierc");
-    KConfigGroup guiConfig(config, "GuiConfig");
-
-    // window properties
-
-    setWindowTitle(i18nc("Untitled Screenshot", "Untitled"));
-    setFixedSize(800, 370);
-
-    QPoint location = guiConfig.readEntry("window-position", QPoint(50, 50));
-    move(location);
-
-    // the QtQuick widget
-
-    mKQmlObject->engine()->addImageProvider(QLatin1String("screenshot"), mScreenshotImageProvider);
-    mQuickWidget = new QQuickWidget(mKQmlObject->engine(), this);
-
-    mQuickWidget->setResizeMode(QQuickWidget::SizeRootObjectToView);
-    mQuickWidget->resize(mQuickWidget->width(), 300);
-    mQuickWidget->setClearColor(QWidget::palette().color(QWidget::backgroundRole()));
-    mQuickWidget->setSource(QUrl("qrc:///MainForm.qml"));
-
-    // connect the qml signals
-
-    QQuickItem *rootItem = mQuickWidget->rootObject();
-    connect(rootItem, SIGNAL(newScreenshotRequest(QString,double,bool,bool)), this, SLOT(captureScreenshot(QString,double,bool,bool)));
-    connect(rootItem, SIGNAL(saveCheckboxStates(bool,bool,bool)), this, SLOT(saveCheckboxStatesConfig(bool,bool,bool)));
-    connect(rootItem, SIGNAL(saveCaptureMode(int)), this, SLOT(saveCaptureModeConfig(int)));
-    connect(rootItem, SIGNAL(startDragAndDrop()), this, SIGNAL(dragAndDropRequest()));
-    connect(rootItem, SIGNAL(startDragAndDrop()), this, SLOT(ungrabMouseWorkaround()));
-
-    // the Button Bar
-
-    mDialogButtonBox = new QDialogButtonBox(this);
-    mDialogButtonBox->setStandardButtons(QDialogButtonBox::Help | QDialogButtonBox::Discard | QDialogButtonBox::Apply | QDialogButtonBox::Save);
-
-    mSendToButton = new QPushButton;
-    KGuiItem::assign(mSendToButton, KGuiItem(i18n("Send To...")));
-    mDialogButtonBox->addButton(mSendToButton, QDialogButtonBox::ActionRole);
-
-    mPrintButton = new QPushButton;
-    KGuiItem::assign(mPrintButton, KStandardGuiItem::print());
-    connect(mPrintButton, &QPushButton::clicked, this, &KScreenGenieGUI::showPrintDialog);
-    mDialogButtonBox->addButton(mPrintButton, QDialogButtonBox::ActionRole);
-
-    connect(mDialogButtonBox->button(QDialogButtonBox::Discard), &QPushButton::clicked, qApp, &QApplication::quit);
-    connect(mDialogButtonBox->button(QDialogButtonBox::Save), &QPushButton::clicked, this, &KScreenGenieGUI::saveAsClicked);
-    KGuiItem::assign(mDialogButtonBox->button(QDialogButtonBox::Save), KStandardGuiItem::saveAs());
-
-    connect(mDialogButtonBox->button(QDialogButtonBox::Apply), &QPushButton::clicked, this, &KScreenGenieGUI::saveAndExit);
-    KGuiItem::assign(mDialogButtonBox->button(QDialogButtonBox::Apply), KStandardGuiItem::save());
-    mDialogButtonBox->button(QDialogButtonBox::Apply)->setText(i18n("Save && Exit"));
-    mDialogButtonBox->button(QDialogButtonBox::Apply)->setToolTip(i18n("Quicksave screenshot in your Pictures directory and exit"));
-
-    KHelpMenu *helpMenu = new KHelpMenu(this, KAboutData::applicationData(), true);
-    mDialogButtonBox->button(QDialogButtonBox::Help)->setMenu(helpMenu->menu());
-
-    // layouts
-
-    QVBoxLayout *layout = new QVBoxLayout;
-    layout->addWidget(mQuickWidget);
-    layout->addWidget(mDialogButtonBox);
-    setLayout(layout);
-    mQuickWidget->setFocus();
-
-    // populate our send-to actions
-
-    connect(mSendToMenu, &KSGSendToMenu::sendToServiceRequest, this, &KScreenGenieGUI::sendToKServiceRequest);
-    connect(mSendToMenu, &KSGSendToMenu::sendToClipboardRequest, this, &KScreenGenieGUI::sendToClipboardRequest);
-    connect(mSendToMenu, &KSGSendToMenu::sendToOpenWithRequest, this, &KScreenGenieGUI::sendToOpenWithRequest);
-
-    mSendToButton->setMenu(mSendToMenu->menu());
-
-    // read in the checkbox states and capture mode index
-
-    bool includePointer = guiConfig.readEntry("includePointer", true);
-    bool includeDecorations = guiConfig.readEntry("includeDecorations", true);
-    bool waitCaptureOnClick = guiConfig.readEntry("waitCaptureOnClick", false);
-    QMetaObject::invokeMethod(rootItem, "loadCheckboxStates",
-                              Q_ARG(QVariant, includePointer),
-                              Q_ARG(QVariant, includeDecorations),
-                              Q_ARG(QVariant, waitCaptureOnClick)
-    );
-
-    int captureModeIndex = guiConfig.readEntry("captureModeIndex", 0);
-    QMetaObject::invokeMethod(rootItem, "loadCaptureMode", Q_ARG(QVariant, captureModeIndex));
-
-    // disable onClick mode if not available on the platform
-
-    if (!mOnClickAvailable) {
-        QMetaObject::invokeMethod(rootItem, "disableOnClick");
-    }
-
-    // done with the init
-}
-
-// overrides
-
-void KScreenGenieGUI::moveEvent(QMoveEvent *event)
-{
-    Q_UNUSED(event);
-
-    KSharedConfigPtr config = KSharedConfig::openConfig("kscreengenierc");
-    KConfigGroup guiConfig(config, "GuiConfig");
-
-    guiConfig.writeEntry("window-position", pos());
-    guiConfig.sync();
-}
-
-// slots
-
-void KScreenGenieGUI::captureScreenshot(QString captureMode, double captureDelay, bool includePointer, bool includeDecorations)
-{
-    hide();
-
-    ImageGrabber::GrabMode mode = ImageGrabber::InvalidChoice;
-    int msec = captureDelay * 1000;;
-
-    if (captureMode == QStringLiteral("fullScreen")) {
-        mode = ImageGrabber::FullScreen;
-    } else if (captureMode == QStringLiteral("currentScreen")) {
-        mode = ImageGrabber::CurrentScreen;
-    } else if (captureMode == QStringLiteral("activeWindow")) {
-        mode = ImageGrabber::ActiveWindow;
-    } else if (captureMode == QStringLiteral("rectangularRegion")) {
-        mode = ImageGrabber::RectangularRegion;
-    } else {
-        qWarning() << "Capture called with invalid mode";
-        show();
-        return;
-    }
-
-    emit newScreenshotRequest(mode, msec, includePointer, includeDecorations);
-}
-
-void KScreenGenieGUI::setScreenshotAndShow(const QPixmap &pixmap)
-{
-    mScreenshotImageProvider->setPixmap(pixmap);
-
-    QQuickItem *rootItem = mQuickWidget->rootObject();
-    QMetaObject::invokeMethod(rootItem, "reloadScreenshot");
-
-    show();
-    if (mSendToMenu->menu()->isEmpty()) {
-        mSendToMenu->populateMenu();
-    }
-}
-
-void KScreenGenieGUI::ungrabMouseWorkaround()
-{
-    QQuickItem *dragMouseArea = mQuickWidget->rootObject()->findChild<QQuickItem *>("screenshotDragMouseArea");
-    QMouseEvent releaseEvent(QMouseEvent::MouseButtonRelease, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, Qt::NoModifier);
-    qApp->sendEvent(mQuickWidget, &releaseEvent);
-    dragMouseArea->ungrabMouse();
-}
-
-void KScreenGenieGUI::showPrintDialog()
-{
-    QPrinter *printer = new QPrinter(QPrinter::HighResolution);
-    QPrintDialog printDialog(printer, this);
-    if (printDialog.exec() == QDialog::Accepted) {
-        emit printRequest(printer);
-        return;
-    }
-    delete printer;
-}
-
-void KScreenGenieGUI::saveCheckboxStatesConfig(bool includePointer, bool includeDecorations, bool waitCaptureOnClick)
-{
-    KSharedConfigPtr config = KSharedConfig::openConfig("kscreengenierc");
-    KConfigGroup guiConfig(config, "GuiConfig");
-
-    guiConfig.writeEntry("includePointer", includePointer);
-    guiConfig.writeEntry("includeDecorations", includeDecorations);
-    guiConfig.writeEntry("waitCaptureOnClick", waitCaptureOnClick);
-    guiConfig.sync();
-}
-
-void KScreenGenieGUI::saveCaptureModeConfig(int modeIndex)
-{
-    KSharedConfigPtr config = KSharedConfig::openConfig("kscreengenierc");
-    KConfigGroup guiConfig(config, "GuiConfig");
-
-    guiConfig.writeEntry("captureModeIndex", modeIndex);
-    guiConfig.sync();
-}
diff --git a/src/QmlResources/MainForm.qml b/src/QmlResources/MainForm.qml
deleted file mode 100644
index bf8ac12..0000000
--- a/src/QmlResources/MainForm.qml
+++ /dev/null
@@ -1,305 +0,0 @@
-/*
- *  Copyright (C) 2015 Boudhayan Gupta <me at BaloneyGeek.com>
- *
- *  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.
- */
-
-import QtQuick 2.0
-import QtQuick.Controls 1.2
-import QtQuick.Layouts 1.1
-import QtGraphicalEffects 1.0
-
-ColumnLayout {
-    id: mainLayout;
-    spacing: 10;
-
-    signal newScreenshotRequest(string captureType, real captureDelay, bool includePointer, bool includeDecorations);
-    signal saveCheckboxStates(bool includePointer, bool includeDecorations, bool waitCaptureOnClick);
-    signal saveCaptureMode(int captureModeIndex);
-    signal startDragAndDrop;
-
-    function saveCheckboxes() {
-        saveCheckboxStates(optionMousePointer.checked, optionWindowDecorations.checked, captureOnClick.checked);
-    }
-
-    function reloadScreenshot() {
-        screenshotImage.refreshImage();
-    }
-
-    function loadCheckboxStates(includePointer, includeDecorations, waitCaptureOnClick) {
-        optionMousePointer.checked = includePointer;
-        optionWindowDecorations.checked = includeDecorations;
-        captureOnClick.checked = waitCaptureOnClick;
-    }
-
-    function loadCaptureMode(captureModeIndex) {
-        captureMode.currentIndex = captureModeIndex;
-    }
-
-    function disableOnClick() {
-        captureOnClick.checked = false;
-        captureOnClick.enabled = false;
-    }
-
-    RowLayout {
-        id: topLayout
-
-        ColumnLayout {
-            id: leftColumn
-            Layout.preferredWidth: 400;
-
-            Item {
-                Layout.preferredWidth: 384;
-                Layout.preferredHeight: 256;
-
-                Item {
-                    id: screenshotContainer;
-                    anchors.fill: parent;
-                    visible: false;
-
-                    Image {
-                        id: screenshotImage;
-
-                        width: parent.width - 10;
-                        height: parent.height - 10;
-
-                        anchors.centerIn: parent;
-
-                        fillMode: Image.PreserveAspectFit;
-                        smooth: true;
-
-                        function refreshImage() {
-                            var rstring = Math.random().toString().substring(4);
-                            screenshotImage.source = "image://screenshot/" + rstring;
-                        }
-                    }
-                }
-
-                DropShadow {
-                    anchors.fill: screenshotContainer;
-                    source: screenshotContainer;
-
-                    horizontalOffset: 0;
-                    verticalOffset: 0;
-                    radius: 5;
-                    samples: 32;
-                    color: "black";
-                }
-
-                MouseArea {
-                    objectName: "screenshotDragMouseArea";
-
-                    anchors.fill: screenshotContainer;
-                    cursorShape: Qt.OpenHandCursor;
-
-                    property int oldMouseX;
-                    property int oldMouseY;
-                    property bool dragEmitted: false;
-
-                    onPressed: {
-                        oldMouseX = mouseX;
-                        oldMouseY = mouseY;
-                        dragEmitted = false;
-
-                        cursorShape = Qt.ClosedHandCursor;
-                    }
-
-                    onReleased: {
-                        dragEmitted = false;
-                        cursorShape = Qt.OpenHandCursor;
-
-                    }
-
-                    onPositionChanged: {
-                        if ( mouseX < (oldMouseX - 5) || mouseX > (oldMouseX + 5) ||
-                             mouseY < (oldMouseY - 5) || mouseY > (oldMouseY + 5) ) {
-
-                            if (!dragEmitted) {
-                                startDragAndDrop();
-                                dragEmitted = true;
-                            }
-                        }
-                    }
-                }
-            }
-        }
-
-        ColumnLayout {
-            id: rightColumn
-            spacing: 20;
-
-            Layout.preferredWidth: 400;
-
-            Label {
-                text: i18n("Capture Mode");
-
-                font.bold: true;
-                font.pointSize: 12;
-            }
-
-            ColumnLayout {
-                id: innerColumnLayoutCaptureMode;
-
-                RowLayout {
-                    id: captureAreaLayout;
-                    anchors.left: parent.left;
-                    anchors.leftMargin: 32;
-
-                    Label {
-                        id: captureAreaLabel;
-                        text: i18n("Capture Area");
-                    }
-
-                    ComboBox {
-                        id: captureMode;
-                        model: captureModeModel;
-
-                        onCurrentIndexChanged: {
-                            saveCaptureMode(captureMode.currentIndex);
-
-                            var capturemode = captureModeModel.get(captureMode.currentIndex)["type"];
-                            if (capturemode === "fullScreen") {
-                                optionMousePointer.enabled = true;
-                                optionWindowDecorations.enabled = false;
-                            } else if (capturemode === "currentScreen") {
-                                optionMousePointer.enabled = true;
-                                optionWindowDecorations.enabled = false;
-                            } else if (capturemode === "activeWindow") {
-                                optionMousePointer.enabled = true;
-                                optionWindowDecorations.enabled = true;
-                            } else if (capturemode === "rectangularRegion") {
-                                optionMousePointer.enabled = false;
-                                optionWindowDecorations.enabled = false;
-                            }
-                        }
-
-                        Layout.preferredWidth: 200;
-                    }
-                }
-
-                RowLayout {
-                    id: captureDelayLayout;
-                    anchors.right: captureAreaLayout.right;
-
-                    Label {
-                        id: captureDelayLabel;
-                        text: i18n("Capture Delay");
-                    }
-
-                    SpinBox {
-                        id: captureDelay;
-
-                        minimumValue: -0.1;
-                        maximumValue: 999.9;
-                        decimals: 1;
-                        stepSize: 0.1;
-                        suffix: i18n(" seconds");
-
-                        Layout.preferredWidth: 120;
-                    }
-
-                    CheckBox {
-                        id: captureOnClick;
-
-                        checked: false;
-                        text: i18n("On Click");
-
-                        onCheckedChanged: {
-                            if (checked) {
-                                captureDelay.enabled = false;
-                            } else {
-                                captureDelay.enabled = true;
-                            }
-
-                            mainLayout.saveCheckboxes();
-                        }
-
-                        Layout.preferredWidth: 75;
-                    }
-                }
-            }
-
-            Label {
-                text: i18n("Capture Options");
-
-                font.bold: true;
-                font.pointSize: 12;
-            }
-
-            ColumnLayout {
-                id: innerColumnLayoutCaptureOptions;
-                spacing: 10;
-
-                CheckBox {
-                    id: optionMousePointer;
-                    anchors.left: parent.left;
-                    anchors.leftMargin: 32;
-
-                    onCheckedChanged: mainLayout.saveCheckboxes();
-
-                    text: i18n("Include mouse pointer");
-                }
-
-                CheckBox {
-                    id: optionWindowDecorations;
-                    anchors.left: parent.left;
-                    anchors.leftMargin: 32;
-
-                    onCheckedChanged: mainLayout.saveCheckboxes();
-
-                    text: i18n("Include window titlebar and borders");
-                }
-            }
-
-            Button {
-                id: takeNewScreenshot;
-                text: i18n("Take New Screenshot");
-                iconName: "ksnapshot"
-                focus: true;
-
-                Layout.alignment: Qt.AlignHCenter | Qt.AlignTop;
-
-                onClicked: {
-                    var capturemode = captureModeModel.get(captureMode.currentIndex)["type"];
-                    var capturedelay = captureOnClick.checked ? -1 : captureDelay.value;
-                    var includepointer = optionMousePointer.checked;
-                    var includedecor = optionWindowDecorations.checked;
-
-                    newScreenshotRequest(capturemode, capturedelay, includepointer, includedecor);
-                }
-            }
-        }
-    }
-
-    Rectangle {
-        Layout.preferredHeight: 1;
-        Layout.fillWidth: true;
-
-        color: "darkgrey";
-    }
-
-    ListModel {
-        id: captureModeModel
-        dynamicRoles: true;
-
-        Component.onCompleted: {
-            captureModeModel.append({ type: "fullScreen", text: "Full Screen (All Monitors)" });
-            captureModeModel.append({ type: "currentScreen", text: i18n("Current Screen") });
-            captureModeModel.append({ type: "activeWindow", text: i18n("Active Window") });
-            captureModeModel.append({ type: "rectangularRegion", text: i18n("Rectangular Region") });
-        }
-    }
-}
diff --git a/src/QmlResources/QmlResources.qrc b/src/QmlResources/QmlResources.qrc
index 9bf3dbc..ebf1483 100644
--- a/src/QmlResources/QmlResources.qrc
+++ b/src/QmlResources/QmlResources.qrc
@@ -1,6 +1,5 @@
 <RCC>
     <qresource prefix="/">
-        <file alias="MainForm.qml">MainForm.qml</file>
         <file alias="HighlightRectangle.qml">HighlightRectangle.qml</file>
         <file alias="RegionGrabber.qml">RegionGrabber.qml</file>
     </qresource>


More information about the kde-doc-english mailing list