plasma-framework/declarativeimports/plasmacomponents/fullscreensheet.cpp

144 lines
4.2 KiB
C++
Raw Normal View History

/***************************************************************************
* Copyright 2012 Marco Martin <mart@kde.org> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU 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 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 "fullscreensheet.h"
#include <QApplication>
#include <QDesktopWidget>
#include <QGraphicsView>
2012-02-28 14:49:20 +01:00
#include <KDebug>
FullScreenSheet::FullScreenSheet(QDeclarativeItem *parent)
2012-02-28 14:49:20 +01:00
: FullScreenWindow(parent)
{
2012-02-28 14:49:20 +01:00
init("Sheet");
2012-02-28 15:23:47 +01:00
view()->setGeometry(QApplication::desktop()->availableGeometry());
2012-02-28 14:49:20 +01:00
if (mainItem()) {
2012-03-01 15:03:45 +01:00
connect(mainItem(), SIGNAL(titleChanged()),
this, SIGNAL(titleChanged()));
2012-02-28 14:49:20 +01:00
connect(mainItem(), SIGNAL(acceptButtonChanged()),
this, SIGNAL(acceptButtonChanged()));
connect(mainItem(), SIGNAL(rejectButtonChanged()),
this, SIGNAL(rejectButtonChanged()));
connect(mainItem(), SIGNAL(acceptButtonTextChanged()),
this, SIGNAL(acceptButtonTextChanged()));
connect(mainItem(), SIGNAL(rejectButtonTextChanged()),
this, SIGNAL(rejectButtonTextChanged()));
}
}
FullScreenSheet::~FullScreenSheet()
{
}
2012-03-01 15:03:45 +01:00
QString FullScreenSheet::title() const
2012-02-28 14:49:20 +01:00
{
if (mainItem()) {
2012-03-01 15:03:45 +01:00
return mainItem()->property("title").toString();
2012-02-28 14:49:20 +01:00
} else {
return 0;
}
}
2012-03-01 15:03:45 +01:00
void FullScreenSheet::setTitle(const QString &text)
{
if (mainItem()) {
mainItem()->setProperty("title", QVariant::fromValue(text));
}
}
QDeclarativeItem *FullScreenSheet::acceptButton() const
{
if (mainItem()) {
return mainItem()->property("acceptButton").value<QDeclarativeItem *>();
} else {
return 0;
}
}
void FullScreenSheet::setAcceptButton(QDeclarativeItem *button)
2012-02-28 14:49:20 +01:00
{
if (mainItem()) {
mainItem()->setProperty("acceptButton", QVariant::fromValue(button));
}
}
2012-03-01 15:03:45 +01:00
QDeclarativeItem *FullScreenSheet::rejectButton() const
2012-02-28 14:49:20 +01:00
{
if (mainItem()) {
2012-03-01 15:03:45 +01:00
return mainItem()->property("rejectButton").value<QDeclarativeItem *>();
2012-02-28 14:49:20 +01:00
} else {
return 0;
}
}
2012-03-01 15:03:45 +01:00
void FullScreenSheet::setRejectButton(QDeclarativeItem *button)
2012-02-28 14:49:20 +01:00
{
if (mainItem()) {
mainItem()->setProperty("rejectButton", QVariant::fromValue(button));
}
}
QString FullScreenSheet::acceptButtonText() const
{
if (mainItem()) {
return mainItem()->property("acceptButtonText").toString();
} else {
return 0;
}
}
void FullScreenSheet::setAcceptButtonText(const QString &text)
{
if (mainItem()) {
mainItem()->setProperty("acceptButtonText", QVariant::fromValue(text));
}
}
QString FullScreenSheet::rejectButtonText() const
{
if (mainItem()) {
return mainItem()->property("rejectButtonText").toString();
} else {
return 0;
}
}
void FullScreenSheet::setRejectButtonText(const QString &text)
{
2012-02-28 14:49:20 +01:00
if (mainItem()) {
mainItem()->setProperty("rejectButtonText", QVariant::fromValue(text));
}
}
2012-03-01 15:03:45 +01:00
void FullScreenSheet::open()
{
if (mainItem()) {
view()->setGeometry(QApplication::desktop()->availableGeometry());
QMetaObject::invokeMethod(mainItem(), "open");
}
}
#include "fullscreensheet.moc"