[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-doc-english
Subject: [kde-doc-english] [trojita] src/Gui: GUI: settings: refactor the IMAP page to include an encryption
From: Jan_Kundrát <jkt () flaska ! net>
Date: 2014-02-02 15:32:53
Message-ID: E1W9z2T-0001A2-NN () scm ! kde ! org
[Download RAW message or body]
Git commit d29430e0193c0beb3efa7588b79921a654120f32 by Jan Kundrát, on behalf of \
Danny Rimmer. Committed on 07/01/2014 at 05:21.
Pushed by jkt into branch 'master'.
GUI: settings: refactor the IMAP page to include an encryption dropdown, reworded \
text
REVIEW: 114878
M +71 -65 src/Gui/SettingsDialog.cpp
M +3 -1 src/Gui/SettingsDialog.h
M +79 -98 src/Gui/SettingsImapPage.ui
http://commits.kde.org/trojita/d29430e0193c0beb3efa7588b79921a654120f32
diff --git a/src/Gui/SettingsDialog.cpp b/src/Gui/SettingsDialog.cpp
index 29da8ef..3971f17 100644
--- a/src/Gui/SettingsDialog.cpp
+++ b/src/Gui/SettingsDialog.cpp
@@ -308,33 +308,46 @@ void EditIdentity::onReject()
ImapPage::ImapPage(QWidget *parent, QSettings &s): QScrollArea(parent), \
Ui_ImapPage() {
Ui_ImapPage::setupUi(this);
- method->insertItem(0, tr("TCP"), QVariant(TCP));
- method->insertItem(1, tr("SSL"), QVariant(SSL));
- method->insertItem(2, tr("Local Process"), QVariant(PROCESS));
+ method->insertItem(NETWORK, tr("Network Connection"));
+ method->insertItem(PROCESS, tr("Local Process"));
+
+ encryption->insertItem(NONE, tr("No encryption"));
+ encryption->insertItem(STARTTLS, tr("Use encryption (STARTTLS)"));
+ encryption->insertItem(SSL, tr("Force encryption (TLS)"));
using Common::SettingsNames;
int defaultImapPort = Common::PORT_IMAPS;
+
if (s.value(SettingsNames::imapMethodKey).toString() == \
SettingsNames::methodTCP) {
- method->setCurrentIndex(0);
+ method->setCurrentIndex(NETWORK);
+
+ if (s.value(SettingsNames::imapStartTlsKey,true).toBool())
+ encryption->setCurrentIndex(STARTTLS);
+ else
+ encryption->setCurrentIndex(NONE);
+
defaultImapPort = Common::PORT_IMAP;
} else if (s.value(SettingsNames::imapMethodKey).toString() == \
SettingsNames::methodSSL) {
- method->setCurrentIndex(1);
+ method->setCurrentIndex(NETWORK);
+ encryption->setCurrentIndex(SSL);
} else if (s.value(SettingsNames::imapMethodKey).toString() == \
SettingsNames::methodProcess) {
- method->setCurrentIndex(2);
+ method->setCurrentIndex(PROCESS);
} else {
// Default settings -- let's assume SSL and hope that users who just press \
Cancel will configure when they see // the network error...
- method->setCurrentIndex(1);
+ method->setCurrentIndex(NETWORK);
+ encryption->setCurrentIndex(SSL);
}
imapHost->setText(s.value(SettingsNames::imapHostKey).toString());
imapPort->setText(s.value(SettingsNames::imapPortKey, \
QString::number(defaultImapPort)).toString()); imapPort->setValidator(new \
QIntValidator(1, 65535, this));
connect(imapPort, SIGNAL(textChanged(QString)), this, \
SLOT(maybeShowPortWarning())); + connect(encryption, \
SIGNAL(currentIndexChanged(int)), this, \
SLOT(maybeShowPortWarning()));
connect(method, SIGNAL(currentIndexChanged(int)), this, \
SLOT(maybeShowPortWarning())); + connect(encryption, \
SIGNAL(currentIndexChanged(int)), this, SLOT(changePort())); \
portWarning->setStyleSheet(SettingsDialog::warningStyleSheet); \
passwordWarning->setStyleSheet(SettingsDialog::warningStyleSheet);
connect(imapPass, SIGNAL(textChanged(QString)), this, \
SLOT(maybeShowPasswordWarning()));
- startTls->setChecked(s.value(SettingsNames::imapStartTlsKey, true).toBool());
imapUser->setText(s.value(SettingsNames::imapUserKey).toString());
imapPass->setText(s.value(SettingsNames::imapPassKey).toString());
processPath->setText(s.value(SettingsNames::imapProcessKey).toString());
@@ -343,7 +356,6 @@ ImapPage::ImapPage(QWidget *parent, QSettings &s): \
QScrollArea(parent), Ui_ImapP
imapCapabilitiesBlacklist->setText(s.value(SettingsNames::imapBlacklistedCapabilities).toStringList().join(QLatin1String(" \
")));
m_imapPort = s.value(SettingsNames::imapPortKey, \
QString::number(defaultImapPort)).value<quint16>();
- m_imapStartTls = s.value(SettingsNames::imapStartTlsKey, true).toBool();
connect(method, SIGNAL(currentIndexChanged(int)), this, SLOT(updateWidgets()));
updateWidgets();
@@ -358,51 +370,47 @@ void ImapPage::resizeEvent(QResizeEvent *event)
scrollAreaWidgetContents->adjustSize();
}
+void ImapPage::changePort()
+{
+ imapPort->setText(QString::number(encryption->currentIndex() == SSL ? \
Common::PORT_IMAPS : Common::PORT_IMAP)); +}
+
void ImapPage::updateWidgets()
{
QFormLayout *lay = formLayout;
Q_ASSERT(lay);
- switch (method->itemData(method->currentIndex()).toInt()) {
- case TCP:
- imapHost->setEnabled(true);
- lay->labelForField(imapHost)->setEnabled(true);
- imapPort->setEnabled(true);
+ switch (method->currentIndex()) {
+ case NETWORK:
+ imapHost->setVisible(true);
+ imapPort->setVisible(true);
+ encryption->setVisible(true);
+ lay->labelForField(imapHost)->setVisible(true);
+ lay->labelForField(imapPort)->setVisible(true);
+ lay->labelForField(encryption)->setVisible(true);
+ processPath->setVisible(false);
+ lay->labelForField(processPath)->setVisible(false);
+ break;
+ default:
+ imapHost->setVisible(false);
+ imapPort->setVisible(false);
+ encryption->setVisible(false);
+ lay->labelForField(imapHost)->setVisible(false);
+ lay->labelForField(imapPort)->setVisible(false);
+ lay->labelForField(encryption)->setVisible(false);
+ processPath->setVisible(true);
+ lay->labelForField(processPath)->setVisible(true);
+ }
+
+ switch (encryption->currentIndex()) {
+ case NONE:
+ case STARTTLS:
if (imapPort->text().isEmpty() || imapPort->text() == \
QString::number(Common::PORT_IMAPS)) \
imapPort->setText(QString::number(Common::PORT_IMAP));
- else
- imapPort->setText(QString::number(m_imapPort));
- lay->labelForField(imapPort)->setEnabled(true);
- startTls->setEnabled(true);
- startTls->setChecked(m_imapStartTls);
- lay->labelForField(startTls)->setEnabled(true);
- processPath->setEnabled(false);
- lay->labelForField(processPath)->setEnabled(false);
break;
- case SSL:
- imapHost->setEnabled(true);
- lay->labelForField(imapHost)->setEnabled(true);
- imapPort->setEnabled(true);
+ default:
if (imapPort->text().isEmpty() || imapPort->text() == \
QString::number(Common::PORT_IMAP)) \
imapPort->setText(QString::number(Common::PORT_IMAPS));
- else
- imapPort->setText(QString::number(m_imapPort));
- lay->labelForField(imapPort)->setEnabled(true);
- startTls->setEnabled(false);
- startTls->setChecked(true);
- lay->labelForField(startTls)->setEnabled(false);
- processPath->setEnabled(false);
- lay->labelForField(processPath)->setEnabled(false);
- break;
- default:
- imapHost->setEnabled(false);
- lay->labelForField(imapHost)->setEnabled(false);
- imapPort->setEnabled(false);
- lay->labelForField(imapPort)->setEnabled(false);
- startTls->setEnabled(false);
- lay->labelForField(startTls)->setEnabled(false);
- processPath->setEnabled(true);
- lay->labelForField(processPath)->setEnabled(true);
}
}
@@ -413,25 +421,21 @@ void ImapPage::save(QSettings &s)
s.remove(Common::SettingsNames::imapSslPemPubKey);
}
switch (method->currentIndex()) {
- case TCP:
+ case NETWORK:
if (imapHost->text().isEmpty()) {
s.remove(SettingsNames::imapMethodKey);
- } else {
+ } else if (encryption->currentIndex() == NONE){
s.setValue(SettingsNames::imapMethodKey, SettingsNames::methodTCP);
- }
- s.setValue(SettingsNames::imapHostKey, imapHost->text());
- s.setValue(SettingsNames::imapPortKey, imapPort->text());
- s.setValue(SettingsNames::imapStartTlsKey, startTls->isChecked());
- break;
- case SSL:
- if (imapHost->text().isEmpty()) {
- s.remove(SettingsNames::imapMethodKey);
+ s.setValue(SettingsNames::imapStartTlsKey, false);
+ } else if (encryption->currentIndex() == STARTTLS){
+ s.setValue(SettingsNames::imapMethodKey, SettingsNames::methodTCP);
+ s.setValue(SettingsNames::imapStartTlsKey, true);
} else {
s.setValue(SettingsNames::imapMethodKey, SettingsNames::methodSSL);
+ s.setValue(SettingsNames::imapStartTlsKey, true);
}
s.setValue(SettingsNames::imapHostKey, imapHost->text());
s.setValue(SettingsNames::imapPortKey, imapPort->text());
- s.setValue(SettingsNames::imapStartTlsKey, startTls->isChecked());
break;
default:
if (processPath->text().isEmpty()) {
@@ -456,8 +460,7 @@ QWidget *ImapPage::asWidget()
bool ImapPage::checkValidity() const
{
switch (method->currentIndex()) {
- case TCP:
- case SSL:
+ case NETWORK:
// We don't require the username, and that's on purpose. Some servers \
*could* possibly support PREAUTH :)
if (checkProblemWithEmptyTextField(imapHost, tr("The IMAP server hostname is \
missing here"))) return false;
@@ -480,16 +483,19 @@ void ImapPage::maybeShowPasswordWarning()
void ImapPage::maybeShowPortWarning()
{
- switch (method->currentIndex()) {
- case TCP:
- portWarning->setVisible(imapPort->text() != QLatin1String("143"));
- break;
- case SSL:
- portWarning->setVisible(imapPort->text() != QLatin1String("993"));
- break;
- default:
+ if (method->currentIndex() == PROCESS) {
portWarning->setVisible(false);
+ return;
}
+
+ if (encryption->currentIndex() == SSL) {
+ portWarning->setVisible(imapPort->text() != \
QString::number(Common::PORT_IMAPS)); + portWarning->setText(tr("This port is \
nonstandard. The default port is 993.")); + } else {
+ portWarning->setVisible(imapPort->text() != \
QString::number(Common::PORT_IMAP)); + portWarning->setText(tr("This port is \
nonstandard. The default port is 143.")); + }
+
}
diff --git a/src/Gui/SettingsDialog.h b/src/Gui/SettingsDialog.h
index e398969..f1ed64f 100644
--- a/src/Gui/SettingsDialog.h
+++ b/src/Gui/SettingsDialog.h
@@ -142,7 +142,8 @@ protected:
virtual void resizeEvent(QResizeEvent *event);
private:
- enum { TCP, SSL, PROCESS };
+ enum { NETWORK, PROCESS };
+ enum Encryption { NONE, STARTTLS, SSL };
quint16 m_imapPort;
bool m_imapStartTls;
@@ -150,6 +151,7 @@ private slots:
void updateWidgets();
void maybeShowPasswordWarning();
void maybeShowPortWarning();
+ void changePort();
private:
ImapPage(const ImapPage &); // don't implement
diff --git a/src/Gui/SettingsImapPage.ui b/src/Gui/SettingsImapPage.ui
index dcd0bf1..f9352df 100644
--- a/src/Gui/SettingsImapPage.ui
+++ b/src/Gui/SettingsImapPage.ui
@@ -42,76 +42,26 @@ p, li { white-space: pre-wrap; }
</widget>
</item>
<item row="1" column="0">
- <widget class="QLabel" name="imapHostLabel">
- <property name="text">
- <string>Ser&ver</string>
- </property>
- <property name="buddy">
- <cstring>imapHost</cstring>
- </property>
- </widget>
- </item>
- <item row="2" column="0">
- <widget class="QLabel" name="imapPortLabel">
- <property name="text">
- <string>&Port</string>
- </property>
- <property name="buddy">
- <cstring>imapPort</cstring>
- </property>
- </widget>
- </item>
- <item row="4" column="0">
- <widget class="QLabel" name="startTlsLabel">
- <property name="text">
- <string>Perform S&TARTTLS</string>
- </property>
- <property name="buddy">
- <cstring>startTls</cstring>
- </property>
- </widget>
- </item>
- <item row="5" column="0">
- <widget class="QLabel" name="imapUserLabel">
+ <widget class="QLabel" name="label">
<property name="text">
- <string>&Username</string>
- </property>
- <property name="buddy">
- <cstring>imapUser</cstring>
+ <string>Encryption</string>
</property>
</widget>
</item>
- <item row="6" column="0">
- <widget class="QLabel" name="imapPassLabel">
- <property name="text">
- <string>Pass&word</string>
- </property>
- <property name="buddy">
- <cstring>imapPass</cstring>
- </property>
- </widget>
- </item>
- <item row="8" column="0">
- <widget class="QLabel" name="processPathLabel">
- <property name="text">
- <string>Path to Server &Binary</string>
- </property>
- <property name="buddy">
- <cstring>processPath</cstring>
- </property>
- </widget>
+ <item row="1" column="1">
+ <widget class="QComboBox" name="encryption"/>
</item>
- <item row="9" column="0">
- <widget class="QLabel" name="startOfflineLabel">
+ <item row="2" column="0">
+ <widget class="QLabel" name="imapHostLabel">
<property name="text">
- <string>Start in O&ffline Mode</string>
+ <string>Ser&ver</string>
</property>
<property name="buddy">
- <cstring>startOffline</cstring>
+ <cstring>imapHost</cstring>
</property>
</widget>
</item>
- <item row="1" column="1">
+ <item row="2" column="1">
<widget class="LineEdit" name="imapHost">
<property name="toolTip">
<string>Hostname of the IMAP server</string>
@@ -124,7 +74,17 @@ p, li { white-space: pre-wrap; }
</property>
</widget>
</item>
- <item row="2" column="1">
+ <item row="3" column="0">
+ <widget class="QLabel" name="imapPortLabel">
+ <property name="text">
+ <string>&Port</string>
+ </property>
+ <property name="buddy">
+ <cstring>imapPort</cstring>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="1">
<widget class="LineEdit" name="imapPort">
<property name="toolTip">
<string>Port number of the IMAP server</string>
@@ -134,22 +94,23 @@ p, li { white-space: pre-wrap; }
</property>
</widget>
</item>
- <item row="4" column="1">
- <widget class="QCheckBox" name="startTls">
- <property name="toolTip">
- <string>Transparently upgrade the plaintext connection to an encrypted \
one</string> + <item row="4" column="0" colspan="2">
+ <widget class="QLabel" name="portWarning">
+ <property name="text">
+ <string>This port number looks suspicious. The usual numbers for IMAP are 143 \
(with the TCP connection method or with STARTTLS) and 993 (when using SSL).</string> \
</property>
- <property name="whatsThis">
- <string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" \
"http://www.w3.org/TR/REC-html40/strict.dtd">
-<html><head><meta name="qrichtext" content="1" \
/><style type="text/css">
-p, li { white-space: pre-wrap; }
-</style></head><body style=" font-family:'DejaVu Sans'; \
font-size:8pt; font-weight:400; font-style:normal;">
-<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; \
margin-right:0px; -qt-block-indent:0; text-indent:0px;">Choose this option to \
require that Trojitá performs a STARTTLS operation on the connection to the remote \
IMAP server. This means that it will make sure that while the connection starts in an \
unencrypted mode, it will get &quot;upgraded&quot; to encryption on the \
fly.</p>
-<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; \
margin-left:0px; margin-right:0px; -qt-block-indent:0; \
text-indent:0px;"></p>
-<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; \
margin-right:0px; -qt-block-indent:0; text-indent:0px;">This option is \
enabled only for plain <span style=" \
font-style:italic;">TCP</span> method of connecting to the IMAP server, \
as the <span style=" font-style:italic;">Local process</span> \
doesn't support it and the <span style=" \
font-style:italic;">SSL</span> one is already \
encrypted.</p></body></html></string> + <property \
name="wordWrap"> + <bool>true</bool>
</property>
+ </widget>
+ </item>
+ <item row="5" column="0">
+ <widget class="QLabel" name="imapUserLabel">
<property name="text">
- <string/>
+ <string>&Username</string>
+ </property>
+ <property name="buddy">
+ <cstring>imapUser</cstring>
</property>
</widget>
</item>
@@ -166,6 +127,16 @@ p, li { white-space: pre-wrap; }
</property>
</widget>
</item>
+ <item row="6" column="0">
+ <widget class="QLabel" name="imapPassLabel">
+ <property name="text">
+ <string>Pass&word</string>
+ </property>
+ <property name="buddy">
+ <cstring>imapPass</cstring>
+ </property>
+ </widget>
+ </item>
<item row="6" column="1">
<widget class="LineEdit" name="imapPass">
<property name="toolTip">
@@ -190,6 +161,26 @@ p, li { white-space: pre-wrap; }
</property>
</widget>
</item>
+ <item row="7" column="0" colspan="2">
+ <widget class="QLabel" name="passwordWarning">
+ <property name="text">
+ <string>The password will be stored in plaintext. Leave it blank for Trojitá \
to prompt when needed.</string> + </property>
+ <property name="wordWrap">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="8" column="0">
+ <widget class="QLabel" name="processPathLabel">
+ <property name="text">
+ <string>Path to Server &Binary</string>
+ </property>
+ <property name="buddy">
+ <cstring>processPath</cstring>
+ </property>
+ </widget>
+ </item>
<item row="8" column="1">
<widget class="LineEdit" name="processPath">
<property name="whatsThis">
@@ -206,6 +197,16 @@ p, li { white-space: pre-wrap; }
</property>
</widget>
</item>
+ <item row="9" column="0">
+ <widget class="QLabel" name="startOfflineLabel">
+ <property name="text">
+ <string>Start in O&ffline Mode</string>
+ </property>
+ <property name="buddy">
+ <cstring>startOffline</cstring>
+ </property>
+ </widget>
+ </item>
<item row="9" column="1">
<widget class="QCheckBox" name="startOffline">
<property name="toolTip">
@@ -219,13 +220,13 @@ p, li { white-space: pre-wrap; }
</property>
</widget>
</item>
- <item row="7" column="0" colspan="2">
- <widget class="QLabel" name="passwordWarning">
+ <item row="10" column="0">
+ <widget class="QLabel" name="imapEnableIdLabel">
<property name="text">
- <string>This password will be saved on disk in clear text. If you do not \
enter password here, Trojitá will prompt for one when needed.</string> + \
<string>Reveal I'm using Trojitá</string> </property>
- <property name="wordWrap">
- <bool>true</bool>
+ <property name="buddy">
+ <cstring>imapEnableId</cstring>
</property>
</widget>
</item>
@@ -245,16 +246,6 @@ p, li { white-space: pre-wrap; }
</property>
</widget>
</item>
- <item row="10" column="0">
- <widget class="QLabel" name="imapEnableIdLabel">
- <property name="text">
- <string>Ask for IMAP &ID</string>
- </property>
- <property name="buddy">
- <cstring>imapEnableId</cstring>
- </property>
- </widget>
- </item>
<item row="11" column="0">
<widget class="QLabel" name="imapCapabilitiesBlacklistLabel">
<property name="text">
@@ -268,16 +259,6 @@ p, li { white-space: pre-wrap; }
<item row="11" column="1">
<widget class="LineEdit" name="imapCapabilitiesBlacklist"/>
</item>
- <item row="3" column="0" colspan="2">
- <widget class="QLabel" name="portWarning">
- <property name="text">
- <string>This port number looks suspicious. The usual numbers for IMAP are 143 \
(with the TCP connection method or with STARTTLS) and 993 (when using \
SSL).</string>
- </property>
- <property name="wordWrap">
- <bool>true</bool>
- </property>
- </widget>
- </item>
</layout>
</widget>
</widget>
_______________________________________________
kde-doc-english mailing list
kde-doc-english@kde.org
https://mail.kde.org/mailman/listinfo/kde-doc-english
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic