summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMontel Laurent <[email protected]>2017-08-14 06:54:40 +0200
committerMontel Laurent <[email protected]>2017-08-14 06:54:40 +0200
commitec0db5f68809a029bc374bcd4fe1e2336f9e2540 (patch)
treec4372369c511fab9ed466d69b810c06addaef105
parent3acfb2ce64ff2c2aef3a3d5de90f99e11b6689ad (diff)
Use new kpasswordlineedit
-rw-r--r--CMakeLists.txt2
-rw-r--r--src/kmailtransport/plugins/smtp/CMakeLists.txt1
-rw-r--r--src/kmailtransport/plugins/smtp/lineeditpassword.cpp90
-rw-r--r--src/kmailtransport/plugins/smtp/lineeditpassword.h47
-rw-r--r--src/kmailtransport/plugins/smtp/smtpsettings.ui8
5 files changed, 5 insertions, 143 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index ebda8e4..bb9259a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.0)
-set(PIM_VERSION "5.6.40")
+set(PIM_VERSION "5.6.41")
project(MailTransport VERSION ${PIM_VERSION})
diff --git a/src/kmailtransport/plugins/smtp/CMakeLists.txt b/src/kmailtransport/plugins/smtp/CMakeLists.txt
index f378daa..168d6bf 100644
--- a/src/kmailtransport/plugins/smtp/CMakeLists.txt
+++ b/src/kmailtransport/plugins/smtp/CMakeLists.txt
@@ -7,7 +7,6 @@ set(mailtransport_smtpplugin_SRCS
smtpconfigdialog.cpp
smtpjob.cpp
smtpconfigwidget.cpp
- lineeditpassword.cpp
)
qt5_add_resources(mailtransport_smtpplugin_SRCS icons.qrc)
ki18n_wrap_ui(mailtransport_smtpplugin_SRCS
diff --git a/src/kmailtransport/plugins/smtp/lineeditpassword.cpp b/src/kmailtransport/plugins/smtp/lineeditpassword.cpp
deleted file mode 100644
index 14892c9..0000000
--- a/src/kmailtransport/plugins/smtp/lineeditpassword.cpp
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- Copyright (c) 2017 Montel Laurent <[email protected]>
-
- based on lineedit in kpassworddialog.cpp
-
- This program is free software; you can redistribute it and/or modify it
- under the terms of the GNU General Public License, version 2, as
- published by the Free Software Foundation.
-
- This program is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License along
- with this program; if not, write to the Free Software Foundation, Inc.,
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-*/
-
-#include "lineeditpassword.h"
-#include <KLocalizedString>
-#include <QIcon>
-#include <QAction>
-#include <QHBoxLayout>
-#include <QLineEdit>
-
-using namespace MailTransport;
-
-LineEditPassword::LineEditPassword(QWidget *parent)
- : QWidget(parent)
- , mIsToggleEchoModeAvailable(true)
-{
- QHBoxLayout *mainLayout = new QHBoxLayout(this);
- mainLayout->setObjectName(QStringLiteral("mainlayout"));
- mainLayout->setMargin(0);
- mPasswordLineEdit = new QLineEdit(this);
- mPasswordLineEdit->setObjectName(QStringLiteral("passwordlineedit"));
- mPasswordLineEdit->setEchoMode(QLineEdit::Password);
- mainLayout->addWidget(mPasswordLineEdit);
- initialize();
-}
-
-LineEditPassword::~LineEditPassword()
-{
-}
-
-void LineEditPassword::initialize()
-{
- QIcon visibilityIcon = QIcon::fromTheme(QStringLiteral("visibility"), QIcon(QStringLiteral(":/icons/visibility.svg")));
- mToggleEchoModeAction = mPasswordLineEdit->addAction(visibilityIcon, QLineEdit::TrailingPosition);
- mToggleEchoModeAction->setObjectName(QStringLiteral("visibilityAction"));
- mToggleEchoModeAction->setVisible(false);
- mToggleEchoModeAction->setToolTip(i18n("Change the visibility of the password"));
-
- connect(mToggleEchoModeAction, &QAction::triggered, this, &LineEditPassword::toggleEchoMode);
-
- connect(mPasswordLineEdit, &QLineEdit::textChanged, this, &LineEditPassword::showToggleEchoModeAction);
-}
-
-void LineEditPassword::toggleEchoMode()
-{
- if (mPasswordLineEdit->echoMode() == QLineEdit::Password) {
- mPasswordLineEdit->setEchoMode(QLineEdit::Normal);
- mToggleEchoModeAction->setIcon(QIcon::fromTheme(QStringLiteral("hint"), QIcon(QStringLiteral(":/icons/hint.svg"))));
- } else if (mPasswordLineEdit->echoMode() == QLineEdit::Normal) {
- mPasswordLineEdit->setEchoMode(QLineEdit::Password);
- mToggleEchoModeAction->setIcon(QIcon::fromTheme(QStringLiteral("visibility"), QIcon(QStringLiteral(":/icons/visibility.svg"))));
- }
-}
-
-void LineEditPassword::setPassword(const QString &p)
-{
- mIsToggleEchoModeAvailable = p.isEmpty();
- mPasswordLineEdit->setText(p);
-}
-
-QString LineEditPassword::password() const
-{
- return mPasswordLineEdit->text();
-}
-
-void LineEditPassword::showToggleEchoModeAction(const QString &text)
-{
- mToggleEchoModeAction->setVisible(mIsToggleEchoModeAvailable && (mPasswordLineEdit->echoMode() == QLineEdit::Normal || !text.isEmpty()));
-}
-
-QAction *LineEditPassword::toggleEchoModeAction() const
-{
- return mToggleEchoModeAction;
-}
diff --git a/src/kmailtransport/plugins/smtp/lineeditpassword.h b/src/kmailtransport/plugins/smtp/lineeditpassword.h
deleted file mode 100644
index 24efbf0..0000000
--- a/src/kmailtransport/plugins/smtp/lineeditpassword.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- Copyright (c) 2017 Montel Laurent <[email protected]>
-
- This program is free software; you can redistribute it and/or modify it
- under the terms of the GNU General Public License, version 2, as
- published by the Free Software Foundation.
-
- This program is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License along
- with this program; if not, write to the Free Software Foundation, Inc.,
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-*/
-
-#ifndef LINEEDITPASSWORD_H
-#define LINEEDITPASSWORD_H
-
-#include <QWidget>
-
-class QLineEdit;
-class QAction;
-namespace MailTransport {
-class LineEditPassword : public QWidget
-{
-public:
- explicit LineEditPassword(QWidget *parent = nullptr);
- ~LineEditPassword();
-
- void setPassword(const QString &p);
- QString password() const;
-
- QAction *toggleEchoModeAction() const;
-
-private:
- void initialize();
- void toggleEchoMode();
- void showToggleEchoModeAction(const QString &text);
- QLineEdit *mPasswordLineEdit = nullptr;
- QAction *mToggleEchoModeAction = nullptr;
- bool mIsToggleEchoModeAvailable;
-};
-}
-
-#endif // LINEEDITPASSWORD_H
diff --git a/src/kmailtransport/plugins/smtp/smtpsettings.ui b/src/kmailtransport/plugins/smtp/smtpsettings.ui
index 2e93d40..f7a6cb7 100644
--- a/src/kmailtransport/plugins/smtp/smtpsettings.ui
+++ b/src/kmailtransport/plugins/smtp/smtpsettings.ui
@@ -103,7 +103,7 @@
</widget>
</item>
<item row="3" column="1">
- <widget class="MailTransport::LineEditPassword" name="password">
+ <widget class="KPasswordLineEdit" name="password">
</widget>
</item>
<item row="4" column="1">
@@ -396,9 +396,9 @@
<header>klineedit.h</header>
</customwidget>
<customwidget>
- <class>MailTransport::LineEditPassword</class>
- <extends>QLineEdit</extends>
- <header>lineeditpassword.h</header>
+ <class>KPasswordLineEdit</class>
+ <extends>QWidget</extends>
+ <header>kpasswordlineedit.h</header>
</customwidget>
</customwidgets>
<tabstops>