Skip to content

Commit

Permalink
12 infinity error message box in kinit (#13)
Browse files Browse the repository at this point in the history
* fix #12
add button for hide/show password

* add highlighting for ticket flags in the legend panel
  • Loading branch information
bas524 authored Jan 1, 2023
1 parent 1ca09cb commit 792732a
Show file tree
Hide file tree
Showing 19 changed files with 1,190 additions and 315 deletions.
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ set(KTW_SRCS
src/keychainclass.cpp
src/KtwOptions.cpp
src/KtwOptions.h
src/pwdialog.cpp
src/pwchangedialog.cpp
src/pwdialog.h
src/pwchangedialog.h
)

# another list, this time it includes all header files that should be treated with moc
Expand Down Expand Up @@ -84,6 +88,8 @@ find_package(Qt5 COMPONENTS Core Widgets Gui Network Keychain REQUIRED)
qt5_wrap_ui(KTW_UI_HDRS ${KTW_UIS} OPTIONS -tr ki18n)
# and finally this will run moc:
qt5_wrap_cpp(KTW_MOC_SRCS ${KTW_MOC_HDRS})
#add resources
qt5_add_resources(KTW_RC_SRCS rc/icons.qrc)

find_package(Gettext REQUIRED)
if (GETTEXT_FOUND)
Expand Down
1 change: 1 addition & 0 deletions rc/eye-close.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions rc/eye.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions rc/icons.qrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<!DOCTYPE RCC><RCC version="1.0">
<qresource>
<file>eye.svg</file>
<file>eye-close.svg</file>
</qresource>
</RCC>
77 changes: 76 additions & 1 deletion src/kinitdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,74 @@

#include "kinitdialog.h"

KinitDialog::KinitDialog(QWidget* parent, const char* name, bool modal, Qt::WindowFlags fl) : QDialog(parent, fl) {
KinitDialog::KinitDialog(QWidget *parent, const char *name, bool modal, Qt::WindowFlags fl)
: QDialog(parent, fl), _icEye(":/eye.svg"), _icClosedEye(":/eye-close.svg") {
setModal(modal);
setAccessibleName(name);
setupUi(this);
changeDetailsState(Qt::Unchecked);
changeRenewState(Qt::Checked);

QSize size32(32, 32);
QList<QSize> qlistSizes = _icClosedEye.availableSizes();
QList<QSize>::const_iterator it =
std::lower_bound(qlistSizes.begin(), qlistSizes.end(), size32, [](const QSize &a, const QSize &b) { return a.width() < b.width(); });
QSize result = (it != qlistSizes.end()) ? *it : size32;

btnShowPwd->setFixedSize(result);
btnShowPwd->setIcon(_icClosedEye);
btnShowPwd->setIconSize(result);

btnShowPwd->setToolTip(ki18n("Show password"));
passwordLineEdit->setEchoMode(QLineEdit::Password);
}

void KinitDialog::errorLabelSetText(const QString &text) { errorLabel->setText(text); }

void KinitDialog::userLineEditSetText(const QString &text) { userLineEdit->setText(text); }

QString KinitDialog::userLineEditText() const { return userLineEdit->text(); }

void KinitDialog::realmLineEditSetText(const QString &text) { realmLineEdit->setText(text); }

QString KinitDialog::realmLineEditText() const { return realmLineEdit->text(); }

void KinitDialog::passwordLineEditSetFocus() { passwordLineEdit->setFocus(); }

QString KinitDialog::passwordLineEditText() { return passwordLineEdit->text(); }

void KinitDialog::forwardCheckBoxSetChecked(bool check) { forwardCheckBox->setChecked(check); }

bool KinitDialog::forwardCheckBoxIsChecked() const { return forwardCheckBox->isChecked(); }

void KinitDialog::proxyCheckBoxSetChecked(bool check) { proxyCheckBox->setChecked(check); }

bool KinitDialog::proxyCheckBoxIsChecked() const { return proxyCheckBox->isChecked(); }

void KinitDialog::lifetimeSpinBoxSetValue(int v) { lifetimeSpinBox->setValue(v); }

void KinitDialog::lifetimeUnitComboBoxSetCurrentText(const QString &text) {
int index = lifetimeUnitComboBox->findText(text);
lifetimeUnitComboBox->setCurrentIndex(index);
}

QString KinitDialog::lifetimeUnitComboBoxCurrentText() const { return lifetimeUnitComboBox->currentText(); }

void KinitDialog::renewtimeSpinBoxSetValue(int v) { renewtimeSpinBox->setValue(v); }

int KinitDialog::renewtimeSpinBoxValue() const { return renewtimeSpinBox->value(); }

void KinitDialog::renewUnitComboBoxSetCurrentText(const QString &text) {
int index = renewUnitComboBox->findText(text);
renewUnitComboBox->setCurrentIndex(index);
}

QString KinitDialog::renewUnitComboBoxCurrentText() const { return renewUnitComboBox->currentText(); }

void KinitDialog::renewCheckBoxSetChecked(bool check) { renewCheckBox->setChecked(check); }

bool KinitDialog::renewCheckBoxIsChecked() const { return renewCheckBox->isChecked(); }

KinitDialog::~KinitDialog() = default;

void KinitDialog::changeDetailsState(int state) {
Expand All @@ -42,3 +102,18 @@ void KinitDialog::changeRenewState(int state) {
renewUnitComboBox->setEnabled(false);
}
}

void KinitDialog::on_btnShowPwd_clicked() {
switch (passwordLineEdit->echoMode()) {
case QLineEdit::Password:
btnShowPwd->setIcon(_icEye);
passwordLineEdit->setEchoMode(QLineEdit::Normal);
btnShowPwd->setToolTip(ki18n("Hide password"));
break;
default:
btnShowPwd->setIcon(_icClosedEye);
passwordLineEdit->setEchoMode(QLineEdit::Password);
btnShowPwd->setToolTip(ki18n("Show password"));
break;
}
}
53 changes: 25 additions & 28 deletions src/kinitdialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,69 +4,66 @@
#include <QDialog>
#include <QString>
#include <QStringList>

#include "krb5_tw_gettext.h"

#include "ui_kinitdialog.h"

class KinitDialog : public QDialog, private Ui::KinitDialog {
Q_OBJECT

QIcon _icEye;
QIcon _icClosedEye;

public:
explicit KinitDialog(QWidget* parent = nullptr, const char* name = nullptr, bool modal = false, Qt::WindowFlags fl = Qt::WindowType::Widget);
~KinitDialog() override;

void errorLabelSetText(const QString& text) { errorLabel->setText(text); }
void errorLabelSetText(const QString& text);

void userLineEditSetText(const QString& text) { userLineEdit->setText(text); }
void userLineEditSetText(const QString& text);

QString userLineEditText() const { return userLineEdit->text(); }
QString userLineEditText() const;

void realmLineEditSetText(const QString& text) { realmLineEdit->setText(text); }
void realmLineEditSetText(const QString& text);

QString realmLineEditText() const { return realmLineEdit->text(); }
QString realmLineEditText() const;

void passwordLineEditSetFocus() { passwordLineEdit->setFocus(); }
void passwordLineEditSetFocus();

QString passwordLineEditText() { return passwordLineEdit->text(); }
QString passwordLineEditText();

void forwardCheckBoxSetChecked(bool check) { forwardCheckBox->setChecked(check); }
void forwardCheckBoxSetChecked(bool check);

bool forwardCheckBoxIsChecked() const { return forwardCheckBox->isChecked(); }
bool forwardCheckBoxIsChecked() const;

void proxyCheckBoxSetChecked(bool check) { proxyCheckBox->setChecked(check); }
void proxyCheckBoxSetChecked(bool check);

bool proxyCheckBoxIsChecked() const { return proxyCheckBox->isChecked(); }
bool proxyCheckBoxIsChecked() const;

void lifetimeSpinBoxSetValue(int v) { lifetimeSpinBox->setValue(v); }
void lifetimeSpinBoxSetValue(int v);

int lifetimeSpinBoxValue() const { return lifetimeSpinBox->value(); }

void lifetimeUnitComboBoxSetCurrentText(const QString& text) {
int index = lifetimeUnitComboBox->findText(text);
lifetimeUnitComboBox->setCurrentIndex(index);
}
void lifetimeUnitComboBoxSetCurrentText(const QString& text);

QString lifetimeUnitComboBoxCurrentText() const { return lifetimeUnitComboBox->currentText(); }
QString lifetimeUnitComboBoxCurrentText() const;

void renewtimeSpinBoxSetValue(int v) { renewtimeSpinBox->setValue(v); }
void renewtimeSpinBoxSetValue(int v);

int renewtimeSpinBoxValue() const { return renewtimeSpinBox->value(); }
int renewtimeSpinBoxValue() const;

void renewUnitComboBoxSetCurrentText(const QString& text) {
int index = renewUnitComboBox->findText(text);
renewUnitComboBox->setCurrentIndex(index);
}
void renewUnitComboBoxSetCurrentText(const QString& text);

QString renewUnitComboBoxCurrentText() const { return renewUnitComboBox->currentText(); }
QString renewUnitComboBoxCurrentText() const;

void renewCheckBoxSetChecked(bool check) { renewCheckBox->setChecked(check); }
void renewCheckBoxSetChecked(bool check);

bool renewCheckBoxIsChecked() const { return renewCheckBox->isChecked(); }
bool renewCheckBoxIsChecked() const;

public slots:
void changeDetailsState(int state);
void changeRenewState(int state);
private slots:
void on_btnShowPwd_clicked();
};

#endif
Loading

0 comments on commit 792732a

Please sign in to comment.