Commit e438bf9b authored by Andrius Štikonas's avatar Andrius Štikonas
Browse files

Convert some KDialogs to QDialogs.

parent 76e83d3b
......@@ -17,6 +17,7 @@ include(ECMPackageConfigHelpers)
find_package(Qt5 ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS
Core
DBus
Gui
Widgets
)
......@@ -26,11 +27,11 @@ find_package(KF5 REQUIRED
AkonadiContact
Archive
DocTools
I18n
IconThemes
Codecs
Contacts
CoreAddons
I18n
IconThemes
KIO
KDELibs4Support
Service
......@@ -220,13 +221,15 @@ if (KGPG_DEBUG_TRANSACTIONS)
endif (KGPG_DEBUG_TRANSACTIONS)
target_link_libraries(kgpg
KF5::AkonadiContact
KF5::Archive
KF5::Codecs
KF5::Contacts
KF5::CoreAddons
KF5::IconThemes
KF5::KDELibs4Support
KF5::KIOCore
KF5::AkonadiContact
KF5::WidgetsAddons
)
install(TARGETS kgpg ${INSTALL_TARGETS_DEFAULT_ARGS} )
......
......@@ -19,18 +19,32 @@
#include <KLocale>
#include <KMessageBox>
#include <KConfigGroup>
#include <QDialogButtonBox>
#include <QPushButton>
#include <QVBoxLayout>
KgpgDetailedInfo::KgpgDetailedInfo(QWidget *parent, const QString &boxLabel, const QString &errormessage,
const QStringList &keysList, const QString &caption)
: KDialog(parent)
: QDialog(parent)
{
if (!caption.isEmpty())
setWindowTitle(caption);
else
setWindowTitle(i18n("Info"));
setButtons(Details | Ok);
setDefaultButton(Ok);
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok);
QWidget *mainWidget = new QWidget(this);
QVBoxLayout *mainLayout = new QVBoxLayout;
setLayout(mainLayout);
mainLayout->addWidget(mainWidget);
QPushButton *okButton = buttonBox->button(QDialogButtonBox::Ok);
okButton->setDefault(true);
okButton->setShortcut(Qt::CTRL | Qt::Key_Return);
connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
mainLayout->addWidget(buttonBox);
okButton->setDefault(true);
setModal(true);
// KMessageBox::createKMessageBox(this, QMessageBox::Information, // krazy:exclude=qtclasses
// boxLabel, keysList, QString(), Q_NULLPTR, 0, errormessage); FIXME:KF5
// boxLabel, keysList, QString(), Q_NULLPTR, 0, errormessage); FIXME: KF5
}
......@@ -18,11 +18,11 @@
#ifndef KGPGDETAILEDCONSOLE_H
#define KGPGDETAILEDCONSOLE_H
#include <KDialog>
#include <QDialog>
#include <kgpgcompiler.h>
class KgpgDetailedInfo : public KDialog
class KgpgDetailedInfo : public QDialog
{
public:
explicit KgpgDetailedInfo(QWidget *parent = Q_NULLPTR, const QString &boxLabel = QString(),
......
......@@ -57,6 +57,9 @@
#include <QWidget>
#include <kio/netaccess.h>
#include <kio/renamedialog.h>
#include <KConfigGroup>
#include <QDialogButtonBox>
#include <QPushButton>
class KgpgView : public QWidget {
public:
......@@ -491,14 +494,24 @@ void KgpgEditor::slotFilePreDec()
oldname.append(QLatin1String( ".clear" ));
oldname.prepend(url.adjusted(QUrl::RemoveFilename).path());
QPointer<KDialog> popn = new KDialog(this);
QPointer<QDialog> popn = new QDialog(this);
popn->setWindowTitle(i18n("Decrypt File To"));
popn->setButtons( KDialog::Ok | KDialog::Cancel );
popn->setDefaultButton( KDialog::Ok );
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok|QDialogButtonBox::Cancel);
QWidget *mainWidget = new QWidget(this);
QVBoxLayout *mainLayout = new QVBoxLayout;
popn->setLayout(mainLayout);
mainLayout->addWidget(mainWidget);
QPushButton *okButton = buttonBox->button(QDialogButtonBox::Ok);
okButton->setDefault(true);
okButton->setShortcut(Qt::CTRL | Qt::Key_Return);
popn->connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
popn->connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
buttonBox->button(QDialogButtonBox::Ok)->setDefault(true);
popn->setModal( true );
SrcSelect *page = new SrcSelect();
popn->setMainWidget(page);
mainLayout->addWidget(page);
mainLayout->addWidget(buttonBox);
page->newFilename->setUrl(QUrl(oldname));
page->newFilename->setMode(KFile::File);
page->newFilename->setWindowTitle(i18n("Save File"));
......
......@@ -20,15 +20,25 @@
#include <KMessageBox>
#include <KLocale>
#include <KLed>
#include <KConfigGroup>
#include <QDialogButtonBox>
#include <QPushButton>
#include <QVBoxLayout>
Md5Widget::Md5Widget(QWidget *parent, const QUrl &url)
: KDialog(parent)
: QDialog(parent)
{
setWindowTitle(i18n("MD5 Checksum"));
setButtons(Apply | Close);
setDefaultButton(Close);
setButtonText(Apply, i18n("Compare MD5 with Clipboard"));
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Close|QDialogButtonBox::Apply);
QWidget *mainWidget = new QWidget(this);
QVBoxLayout *mainLayout = new QVBoxLayout;
setLayout(mainLayout);
mainLayout->addWidget(mainWidget);
connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
buttonBox->button(QDialogButtonBox::Close)->setDefault(true);
buttonBox->button(QDialogButtonBox::Apply)->setText(i18n("Compare MD5 with Clipboard"));
QFile f(url.path());
QCryptographicHash checkfile(QCryptographicHash::Md5);
......@@ -63,16 +73,15 @@ Md5Widget::Md5Widget(QWidget *parent, const QUrl &url)
ledlayout->addWidget(m_label);
QVBoxLayout *dialoglayout = new QVBoxLayout(page);
dialoglayout->setMargin(marginHint());
dialoglayout->setSpacing(spacingHint());
dialoglayout->addWidget(firstlabel);
dialoglayout->addWidget(md5lineedit);
dialoglayout->addLayout(ledlayout);
dialoglayout->addStretch();
setMainWidget(page);
mainLayout->addWidget(page);
mainLayout->addWidget(buttonBox);
connect(this, SIGNAL(applyClicked()), this, SLOT(slotApply()));
connect(buttonBox->button(QDialogButtonBox::Apply), SIGNAL(clicked()), this, SLOT(slotApply()));
}
void Md5Widget::slotApply()
......
......@@ -19,7 +19,7 @@ class QLabel;
class KLed;
class Md5Widget : public KDialog
class Md5Widget : public QDialog
{
Q_OBJECT
......
......@@ -37,6 +37,7 @@
#include <QMimeData>
#include <QTextStream>
#include <kio/netaccess.h>
#include <KConfigGroup>
#define SIGNEDMESSAGE_BEGIN QLatin1String( "-----BEGIN PGP SIGNED MESSAGE-----" )
#define SIGNEDMESSAGE_END QLatin1String( "-----END PGP SIGNATURE-----" )
......@@ -159,7 +160,7 @@ void KgpgTextEdit::openDroppedFile(const QUrl &url, const bool probe)
void KgpgTextEdit::slotEncode()
{
QPointer<KgpgSelectPublicKeyDlg> dialog = new KgpgSelectPublicKeyDlg(this, m_model, m_keysmanager->goDefaultShortcut(), true);
if (dialog->exec() == KDialog::Accepted) {
if (dialog->exec() == QDialog::Accepted) {
QStringList options;
KGpgEncrypt::EncryptOptions opts = KGpgEncrypt::DefaultEncryption;
......
......@@ -26,17 +26,22 @@
#include "model/kgpgitemnode.h"
#include "transactions/kgpgchangepass.h"
#include <KConfigGroup>
#include <KGlobal>
#include <KLocale>
#include <KMessageBox>
#include <KPushButton>
#include <KToolInvocation>
#include <QApplication>
#include <QCheckBox>
#include <QDialogButtonBox>
#include <QFormLayout>
#include <QHBoxLayout>
#include <QImage>
#include <QPixmap>
#include <QPushButton>
#include <QVBoxLayout>
using namespace KgpgCore;
......@@ -95,7 +100,7 @@ void KgpgTrustLabel::change()
}
KgpgKeyInfo::KgpgKeyInfo(KGpgKeyNode *node, KGpgItemModel *model, QWidget *parent)
: KDialog(parent),
: QDialog(parent),
keychange(new KGpgChangeKey(node, this)),
m_node(node),
m_model(model),
......@@ -107,10 +112,20 @@ KgpgKeyInfo::KgpgKeyInfo(KGpgKeyNode *node, KGpgItemModel *model, QWidget *paren
setupUi(this);
setButtons(Ok | Apply | Cancel);
setDefaultButton(Ok);
setModal(true);
enableButtonApply(false);
QVBoxLayout *mainLayout = new QVBoxLayout(this);
QWidget *mainWidget = new QWidget(this);
setLayout(mainLayout);
mainLayout->addWidget(mainWidget);
buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok|QDialogButtonBox::Cancel|QDialogButtonBox::Apply);
QPushButton *okButton = buttonBox->button(QDialogButtonBox::Ok);
okButton->setDefault(true);
okButton->setShortcut(Qt::CTRL | Qt::Key_Return);
connect(buttonBox, &QDialogButtonBox::accepted, this, &KgpgKeyInfo::okButtonClicked);
connect(buttonBox->button(QDialogButtonBox::Apply), &QPushButton::clicked, this, &KgpgKeyInfo::applyButtonClicked);
connect(buttonBox->button(QDialogButtonBox::Cancel), &QPushButton::clicked, this, &KgpgKeyInfo::cancelButtonClicked);
connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
okButton->setDefault(true);
buttonBox->button(QDialogButtonBox::Apply)->setEnabled(false);
m_email->setUnderline(false);
m_trust = new KgpgTrustLabel(this);
......@@ -124,7 +139,8 @@ KgpgKeyInfo::KgpgKeyInfo(KGpgKeyNode *node, KGpgItemModel *model, QWidget *paren
m_password->hide();
}
setMainWidget(page);
mainLayout->addWidget(page);
mainLayout->addWidget(buttonBox);
connect(m_owtrust, SIGNAL(activated(int)), this, SLOT(slotChangeTrust(int)));
connect(m_photoid, SIGNAL(activated(QString)), this, SLOT(slotLoadPhoto(QString)));
......@@ -262,7 +278,7 @@ void KgpgKeyInfo::slotChangeDate()
QPointer<SelectExpiryDate> dialog = new SelectExpiryDate(this, m_node->getExpiration());
if (dialog->exec() == QDialog::Accepted) {
keychange->setExpiration(dialog->date());
enableButtonApply(keychange->wasChanged());
buttonBox->button(QDialogButtonBox::Apply)->setEnabled(keychange->wasChanged());
}
delete dialog;
}
......@@ -270,7 +286,7 @@ void KgpgKeyInfo::slotChangeDate()
void KgpgKeyInfo::slotDisableKey(const bool ison)
{
keychange->setDisable(ison);
enableButtonApply(keychange->wasChanged());
buttonBox->button(QDialogButtonBox::Apply)->setEnabled(keychange->wasChanged());
}
void KgpgKeyInfo::slotChangePass()
......@@ -306,14 +322,14 @@ void KgpgKeyInfo::slotInfoPasswordChanged(int result)
void KgpgKeyInfo::slotChangeTrust(const int newtrust)
{
keychange->setOwTrust(static_cast<gpgme_validity_t>(newtrust + 1));
enableButtonApply(keychange->wasChanged());
buttonBox->button(QDialogButtonBox::Apply)->setEnabled(keychange->wasChanged());
}
void KgpgKeyInfo::setControlEnable(const bool b)
{
m_owtrust->setEnabled(b);
m_disable->setEnabled(b);
enableButtonApply(b && keychange->wasChanged());
buttonBox->button(QDialogButtonBox::Apply)->setEnabled(b && keychange->wasChanged());
if (m_expirationbtn)
m_expirationbtn->setEnabled(b);
......@@ -326,24 +342,23 @@ void KgpgKeyInfo::setControlEnable(const bool b)
QApplication::setOverrideCursor(QCursor(Qt::BusyCursor));
}
void KgpgKeyInfo::slotButtonClicked(int button)
void KgpgKeyInfo::okButtonClicked()
{
switch (button) {
case Ok:
m_closewhendone = true;
// Fall-through
case Apply:
setControlEnable(false);
keychange->apply();
break;
case Cancel:
if (m_keywaschanged && m_node)
emit keyNeedsRefresh(m_node);
reject();
break;
default:
KDialog::slotButtonClicked(button);
}
m_closewhendone = true;
applyButtonClicked();
}
void KgpgKeyInfo::applyButtonClicked()
{
setControlEnable(false);
keychange->apply();
}
void KgpgKeyInfo::cancelButtonClicked()
{
if (m_keywaschanged && m_node)
emit keyNeedsRefresh(m_node);
reject();
}
void KgpgKeyInfo::slotApplied(int result)
......
......@@ -17,15 +17,16 @@
#ifndef KGPGKEYINFODIALOG_H
#define KGPGKEYINFODIALOG_H
#include <QString>
#include <QLabel>
#include <QColor>
#include <KDialog>
#include <QDialog>
#include <QLabel>
#include <QString>
#include <kgpgcompiler.h>
#include "ui_kgpgKeyInfo.h"
class QDialogButtonBox;
class KGpgItemModel;
class KGpgKeyNode;
class KGpgChangeKey;
......@@ -53,7 +54,7 @@ private:
QColor m_color;
};
class KgpgKeyInfo : public KDialog, public Ui::kgpgKeyInfo
class KgpgKeyInfo : public QDialog, public Ui::kgpgKeyInfo
{
Q_OBJECT
......@@ -68,14 +69,14 @@ public:
signals:
void keyNeedsRefresh(KGpgKeyNode *node);
protected slots:
void slotButtonClicked(int button);
private:
void reloadKey();
void reloadNode();
void displayKey();
void setControlEnable(const bool b);
void okButtonClicked();
void applyButtonClicked();
void cancelButtonClicked();
private slots:
void slotOpenUrl(const QString &url) const;
......@@ -101,6 +102,8 @@ private:
KgpgTrustLabel *m_trust;
QDialogButtonBox *buttonBox;
bool m_keywaschanged;
bool m_closewhendone;
};
......
......@@ -1312,7 +1312,7 @@ KeysManager::slotMenu(const QPoint &pos)
void KeysManager::revokeWidget()
{
KGpgNode *nd = iview->selectedNode();
KDialog *keyRevokeDialog = new KGpgRevokeDialog(this, nd->toKeyNode());
QDialog *keyRevokeDialog = new KGpgRevokeDialog(this, nd->toKeyNode());
connect(keyRevokeDialog, SIGNAL(finished(int)), SLOT(slotRevokeDialogFinished(int)));
......
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>kgpgKeyInfo</class>
<widget class="KDialog" name="kgpgKeyInfo">
<widget class="QDialog" name="kgpgKeyInfo">
<property name="geometry">
<rect>
<x>0</x>
......@@ -441,12 +441,6 @@
</widget>
</widget>
<customwidgets>
<customwidget>
<class>KDialog</class>
<extends>QDialog</extends>
<header>kdialog.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>KPushButton</class>
<extends>QPushButton</extends>
......
......@@ -37,6 +37,7 @@
#include <KActionCollection>
#include <KHelpClient>
#include <KMessageBox>
#include <KHBox>
#include <QFont>
#include <QProcess>
......
......@@ -28,27 +28,39 @@
#include <QVBoxLayout>
#include <QWhatsThis>
#include <QWidget>
#include <KConfigGroup>
#include <QDialogButtonBox>
#include <QPushButton>
using namespace KgpgCore;
KgpgKeyGenerate::KgpgKeyGenerate(QWidget *parent)
: KDialog(parent),
: QDialog(parent),
m_expert(false)
{
setupUi(this);
setButtons(User1 | Ok | Cancel);
setButtonText(User1, i18n("&Expert Mode"));
setButtonToolTip(User1, i18n("Go to Expert Mode"));
setButtonWhatsThis(User1, i18n( "If you go to expert mode, you will use the command line to create your key." ));
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok|QDialogButtonBox::Cancel);
QWidget *mainWidget = new QWidget(this);
QVBoxLayout *mainLayout = new QVBoxLayout;
setLayout(mainLayout);
mainLayout->addWidget(mainWidget);
okButton = buttonBox->button(QDialogButtonBox::Ok);
okButton->setDefault(true);
okButton->setShortcut(Qt::CTRL | Qt::Key_Return);
QPushButton *user1Button = new QPushButton;
buttonBox->addButton(user1Button, QDialogButtonBox::ActionRole);
connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
user1Button->setText(i18n("&Expert Mode"));
user1Button->setToolTip(i18n("Go to Expert Mode"));
user1Button->setWhatsThis(i18n( "If you go to expert mode, you will use the command line to create your key." ));
connect(m_kname, SIGNAL(textChanged(QString)), this, SLOT(slotEnableOk()));
KHBox *hgroup = new KHBox(vgroup);
hgroup->setFrameShape(QFrame::StyledPanel);
hgroup->setMargin(marginHint());
hgroup->setSpacing(spacingHint());
m_days->setParent(hgroup);
QIntValidator *validator = new QIntValidator(m_days);
validator->setBottom(0);
......@@ -84,29 +96,18 @@ KgpgKeyGenerate::KgpgKeyGenerate(QWidget *parent)
slotEnableCaps(m_keykind->currentIndex());
m_keykind->setMinimumSize(m_keykind->sizeHint());
setMainWidget(vgroup);
mainLayout->addWidget(vgroup);
mainLayout->addWidget(buttonBox);
slotEnableOk();
updateGeometry();
show();
connect(this, SIGNAL(okClicked()), this, SLOT(slotOk()));
connect(this, SIGNAL(user1Clicked()), this, SLOT(slotUser1()));
connect(okButton, SIGNAL(clicked()), this, SLOT(slotOk()));
connect(user1Button, SIGNAL(clicked()), this, SLOT(slotUser1()));
connect(m_keykind, SIGNAL(activated(int)), SLOT(slotEnableCaps(int)));
}
void KgpgKeyGenerate::slotButtonClicked(int button)
{
if (button == Ok)
slotOk();
else
if (button == User1)
slotUser1();
else
if (button == Cancel)
reject();
}
void KgpgKeyGenerate::slotOk()
{
if (m_kname->text().simplified().isEmpty())
......@@ -164,7 +165,7 @@ void KgpgKeyGenerate::slotEnableCaps(const int state)
void KgpgKeyGenerate::slotEnableOk()
{
enableButtonOk((m_kname->text().simplified().length() >= 5) &&
okButton->setEnabled((m_kname->text().simplified().length() >= 5) &&
!m_kname->text().simplified().at(0).isDigit());
}
......
......@@ -19,11 +19,12 @@
#include "core/kgpgkey.h"
#include <KDialog>
#include <QDialog>
#include <QPushButton>
class KComboBox;
class KgpgKeyGenerate : public KDialog, public Ui::kgpgKeyGenerate
class KgpgKeyGenerate : public QDialog, public Ui::kgpgKeyGenerate
{
Q_OBJECT
......@@ -48,12 +49,13 @@ public:
private slots:
void slotOk();
void slotUser1();
void slotButtonClicked(int button);
void slotEnableOk();
void slotEnableDays(const int state);
void slotEnableCaps(const int state);
private:
QPushButton *okButton;
KComboBox *m_keyexp;
bool m_expert;
};
......
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>kgpgKeyGenerate</class>
<widget class="KDialog" name="kgpgKeyGenerate">
<widget class="QDialog" name="kgpgKeyGenerate">
<property name="geometry">
<rect>
<x>0</x>
......@@ -183,22 +183,11 @@
</widget>
</widget>
<customwidgets>
<customwidget>
<class>KDialog</class>
<extends>QDialog</extends>
<header>kdialog.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>KComboBox</class>
<extends>QComboBox</extends>
<header>kcombobox.h</header>
</customwidget>
<customwidget>
<class>QLineEdit</class>
<extends>QLineEdit</extends>
<header>klineedit.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
......
......@@ -38,6 +38,7 @@
#include <QTextStream>
#include <QVBoxLayout>
#include <QStandardPaths>
#include <KConfigGroup>
using namespace KgpgCore;
......@@ -221,14 +222,13 @@ void kgpgOptions::slotAddKeyServer()
return;
m_serverModel->setStringList(m_serverModel->stringList() << newServer);
// enableButtonApply(true); FIXME: KF5
settingsChangedSlot();
}
void kgpgOptions::slotChangeEncryptTo()
{
bool enable = (m_page1->encrypt_to_always->isChecked() != m_encrypttoalways);
// enableButtonApply(enable); FIXME: KF5
settingsChangedSlot();
}
void kgpgOptions::slotDelKeyServer()
......@@ -236,7 +236,7 @@ void kgpgOptions::slotDelKeyServer()
QModelIndex cur = m_page6->ServerBox->selectionModel()->currentIndex();
m_serverModel->removeRows(cur.row(), 1);