Added IconDialog class to the platform components

This commit is contained in:
Ivan Čukić 2014-03-08 18:02:39 +01:00
parent 50b5c62d81
commit 4b3ae32b17
4 changed files with 125 additions and 9 deletions

View File

@ -1,10 +1,6 @@
set(CMAKE_AUTOMOC ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
include(CheckCXXSourceCompiles)
add_definitions("-std=c++0x")
set(CMAKE_MODULE_PATH
/opt/kf5/usr/kde/share/ECM-0.0.8/find-modules/
${CMAKE_MODULE_PATH}
@ -13,12 +9,9 @@ set(CMAKE_MODULE_PATH
set(platformcomponents_SRCS
platformextensionplugin.cpp
application.cpp
icondialog.cpp
)
include(CheckIncludeFiles)
include(CheckFunctionExists)
include(CheckCXXSourceCompiles)
find_package(Qt5 5.2.0 REQUIRED NO_MODULE COMPONENTS Core DBus Quick Qml)
add_library(platformcomponentsplugin SHARED ${platformcomponents_SRCS})
@ -29,6 +22,8 @@ target_link_libraries(
platformcomponentsplugin
Qt5::Core
Qt5::DBus
KF5::WindowSystem
KF5::IconThemes
)
install(TARGETS platformcomponentsplugin DESTINATION ${QML_INSTALL_DIR}/org/kde/plasma/platformcomponents)

View File

@ -0,0 +1,63 @@
/*
* Copyright (C) 2014 Ivan Cukic <ivan.cukic(at)kde.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2,
* or (at your option) any later version, as published by the Free
* Software Foundation
*
* 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 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 "icondialog.h"
#include "utils/d_ptr_implementation.h"
#include <QDebug>
#include <KIconDialog>
#include <KWindowSystem>
#include "utils/sharedsingleton.h"
/**
*
*/
class IconDialog::Private {
public:
utils::SharedSingleton<KIconDialog> dialog;
};
IconDialog::IconDialog(QObject * parent)
: QObject(parent)
{
}
QString IconDialog::openDialog()
{
auto dialog = d->dialog.instance();
dialog->setup(KIconLoader::Desktop);
dialog->setProperty("DoNotCloseController", true);
KWindowSystem::setOnAllDesktops(dialog->winId(), true);
dialog->showDialog();
KWindowSystem::forceActiveWindow(dialog->winId());
return dialog->openDialog();
}
IconDialog::~IconDialog()
{
}

View File

@ -0,0 +1,56 @@
/*
* Copyright (C) 2014 Ivan Cukic <ivan.cukic(at)kde.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2,
* or (at your option) any later version, as published by the Free
* Software Foundation
*
* 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 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 ICONDIALOG_H
#define ICONDIALOG_H
#include <QObject>
#include <QString>
#include "utils/d_ptr.h"
/**
* Class which handles an icondialog execution.
*
* Example:
* <code>
* IconDialog {
* id: iconDialog
* }
*
* ...
*
* icon = iconDialog.openDialog()
* </code>
*/
class IconDialog: public QObject {
Q_OBJECT
public:
IconDialog(QObject * parent = Q_NULLPTR);
~IconDialog();
Q_INVOKABLE QString openDialog();
private:
D_PTR;
};
#endif /* ICONDIALOG_H */

View File

@ -22,6 +22,7 @@
#include <QDebug>
#include "application.h"
#include "icondialog.h"
class PlatformComponentsPlugin: public QQmlExtensionPlugin {
Q_OBJECT
@ -40,7 +41,8 @@ public:
Q_ASSERT(QLatin1String(uri) == QLatin1String("org.kde.plasma.platformcomponents"));
qmlRegisterType<Application> (uri, 1, 0, "Application");
qmlRegisterType<Application> (uri, 2, 0, "Application");
qmlRegisterType<IconDialog> (uri, 2, 0, "IconDialog");
}
};