mirror of
https://invent.kde.org/system/dolphin
synced 2024-08-22 01:40:02 +00:00
Port to QDialog
This commit is contained in:
parent
9c6c0089c9
commit
dfd3232496
|
@ -38,9 +38,12 @@
|
|||
#include <QEvent>
|
||||
#include <QFormLayout>
|
||||
#include <QVBoxLayout>
|
||||
#include <KConfigGroup>
|
||||
#include <QDialogButtonBox>
|
||||
#include <QPushButton>
|
||||
|
||||
PlacesItemEditDialog::PlacesItemEditDialog(QWidget* parent) :
|
||||
KDialog(parent),
|
||||
QDialog(parent),
|
||||
m_icon(),
|
||||
m_text(),
|
||||
m_url(),
|
||||
|
@ -50,9 +53,6 @@ PlacesItemEditDialog::PlacesItemEditDialog(QWidget* parent) :
|
|||
m_iconButton(0),
|
||||
m_appLocal(0)
|
||||
{
|
||||
setButtons( Ok | Cancel );
|
||||
setModal(true);
|
||||
setDefaultButton(Ok);
|
||||
}
|
||||
|
||||
void PlacesItemEditDialog::setIcon(const QString& icon)
|
||||
|
@ -110,7 +110,7 @@ bool PlacesItemEditDialog::event(QEvent* event)
|
|||
|
||||
void PlacesItemEditDialog::slotUrlChanged(const QString& text)
|
||||
{
|
||||
enableButtonOk(!text.isEmpty());
|
||||
m_okButton->setEnabled(!text.isEmpty());
|
||||
}
|
||||
|
||||
PlacesItemEditDialog::~PlacesItemEditDialog()
|
||||
|
@ -119,7 +119,21 @@ PlacesItemEditDialog::~PlacesItemEditDialog()
|
|||
|
||||
void PlacesItemEditDialog::initialize()
|
||||
{
|
||||
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok|QDialogButtonBox::Cancel);
|
||||
m_okButton = buttonBox->button(QDialogButtonBox::Ok);
|
||||
m_okButton->setDefault(true);
|
||||
m_okButton->setShortcut(Qt::CTRL | Qt::Key_Return);
|
||||
connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
|
||||
connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
|
||||
setModal(true);
|
||||
m_okButton->setDefault(true);
|
||||
|
||||
QVBoxLayout *mainLayout = new QVBoxLayout;
|
||||
setLayout(mainLayout);
|
||||
QWidget* mainWidget = new QWidget(this);
|
||||
mainLayout->addWidget(mainWidget);
|
||||
mainLayout->addWidget(buttonBox);
|
||||
|
||||
QVBoxLayout* vBox = new QVBoxLayout(mainWidget);
|
||||
|
||||
QFormLayout* formLayout = new QFormLayout();
|
||||
|
@ -166,6 +180,5 @@ void PlacesItemEditDialog::initialize()
|
|||
m_textEdit->setFocus();
|
||||
}
|
||||
|
||||
setMainWidget(mainWidget);
|
||||
}
|
||||
|
||||
|
|
|
@ -24,15 +24,16 @@
|
|||
#ifndef PLACESITEMEDITDIALOG_H
|
||||
#define PLACESITEMEDITDIALOG_H
|
||||
|
||||
#include <KDialog>
|
||||
#include <QDialog>
|
||||
#include <KUrl>
|
||||
|
||||
class KIconButton;
|
||||
class KLineEdit;
|
||||
class KUrlRequester;
|
||||
class QCheckBox;
|
||||
class QPushButton;
|
||||
|
||||
class PlacesItemEditDialog: public KDialog
|
||||
class PlacesItemEditDialog: public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
@ -71,6 +72,7 @@ private:
|
|||
KLineEdit* m_textEdit;
|
||||
KIconButton* m_iconButton;
|
||||
QCheckBox* m_appLocal;
|
||||
QPushButton *m_okButton;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -467,7 +467,7 @@ void PlacesPanel::addEntry()
|
|||
const KUrl url = m_model->data(index).value("url").value<KUrl>();
|
||||
|
||||
QPointer<PlacesItemEditDialog> dialog = new PlacesItemEditDialog(this);
|
||||
dialog->setCaption(i18nc("@title:window", "Add Places Entry"));
|
||||
dialog->setWindowTitle(i18nc("@title:window", "Add Places Entry"));
|
||||
dialog->setAllowGlobal(true);
|
||||
dialog->setUrl(url);
|
||||
if (dialog->exec() == QDialog::Accepted) {
|
||||
|
@ -483,7 +483,7 @@ void PlacesPanel::editEntry(int index)
|
|||
QHash<QByteArray, QVariant> data = m_model->data(index);
|
||||
|
||||
QPointer<PlacesItemEditDialog> dialog = new PlacesItemEditDialog(this);
|
||||
dialog->setCaption(i18nc("@title:window", "Edit Places Entry"));
|
||||
dialog->setWindowTitle(i18nc("@title:window", "Edit Places Entry"));
|
||||
dialog->setIcon(data.value("iconName").toString());
|
||||
dialog->setText(data.value("text").toString());
|
||||
dialog->setUrl(data.value("url").value<KUrl>());
|
||||
|
|
Loading…
Reference in a new issue