X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fqtui%2Fsettingspages%2Fidentityeditwidget.cpp;h=3a2534b67c9a64e6346353988b826fbca0c5b11d;hp=f670753f09097c12e231af4f9ec7222f1ce9939f;hb=3a3e844f9fcfd12235a0086af75ecd503b621ef4;hpb=9fc57dc2c000e80fb8bd746a090e2e8210e1278e diff --git a/src/qtui/settingspages/identityeditwidget.cpp b/src/qtui/settingspages/identityeditwidget.cpp index f670753f..3a2534b6 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-2018 by the Quassel Project * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * @@ -20,25 +20,27 @@ #include "identityeditwidget.h" -#include #include #include #include +#include +#include #include +#include #include "client.h" -#include "iconloader.h" +#include "icon.h" IdentityEditWidget::IdentityEditWidget(QWidget *parent) : QWidget(parent) { ui.setupUi(this); - ui.addNick->setIcon(SmallIcon("list-add")); - ui.deleteNick->setIcon(SmallIcon("edit-delete")); - ui.renameNick->setIcon(SmallIcon("edit-rename")); - ui.nickUp->setIcon(SmallIcon("go-up")); - ui.nickDown->setIcon(SmallIcon("go-down")); + ui.addNick->setIcon(icon::get("list-add")); + ui.deleteNick->setIcon(icon::get("edit-delete")); + ui.renameNick->setIcon(icon::get("edit-rename")); + ui.nickUp->setIcon(icon::get("go-up")); + ui.nickDown->setIcon(icon::get("go-down")); // We need to know whenever the state of input widgets changes... connect(ui.realName, SIGNAL(textEdited(const QString &)), this, SIGNAL(widgetHasChanged())); @@ -78,6 +80,48 @@ IdentityEditWidget::IdentityEditWidget(QWidget *parent) ui.sslCertGroupBox->setAcceptDrops(true); ui.sslCertGroupBox->installEventFilter(this); #endif + + if (Client::isCoreFeatureEnabled(Quassel::Feature::AwayFormatTimestamp)) { + // Core allows formatting %%timestamp%% messages in away strings. Update tooltips. + QString strFormatTooltip; + QTextStream formatTooltip( &strFormatTooltip, QIODevice::WriteOnly ); + formatTooltip << ""; + + // Function to add a row to the tooltip table + auto addRow = [&](const QString& key, const QString& value, bool condition) { + if (condition) { + formatTooltip << "" + << key << "" << value << ""; + } + }; + + // Original tooltip goes here + formatTooltip << "

%1

"; + // New timestamp formatting guide here + formatTooltip << "

" << tr("You can add date/time to this message " + "using the syntax: " + "
%%<format>%%, where " + "<format> is:") << "

"; + formatTooltip << ""; + addRow("hh", tr("the hour"), true); + addRow("mm", tr("the minutes"), true); + addRow("ss", tr("seconds"), true); + addRow("AP", tr("AM/PM"), true); + addRow("dd", tr("day"), true); + addRow("MM", tr("month"), true); + addRow("t", tr("current timezone"), true); + formatTooltip << "
"; + formatTooltip << "

" << tr("Example: Away since %%hh:mm%% on %%dd.MM%%.") << "

"; + formatTooltip << "

" << tr("%%%% without anything inside represents %%. Other format " + "codes are available.") << "

"; + formatTooltip << "
"; + + // Split up the message to allow re-using translations: + // [Original tool-tip] [Timestamp format message] + ui.awayReason->setToolTip(strFormatTooltip.arg(ui.awayReason->toolTip())); + ui.detachAwayEnabled->setToolTip(strFormatTooltip.arg(ui.detachAwayEnabled->toolTip())); + } // else: Do nothing, leave the original translated string } @@ -299,7 +343,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 +361,7 @@ 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"), QStandardPaths::writableLocation(QStandardPaths::HomeLocation))); showKeyState(key); emit widgetHasChanged(); @@ -334,13 +378,19 @@ QSslKey IdentityEditWidget::keyByFilename(const QString &filename) keyFile.close(); for (int i = 0; i < 2; i++) { - for (int j = 0; j < 2; j++) { + // On Qt5.5+, support QSsl::KeyAlgorithm::Rsa (1), QSsl::KeyAlgorithm::Dsa (2), and QSsl::KeyAlgorithm::Ec (3) + for (int j = 1; j < 4; j++) { key = QSslKey(keyRaw, (QSsl::KeyAlgorithm)j, (QSsl::EncodingFormat)i); if (!key.isNull()) 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: + if(!key.isNull() && key.algorithm() == QSsl::KeyAlgorithm::Ec && !Client::isCoreFeatureEnabled(Quassel::Feature::EcdsaCertfpKeys)) { + QMessageBox::information(this, tr("Core does not support ECDSA keys"), tr("You loaded an ECDSA key, but the core does not support ECDSA keys. Please contact the core administrator.")); + key.clear(); + } return key; } @@ -356,11 +406,14 @@ void IdentityEditWidget::showKeyState(const QSslKey &key) case QSsl::Rsa: ui.keyTypeLabel->setText(tr("RSA")); break; + case QSsl::Ec: + ui.keyTypeLabel->setText(tr("ECDSA")); + break; case QSsl::Dsa: ui.keyTypeLabel->setText(tr("DSA")); break; default: - ui.keyTypeLabel->setText(tr("No Key loaded")); + ui.keyTypeLabel->setText(tr("Invalid key or no key loaded")); } ui.clearOrLoadKeyButton->setText(tr("Clear")); } @@ -374,8 +427,7 @@ 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"), QStandardPaths::writableLocation(QStandardPaths::HomeLocation))); showCertState(cert); emit widgetHasChanged(); } @@ -391,7 +443,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 +452,14 @@ 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 { - ui.certOrgLabel->setText(cert.subjectInfo(QSslCertificate::Organization)); - ui.certCNameLabel->setText(cert.subjectInfo(QSslCertificate::CommonName)); + ui.certOrgLabel->setText(cert.subjectInfo(QSslCertificate::Organization).join(", ")); + ui.certCNameLabel->setText(cert.subjectInfo(QSslCertificate::CommonName).join(", ")); ui.clearOrLoadCertButton->setText(tr("Clear")); } ui.certOrgLabel->setProperty("sslCert", cert.toPem());