use a system KDialog for QueryDialog
This commit is contained in:
parent
a462112815
commit
3e1359a8bc
@ -6,6 +6,7 @@ set(plasmacomponents_SRCS
|
||||
enums.cpp
|
||||
qmenu.cpp
|
||||
qmenuitem.cpp
|
||||
kdialogproxy.cpp
|
||||
)
|
||||
|
||||
INCLUDE_DIRECTORIES(
|
||||
@ -18,7 +19,7 @@ qt4_automoc(${plasmacomponents_SRCS})
|
||||
|
||||
|
||||
add_library(plasmacomponentsplugin SHARED ${plasmacomponents_SRCS})
|
||||
target_link_libraries(plasmacomponentsplugin ${QT_QTCORE_LIBRARY} ${QT_QTDECLARATIVE_LIBRARY} ${QT_QTGUI_LIBRARY})
|
||||
target_link_libraries(plasmacomponentsplugin ${QT_QTCORE_LIBRARY} ${QT_QTDECLARATIVE_LIBRARY} ${QT_QTGUI_LIBRARY} ${KDE4_KDEUI_LIBRARY})
|
||||
|
||||
install(TARGETS plasmacomponentsplugin DESTINATION ${IMPORTS_INSTALL_DIR}/org/kde/plasma/components)
|
||||
|
||||
|
150
declarativeimports/plasmacomponents/kdialogproxy.cpp
Normal file
150
declarativeimports/plasmacomponents/kdialogproxy.cpp
Normal file
@ -0,0 +1,150 @@
|
||||
/*
|
||||
* 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()));
|
||||
}
|
||||
|
||||
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"
|
||||
|
88
declarativeimports/plasmacomponents/kdialogproxy.h
Normal file
88
declarativeimports/plasmacomponents/kdialogproxy.h
Normal file
@ -0,0 +1,88 @@
|
||||
/*
|
||||
* 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
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include "enums.h"
|
||||
#include "qmenu.h"
|
||||
#include "qmenuitem.h"
|
||||
#include "kdialogproxy.h"
|
||||
|
||||
|
||||
void PlasmaComponentsPlugin::registerTypes(const char *uri)
|
||||
@ -37,6 +38,8 @@ void PlasmaComponentsPlugin::registerTypes(const char *uri)
|
||||
qmlRegisterType<QMenuProxy>(uri, 0, 1, "ContextMenu");
|
||||
qmlRegisterType<QMenuItem>(uri, 0, 1, "MenuItem");
|
||||
|
||||
qmlRegisterType<KDialogProxy>(uri, 0, 1, "QueryDialog");
|
||||
|
||||
qmlRegisterType<Plasma::QRangeModel>(uri, 0, 1, "RangeModel");
|
||||
|
||||
qmlRegisterUncreatableType<DialogStatus>(uri, 0, 1, "DialogStatus", "");
|
||||
|
Loading…
x
Reference in New Issue
Block a user