1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
|
/**
* 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.
*/
#include <tqlabel.h>
#include <tqlayout.h>
#include <tqlistbox.h>
#include <tqwhatsthis.h>
#include <tqpushbutton.h>
#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"
UALineEdit::UALineEdit( TQWidget *parent, const char *name )
: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 );
}
void UALineEdit::keyPressEvent( TQKeyEvent* e )
{
int key = e->key();
TQString keycode = e->text();
if ( (key >= Qt::Key_Escape && key <= Qt::Key_Help) || key == Qt::Key_Period ||
(cursorPosition() > 0 && key == Qt::Key_Minus) ||
(!keycode.isEmpty() && keycode.unicode()->isLetterOrNumber()) )
{
KLineEdit::keyPressEvent(e);
return;
}
e->accept();
}
UAProviderDlg::UAProviderDlg( const TQString& caption, TQWidget *parent,
FakeUASProvider* provider, const char *name )
:KDialog(parent, name, true), m_provider(provider)
{
setCaption ( caption );
TQVBoxLayout* mainLayout = new TQVBoxLayout(this, 0, 0);
dlg = new UAProviderDlgUI (this);
mainLayout->addWidget(dlg);
//dlg->leIdentity->setEnableSqueezedText( true );
if (!m_provider)
{
setEnabled( false );
return;
}
init();
}
UAProviderDlg::~UAProviderDlg()
{
}
void UAProviderDlg::init()
{
connect( dlg->pbOk, TQT_SIGNAL(clicked()), TQT_SLOT(accept()) );
connect( dlg->pbCancel, TQT_SIGNAL(clicked()), TQT_SLOT(reject()) );
connect( dlg->leSite, TQT_SIGNAL(textChanged(const TQString&)),
TQT_SLOT(slotTextChanged( const TQString&)) );
connect( dlg->cbAlias, TQT_SIGNAL(activated(const TQString&)),
TQT_SLOT(slotActivated(const TQString&)) );
dlg->cbAlias->clear();
dlg->cbAlias->insertStringList( m_provider->userAgentAliasList() );
dlg->cbAlias->insertItem( "", 0 );
dlg->cbAlias->listBox()->sort();
dlg->leSite->setFocus();
}
void UAProviderDlg::slotActivated( const TQString& text )
{
if ( text.isEmpty() )
dlg->leIdentity->setText( "" );
else
dlg->leIdentity->setText( m_provider->agentStr(text) );
dlg->pbOk->setEnabled( (!dlg->leSite->text().isEmpty() && !text.isEmpty()) );
}
void UAProviderDlg::slotTextChanged( const TQString& text )
{
dlg->pbOk->setEnabled( (!text.isEmpty() && !dlg->cbAlias->currentText().isEmpty()) );
}
void UAProviderDlg::setSiteName( const TQString& text )
{
dlg->leSite->setText( text );
}
void UAProviderDlg::setIdentity( const TQString& text )
{
int id = dlg->cbAlias->listBox()->index( dlg->cbAlias->listBox()->findItem(text) );
dlg->cbAlias->setCurrentItem( id );
slotActivated( dlg->cbAlias->currentText() );
if ( !dlg->leSite->isEnabled() )
dlg->cbAlias->setFocus();
}
TQString UAProviderDlg::siteName()
{
TQString site_name=dlg->leSite->text().lower();
site_name = site_name.remove( "https://" );
site_name = site_name.remove( "http://" );
return site_name;
}
TQString UAProviderDlg::identity()
{
return dlg->cbAlias->currentText();
}
TQString UAProviderDlg::alias()
{
return dlg->leIdentity->text();
}
#include "uagentproviderdlg.moc"
|