You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
150 lines
4.1 KiB
150 lines
4.1 KiB
15 years ago
|
/**
|
||
|
* Copyright (c) 2001 Dawit Alemayehu <adawit@kde.org>
|
||
|
*
|
||
|
* This program is free software; you can redistribute it and/or modify
|
||
|
* it under the terms of the GNU General Public License as published by
|
||
|
* the Free Software Foundation; either version 2 of the License, or
|
||
|
* (at your option) any later version.
|
||
|
*
|
||
|
* 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.
|
||
|
*/
|
||
|
|
||
15 years ago
|
#include <tqlabel.h>
|
||
13 years ago
|
#include <tqlayout.h>
|
||
15 years ago
|
#include <tqlistbox.h>
|
||
|
#include <tqwhatsthis.h>
|
||
|
#include <tqpushbutton.h>
|
||
15 years ago
|
|
||
|
#include <kdebug.h>
|
||
|
#include <klocale.h>
|
||
|
#include <kcombobox.h>
|
||
|
#include <klineedit.h>
|
||
|
#include <kurllabel.h>
|
||
|
|
||
|
#include "fakeuaprovider.h"
|
||
|
#include "uagentproviderdlg.h"
|
||
|
#include "uagentproviderdlg_ui.h"
|
||
|
|
||
15 years ago
|
UALineEdit::UALineEdit( TQWidget *parent, const char *name )
|
||
15 years ago
|
:KLineEdit( parent, name )
|
||
|
{
|
||
|
// For now do not accept any drops since they might contain
|
||
|
// characters we do not accept.
|
||
|
// TODO: Re-implement ::dropEvent to allow acceptable formats...
|
||
|
setAcceptDrops( false );
|
||
|
}
|
||
|
|
||
15 years ago
|
void UALineEdit::keyPressEvent( TQKeyEvent* e )
|
||
15 years ago
|
{
|
||
|
int key = e->key();
|
||
15 years ago
|
TQString keycode = e->text();
|
||
15 years ago
|
if ( (key >= Qt::Key_Escape && key <= Qt::Key_Help) || key == Qt::Key_Period ||
|
||
|
(cursorPosition() > 0 && key == Qt::Key_Minus) ||
|
||
13 years ago
|
(!keycode.isEmpty() && keycode.unicode()->isLetterOrNumber()) )
|
||
15 years ago
|
{
|
||
|
KLineEdit::keyPressEvent(e);
|
||
|
return;
|
||
|
}
|
||
|
e->accept();
|
||
|
}
|
||
|
|
||
15 years ago
|
UAProviderDlg::UAProviderDlg( const TQString& caption, TQWidget *parent,
|
||
15 years ago
|
FakeUASProvider* provider, const char *name )
|
||
|
:KDialog(parent, name, true), m_provider(provider)
|
||
|
{
|
||
|
setCaption ( caption );
|
||
|
|
||
15 years ago
|
TQVBoxLayout* mainLayout = new TQVBoxLayout(this, 0, 0);
|
||
15 years ago
|
|
||
|
dlg = new UAProviderDlgUI (this);
|
||
|
mainLayout->addWidget(dlg);
|
||
|
//dlg->leIdentity->setEnableSqueezedText( true );
|
||
|
|
||
|
if (!m_provider)
|
||
|
{
|
||
|
setEnabled( false );
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
init();
|
||
|
}
|
||
|
|
||
|
UAProviderDlg::~UAProviderDlg()
|
||
|
{
|
||
|
}
|
||
|
|
||
|
void UAProviderDlg::init()
|
||
|
{
|
||
15 years ago
|
connect( dlg->pbOk, TQT_SIGNAL(clicked()), TQT_SLOT(accept()) );
|
||
|
connect( dlg->pbCancel, TQT_SIGNAL(clicked()), TQT_SLOT(reject()) );
|
||
15 years ago
|
|
||
15 years ago
|
connect( dlg->leSite, TQT_SIGNAL(textChanged(const TQString&)),
|
||
|
TQT_SLOT(slotTextChanged( const TQString&)) );
|
||
15 years ago
|
|
||
15 years ago
|
connect( dlg->cbAlias, TQT_SIGNAL(activated(const TQString&)),
|
||
|
TQT_SLOT(slotActivated(const TQString&)) );
|
||
15 years ago
|
|
||
|
dlg->cbAlias->clear();
|
||
|
dlg->cbAlias->insertStringList( m_provider->userAgentAliasList() );
|
||
|
dlg->cbAlias->insertItem( "", 0 );
|
||
|
dlg->cbAlias->listBox()->sort();
|
||
|
|
||
|
dlg->leSite->setFocus();
|
||
|
}
|
||
|
|
||
15 years ago
|
void UAProviderDlg::slotActivated( const TQString& text )
|
||
15 years ago
|
{
|
||
|
if ( text.isEmpty() )
|
||
|
dlg->leIdentity->setText( "" );
|
||
|
else
|
||
|
dlg->leIdentity->setText( m_provider->agentStr(text) );
|
||
|
|
||
|
dlg->pbOk->setEnabled( (!dlg->leSite->text().isEmpty() && !text.isEmpty()) );
|
||
|
}
|
||
|
|
||
15 years ago
|
void UAProviderDlg::slotTextChanged( const TQString& text )
|
||
15 years ago
|
{
|
||
|
dlg->pbOk->setEnabled( (!text.isEmpty() && !dlg->cbAlias->currentText().isEmpty()) );
|
||
|
}
|
||
|
|
||
15 years ago
|
void UAProviderDlg::setSiteName( const TQString& text )
|
||
15 years ago
|
{
|
||
|
dlg->leSite->setText( text );
|
||
|
}
|
||
|
|
||
15 years ago
|
void UAProviderDlg::setIdentity( const TQString& text )
|
||
15 years ago
|
{
|
||
13 years ago
|
int id = dlg->cbAlias->listBox()->index( dlg->cbAlias->listBox()->findItem(text) );
|
||
15 years ago
|
dlg->cbAlias->setCurrentItem( id );
|
||
|
slotActivated( dlg->cbAlias->currentText() );
|
||
|
if ( !dlg->leSite->isEnabled() )
|
||
|
dlg->cbAlias->setFocus();
|
||
|
}
|
||
|
|
||
15 years ago
|
TQString UAProviderDlg::siteName()
|
||
15 years ago
|
{
|
||
15 years ago
|
TQString site_name=dlg->leSite->text().lower();
|
||
15 years ago
|
site_name = site_name.remove( "https://" );
|
||
|
site_name = site_name.remove( "http://" );
|
||
|
return site_name;
|
||
|
}
|
||
|
|
||
15 years ago
|
TQString UAProviderDlg::identity()
|
||
15 years ago
|
{
|
||
|
return dlg->cbAlias->currentText();
|
||
|
}
|
||
|
|
||
15 years ago
|
TQString UAProviderDlg::alias()
|
||
15 years ago
|
{
|
||
|
return dlg->leIdentity->text();
|
||
|
}
|
||
|
|
||
|
#include "uagentproviderdlg.moc"
|