Merge branch 'plasmaextracomponents'
This commit is contained in:
commit
d0c2a45738
@ -3,4 +3,5 @@ add_subdirectory(draganddrop)
|
||||
add_subdirectory(graphicslayouts)
|
||||
add_subdirectory(graphicswidgets)
|
||||
add_subdirectory(qtextracomponents)
|
||||
add_subdirectory(plasmacomponents)
|
||||
add_subdirectory(plasmacomponents)
|
||||
add_subdirectory(plasmaextracomponents)
|
||||
|
44
declarativeimports/plasmaextracomponents/CMakeLists.txt
Normal file
44
declarativeimports/plasmaextracomponents/CMakeLists.txt
Normal file
@ -0,0 +1,44 @@
|
||||
project(plasmaextracomponents)
|
||||
|
||||
find_package(KActivities REQUIRED)
|
||||
|
||||
#include(KDE4Defaults)
|
||||
|
||||
set(plasmaextracomponents_SRCS
|
||||
appbackgroundprovider.cpp
|
||||
resourceinstance.cpp
|
||||
plasmaextracomponentsplugin.cpp
|
||||
)
|
||||
|
||||
INCLUDE_DIRECTORIES(
|
||||
${CMAKE_SOURCE_DIR}
|
||||
${CMAKE_BINARY_DIR}
|
||||
${KDE4_INCLUDES}
|
||||
)
|
||||
|
||||
qt4_automoc(${plasmaextracomponents_SRCS})
|
||||
|
||||
|
||||
add_library(plasmaextracomponentsplugin SHARED ${plasmaextracomponents_SRCS})
|
||||
target_link_libraries(plasmaextracomponentsplugin ${QT_QTCORE_LIBRARY} ${QT_QTDECLARATIVE_LIBRARY} ${QT_QTGUI_LIBRARY} ${KDE4_PLASMA_LIBS} ${KACTIVITIES_LIBRARY} )
|
||||
|
||||
#target_link_libraries(plasmaextracomponentsplugin ${QT_QTCORE_LIBRARY} ${QT_QTDBUS_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTSCRIPT_LIBRARY} ${QT_QTDECLARATIVE_LIBRARY} ${KDE4_KDECORE_LIBRARY} ${KDE4_PLASMA_LIBS} ${KACTIVITIES_LIBRARY})
|
||||
|
||||
|
||||
install(TARGETS plasmaextracomponentsplugin DESTINATION ${IMPORTS_INSTALL_DIR}/org/kde/plasma/extras)
|
||||
|
||||
install(DIRECTORY qml/ DESTINATION ${IMPORTS_INSTALL_DIR}/org/kde/plasma/extras)
|
||||
|
||||
|
||||
# The platform specific stuff, overwrites a copy of the desktop one
|
||||
# it does install some files on top of the old ones, has to be done
|
||||
# file by file since if some component from the generic set is more
|
||||
# recent than the specifc ones, it wouldn't be overwritten
|
||||
|
||||
install(TARGETS plasmaextracomponentsplugin DESTINATION ${PLUGIN_INSTALL_DIR}/platformimports/touch/org/kde/plasma/extras)
|
||||
|
||||
install(FILES qml/App.qml DESTINATION ${PLUGIN_INSTALL_DIR}/platformimports/touch/org/kde/plasma/extras)
|
||||
install(FILES qml/Title.qml DESTINATION ${PLUGIN_INSTALL_DIR}/platformimports/touch/org/kde/plasma/extras)
|
||||
|
||||
#install platform overrides
|
||||
install(DIRECTORY platformcomponents/touch/ DESTINATION ${PLUGIN_INSTALL_DIR}/platformimports/touch/org/kde/plasma/extras)
|
11
declarativeimports/plasmaextracomponents/TODO
Normal file
11
declarativeimports/plasmaextracomponents/TODO
Normal file
@ -0,0 +1,11 @@
|
||||
TODO:
|
||||
|
||||
o imageprovider from mobilecomponents
|
||||
o resourceinstance from mobilecomponents
|
||||
o remove mobilecomponents' resourceinstance
|
||||
o port appbackgrounds
|
||||
o porting ResourceInstance
|
||||
- subtitle for Title (take from active-settings)
|
||||
- Heading { level: 1 } new Component
|
||||
- App.qml
|
||||
|
@ -0,0 +1,41 @@
|
||||
/*
|
||||
Copyright 2011 Marco Martin <notmart@gmail.com>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public License
|
||||
along with this library; see the file COPYING.LIB. If not, write to
|
||||
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "appbackgroundprovider_p.h"
|
||||
|
||||
#include <QLatin1Literal>
|
||||
#include <QPixmap>
|
||||
#include <QSize>
|
||||
|
||||
#include <KStandardDirs>
|
||||
|
||||
#include <Plasma/Theme>
|
||||
|
||||
AppBackgroundProvider::AppBackgroundProvider()
|
||||
: QDeclarativeImageProvider(QDeclarativeImageProvider::Image)
|
||||
{
|
||||
}
|
||||
|
||||
QImage AppBackgroundProvider::requestImage(const QString &id, QSize *size, const QSize &requestedSize)
|
||||
{
|
||||
QString search = QLatin1Literal("desktoptheme/") % Plasma::Theme::defaultTheme()->themeName() % QLatin1Literal("/appbackgrounds/") % id % ".png";
|
||||
search = KStandardDirs::locate("data", search);
|
||||
return QImage(search);
|
||||
}
|
||||
|
@ -0,0 +1,34 @@
|
||||
/*
|
||||
Copyright 2011 Marco Martin <notmart@gmail.com>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public License
|
||||
along with this library; see the file COPYING.LIB. If not, write to
|
||||
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef APPBACKGROUND_PROVIDER_H
|
||||
#define APPBACKGROUND_PROVIDER_H
|
||||
|
||||
#include <QDeclarativeImageProvider>
|
||||
|
||||
|
||||
class AppBackgroundProvider : public QDeclarativeImageProvider
|
||||
{
|
||||
|
||||
public:
|
||||
AppBackgroundProvider();
|
||||
virtual QImage requestImage(const QString &id, QSize *size, const QSize &requestedSize);
|
||||
};
|
||||
|
||||
#endif
|
@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Copyright 2012 by Sebastian Kügler <sebas@kde.org>
|
||||
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Library General Public License as
|
||||
* published by the Free Software Foundation; either version 2, 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 Library 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 "plasmaextracomponentsplugin.h"
|
||||
|
||||
#include "appbackgroundprovider_p.h"
|
||||
#include "resourceinstance.h"
|
||||
|
||||
#include <QtDeclarative/qdeclarative.h>
|
||||
#include <QtDeclarative/QDeclarativeEngine>
|
||||
|
||||
|
||||
// #include <KSharedConfig>
|
||||
// #include <KConfigGroup>
|
||||
|
||||
void PlasmaExtraComponentsPlugin::initializeEngine(QDeclarativeEngine *engine, const char *uri)
|
||||
{
|
||||
Q_ASSERT(uri == QLatin1String("org.kde.plasma.extras"));
|
||||
engine->addImageProvider(QLatin1String("appbackgrounds"), new AppBackgroundProvider);
|
||||
}
|
||||
|
||||
void PlasmaExtraComponentsPlugin::registerTypes(const char *uri)
|
||||
{
|
||||
Q_ASSERT(uri == QLatin1String("org.kde.plasma.extras"));
|
||||
/*
|
||||
// Enable when adding touch-specific components
|
||||
QString componentsPlatform = getenv("KDE_PLASMA_COMPONENTS_PLATFORM");
|
||||
if (componentsPlatform.isEmpty()) {
|
||||
KConfigGroup cg(KSharedConfig::openConfig("kdeclarativerc"), "Components-platform");
|
||||
componentsPlatform = cg.readEntry("name", "desktop");
|
||||
}
|
||||
*/
|
||||
// Register additional types here...
|
||||
qmlRegisterType<ResourceInstance>(uri, 0, 1, "ResourceInstance");
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
#include "plasmaextracomponentsplugin.moc"
|
||||
|
@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright 2011 by Marco Martin <mart@kde.org>
|
||||
* Copyright 2012 by Sebastian Kügler <sebas@kde.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Library General Public License as
|
||||
* published by the Free Software Foundation; either version 2, 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 Library 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 PLASMAEXTRACOMPONENTSPLUGIN_H
|
||||
#define PLASMAEXTRACOMPONENTSPLUGIN_H
|
||||
|
||||
#include <QDeclarativeExtensionPlugin>
|
||||
|
||||
class QDeclarativeEngine;
|
||||
|
||||
class PlasmaExtraComponentsPlugin : public QDeclarativeExtensionPlugin
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
void initializeEngine(QDeclarativeEngine *engine, const char *uri);
|
||||
void registerTypes(const char *uri);
|
||||
};
|
||||
|
||||
Q_EXPORT_PLUGIN2(plasmaexracomponentsplugin, PlasmaExtraComponentsPlugin);
|
||||
|
||||
#endif
|
102
declarativeimports/plasmaextracomponents/qml/App.qml
Normal file
102
declarativeimports/plasmaextracomponents/qml/App.qml
Normal file
@ -0,0 +1,102 @@
|
||||
/*
|
||||
* Copyright 2012 by Sebastian Kügler <sebas@kde.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Library General Public License as
|
||||
* published by the Free Software Foundation; either version 2, 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 Library General Public License for more details
|
||||
*
|
||||
* You should have received a copy of the GNU Library 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.
|
||||
*/
|
||||
|
||||
/**Documented API
|
||||
Inherits:
|
||||
Item
|
||||
|
||||
Imports:
|
||||
QtQuick 1.1
|
||||
org.kde.plasma.extras
|
||||
|
||||
Description:
|
||||
This is a container for Apps. Navigation and Content area layout can
|
||||
vary depending on the available size.
|
||||
|
||||
Properties:
|
||||
Item navigation: Navigation or Context Area.
|
||||
Item content: The "main view"
|
||||
|
||||
Methods:
|
||||
|
||||
|
||||
Signals:
|
||||
|
||||
**/
|
||||
|
||||
import QtQuick 1.1
|
||||
import org.kde.plasma.core 0.1 as PlasmaCore
|
||||
import org.kde.plasma.components 0.1 as PlasmaComponents
|
||||
//import org.kde.plasma.extras 0.1 as PlasmaExtras
|
||||
|
||||
Item {
|
||||
id: app
|
||||
property alias navigation: navigationItem.children
|
||||
property alias content: contentItem.children
|
||||
property int space: 12
|
||||
property int navigationWidth: 340
|
||||
property int contentWidth: app.width - navigationWidth
|
||||
anchors.fill: parent
|
||||
|
||||
PlasmaCore.Theme { id: theme }
|
||||
|
||||
Image {
|
||||
id: contentBackground
|
||||
anchors { left: navigationBackground.right; right: parent.right; top: parent.top; bottom: parent.bottom; }
|
||||
source: "image://appbackgrounds/standard"
|
||||
fillMode: Image.Tile
|
||||
asynchronous: true
|
||||
width: childrenRect.width
|
||||
Item {
|
||||
id: contentItem
|
||||
width: app.width - navigationWidth - space*2
|
||||
height: app.height
|
||||
anchors { left: parent.left; leftMargin: space; rightMargin: space; top: parent.top; bottom: parent.bottom; right: parent.right; }
|
||||
}
|
||||
|
||||
}
|
||||
Image {
|
||||
id: navigationBackground
|
||||
anchors { left: parent.left; top: parent.top; bottom: parent.bottom; }
|
||||
source: "image://appbackgrounds/contextarea"
|
||||
fillMode: Image.Tile
|
||||
asynchronous: true
|
||||
clip: true
|
||||
width: navigationWidth + space
|
||||
Item {
|
||||
id: navigationItem
|
||||
anchors.fill: parent
|
||||
}
|
||||
}
|
||||
Image {
|
||||
source: "image://appbackgrounds/shadow-right"
|
||||
fillMode: Image.Tile
|
||||
anchors {
|
||||
left: navigationBackground.right
|
||||
top: parent.top
|
||||
bottom: parent.bottom
|
||||
leftMargin: -1
|
||||
}
|
||||
}
|
||||
|
||||
onNavigationWidthChanged: {
|
||||
navigationBackground.width = navigationWidth;
|
||||
navigationItem.width = navigationWidth;
|
||||
}
|
||||
}
|
72
declarativeimports/plasmaextracomponents/qml/Heading.qml
Normal file
72
declarativeimports/plasmaextracomponents/qml/Heading.qml
Normal file
@ -0,0 +1,72 @@
|
||||
/*
|
||||
* Copyright 2012 by Sebastian Kügler <sebas@kde.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Library General Public License as
|
||||
* published by the Free Software Foundation; either version 2, 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 Library General Public License for more details
|
||||
*
|
||||
* You should have received a copy of the GNU Library 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.
|
||||
*/
|
||||
|
||||
/**Documented API
|
||||
Inherits:
|
||||
Label
|
||||
|
||||
Imports:
|
||||
QtQuick 1.1
|
||||
org.kde.plasma.extras
|
||||
|
||||
Description:
|
||||
This is a title label which uses the plasma theme.
|
||||
The characteristics of the text will be automatically set
|
||||
according to the plasma theme. Use this components for titles
|
||||
in your UI, for example page or section titles.
|
||||
|
||||
Properties:
|
||||
string text:
|
||||
The most important property is "text", which applies to the text property of Label
|
||||
For the other ones see Plasma Component's Label or QML primitive Text element
|
||||
int level:
|
||||
The level determines how big the section header is display, values between 1 (big)
|
||||
and 5 (small) are accepted
|
||||
|
||||
Methods:
|
||||
See Plasma Component's Label and primitive QML Text element
|
||||
|
||||
Signals:
|
||||
See Plasma Component's Label and primitive QML Text element
|
||||
**/
|
||||
|
||||
import QtQuick 1.1
|
||||
import org.kde.plasma.components 0.1
|
||||
|
||||
Label {
|
||||
id: heading
|
||||
property int level: 1
|
||||
property int step: 2
|
||||
|
||||
anchors.topMargin: 8
|
||||
font.pointSize: headerPointSize(level)
|
||||
|
||||
function headerPointSize(l) {
|
||||
var n = theme.defaultFont.pointSize;
|
||||
var s;
|
||||
if (l > 4) {
|
||||
s = n
|
||||
} else if (l < 2) {
|
||||
s = n + (5*step)
|
||||
} else {
|
||||
s = n + ((5-level)*2)
|
||||
}
|
||||
return s;
|
||||
}
|
||||
}
|
53
declarativeimports/plasmaextracomponents/qml/Title.qml
Normal file
53
declarativeimports/plasmaextracomponents/qml/Title.qml
Normal file
@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright 2012 by Sebastian Kügler <sebas@kde.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Library General Public License as
|
||||
* published by the Free Software Foundation; either version 2, 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 Library General Public License for more details
|
||||
*
|
||||
* You should have received a copy of the GNU Library 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.
|
||||
*/
|
||||
|
||||
/**Documented API
|
||||
Inherits:
|
||||
Label
|
||||
|
||||
Imports:
|
||||
QtQuick 1.1
|
||||
org.kde.plasma.components
|
||||
|
||||
Description:
|
||||
This is a title label which uses the plasma theme.
|
||||
The characteristics of the text will be automatically set
|
||||
according to the plasma theme. Use this components for titles
|
||||
in your UI, for example page or section titles.
|
||||
|
||||
Properties:
|
||||
string text:
|
||||
The most important property is "text", which applies to the text property of Label
|
||||
For the other ones see Plasma Component's Label or QML primitive Text element
|
||||
|
||||
Methods:
|
||||
See Plasma Component's Label and primitive QML Text element
|
||||
|
||||
Signals:
|
||||
See Plasma Component's Label and primitive QML Text element
|
||||
**/
|
||||
|
||||
import QtQuick 1.1
|
||||
import org.kde.plasma.components 0.1
|
||||
|
||||
Label {
|
||||
id: root
|
||||
|
||||
font.pointSize: theme.defaultFont.pointSize*2
|
||||
}
|
5
declarativeimports/plasmaextracomponents/qml/qmldir
Normal file
5
declarativeimports/plasmaextracomponents/qml/qmldir
Normal file
@ -0,0 +1,5 @@
|
||||
plugin plasmaextracomponentsplugin
|
||||
|
||||
App 0.1 App.qml
|
||||
Title 0.1 Title.qml
|
||||
Heading 0.1 Heading.qml
|
171
declarativeimports/plasmaextracomponents/resourceinstance.cpp
Normal file
171
declarativeimports/plasmaextracomponents/resourceinstance.cpp
Normal file
@ -0,0 +1,171 @@
|
||||
/***************************************************************************
|
||||
* Copyright 2011 Marco Martin <mart@kde.org> *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Library 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 Library General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Library 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 "resourceinstance.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QGraphicsObject>
|
||||
#include <QGraphicsView>
|
||||
#include <QTimer>
|
||||
|
||||
#include <KDE/KActivities/ResourceInstance>
|
||||
#include <KDebug>
|
||||
|
||||
|
||||
ResourceInstance::ResourceInstance(QDeclarativeItem *parent)
|
||||
: QDeclarativeItem(parent)
|
||||
{
|
||||
m_syncTimer = new QTimer(this);
|
||||
m_syncTimer->setSingleShot(true);
|
||||
connect(m_syncTimer, SIGNAL(timeout()), this, SLOT(syncWid()));
|
||||
}
|
||||
|
||||
ResourceInstance::~ResourceInstance()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
QGraphicsView *ResourceInstance::view() const
|
||||
{
|
||||
// It's assumed that we won't be visible on more than one view here.
|
||||
// Anything that actually needs view() should only really care about
|
||||
// one of them anyway though.
|
||||
if (!scene()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
QGraphicsView *found = 0;
|
||||
QGraphicsView *possibleFind = 0;
|
||||
//kDebug() << "looking through" << scene()->views().count() << "views";
|
||||
foreach (QGraphicsView *view, scene()->views()) {
|
||||
//kDebug() << " checking" << view << view->sceneRect()
|
||||
// << "against" << sceneBoundingRect() << scenePos();
|
||||
if (view->sceneRect().intersects(sceneBoundingRect()) ||
|
||||
view->sceneRect().contains(scenePos())) {
|
||||
//kDebug() << " found something!" << view->isActiveWindow();
|
||||
if (view->isActiveWindow()) {
|
||||
found = view;
|
||||
} else {
|
||||
possibleFind = view;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return found ? found : possibleFind;
|
||||
}
|
||||
|
||||
void ResourceInstance::syncWid()
|
||||
{
|
||||
QGraphicsView *v = view();
|
||||
if (!v) {
|
||||
return;
|
||||
}
|
||||
|
||||
WId wid = v->topLevelWidget()->effectiveWinId();
|
||||
if (!m_resourceInstance || m_resourceInstance->winId() != wid) {
|
||||
delete m_resourceInstance;
|
||||
|
||||
kDebug() << "Creating a new instance of the resource" << m_uri << "window id" << wid;
|
||||
m_resourceInstance = new KActivities::ResourceInstance(wid, m_uri, m_mimetype, m_title);
|
||||
} else {
|
||||
|
||||
if (m_uri.scheme().startsWith("http") && !m_uri.hasQuery() && m_uri.path().endsWith('/')) {
|
||||
const QString & oldPath = m_uri.path();
|
||||
m_uri.setPath(oldPath.left(oldPath.length() - 1));
|
||||
|
||||
kDebug() << "Old and new path" << oldPath << m_uri;
|
||||
|
||||
} else {
|
||||
m_resourceInstance->setUri(m_uri);
|
||||
}
|
||||
|
||||
kDebug() << "Setting" << m_uri << m_mimetype << "to window" << wid;
|
||||
|
||||
m_resourceInstance->setMimetype(m_mimetype);
|
||||
m_resourceInstance->setTitle(m_title);
|
||||
}
|
||||
}
|
||||
|
||||
QUrl ResourceInstance::uri() const
|
||||
{
|
||||
return m_uri;
|
||||
}
|
||||
|
||||
void ResourceInstance::setUri(const QUrl &uri)
|
||||
{
|
||||
if (m_uri == uri) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_uri = uri;
|
||||
m_syncTimer->start(100);
|
||||
}
|
||||
|
||||
QString ResourceInstance::mimetype() const
|
||||
{
|
||||
return m_mimetype;
|
||||
}
|
||||
|
||||
void ResourceInstance::setMimetype(const QString &mimetype)
|
||||
{
|
||||
if (m_mimetype == mimetype) {
|
||||
return;
|
||||
}
|
||||
m_mimetype = mimetype;
|
||||
m_syncTimer->start(100);
|
||||
}
|
||||
|
||||
QString ResourceInstance::title() const
|
||||
{
|
||||
return m_title;
|
||||
}
|
||||
|
||||
void ResourceInstance::setTitle(const QString &title)
|
||||
{
|
||||
if (m_title == title) {
|
||||
return;
|
||||
}
|
||||
m_title = title;
|
||||
m_syncTimer->start(100);
|
||||
}
|
||||
|
||||
void ResourceInstance::notifyModified()
|
||||
{
|
||||
//ensure the resource instance exists
|
||||
syncWid();
|
||||
m_resourceInstance->notifyModified();
|
||||
}
|
||||
|
||||
void ResourceInstance::notifyFocusedIn()
|
||||
{
|
||||
//ensure the resource instance exists
|
||||
syncWid();
|
||||
m_resourceInstance->notifyFocusedIn();
|
||||
}
|
||||
|
||||
|
||||
void ResourceInstance::notifyFocusedOut()
|
||||
{
|
||||
//ensure the resource instance exists
|
||||
syncWid();
|
||||
m_resourceInstance->notifyFocusedOut();
|
||||
}
|
||||
|
||||
#include "resourceinstance.moc"
|
||||
|
94
declarativeimports/plasmaextracomponents/resourceinstance.h
Normal file
94
declarativeimports/plasmaextracomponents/resourceinstance.h
Normal file
@ -0,0 +1,94 @@
|
||||
/***************************************************************************
|
||||
* Copyright 2011 Marco Martin <mart@kde.org> *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Library 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 Library General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Library 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 RESOURCEINSTANCE_H
|
||||
#define RESOURCEINSTANCE_H
|
||||
|
||||
#include <QDeclarativeItem>
|
||||
#include <QUrl>
|
||||
|
||||
namespace KActivities {
|
||||
class ResourceInstance;
|
||||
}
|
||||
|
||||
class QTimer;
|
||||
class QGraphicsView;
|
||||
|
||||
class ResourceInstance : public QDeclarativeItem
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
Q_PROPERTY(QUrl uri READ uri WRITE setUri NOTIFY uriChanged)
|
||||
Q_PROPERTY(QString mimetype READ mimetype WRITE setMimetype NOTIFY mimetypeChanged)
|
||||
Q_PROPERTY(QString title READ title WRITE setTitle NOTIFY titleChanged)
|
||||
//Q_PROPERTY(OpenReason openReason READ openReason)
|
||||
|
||||
public:
|
||||
ResourceInstance(QDeclarativeItem *parent = 0);
|
||||
~ResourceInstance();
|
||||
|
||||
QUrl uri() const;
|
||||
void setUri(const QUrl &uri);
|
||||
|
||||
QString mimetype() const;
|
||||
void setMimetype(const QString &mimetype);
|
||||
|
||||
QString title() const;
|
||||
void setTitle(const QString &title);
|
||||
|
||||
protected:
|
||||
QGraphicsView *view() const;
|
||||
|
||||
protected Q_SLOTS:
|
||||
void syncWid();
|
||||
|
||||
Q_SIGNALS:
|
||||
void uriChanged();
|
||||
void mimetypeChanged();
|
||||
void titleChanged();
|
||||
|
||||
public Q_SLOTS:
|
||||
/**
|
||||
* Call this method to notify the system that you modified
|
||||
* (the contents of) the resource
|
||||
*/
|
||||
void notifyModified();
|
||||
|
||||
/**
|
||||
* Call this method to notify the system that the resource
|
||||
* has the focus in your application
|
||||
* @note You only need to call this in MDI applications
|
||||
*/
|
||||
void notifyFocusedIn();
|
||||
|
||||
/**
|
||||
* Call this method to notify the system that the resource
|
||||
* lost the focus in your application
|
||||
* @note You only need to call this in MDI applications
|
||||
*/
|
||||
void notifyFocusedOut();
|
||||
|
||||
private:
|
||||
KActivities::ResourceInstance *m_resourceInstance;
|
||||
QUrl m_uri;
|
||||
QString m_mimetype;
|
||||
QString m_title;
|
||||
QTimer *m_syncTimer;
|
||||
};
|
||||
|
||||
#endif
|
139
declarativeimports/plasmaextracomponents/tests/AppTest.qml
Normal file
139
declarativeimports/plasmaextracomponents/tests/AppTest.qml
Normal file
@ -0,0 +1,139 @@
|
||||
// -*- coding: iso-8859-1 -*-
|
||||
/*
|
||||
* Copyright 2011 Sebastian Kügler <mart@kde.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Library General Public License as
|
||||
* published by the Free Software Foundation; either version 2 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 Library General Public License for more details
|
||||
*
|
||||
* You should have received a copy of the GNU Library 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 1.1
|
||||
import org.kde.plasma.core 0.1 as PlasmaCore
|
||||
import org.kde.plasma.components 0.1 as PlasmaComponents
|
||||
import org.kde.plasma.extras 0.1 as PlasmaExtras
|
||||
|
||||
PlasmaExtras.App {
|
||||
id: app
|
||||
width: 800
|
||||
height: 600
|
||||
|
||||
property string formFactor: "tablet"
|
||||
|
||||
navigation: navigationItem
|
||||
content: contentItem
|
||||
|
||||
Item {
|
||||
id: navigationItem
|
||||
width: navigationWidth + space
|
||||
height: parent.height
|
||||
// PlasmaExtras.Title {
|
||||
// text: "Navigation is zoo"
|
||||
// elide: Text.ElideMiddle
|
||||
// anchors { top: parent.top; left: parent.left; right: parent.right; }
|
||||
// }
|
||||
Column {
|
||||
id: navigationColumn
|
||||
anchors.fill: navigationItem
|
||||
width: navigationWidth
|
||||
PlasmaExtras.Title {
|
||||
width: navigationColumn.width
|
||||
visible: widthCheck.checked
|
||||
text: "Navigation Pane."
|
||||
elide: Text.ElideRight
|
||||
//anchors { top: parent.top; left: parent.left; topMargin: 48; }
|
||||
}
|
||||
}
|
||||
PlasmaComponents.CheckBox {
|
||||
id: widthCheck
|
||||
text: checked ? "Make big" : " "
|
||||
//width: navigationWidth
|
||||
checked: navigationWidth > 200
|
||||
anchors { left: parent.left; leftMargin: space; bottomMargin: space; bottom: parent.bottom; }
|
||||
onCheckedChanged: {
|
||||
var w = !checked ? 48 : 340;
|
||||
//print(" new: " + w);
|
||||
navigationWidth = w;
|
||||
}
|
||||
//width: contentItem.width
|
||||
}
|
||||
//Rectangle { color: "blue"; opacity: 0.3; anchors.fill: parent; }
|
||||
}
|
||||
|
||||
Item {
|
||||
id: contentItem
|
||||
width: app.width - navigationWidth - space*2
|
||||
//anchors.rightMargin: space*2
|
||||
|
||||
Column {
|
||||
width: contentItem.width
|
||||
id: contentColumn
|
||||
anchors.fill: contentItem
|
||||
spacing: 8
|
||||
PlasmaExtras.Title {
|
||||
text: "Content Section"
|
||||
elide: Text.ElideMiddle
|
||||
//anchors { top: parent.top; left: parent.left; topMargin: 48; }
|
||||
}
|
||||
PlasmaExtras.Heading {
|
||||
text: "Heading " + level
|
||||
level: 1
|
||||
}
|
||||
PlasmaComponents.Label {
|
||||
width: contentColumn.width
|
||||
wrapMode: Text.WordWrap
|
||||
text: "Lorem Ipsum is slechts een proeftekst uit het drukkerij- en zetterijwezen. Lorem Ipsum is de standaard proeftekst in deze bedrijfstak sinds de 16e eeuw, toen een onbekende drukker een zethaak met letters nam en ze door elkaar husselde om een font-catalogus te maken. Het heeft niet alleen vijf eeuwen overleefd maar is ook, vrijwel onveranderd, overgenomen in elektronische letterzetting. Het is in de jaren '60 populair geworden met de introductie van Letraset vellen met Lorem Ipsum passages en meer recentelijk door desktop publishing software zoals Aldus PageMaker die versies van Lorem Ipsum bevatten."
|
||||
}
|
||||
PlasmaExtras.Heading {
|
||||
text: "Heading " + level
|
||||
level: 2
|
||||
}
|
||||
PlasmaExtras.Heading {
|
||||
text: "Heading " + level
|
||||
level: 3
|
||||
}
|
||||
PlasmaComponents.Label {
|
||||
wrapMode: Text.WordWrap
|
||||
width: contentColumn.width
|
||||
text: "Lorem Ipsum is slechts een proeftekst uit het drukkerij- en zetterijwezen. Lorem Ipsum is de standaard proeftekst in deze bedrijfstak sinds de 16e eeuw, toen een onbekende drukker een zethaak met letters nam en ze door elkaar husselde om een font-catalogus te maken. Het heeft niet alleen vijf eeuwen overleefd maar is ook, vrijwel onveranderd, overgenomen in elektronische letterzetting. Het is in de jaren '60 populair geworden met de introductie van Letraset vellen met Lorem Ipsum passages en meer recentelijk door desktop publishing software zoals Aldus PageMaker die versies van Lorem Ipsum bevatten."
|
||||
}
|
||||
PlasmaExtras.Heading {
|
||||
text: "Heading " + level
|
||||
level: 4
|
||||
}
|
||||
PlasmaExtras.Heading {
|
||||
text: "Heading " + level
|
||||
level: 5
|
||||
}
|
||||
PlasmaComponents.Label {
|
||||
wrapMode: Text.WordWrap
|
||||
width: contentColumn.width
|
||||
text: "Lorem Ipsum is slechts een proeftekst uit het drukkerij- en zetterijwezen. Lorem Ipsum is de standaard proeftekst in deze bedrijfstak sinds de 16e eeuw, toen een onbekende drukker een zethaak met letters nam en ze door elkaar husselde om een font-catalogus te maken. Het heeft niet alleen vijf eeuwen overleefd maar is ook, vrijwel onveranderd, overgenomen in elektronische letterzetting. Het is in de jaren '60 populair geworden met de introductie van Letraset vellen met Lorem Ipsum passages en meer recentelijk door desktop publishing software zoals Aldus PageMaker die versies van Lorem Ipsum bevatten."
|
||||
}
|
||||
}
|
||||
Rectangle { color: "green"; opacity: 0.8; anchors.fill: contentItem; }
|
||||
}
|
||||
|
||||
onWidthChanged: {
|
||||
//return;
|
||||
if (width < 340 + 200) {
|
||||
//print("window changed: small " + width);
|
||||
navigationWidth = 48;
|
||||
} else {
|
||||
//print("window changed: tablet " + width);
|
||||
navigationWidth = 340;
|
||||
}
|
||||
widthCheck.checked = navigationWidth > 200;
|
||||
}
|
||||
|
||||
}
|
@ -31,7 +31,6 @@ PlasmaComponents.Page {
|
||||
}
|
||||
PlasmaComponents.Slider {
|
||||
width: 140
|
||||
animated: true
|
||||
enabled: true
|
||||
}
|
||||
PlasmaComponents.TextField {
|
||||
@ -80,7 +79,6 @@ PlasmaComponents.Page {
|
||||
minimumValue: 0
|
||||
maximumValue: 255
|
||||
stepSize: 10
|
||||
animated: true
|
||||
Keys.onTabPressed: blueSlider.forceActiveFocus()
|
||||
}
|
||||
|
||||
@ -112,7 +110,6 @@ PlasmaComponents.Page {
|
||||
id: horizontalSlider
|
||||
width: 140
|
||||
height: 20
|
||||
animated: true
|
||||
enabled: false
|
||||
}
|
||||
|
||||
@ -123,7 +120,6 @@ PlasmaComponents.Page {
|
||||
width: 140
|
||||
height: 20
|
||||
inverted: true
|
||||
animated: true
|
||||
enabled: true
|
||||
}
|
||||
|
||||
@ -140,7 +136,6 @@ PlasmaComponents.Page {
|
||||
maximumValue: 1000
|
||||
stepSize: 50
|
||||
inverted: true
|
||||
animated: true
|
||||
}
|
||||
PlasmaComponents.Label { text: verticalSlider.value }
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user