remove the kdialog based querydialog
Dialogs are always plasma-themed, and if possible are inline. only if there is not enough space (like in a panel) they get moved in a separate window this removes quite some c++ usage and hopefully solves some layouting problems in dialogs
This commit is contained in:
parent
59e13182cb
commit
57e77a8591
@ -89,8 +89,8 @@ int DialogMargins::bottom() const
|
|||||||
return m_bottom;
|
return m_bottom;
|
||||||
}
|
}
|
||||||
|
|
||||||
DialogProxy::DialogProxy(QObject *parent)
|
DialogProxy::DialogProxy(QDeclarativeItem *parent)
|
||||||
: QObject(parent),
|
: QDeclarativeItem(parent),
|
||||||
m_declarativeItemContainer(0),
|
m_declarativeItemContainer(0),
|
||||||
m_activeWindow(false),
|
m_activeWindow(false),
|
||||||
m_location(Plasma::Floating)
|
m_location(Plasma::Floating)
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
#ifndef DIALOG_PROXY_P
|
#ifndef DIALOG_PROXY_P
|
||||||
#define DIALOG_PROXY_P
|
#define DIALOG_PROXY_P
|
||||||
|
|
||||||
#include <QObject>
|
#include <QDeclarativeItem>
|
||||||
#include <QWeakPointer>
|
#include <QWeakPointer>
|
||||||
#include <QPoint>
|
#include <QPoint>
|
||||||
|
|
||||||
@ -84,7 +84,7 @@ private:
|
|||||||
friend class DialogProxy;
|
friend class DialogProxy;
|
||||||
};
|
};
|
||||||
|
|
||||||
class DialogProxy : public QObject
|
class DialogProxy : public QDeclarativeItem
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
@ -152,7 +152,7 @@ public:
|
|||||||
WA_X11NetWmWindowTypeDock = Qt::WA_X11NetWmWindowTypeDock
|
WA_X11NetWmWindowTypeDock = Qt::WA_X11NetWmWindowTypeDock
|
||||||
};
|
};
|
||||||
|
|
||||||
DialogProxy(QObject *parent = 0);
|
DialogProxy(QDeclarativeItem *parent = 0);
|
||||||
~DialogProxy();
|
~DialogProxy();
|
||||||
|
|
||||||
QGraphicsObject *mainItem() const;
|
QGraphicsObject *mainItem() const;
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
project(plasmacomponents)
|
project(plasmacomponents)
|
||||||
|
|
||||||
set(plasmacomponents_SRCS
|
set(plasmacomponents_SRCS
|
||||||
fullscreendialog.cpp
|
|
||||||
fullscreensheet.cpp
|
fullscreensheet.cpp
|
||||||
fullscreenwindow.cpp
|
fullscreenwindow.cpp
|
||||||
plasmacomponentsplugin.cpp
|
plasmacomponentsplugin.cpp
|
||||||
@ -9,7 +8,6 @@ set(plasmacomponents_SRCS
|
|||||||
enums.cpp
|
enums.cpp
|
||||||
qmenu.cpp
|
qmenu.cpp
|
||||||
qmenuitem.cpp
|
qmenuitem.cpp
|
||||||
kdialogproxy.cpp
|
|
||||||
../core/declarativeitemcontainer.cpp
|
../core/declarativeitemcontainer.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -43,12 +41,14 @@ install(FILES qml/Button.qml DESTINATION ${PLUGIN_INSTALL_DIR}/platformimports/t
|
|||||||
install(FILES qml/ButtonRow.qml DESTINATION ${PLUGIN_INSTALL_DIR}/platformimports/touch/org/kde/plasma/components)
|
install(FILES qml/ButtonRow.qml DESTINATION ${PLUGIN_INSTALL_DIR}/platformimports/touch/org/kde/plasma/components)
|
||||||
install(FILES qml/CheckBox.qml DESTINATION ${PLUGIN_INSTALL_DIR}/platformimports/touch/org/kde/plasma/components)
|
install(FILES qml/CheckBox.qml DESTINATION ${PLUGIN_INSTALL_DIR}/platformimports/touch/org/kde/plasma/components)
|
||||||
install(FILES qml/CommonDialog.qml DESTINATION ${PLUGIN_INSTALL_DIR}/platformimports/touch/org/kde/plasma/components)
|
install(FILES qml/CommonDialog.qml DESTINATION ${PLUGIN_INSTALL_DIR}/platformimports/touch/org/kde/plasma/components)
|
||||||
|
install(FILES qml/Dialog.qml DESTINATION ${PLUGIN_INSTALL_DIR}/platformimports/touch/org/kde/plasma/components)
|
||||||
install(FILES qml/Highlight.qml DESTINATION ${PLUGIN_INSTALL_DIR}/platformimports/touch/org/kde/plasma/components)
|
install(FILES qml/Highlight.qml DESTINATION ${PLUGIN_INSTALL_DIR}/platformimports/touch/org/kde/plasma/components)
|
||||||
install(FILES qml/Label.qml DESTINATION ${PLUGIN_INSTALL_DIR}/platformimports/touch/org/kde/plasma/components)
|
install(FILES qml/Label.qml DESTINATION ${PLUGIN_INSTALL_DIR}/platformimports/touch/org/kde/plasma/components)
|
||||||
install(FILES qml/ListItem.qml DESTINATION ${PLUGIN_INSTALL_DIR}/platformimports/touch/org/kde/plasma/components)
|
install(FILES qml/ListItem.qml DESTINATION ${PLUGIN_INSTALL_DIR}/platformimports/touch/org/kde/plasma/components)
|
||||||
install(FILES qml/Page.qml DESTINATION ${PLUGIN_INSTALL_DIR}/platformimports/touch/org/kde/plasma/components)
|
install(FILES qml/Page.qml DESTINATION ${PLUGIN_INSTALL_DIR}/platformimports/touch/org/kde/plasma/components)
|
||||||
install(FILES qml/PageStack.qml DESTINATION ${PLUGIN_INSTALL_DIR}/platformimports/touch/org/kde/plasma/components)
|
install(FILES qml/PageStack.qml DESTINATION ${PLUGIN_INSTALL_DIR}/platformimports/touch/org/kde/plasma/components)
|
||||||
install(FILES qml/ProgressBar.qml DESTINATION ${PLUGIN_INSTALL_DIR}/platformimports/touch/org/kde/plasma/components)
|
install(FILES qml/ProgressBar.qml DESTINATION ${PLUGIN_INSTALL_DIR}/platformimports/touch/org/kde/plasma/components)
|
||||||
|
install(FILES qml/QueryDialog.qml DESTINATION ${PLUGIN_INSTALL_DIR}/platformimports/touch/org/kde/plasma/components)
|
||||||
install(FILES qml/RadioButton.qml DESTINATION ${PLUGIN_INSTALL_DIR}/platformimports/touch/org/kde/plasma/components)
|
install(FILES qml/RadioButton.qml DESTINATION ${PLUGIN_INSTALL_DIR}/platformimports/touch/org/kde/plasma/components)
|
||||||
install(FILES qml/SelectionDialog.qml DESTINATION ${PLUGIN_INSTALL_DIR}/platformimports/touch/org/kde/plasma/components)
|
install(FILES qml/SelectionDialog.qml DESTINATION ${PLUGIN_INSTALL_DIR}/platformimports/touch/org/kde/plasma/components)
|
||||||
install(FILES qml/Slider.qml DESTINATION ${PLUGIN_INSTALL_DIR}/platformimports/touch/org/kde/plasma/components)
|
install(FILES qml/Slider.qml DESTINATION ${PLUGIN_INSTALL_DIR}/platformimports/touch/org/kde/plasma/components)
|
||||||
@ -65,6 +65,7 @@ install(FILES qml/ToolButton.qml DESTINATION ${PLUGIN_INSTALL_DIR}/platformimpor
|
|||||||
|
|
||||||
#Now install the private stuff!
|
#Now install the private stuff!
|
||||||
install(FILES qml/private/DualStateButton.qml DESTINATION ${PLUGIN_INSTALL_DIR}/platformimports/touch/org/kde/plasma/components/private)
|
install(FILES qml/private/DualStateButton.qml DESTINATION ${PLUGIN_INSTALL_DIR}/platformimports/touch/org/kde/plasma/components/private)
|
||||||
|
install(FILES qml/private/InlineDialog.qml DESTINATION ${PLUGIN_INSTALL_DIR}/platformimports/touch/org/kde/plasma/components/private)
|
||||||
install(FILES qml/private/PageStack.js DESTINATION ${PLUGIN_INSTALL_DIR}/platformimports/touch/org/kde/plasma/components/private)
|
install(FILES qml/private/PageStack.js DESTINATION ${PLUGIN_INSTALL_DIR}/platformimports/touch/org/kde/plasma/components/private)
|
||||||
install(FILES qml/private/TabGroup.js DESTINATION ${PLUGIN_INSTALL_DIR}/platformimports/touch/org/kde/plasma/components/private)
|
install(FILES qml/private/TabGroup.js DESTINATION ${PLUGIN_INSTALL_DIR}/platformimports/touch/org/kde/plasma/components/private)
|
||||||
install(FILES qml/private/ScrollBarDelegate.qml DESTINATION ${PLUGIN_INSTALL_DIR}/platformimports/touch/org/kde/plasma/components/private)
|
install(FILES qml/private/ScrollBarDelegate.qml DESTINATION ${PLUGIN_INSTALL_DIR}/platformimports/touch/org/kde/plasma/components/private)
|
||||||
|
@ -1,35 +0,0 @@
|
|||||||
/***************************************************************************
|
|
||||||
* 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 "fullscreendialog.h"
|
|
||||||
|
|
||||||
|
|
||||||
FullScreenDialog::FullScreenDialog(QDeclarativeItem *parent)
|
|
||||||
: FullScreenWindow(parent)
|
|
||||||
{
|
|
||||||
init("Dialog");
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
FullScreenDialog::~FullScreenDialog()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
#include "fullscreendialog.moc"
|
|
||||||
|
|
@ -1,33 +0,0 @@
|
|||||||
/***************************************************************************
|
|
||||||
* 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 . *
|
|
||||||
***************************************************************************/
|
|
||||||
#ifndef FULLSCREENDIALOG_P
|
|
||||||
#define FULLSCREENDIALOG_P
|
|
||||||
|
|
||||||
#include "fullscreenwindow.h"
|
|
||||||
|
|
||||||
class FullScreenDialog : public FullScreenWindow
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
FullScreenDialog(QDeclarativeItem *parent = 0);
|
|
||||||
~FullScreenDialog();
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,151 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2011 by 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, 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 "kdialogproxy.h"
|
|
||||||
|
|
||||||
#include <QLabel>
|
|
||||||
|
|
||||||
#include <KIcon>
|
|
||||||
|
|
||||||
KDialogProxy::KDialogProxy (QObject *parent)
|
|
||||||
: QObject(parent),
|
|
||||||
m_status(DialogStatus::Closed)
|
|
||||||
{
|
|
||||||
m_dialog = new KDialog(0);
|
|
||||||
m_label = new QLabel(m_dialog);
|
|
||||||
m_label->setWordWrap(true);
|
|
||||||
m_dialog->setMainWidget(m_label);
|
|
||||||
m_dialog->setButtons( KDialog::Ok | KDialog::Cancel);
|
|
||||||
connect(m_dialog, SIGNAL(okClicked()), this, SIGNAL(accepted()));
|
|
||||||
connect(m_dialog, SIGNAL(cancelClicked()), this, SIGNAL(rejected()));
|
|
||||||
connect(m_dialog, SIGNAL(closeClicked()), this, SIGNAL(rejected()));
|
|
||||||
}
|
|
||||||
|
|
||||||
KDialogProxy::~KDialogProxy()
|
|
||||||
{
|
|
||||||
delete m_dialog;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void KDialogProxy::setTitleText(const QString &text)
|
|
||||||
{
|
|
||||||
if (text == m_titleText) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_dialog->setCaption(text);
|
|
||||||
m_titleText = text;
|
|
||||||
emit titleTextChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
QString KDialogProxy::titleText() const
|
|
||||||
{
|
|
||||||
return m_titleText;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void KDialogProxy::setTitleIcon(const QString &icon)
|
|
||||||
{
|
|
||||||
if (icon == m_titleIcon) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_dialog->setWindowIcon(KIcon(icon));
|
|
||||||
m_titleIcon = icon;
|
|
||||||
emit titleIconChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
QString KDialogProxy::titleIcon() const
|
|
||||||
{
|
|
||||||
return m_titleIcon;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void KDialogProxy::setMessage(const QString &message)
|
|
||||||
{
|
|
||||||
if (message == m_message) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_label->setText(message);
|
|
||||||
m_message = message;
|
|
||||||
emit messageChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
QString KDialogProxy::message() const
|
|
||||||
{
|
|
||||||
return m_message;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void KDialogProxy::setAcceptButtonText(const QString &text)
|
|
||||||
{
|
|
||||||
if (text == m_acceptButtonText) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_dialog->setButtonText(KDialog::Ok, text);
|
|
||||||
m_acceptButtonText = text;
|
|
||||||
emit acceptButtonTextChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
QString KDialogProxy::acceptButtonText() const
|
|
||||||
{
|
|
||||||
return m_acceptButtonText;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void KDialogProxy::setRejectButtonText(const QString &text)
|
|
||||||
{
|
|
||||||
if (text == m_rejectButtonText) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_dialog->setButtonText(KDialog::Cancel, text);
|
|
||||||
m_rejectButtonText = text;
|
|
||||||
emit rejectButtonTextChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
QString KDialogProxy::rejectButtonText() const
|
|
||||||
{
|
|
||||||
return m_rejectButtonText;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
DialogStatus::Status KDialogProxy::status() const
|
|
||||||
{
|
|
||||||
return m_status;
|
|
||||||
}
|
|
||||||
|
|
||||||
void KDialogProxy::open()
|
|
||||||
{
|
|
||||||
m_dialog->show();
|
|
||||||
m_status = DialogStatus::Open;
|
|
||||||
emit statusChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
void KDialogProxy::close()
|
|
||||||
{
|
|
||||||
m_dialog->hide();
|
|
||||||
m_status = DialogStatus::Closed;
|
|
||||||
emit statusChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
#include "kdialogproxy.moc"
|
|
||||||
|
|
@ -1,88 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2011 by 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, 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 KDIALOG_PROXY_H
|
|
||||||
#define KDIALOG_PROXY_H
|
|
||||||
|
|
||||||
#include <QObject>
|
|
||||||
#include <KDialog>
|
|
||||||
#include "kdialogproxy.h"
|
|
||||||
#include "enums.h"
|
|
||||||
|
|
||||||
class QLabel;
|
|
||||||
|
|
||||||
class KDialogProxy : public QObject
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
Q_PROPERTY(QString titleText READ titleText WRITE setTitleText NOTIFY titleTextChanged)
|
|
||||||
Q_PROPERTY(QString titleIcon READ titleIcon WRITE setTitleIcon NOTIFY titleIconChanged)
|
|
||||||
Q_PROPERTY(QString message READ message WRITE setMessage NOTIFY messageChanged)
|
|
||||||
Q_PROPERTY(QString acceptButtonText READ acceptButtonText WRITE setAcceptButtonText NOTIFY acceptButtonTextChanged)
|
|
||||||
Q_PROPERTY(QString rejectButtonText READ rejectButtonText WRITE setRejectButtonText NOTIFY rejectButtonTextChanged)
|
|
||||||
Q_PROPERTY(DialogStatus::Status status READ status NOTIFY statusChanged)
|
|
||||||
|
|
||||||
public:
|
|
||||||
KDialogProxy(QObject *parent = 0);
|
|
||||||
~KDialogProxy();
|
|
||||||
|
|
||||||
void setTitleText(const QString &text);
|
|
||||||
QString titleText() const;
|
|
||||||
|
|
||||||
void setTitleIcon(const QString &icon);
|
|
||||||
QString titleIcon() const;
|
|
||||||
|
|
||||||
void setMessage(const QString &message);
|
|
||||||
QString message() const;
|
|
||||||
|
|
||||||
void setAcceptButtonText(const QString &text);
|
|
||||||
QString acceptButtonText() const;
|
|
||||||
|
|
||||||
void setRejectButtonText(const QString &text);
|
|
||||||
QString rejectButtonText() const;
|
|
||||||
|
|
||||||
void setStatus(DialogStatus::Status status);
|
|
||||||
DialogStatus::Status status() const;
|
|
||||||
|
|
||||||
Q_INVOKABLE void open();
|
|
||||||
Q_INVOKABLE void close();
|
|
||||||
|
|
||||||
Q_SIGNALS:
|
|
||||||
void titleTextChanged();
|
|
||||||
void titleIconChanged();
|
|
||||||
void messageChanged();
|
|
||||||
void acceptButtonTextChanged();
|
|
||||||
void rejectButtonTextChanged();
|
|
||||||
void statusChanged();
|
|
||||||
void accepted();
|
|
||||||
void rejected();
|
|
||||||
|
|
||||||
private:
|
|
||||||
KDialog *m_dialog;
|
|
||||||
QLabel *m_label;
|
|
||||||
QString m_titleText;
|
|
||||||
QString m_titleIcon;
|
|
||||||
QString m_message;
|
|
||||||
QString m_acceptButtonText;
|
|
||||||
QString m_rejectButtonText;
|
|
||||||
DialogStatus::Status m_status;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif //KDIALOG_PROXY_H
|
|
||||||
|
|
@ -28,14 +28,13 @@
|
|||||||
|
|
||||||
#include <KSharedConfig>
|
#include <KSharedConfig>
|
||||||
#include <KDebug>
|
#include <KDebug>
|
||||||
|
#include <KGlobal>
|
||||||
|
|
||||||
#include <kdeclarative.h>
|
#include <kdeclarative.h>
|
||||||
|
|
||||||
#include "enums.h"
|
#include "enums.h"
|
||||||
#include "qmenu.h"
|
#include "qmenu.h"
|
||||||
#include "qmenuitem.h"
|
#include "qmenuitem.h"
|
||||||
#include "kdialogproxy.h"
|
|
||||||
#include "fullscreendialog.h"
|
|
||||||
#include "fullscreensheet.h"
|
#include "fullscreensheet.h"
|
||||||
|
|
||||||
Q_EXPORT_PLUGIN2(plasmacomponentsplugin, PlasmaComponentsPlugin)
|
Q_EXPORT_PLUGIN2(plasmacomponentsplugin, PlasmaComponentsPlugin)
|
||||||
@ -94,12 +93,9 @@ void PlasmaComponentsPlugin::registerTypes(const char *uri)
|
|||||||
//platform specific c++ components
|
//platform specific c++ components
|
||||||
const QString target = KDeclarative::componentsTarget();
|
const QString target = KDeclarative::componentsTarget();
|
||||||
if (target == KDeclarative::defaultComponentsTarget()) {
|
if (target == KDeclarative::defaultComponentsTarget()) {
|
||||||
qmlRegisterType<KDialogProxy>(uri, 0, 1, "QueryDialog");
|
|
||||||
qmlRegisterType<QMenuProxy>(uri, 0, 1, "Menu");
|
qmlRegisterType<QMenuProxy>(uri, 0, 1, "Menu");
|
||||||
qmlRegisterType<QMenuItem>(uri, 0, 1, "MenuItem");
|
qmlRegisterType<QMenuItem>(uri, 0, 1, "MenuItem");
|
||||||
} else {
|
} else {
|
||||||
//on touch systems the dialog is fullscreen, c++ needed to do that
|
|
||||||
qmlRegisterType<FullScreenDialog>(uri, 0, 1, "Dialog");
|
|
||||||
qmlRegisterType<FullScreenSheet>(uri, 0, 1, "Sheet");
|
qmlRegisterType<FullScreenSheet>(uri, 0, 1, "Sheet");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,200 +0,0 @@
|
|||||||
/****************************************************************************
|
|
||||||
**
|
|
||||||
** Copyright (C) 2011 Marco Martin <mart@kde.org>
|
|
||||||
**
|
|
||||||
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
|
||||||
** All rights reserved.
|
|
||||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
|
||||||
**
|
|
||||||
** This file is part of the Qt Components project.
|
|
||||||
**
|
|
||||||
** $QT_BEGIN_LICENSE:BSD$
|
|
||||||
** You may use this file under the terms of the BSD license as follows:
|
|
||||||
**
|
|
||||||
** "Redistribution and use in source and binary forms, with or without
|
|
||||||
** modification, are permitted provided that the following conditions are
|
|
||||||
** met:
|
|
||||||
** * Redistributions of source code must retain the above copyright
|
|
||||||
** notice, this list of conditions and the following disclaimer.
|
|
||||||
** * Redistributions in binary form must reproduce the above copyright
|
|
||||||
** notice, this list of conditions and the following disclaimer in
|
|
||||||
** the documentation and/or other materials provided with the
|
|
||||||
** distribution.
|
|
||||||
** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
|
|
||||||
** the names of its contributors may be used to endorse or promote
|
|
||||||
** products derived from this software without specific prior written
|
|
||||||
** permission.
|
|
||||||
**
|
|
||||||
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
|
|
||||||
** $QT_END_LICENSE$
|
|
||||||
**
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
import QtQuick 1.0
|
|
||||||
import org.kde.plasma.core 0.1 as PlasmaCore
|
|
||||||
import "private/AppManager.js" as Utils
|
|
||||||
import "." 0.1
|
|
||||||
|
|
||||||
Item {
|
|
||||||
id: root
|
|
||||||
|
|
||||||
width: 300
|
|
||||||
height: 200
|
|
||||||
|
|
||||||
property alias title: titleBar.children
|
|
||||||
property alias content: contentItem.children
|
|
||||||
property alias buttons: buttonItem.children
|
|
||||||
// property alias visualParent: dialog.visualParent
|
|
||||||
property int status: DialogStatus.Closed
|
|
||||||
|
|
||||||
|
|
||||||
property alias privateTitleHeight: titleBar.height
|
|
||||||
property alias privateButtonsHeight: buttonItem.height
|
|
||||||
|
|
||||||
signal accepted
|
|
||||||
signal rejected
|
|
||||||
signal clickedOutside
|
|
||||||
|
|
||||||
function open()
|
|
||||||
{
|
|
||||||
status = DialogStatus.Opening
|
|
||||||
delayOpenTimer.restart()
|
|
||||||
}
|
|
||||||
|
|
||||||
function accept()
|
|
||||||
{
|
|
||||||
if (status == DialogStatus.Open) {
|
|
||||||
status = DialogStatus.Closing
|
|
||||||
accepted()
|
|
||||||
dialog.state = "closed"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function reject()
|
|
||||||
{
|
|
||||||
if (status == DialogStatus.Open) {
|
|
||||||
status = DialogStatus.Closing
|
|
||||||
dialog.state = "closed"
|
|
||||||
rejected()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function close()
|
|
||||||
{
|
|
||||||
dialog.state = "closed"
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
MouseArea {
|
|
||||||
anchors.fill: parent
|
|
||||||
onClicked: {
|
|
||||||
clickedOutside()
|
|
||||||
close()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Timer {
|
|
||||||
id: delayOpenTimer
|
|
||||||
running: false
|
|
||||||
interval: 100
|
|
||||||
onTriggered: dialog.state = ""
|
|
||||||
}
|
|
||||||
|
|
||||||
PlasmaCore.FrameSvgItem {
|
|
||||||
id: dialog
|
|
||||||
anchors.fill: parent
|
|
||||||
imagePath: "dialogs/background"
|
|
||||||
|
|
||||||
state: "closed"
|
|
||||||
|
|
||||||
//state: "Hidden"
|
|
||||||
|
|
||||||
Item {
|
|
||||||
id: mainItem
|
|
||||||
anchors {
|
|
||||||
fill: parent
|
|
||||||
leftMargin: dialog.margins.left
|
|
||||||
topMargin: dialog.margins.top
|
|
||||||
rightMargin: dialog.margins.right
|
|
||||||
bottomMargin: dialog.margins.bottom
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Consume all key events that are not processed by children
|
|
||||||
Keys.onPressed: event.accepted = true
|
|
||||||
Keys.onReleased: event.accepted = true
|
|
||||||
|
|
||||||
Item {
|
|
||||||
id: titleBar
|
|
||||||
height: Math.max(theme.defaultFont.mSize.height * 1.5, childrenRect.height)
|
|
||||||
anchors {
|
|
||||||
top: parent.top
|
|
||||||
left: parent.left
|
|
||||||
right: parent.right
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Item {
|
|
||||||
id: contentItem
|
|
||||||
|
|
||||||
clip: true
|
|
||||||
|
|
||||||
function adjustSize() {
|
|
||||||
root.width = Math.max(childrenRect.width, buttonItem.childrenRect.width) + dialog.margins.left + dialog.margins.right
|
|
||||||
|
|
||||||
root.height = Math.max(children[0].implicitHeight, childrenRect.height) + titleBar.height + buttonItem.height + dialog.margins.top + dialog.margins.bottom
|
|
||||||
}
|
|
||||||
onChildrenRectChanged: adjustSize()
|
|
||||||
Component.onCompleted: adjustSize()
|
|
||||||
|
|
||||||
anchors {
|
|
||||||
top: titleBar.bottom
|
|
||||||
left: parent.left
|
|
||||||
right: parent.right
|
|
||||||
bottom: buttonItem.top
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Item {
|
|
||||||
id: buttonItem
|
|
||||||
|
|
||||||
height: childrenRect.height
|
|
||||||
onChildrenRectChanged: contentItem.adjustSize()
|
|
||||||
Component.onCompleted: contentItem.adjustSize()
|
|
||||||
anchors {
|
|
||||||
left: parent.left
|
|
||||||
right: parent.right
|
|
||||||
bottom: parent.bottom
|
|
||||||
bottomMargin: 8
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
states: [
|
|
||||||
State {
|
|
||||||
name: "closed"
|
|
||||||
PropertyChanges {
|
|
||||||
target: root
|
|
||||||
status: DialogStatus.Closed
|
|
||||||
}
|
|
||||||
},
|
|
||||||
State {
|
|
||||||
name: ""
|
|
||||||
PropertyChanges {
|
|
||||||
target: root
|
|
||||||
status: DialogStatus.Open
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -71,7 +71,7 @@ Properties:
|
|||||||
A list of items in the dialog's title area. You can use a Text component but also any number of components that are based on Item. For example, you can use Text and Image components.
|
A list of items in the dialog's title area. You can use a Text component but also any number of components that are based on Item. For example, you can use Text and Image components.
|
||||||
|
|
||||||
Item visualParent:
|
Item visualParent:
|
||||||
The item that is dimmed when the dialog opens. By default the root parent object is visualParent.
|
The item that the dialog refers to. The dialog will usually be positioned relative to VisualParent
|
||||||
|
|
||||||
Signals:
|
Signals:
|
||||||
accepted():
|
accepted():
|
||||||
@ -87,7 +87,7 @@ Signals:
|
|||||||
|
|
||||||
Methods:
|
Methods:
|
||||||
void accept():
|
void accept():
|
||||||
Accepts the dialog's request without any user interaction. The method emits the accepted() signal and closes the dialog.
|
Accepts the dialog's request without any user interaction. The method emits the accepted() signal and closes the internalLoader.dialog.
|
||||||
See also reject().
|
See also reject().
|
||||||
|
|
||||||
void close():
|
void close():
|
||||||
@ -97,7 +97,7 @@ Methods:
|
|||||||
Shows the dialog to the user.
|
Shows the dialog to the user.
|
||||||
|
|
||||||
void reject():
|
void reject():
|
||||||
Rejects the dialog's request without any user interaction. The method emits the rejected() signal and closes the dialog.
|
Rejects the dialog's request without any user interaction. The method emits the rejected() signal and closes the internalLoader.dialog.
|
||||||
See also accept().
|
See also accept().
|
||||||
**/
|
**/
|
||||||
|
|
||||||
@ -105,6 +105,7 @@ import QtQuick 1.0
|
|||||||
import org.kde.plasma.core 0.1 as PlasmaCore
|
import org.kde.plasma.core 0.1 as PlasmaCore
|
||||||
import "private/AppManager.js" as Utils
|
import "private/AppManager.js" as Utils
|
||||||
import "." 0.1
|
import "." 0.1
|
||||||
|
import "private" as Private
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
id: root
|
id: root
|
||||||
@ -112,7 +113,7 @@ Item {
|
|||||||
property alias title: titleBar.children
|
property alias title: titleBar.children
|
||||||
property alias content: contentItem.children
|
property alias content: contentItem.children
|
||||||
property alias buttons: buttonItem.children
|
property alias buttons: buttonItem.children
|
||||||
// property alias visualParent: dialog.visualParent
|
property Item visualParent
|
||||||
property int status: DialogStatus.Closed
|
property int status: DialogStatus.Closed
|
||||||
|
|
||||||
|
|
||||||
@ -123,105 +124,174 @@ Item {
|
|||||||
signal rejected
|
signal rejected
|
||||||
signal clickedOutside
|
signal clickedOutside
|
||||||
|
|
||||||
function open()
|
function open() {
|
||||||
{
|
dialogLayout.parent = internalLoader.item.mainItem
|
||||||
var pos = dialog.popupPosition(null, Qt.AlignCenter)
|
|
||||||
dialog.x = pos.x
|
|
||||||
dialog.y = pos.y
|
|
||||||
|
|
||||||
dialog.visible = true
|
if (internalLoader.dialog) {
|
||||||
dialog.activateWindow()
|
var pos = internalLoader.dialog.popupPosition(root.visualParent, Qt.AlignCenter)
|
||||||
|
internalLoader.dialog.x = pos.x
|
||||||
|
internalLoader.dialog.y = pos.y
|
||||||
|
|
||||||
|
internalLoader.dialog.visible = true
|
||||||
|
internalLoader.dialog.activateWindow()
|
||||||
|
} else {
|
||||||
|
internalLoader.inlineDialog.open()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function accept()
|
function accept() {
|
||||||
{
|
|
||||||
if (status == DialogStatus.Open) {
|
if (status == DialogStatus.Open) {
|
||||||
dialog.visible = false
|
if (internalLoader.dialog) {
|
||||||
|
internalLoader.dialog.visible = false
|
||||||
|
} else {
|
||||||
|
internalLoader.inlineDialog.close()
|
||||||
|
}
|
||||||
accepted()
|
accepted()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function reject() {
|
function reject() {
|
||||||
if (status == DialogStatus.Open) {
|
if (status == DialogStatus.Open) {
|
||||||
dialog.visible = false
|
if (internalLoader.dialog) {
|
||||||
|
internalLoader.dialog.visible = false
|
||||||
|
} else {
|
||||||
|
internalLoader.inlineDialog.close()
|
||||||
|
}
|
||||||
rejected()
|
rejected()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function close() {
|
function close() {
|
||||||
dialog.visible = false
|
if (internalLoader.dialog) {
|
||||||
|
internalLoader.dialog.visible = false
|
||||||
|
} else {
|
||||||
|
internalLoader.inlineDialog.close()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
visible: false
|
visible: false
|
||||||
|
|
||||||
PlasmaCore.Dialog {
|
Loader {
|
||||||
id: dialog
|
id: internalLoader
|
||||||
windowFlags: Qt.Dialog
|
//the root item of the scene. Determines if there is enough room for an inline dialog
|
||||||
|
|
||||||
|
|
||||||
//onFaderClicked: root.clickedOutside()
|
|
||||||
property Item rootItem
|
property Item rootItem
|
||||||
|
|
||||||
//state: "Hidden"
|
//this is when the dialog is a separate window
|
||||||
visible: false
|
property Item dialog: sourceComponent == dialogComponent ? item : null
|
||||||
onVisibleChanged: {
|
//this is when the dialog is inline
|
||||||
if (visible) {
|
property Item inlineDialog: sourceComponent == inlineDialogComponent ? item : null
|
||||||
status = DialogStatus.Open
|
|
||||||
} else {
|
|
||||||
status = DialogStatus.Closed
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
mainItem: Item {
|
property bool loadCompleted: false
|
||||||
id: mainItem
|
|
||||||
width: theme.defaultFont.mSize.width * 40
|
|
||||||
height: titleBar.childrenRect.height + contentItem.childrenRect.height + buttonItem.childrenRect.height + 8
|
|
||||||
|
|
||||||
// Consume all key events that are not processed by children
|
|
||||||
Keys.onPressed: event.accepted = true
|
|
||||||
Keys.onReleased: event.accepted = true
|
|
||||||
|
|
||||||
Item {
|
|
||||||
id: titleBar
|
|
||||||
|
|
||||||
height: childrenRect.height
|
|
||||||
anchors {
|
|
||||||
top: parent.top
|
|
||||||
left: parent.left
|
|
||||||
right: parent.right
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Item {
|
|
||||||
id: contentItem
|
|
||||||
|
|
||||||
onChildrenRectChanged: mainItem.width = Math.max(childrenRect.width, buttonItem.childrenRect.width)
|
|
||||||
|
|
||||||
clip: true
|
|
||||||
anchors {
|
|
||||||
top: titleBar.bottom
|
|
||||||
left: parent.left
|
|
||||||
right: parent.right
|
|
||||||
bottom: buttonItem.top
|
|
||||||
bottomMargin: 8
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Item {
|
|
||||||
id: buttonItem
|
|
||||||
|
|
||||||
height: childrenRect.height
|
|
||||||
anchors {
|
|
||||||
left: parent.left
|
|
||||||
right: parent.right
|
|
||||||
bottom: parent.bottom
|
|
||||||
bottomMargin: 4
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
rootItem = Utils.rootObject()
|
rootItem = Utils.rootObject()
|
||||||
|
loadCompleted = true
|
||||||
|
}
|
||||||
|
|
||||||
|
sourceComponent: {
|
||||||
|
if (loadCompleted) {
|
||||||
|
if (rootItem == null || dialogLayout.width > rootItem.width || dialogLayout.height > rootItem.height) {
|
||||||
|
dialogComponent
|
||||||
|
} else {
|
||||||
|
inlineDialogComponent
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Component {
|
||||||
|
id: dialogComponent
|
||||||
|
PlasmaCore.Dialog {
|
||||||
|
windowFlags: Qt.Popup
|
||||||
|
|
||||||
|
//state: "Hidden"
|
||||||
|
visible: false
|
||||||
|
onVisibleChanged: {
|
||||||
|
if (visible) {
|
||||||
|
root.status = DialogStatus.Open
|
||||||
|
} else {
|
||||||
|
root.status = DialogStatus.Closed
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
mainItem: Item {
|
||||||
|
id: dialogMainItem
|
||||||
|
width: dialogLayout.width
|
||||||
|
height: dialogLayout.height
|
||||||
|
}
|
||||||
|
|
||||||
|
Component.onCompleted: dialogLayout.parent = dialogMainItem
|
||||||
|
Component.onDestruction: dialogLayout.parent = root
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Component {
|
||||||
|
id: inlineDialogComponent
|
||||||
|
Private.InlineDialog {
|
||||||
|
id: inlineDialog
|
||||||
|
visualParent: root.visualParent
|
||||||
|
property Item mainItem: inlineDialogMainItem
|
||||||
|
onStatusChanged: root.status = status
|
||||||
|
|
||||||
|
Item {
|
||||||
|
id: inlineDialogMainItem
|
||||||
|
width: dialogLayout.width
|
||||||
|
height: dialogLayout.height
|
||||||
|
}
|
||||||
|
|
||||||
|
Component.onCompleted: {
|
||||||
|
dialogLayout.parent = inlineDialogMainItem
|
||||||
|
}
|
||||||
|
Component.onDestruction: dialogLayout.parent = root
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Item {
|
||||||
|
id: dialogLayout
|
||||||
|
width: theme.defaultFont.mSize.width * 40
|
||||||
|
height: titleBar.childrenRect.height + contentItem.childrenRect.height + buttonItem.childrenRect.height + 8
|
||||||
|
|
||||||
|
parent: internalLoader.dialog ? internalLoader.dialog : internalLoader.inlineDialog
|
||||||
|
// Consume all key events that are not processed by children
|
||||||
|
Keys.onPressed: event.accepted = true
|
||||||
|
Keys.onReleased: event.accepted = true
|
||||||
|
|
||||||
|
Item {
|
||||||
|
id: titleBar
|
||||||
|
|
||||||
|
height: childrenRect.height
|
||||||
|
anchors {
|
||||||
|
top: parent.top
|
||||||
|
left: parent.left
|
||||||
|
right: parent.right
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Item {
|
||||||
|
id: contentItem
|
||||||
|
|
||||||
|
onChildrenRectChanged: mainItem.width = Math.max(childrenRect.width, buttonItem.childrenRect.width)
|
||||||
|
|
||||||
|
clip: true
|
||||||
|
anchors {
|
||||||
|
top: titleBar.bottom
|
||||||
|
left: parent.left
|
||||||
|
right: parent.right
|
||||||
|
bottom: buttonItem.top
|
||||||
|
bottomMargin: 8
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Item {
|
||||||
|
id: buttonItem
|
||||||
|
|
||||||
|
height: childrenRect.height
|
||||||
|
anchors {
|
||||||
|
left: parent.left
|
||||||
|
right: parent.right
|
||||||
|
bottom: parent.bottom
|
||||||
|
bottomMargin: 4
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -57,9 +57,9 @@ CommonDialog {
|
|||||||
|
|
||||||
onButtonClicked: {
|
onButtonClicked: {
|
||||||
if (acceptButtonText && index == 0)
|
if (acceptButtonText && index == 0)
|
||||||
accepted()
|
accept()
|
||||||
else
|
else
|
||||||
rejected()
|
reject()
|
||||||
}
|
}
|
||||||
|
|
||||||
content: Item {
|
content: Item {
|
146
declarativeimports/plasmacomponents/qml/private/InlineDialog.qml
Normal file
146
declarativeimports/plasmacomponents/qml/private/InlineDialog.qml
Normal file
@ -0,0 +1,146 @@
|
|||||||
|
/*
|
||||||
|
* 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 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
|
||||||
|
|
||||||
|
Item {
|
||||||
|
id: root
|
||||||
|
property Item visualParent
|
||||||
|
z: 9000
|
||||||
|
property int status: PlasmaComponents.DialogStatus.Closed
|
||||||
|
default property alias data: contentItem.data
|
||||||
|
|
||||||
|
function open()
|
||||||
|
{
|
||||||
|
if (root.visualParent) {
|
||||||
|
internal.parentPos = root.visualParent.mapToItem(dismissArea.parent, 0, 0)
|
||||||
|
}
|
||||||
|
root.status = PlasmaComponents.DialogStatus.Opening
|
||||||
|
appearAnimation.running = true
|
||||||
|
}
|
||||||
|
|
||||||
|
function close()
|
||||||
|
{
|
||||||
|
root.status = PlasmaComponents.DialogStatus.Closing
|
||||||
|
appearAnimation.running = true
|
||||||
|
}
|
||||||
|
|
||||||
|
SequentialAnimation {
|
||||||
|
id: appearAnimation
|
||||||
|
NumberAnimation {
|
||||||
|
duration: 250
|
||||||
|
easing.type: Easing.InOutQuad
|
||||||
|
target: dismissArea
|
||||||
|
properties: "opacity"
|
||||||
|
to: root.status == PlasmaComponents.DialogStatus.Opening ? 1 : 0
|
||||||
|
}
|
||||||
|
ScriptAction {
|
||||||
|
script: root.status == PlasmaComponents.DialogStatus.Opening ? root.status = PlasmaComponents.DialogStatus.Open : PlasmaComponents.DialogStatus.Closed
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
MouseArea {
|
||||||
|
id: dismissArea
|
||||||
|
z: 9000
|
||||||
|
anchors.fill: parent
|
||||||
|
opacity: 0
|
||||||
|
|
||||||
|
PlasmaCore.FrameSvgItem {
|
||||||
|
id: internal
|
||||||
|
property variant parentPos
|
||||||
|
imagePath: "widgets/background"
|
||||||
|
property bool under: root.visualParent ? internal.parentPos.y + root.visualParent.height + height < dismissArea.height : true
|
||||||
|
//bindings won't work inside anchers definition
|
||||||
|
onUnderChanged: {
|
||||||
|
if (under) {
|
||||||
|
tipSvg.anchors.top = undefined
|
||||||
|
tipSvg.anchors.bottom = tipSvg.parent.top
|
||||||
|
} else {
|
||||||
|
tipSvg.anchors.bottom = undefined
|
||||||
|
tipSvg.anchors.top = tipSvg.parent.bottom
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
x: {
|
||||||
|
if (root.visualParent) {
|
||||||
|
internal.parentPos.x - internal.width/2 + root.visualParent.width/2
|
||||||
|
} else {
|
||||||
|
dismissArea.width/2 - internal.width/2
|
||||||
|
}
|
||||||
|
}
|
||||||
|
y: {
|
||||||
|
if (root.visualParent) {
|
||||||
|
if (under) {
|
||||||
|
internal.parentPos.y + root.visualParent.height
|
||||||
|
} else {
|
||||||
|
internal.parentPos.y - internal.height
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
dismissArea.height/2 - internal.height/2
|
||||||
|
}
|
||||||
|
}
|
||||||
|
width: contentItem.width + margins.left + margins.right
|
||||||
|
height: contentItem.height + margins.top + margins.bottom
|
||||||
|
|
||||||
|
PlasmaCore.SvgItem {
|
||||||
|
id: tipSvg
|
||||||
|
visible: root.visualParent != null
|
||||||
|
svg: PlasmaCore.Svg {
|
||||||
|
id: backgroundSvg
|
||||||
|
imagePath: "widgets/background"
|
||||||
|
}
|
||||||
|
elementId: internal.under ? "baloon-tip-top" : "baloon-tip-bottom"
|
||||||
|
anchors {
|
||||||
|
horizontalCenter: parent.horizontalCenter
|
||||||
|
bottom: parent.top
|
||||||
|
top: parent.bottom
|
||||||
|
topMargin: -backgroundSvg.elementSize("hint-bottom-shadow").height
|
||||||
|
bottomMargin: -backgroundSvg.elementSize("hint-top-shadow").height
|
||||||
|
}
|
||||||
|
width: naturalSize.width
|
||||||
|
height: naturalSize.height
|
||||||
|
}
|
||||||
|
MouseArea {
|
||||||
|
id: contentItem
|
||||||
|
x: parent.margins.left
|
||||||
|
y: parent.margins.top
|
||||||
|
width: childrenRect.width
|
||||||
|
height: childrenRect.height
|
||||||
|
onClicked: mouse.accepted = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
onClicked: {
|
||||||
|
root.close()
|
||||||
|
}
|
||||||
|
Component.onCompleted: {
|
||||||
|
var candidate = root
|
||||||
|
while (candidate.parent) {
|
||||||
|
candidate = candidate.parent
|
||||||
|
}
|
||||||
|
if (candidate) {
|
||||||
|
dismissArea.parent = candidate
|
||||||
|
} else {
|
||||||
|
dismissArea.visible = false
|
||||||
|
}
|
||||||
|
internal.parentPos = root.mapToItem(dismissArea.parent, 0, 0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -15,6 +15,7 @@ ListItem 0.1 ListItem.qml
|
|||||||
Page 0.1 Page.qml
|
Page 0.1 Page.qml
|
||||||
PageStack 0.1 PageStack.qml
|
PageStack 0.1 PageStack.qml
|
||||||
ProgressBar 0.1 ProgressBar.qml
|
ProgressBar 0.1 ProgressBar.qml
|
||||||
|
QueryDialog 0.1 QueryDialog.qml
|
||||||
RadioButton 0.1 RadioButton.qml
|
RadioButton 0.1 RadioButton.qml
|
||||||
ScrollBar 0.1 ScrollBar.qml
|
ScrollBar 0.1 ScrollBar.qml
|
||||||
SectionScroller 0.1 SectionScroller.qml
|
SectionScroller 0.1 SectionScroller.qml
|
||||||
|
Loading…
x
Reference in New Issue
Block a user