diff --git a/kdesktop/lock/querydlg.cc b/kdesktop/lock/querydlg.cc new file mode 100644 index 000000000..7bdedf0e8 --- /dev/null +++ b/kdesktop/lock/querydlg.cc @@ -0,0 +1,146 @@ +//=========================================================================== +// +// This file is part of the KDE project +// +// Copyright (c) 2010 Timothy Pearson + +#include + +#include "querydlg.h" + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#ifndef AF_LOCAL +# define AF_LOCAL AF_UNIX +#endif + +//=========================================================================== +// +// Simple dialog for displaying a password/PIN entry dialog +// +QueryDlg::QueryDlg(LockProcess *parent) + : QDialog(parent, "query dialog", true, WX11BypassWM), + mUnlockingFailed(false) +{ + frame = new QFrame( this ); + frame->setFrameStyle( QFrame::Panel | QFrame::Raised ); + frame->setLineWidth( 2 ); + + mpixLabel = new QLabel( frame, "pixlabel" ); + mpixLabel->setPixmap(DesktopIcon("unlock")); + + KUser user; + + mStatusLabel = new QLabel( " ", frame ); + //mStatusLabel->setAlignment( QLabel::AlignCenter ); + mStatusLabel->setAlignment( QLabel::AlignLeft ); + + KSeparator *sep = new KSeparator( KSeparator::HLine, frame ); + + ok = new KPushButton( i18n("Unl&ock"), frame ); + + QVBoxLayout *unlockDialogLayout = new QVBoxLayout( this ); + unlockDialogLayout->addWidget( frame ); + + QHBoxLayout *layStatus = new QHBoxLayout( 0, 0, KDialog::spacingHint()); + layStatus->addWidget( mStatusLabel ); + + QHBoxLayout *layPin = new QHBoxLayout( 0, 0, KDialog::spacingHint()); + pin_box = new KPasswordEdit( this, "pin_box" ); + layPin->addWidget( pin_box ); + pin_box->setFocus(); + + QHBoxLayout *layButtons = new QHBoxLayout( 0, 0, KDialog::spacingHint()); + layButtons->addStretch(); + layButtons->addWidget( ok ); + + frameLayout = new QGridLayout( frame, 1, 1, KDialog::marginHint(), KDialog::spacingHint() ); + frameLayout->addMultiCellWidget( mpixLabel, 0, 2, 0, 0, AlignTop ); + frameLayout->addLayout( layStatus, 0, 1 ); + frameLayout->addLayout( layPin, 2, 1 ); + frameLayout->addMultiCellWidget( sep, 3, 3, 0, 1 ); + frameLayout->addMultiCellLayout( layButtons, 4, 4, 0, 1 ); + + connect(ok, SIGNAL(clicked()), SLOT(slotOK())); + + installEventFilter(this); +} + +QueryDlg::~QueryDlg() +{ + hide(); +} + +void QueryDlg::slotOK() +{ + close(); +} + +const char * QueryDlg::getEntry() +{ + return pin_box->password(); +} + +void QueryDlg::updateLabel(QString &txt) +{ + mStatusLabel->setPaletteForegroundColor(Qt::black); + mStatusLabel->setText("" + txt + ""); +} + +void QueryDlg::setUnlockIcon() +{ + mpixLabel->setPixmap(DesktopIcon("unlock")); +} + +void QueryDlg::setWarningIcon() +{ + mpixLabel->setPixmap(DesktopIcon("messagebox_warning")); +} + +void QueryDlg::show() +{ + QDialog::show(); + QApplication::flushX(); +} + +#include "querydlg.moc" diff --git a/kdesktop/lock/querydlg.h b/kdesktop/lock/querydlg.h new file mode 100644 index 000000000..caf73c180 --- /dev/null +++ b/kdesktop/lock/querydlg.h @@ -0,0 +1,59 @@ +//=========================================================================== +// +// This file is part of the KDE project +// +// Copyright (c) 2010 Timothy Pearson +// + +#ifndef __QUERYDLG_H__ +#define __QUERYDLG_H__ + +#include +#include + +#include + +class QFrame; +class QGridLayout; +class QLabel; +class KPushButton; +class QListView; + +//=========================================================================== +// +// Simple dialog for displaying an query dialog. +// It does not handle password validation. +// +class QueryDlg : public QDialog +{ + Q_OBJECT + +public: + QueryDlg(LockProcess *parent); + ~QueryDlg(); + virtual void show(); + + void updateLabel( QString &txt ); + void setUnlockIcon(); + void setWarningIcon(); + const char * getEntry(); + +private slots: + void slotOK(); + +private: + QFrame *frame; + QGridLayout *frameLayout; + QLabel *mStatusLabel; + QLabel *mpixLabel; + int mCapsLocked; + bool mUnlockingFailed; + QStringList layoutsList; + QStringList::iterator currLayout; + int sPid, sFd; + KPushButton *ok; + KPasswordEdit *pin_box; +}; + +#endif +