X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fqtui%2Fsettingspages%2Fidentityeditwidget.cpp;h=f9b30408faf5c380b007e0812eabd68e686d5bc3;hp=f670753f09097c12e231af4f9ec7222f1ce9939f;hb=7782e88e931f13f15101b4b7fdfff0b9ffb4d980;hpb=04315f46a16fc3627218377071e008b6b9744992 diff --git a/src/qtui/settingspages/identityeditwidget.cpp b/src/qtui/settingspages/identityeditwidget.cpp index f670753f..f9b30408 100644 --- a/src/qtui/settingspages/identityeditwidget.cpp +++ b/src/qtui/settingspages/identityeditwidget.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005-2013 by the Quassel Project * + * Copyright (C) 2005-2014 by the Quassel Project * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * @@ -20,11 +20,17 @@ #include "identityeditwidget.h" -#include #include #include #include #include +#include + +#if QT_VERSION < 0x050000 +# include +#else +# include +#endif #include "client.h" #include "iconloader.h" @@ -299,7 +305,7 @@ void IdentityEditWidget::sslDropEvent(QDropEvent *event, bool isCert) if (isCert) { QSslCertificate cert = certByFilename(filename); - if (cert.isValid()) + if (!cert.isNull()) showCertState(cert); } else { @@ -317,7 +323,12 @@ void IdentityEditWidget::on_clearOrLoadKeyButton_clicked() QSslKey key; if (ui.keyTypeLabel->property("sslKey").toByteArray().isEmpty()) - key = keyByFilename(QFileDialog::getOpenFileName(this, tr("Load a Key"), QDesktopServices::storageLocation(QDesktopServices::HomeLocation))); + key = keyByFilename(QFileDialog::getOpenFileName(this, tr("Load a Key"), +#if QT_VERSION < 0x050000 + QDesktopServices::storageLocation(QDesktopServices::HomeLocation))); +#else + QStandardPaths::writableLocation(QStandardPaths::HomeLocation))); +#endif showKeyState(key); emit widgetHasChanged(); @@ -340,6 +351,7 @@ QSslKey IdentityEditWidget::keyByFilename(const QString &filename) goto returnKey; } } + QMessageBox::information(this, tr("Failed to read key"), tr("Failed to read the key file. It is either incompatible or invalid. Note that the key file must not have a passphrase.")); returnKey: return key; } @@ -374,8 +386,12 @@ void IdentityEditWidget::on_clearOrLoadCertButton_clicked() QSslCertificate cert; if (ui.certOrgLabel->property("sslCert").toByteArray().isEmpty()) - cert = certByFilename(QFileDialog::getOpenFileName(this, tr("Load a Certificate"), QDesktopServices::storageLocation(QDesktopServices::HomeLocation))); - + cert = certByFilename(QFileDialog::getOpenFileName(this, tr("Load a Certificate"), +#if QT_VERSION < 0x050000 + QDesktopServices::storageLocation(QDesktopServices::HomeLocation))); +#else + QStandardPaths::writableLocation(QStandardPaths::HomeLocation))); +#endif showCertState(cert); emit widgetHasChanged(); } @@ -391,7 +407,7 @@ QSslCertificate IdentityEditWidget::certByFilename(const QString &filename) for (int i = 0; i < 2; i++) { cert = QSslCertificate(certRaw, (QSsl::EncodingFormat)i); - if (cert.isValid()) + if (!cert.isNull()) break; } return cert; @@ -400,14 +416,19 @@ QSslCertificate IdentityEditWidget::certByFilename(const QString &filename) void IdentityEditWidget::showCertState(const QSslCertificate &cert) { - if (!cert.isValid()) { + if (cert.isNull()) { ui.certOrgLabel->setText(tr("No Certificate loaded")); ui.certCNameLabel->setText(tr("No Certificate loaded")); ui.clearOrLoadCertButton->setText(tr("Load")); } else { +#if QT_VERSION < 0x050000 ui.certOrgLabel->setText(cert.subjectInfo(QSslCertificate::Organization)); ui.certCNameLabel->setText(cert.subjectInfo(QSslCertificate::CommonName)); +#else + ui.certOrgLabel->setText(cert.subjectInfo(QSslCertificate::Organization).join(", ")); + ui.certCNameLabel->setText(cert.subjectInfo(QSslCertificate::CommonName).join(", ")); +#endif ui.clearOrLoadCertButton->setText(tr("Clear")); } ui.certOrgLabel->setProperty("sslCert", cert.toPem());