summaryrefslogtreecommitdiffstats
path: root/kdeprint/management/kmwpassword.cpp
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commitce4a32fe52ef09d8f5ff1dd22c001110902b60a2 (patch)
tree5ac38a06f3dde268dc7927dc155896926aaf7012 /kdeprint/management/kmwpassword.cpp
downloadtdelibs-ce4a32fe52ef09d8f5ff1dd22c001110902b60a2.tar.gz
tdelibs-ce4a32fe52ef09d8f5ff1dd22c001110902b60a2.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdelibs@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kdeprint/management/kmwpassword.cpp')
-rw-r--r--kdeprint/management/kmwpassword.cpp133
1 files changed, 133 insertions, 0 deletions
diff --git a/kdeprint/management/kmwpassword.cpp b/kdeprint/management/kmwpassword.cpp
new file mode 100644
index 000000000..1b67ac6be
--- /dev/null
+++ b/kdeprint/management/kmwpassword.cpp
@@ -0,0 +1,133 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <kdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ **/
+
+#include "kmwpassword.h"
+#include "kmwizard.h"
+#include "kmprinter.h"
+
+#include <qlabel.h>
+#include <qlineedit.h>
+#include <qvbuttongroup.h>
+#include <qradiobutton.h>
+#include <qlayout.h>
+#include <klocale.h>
+#include <kcursor.h>
+
+#include <stdlib.h>
+
+KMWPassword::KMWPassword(QWidget *parent, const char *name)
+: KMWizardPage(parent,name)
+{
+ m_title = i18n("User Identification");
+ m_ID = KMWizard::Password;
+ m_nextpage = KMWizard::SMB;
+
+ // create widgets
+ QLabel *infotext_ = new QLabel(this);
+ infotext_->setText(i18n("<p>This backend may require a login/password to work properly. "
+ "Select the type of access to use and fill in the login and password entries if needed.</p>"));
+ m_login = new QLineEdit(this);
+ m_login->setText(QString::fromLocal8Bit(getenv("USER")));
+ m_password = new QLineEdit(this);
+ m_password->setEchoMode(QLineEdit::Password);
+ QLabel *loginlabel_ = new QLabel(i18n("&Login:"),this);
+ QLabel *passwdlabel_ = new QLabel(i18n("&Password:"),this);
+ m_btngroup = new QVButtonGroup( this );
+ m_btngroup->setFrameStyle( QFrame::NoFrame );
+ QRadioButton *btn1 = new QRadioButton( i18n( "&Anonymous (no login/password)" ), m_btngroup );
+ QRadioButton *btn2 = new QRadioButton( i18n( "&Guest account (login=\"guest\")" ), m_btngroup );
+ QRadioButton *btn3 = new QRadioButton( i18n( "Nor&mal account" ), m_btngroup );
+ btn1->setCursor( KCursor::handCursor() );
+ btn2->setCursor( KCursor::handCursor() );
+ btn3->setCursor( KCursor::handCursor() );
+ m_btngroup->setButton( 0 );
+
+ loginlabel_->setBuddy(m_login);
+ passwdlabel_->setBuddy(m_password);
+
+ m_login->setEnabled(false);
+ m_password->setEnabled(false);
+ connect(btn3,SIGNAL(toggled(bool)),m_login,SLOT(setEnabled(bool)));
+ connect(btn3,SIGNAL(toggled(bool)),m_password,SLOT(setEnabled(bool)));
+
+ // layout
+ QVBoxLayout *main_ = new QVBoxLayout( this, 0, 0 );
+ main_->addWidget( infotext_ );
+ main_->addSpacing( 10 );
+ main_->addWidget( m_btngroup );
+ QGridLayout *l1 = new QGridLayout( 0, 2, 3 );
+ main_->addLayout( l1 );
+ main_->addStretch( 1 );
+ l1->setColSpacing( 0, 35 );
+ l1->setColStretch( 2, 1 );
+ l1->addWidget( loginlabel_, 0, 1 );
+ l1->addWidget( passwdlabel_, 1, 1 );
+ l1->addWidget( m_login, 0, 2 );
+ l1->addWidget( m_password, 1, 2 );
+}
+
+bool KMWPassword::isValid(QString& msg)
+{
+ if ( !m_btngroup->selected() )
+ msg = i18n( "Select one option" );
+ else if (m_btngroup->selectedId() == 2 && m_login->text().isEmpty())
+ msg = i18n("User name is empty.");
+ else
+ return true;
+ return false;
+}
+
+void KMWPassword::initPrinter( KMPrinter* p )
+{
+ /* guest account only for SMB backend */
+ if ( p->option( "kde-backend" ).toInt() != KMWizard::SMB )
+ {
+ int ID = m_btngroup->selectedId();
+ m_btngroup->find( 1 )->hide();
+ if ( ID == 1 )
+ m_btngroup->setButton( 0 );
+ }
+ else
+ m_btngroup->find( 1 )->show();
+}
+
+void KMWPassword::updatePrinter(KMPrinter *p)
+{
+ QString s = p->option("kde-backend");
+ if (!s.isEmpty())
+ setNextPage(s.toInt());
+ else
+ setNextPage(KMWizard::Error);
+ switch ( m_btngroup->selectedId() )
+ {
+ case 0:
+ p->setOption( "kde-login", QString::null );
+ p->setOption( "kde-password", QString::null );
+ break;
+ case 1:
+ p->setOption( "kde-login", QString::fromLatin1( "guest" ) );
+ p->setOption( "kde-password", QString::null );
+ break;
+ case 2:
+ p->setOption( "kde-login", m_login->text() );
+ p->setOption( "kde-password", m_password->text() );
+ break;
+ }
+}
+