mirror of
https://bitbucket.org/smil3y/kdelibs.git
synced 2025-02-23 18:32:49 +00:00
kdeui: format and indent
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
b5b1741ca5
commit
b3eee3d695
2 changed files with 118 additions and 124 deletions
|
@ -41,10 +41,11 @@ class KPasswordDialog::KPasswordDialogPrivate
|
|||
public:
|
||||
KPasswordDialogPrivate(KPasswordDialog *q)
|
||||
: q(q),
|
||||
userEditCombo(0),
|
||||
pixmapWidget(0),
|
||||
userEditCombo(nullptr),
|
||||
pixmapWidget(nullptr),
|
||||
commentRow(0)
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
void actuallyAccept();
|
||||
void activated(const QString &userName);
|
||||
|
@ -62,14 +63,15 @@ public:
|
|||
};
|
||||
|
||||
KPasswordDialog::KPasswordDialog(QWidget *parent,
|
||||
const KPasswordDialogFlags& flags,
|
||||
const KPasswordDialogFlags flags,
|
||||
const KDialog::ButtonCodes otherButtons)
|
||||
: KDialog( parent ), d(new KPasswordDialogPrivate(this))
|
||||
: KDialog(parent),
|
||||
d(new KPasswordDialogPrivate(this))
|
||||
{
|
||||
setCaption(i18n("Password"));
|
||||
setWindowIcon(KIcon("dialog-password"));
|
||||
setButtons( Ok | Cancel | otherButtons );
|
||||
setDefaultButton( Ok );
|
||||
setButtons(KDialog::Ok | KDialog::Cancel | otherButtons);
|
||||
setDefaultButton(KDialog::Ok);
|
||||
d->m_flags = flags;
|
||||
d->init();
|
||||
}
|
||||
|
@ -105,14 +107,12 @@ void KPasswordDialog::KPasswordDialogPrivate::init()
|
|||
ui.credentialsGroup->setFocusProxy(ui.passEdit);
|
||||
}
|
||||
|
||||
if ( !( m_flags & KPasswordDialog::ShowAnonymousLoginCheckBox ) )
|
||||
{
|
||||
if (!(m_flags & KPasswordDialog::ShowAnonymousLoginCheckBox)) {
|
||||
ui.anonymousRadioButton->hide();
|
||||
ui.usePasswordButton->hide();
|
||||
}
|
||||
|
||||
if ( !( m_flags & KPasswordDialog::ShowKeepPassword ) )
|
||||
{
|
||||
if (!(m_flags & KPasswordDialog::ShowKeepPassword)) {
|
||||
ui.keepCheckBox->hide();
|
||||
}
|
||||
|
||||
|
@ -125,8 +125,7 @@ void KPasswordDialog::KPasswordDialogPrivate::init()
|
|||
|
||||
void KPasswordDialog::setPixmap(const QPixmap &pixmap)
|
||||
{
|
||||
if ( !d->pixmapWidget )
|
||||
{
|
||||
if (!d->pixmapWidget) {
|
||||
d->pixmapWidget = new KPixmapWidget(mainWidget());
|
||||
d->pixmapWidget->setAlignment(Qt::AlignLeft | Qt::AlignTop);
|
||||
d->ui.hboxLayout->insertWidget(0, d->pixmapWidget);
|
||||
|
@ -140,25 +139,21 @@ QPixmap KPasswordDialog::pixmap() const
|
|||
if (!d->pixmapWidget ) {
|
||||
return QPixmap();
|
||||
}
|
||||
|
||||
return d->pixmapWidget->pixmap();
|
||||
}
|
||||
|
||||
|
||||
void KPasswordDialog::setUsername(const QString &user)
|
||||
{
|
||||
d->ui.userEdit->setText(user);
|
||||
if ( user.isEmpty() )
|
||||
if (user.isEmpty()) {
|
||||
return;
|
||||
|
||||
}
|
||||
d->activated(user);
|
||||
if ( d->ui.userEdit->isVisibleTo( this ) )
|
||||
{
|
||||
if (d->ui.userEdit->isVisibleTo(this)) {
|
||||
d->ui.passEdit->setFocus();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
QString KPasswordDialog::username() const
|
||||
{
|
||||
return d->ui.userEdit->text();
|
||||
|
@ -179,7 +174,6 @@ void KPasswordDialog::setAnonymousMode(bool anonymous)
|
|||
d->ui.usePasswordButton->setVisible(true);
|
||||
d->ui.usePasswordButton->setEnabled(false);
|
||||
}
|
||||
|
||||
d->ui.anonymousRadioButton->setChecked(anonymous);
|
||||
}
|
||||
|
||||
|
@ -188,7 +182,6 @@ bool KPasswordDialog::anonymousMode() const
|
|||
return d->ui.anonymousRadioButton->isChecked();
|
||||
}
|
||||
|
||||
|
||||
void KPasswordDialog::setKeepPassword(bool b)
|
||||
{
|
||||
d->ui.keepCheckBox->setChecked(b);
|
||||
|
@ -199,10 +192,12 @@ bool KPasswordDialog::keepPassword() const
|
|||
return d->ui.keepCheckBox->isChecked();
|
||||
}
|
||||
|
||||
void KPasswordDialog::addCommentLine( const QString& label,
|
||||
const QString& comment )
|
||||
void KPasswordDialog::addCommentLine(const QString &label, const QString &comment)
|
||||
{
|
||||
int gridMarginLeft, gridMarginTop, gridMarginRight, gridMarginBottom;
|
||||
int gridMarginLeft = 0;
|
||||
int gridMarginTop = 0;
|
||||
int gridMarginRight = 0;
|
||||
int gridMarginBottom = 0;
|
||||
d->ui.formLayout->getContentsMargins(&gridMarginLeft, &gridMarginTop, &gridMarginRight, &gridMarginBottom);
|
||||
|
||||
int spacing = d->ui.formLayout->horizontalSpacing();
|
||||
|
@ -248,29 +243,32 @@ void KPasswordDialog::showErrorMessage( const QString& message, const ErrorType
|
|||
QFont bold = font();
|
||||
bold.setBold( true );
|
||||
switch (type) {
|
||||
case PasswordError:
|
||||
case KPasswordDialog::PasswordError: {
|
||||
d->ui.passwordLabel->setFont(bold);
|
||||
d->ui.passEdit->clear();
|
||||
d->ui.passEdit->setFocus();
|
||||
break;
|
||||
case UsernameError:
|
||||
if ( d->ui.userEdit->isVisibleTo( this ) )
|
||||
{
|
||||
}
|
||||
case KPasswordDialog::UsernameError: {
|
||||
if (d->ui.userEdit->isVisibleTo(this)) {
|
||||
d->ui.userNameLabel->setFont(bold);
|
||||
d->ui.userEdit->setFocus();
|
||||
}
|
||||
break;
|
||||
case FatalError:
|
||||
}
|
||||
case KPasswordDialog::FatalError: {
|
||||
d->ui.userNameLabel->setEnabled(false);
|
||||
d->ui.userEdit->setEnabled(false);
|
||||
d->ui.passwordLabel->setEnabled(false);
|
||||
d->ui.passEdit->setEnabled(false);
|
||||
d->ui.keepCheckBox->setEnabled(false);
|
||||
enableButton( Ok, false );
|
||||
enableButton(KDialog::Ok, false);
|
||||
break;
|
||||
default:
|
||||
}
|
||||
default: {
|
||||
break;
|
||||
}
|
||||
}
|
||||
adjustSize();
|
||||
}
|
||||
|
||||
|
@ -294,7 +292,6 @@ void KPasswordDialog::setPassword(const QString &p)
|
|||
void KPasswordDialog::setUsernameReadOnly(bool readOnly)
|
||||
{
|
||||
d->ui.userEdit->setReadOnly(readOnly);
|
||||
|
||||
if (readOnly && d->ui.userEdit->hasFocus()) {
|
||||
d->ui.passEdit->setFocus();
|
||||
}
|
||||
|
@ -336,8 +333,7 @@ void KPasswordDialog::setKnownLogins( const QMap<QString, QString>& knownLogins
|
|||
d->userEditCombo->addItems( knownLogins.keys() );
|
||||
d->userEditCombo->setFocus();
|
||||
|
||||
connect( d->userEditCombo, SIGNAL(activated(QString)),
|
||||
this, SLOT(activated(QString)) );
|
||||
connect(d->userEditCombo, SIGNAL(activated(QString)), this, SLOT(activated(QString)));
|
||||
}
|
||||
|
||||
void KPasswordDialog::KPasswordDialogPrivate::activated(const QString &userName)
|
||||
|
@ -350,7 +346,9 @@ void KPasswordDialog::KPasswordDialogPrivate::activated( const QString& userName
|
|||
|
||||
void KPasswordDialog::accept()
|
||||
{
|
||||
if (!d->ui.errorMessage->isHidden()) d->ui.errorMessage->setText( QString() );
|
||||
if (!d->ui.errorMessage->isHidden()) {
|
||||
d->ui.errorMessage->setText(QString());
|
||||
}
|
||||
|
||||
// reset the font in case we had an error previously
|
||||
if (!d->ui.passwordLabel->isHidden()) {
|
||||
|
@ -358,19 +356,17 @@ void KPasswordDialog::accept()
|
|||
d->ui.userNameLabel->setFont(font());
|
||||
}
|
||||
|
||||
// we do this to allow the error message, if any, to go away
|
||||
// checkPassword() may block for a period of time
|
||||
// allow the error message, if any, to go away. checkPassword() may block for a period of time
|
||||
QTimer::singleShot(0, this, SLOT(actuallyAccept()));
|
||||
}
|
||||
|
||||
void KPasswordDialog::KPasswordDialogPrivate::actuallyAccept()
|
||||
{
|
||||
if ( !q->checkPassword() )
|
||||
{
|
||||
if (!q->checkPassword()) {
|
||||
return;
|
||||
}
|
||||
|
||||
bool keep = ui.keepCheckBox->isVisibleTo( q ) && ui.keepCheckBox->isChecked();
|
||||
bool keep = (ui.keepCheckBox->isVisibleTo(q) && ui.keepCheckBox->isChecked());
|
||||
emit q->gotPassword(q->password(), keep);
|
||||
|
||||
if (ui.userEdit->isVisibleTo(q)) {
|
||||
|
|
|
@ -55,9 +55,7 @@
|
|||
class KDEUI_EXPORT KPasswordDialog : public KDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
enum KPasswordDialogFlag
|
||||
{
|
||||
NoFlags = 0x00,
|
||||
|
@ -112,9 +110,9 @@ public:
|
|||
* Useful for adding application-specific buttons like
|
||||
* "ignore" or "skip".
|
||||
*/
|
||||
explicit KPasswordDialog( QWidget *parent = 0L,
|
||||
const KPasswordDialogFlags& flags = 0,
|
||||
const KDialog::ButtonCodes otherButtons = 0);
|
||||
explicit KPasswordDialog(QWidget *parent = nullptr,
|
||||
const KPasswordDialogFlags flags = NoFlags,
|
||||
const KDialog::ButtonCodes otherButtons = KDialog::None);
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
|
@ -169,7 +167,7 @@ public:
|
|||
/**
|
||||
* set the default username.
|
||||
*/
|
||||
void setUsername(const QString&);
|
||||
void setUsername(const QString &user);
|
||||
|
||||
/**
|
||||
* Returns the username entered by the user.
|
||||
|
|
Loading…
Add table
Reference in a new issue