23 #include <klineedit.h>
24 #include <kurlrequester.h>
25 #include <kprotocolmanager.h>
29 class KonqNameAndUrlInputDialogPrivate
32 KonqNameAndUrlInputDialogPrivate(
KonqNameAndUrlInputDialog* qq) : m_leName(0), m_urlRequester(0), m_fileNameEdited(false), q(qq) {}
35 void _k_slotNameTextChanged(
const QString&);
36 void _k_slotURLTextChanged(
const QString&);
45 KUrlRequester *m_urlRequester;
49 bool m_fileNameEdited;
54 :
KDialog( parent ), d(new KonqNameAndUrlInputDialogPrivate(this))
56 setButtons( Ok | Cancel | User1 );
57 setButtonGuiItem( User1, KStandardGuiItem::clear() );
59 QFrame *plainPage =
new QFrame(
this );
60 setMainWidget( plainPage );
62 QVBoxLayout * topLayout =
new QVBoxLayout( plainPage );
63 topLayout->setMargin( 0 );
64 topLayout->setSpacing( spacingHint() );
67 KHBox * fileNameBox =
new KHBox( plainPage );
68 topLayout->addWidget( fileNameBox );
70 QLabel * label =
new QLabel(nameLabel, fileNameBox);
71 d->m_leName =
new KLineEdit(fileNameBox);
72 d->m_leName->setMinimumWidth(d->m_leName->sizeHint().width() * 3);
73 label->setBuddy(d->m_leName);
74 d->m_leName->setSelection(0, d->m_leName->text().length());
75 connect(d->m_leName, SIGNAL(textChanged(QString)),
76 SLOT(_k_slotNameTextChanged(QString)));
79 KHBox * urlBox =
new KHBox( plainPage );
80 topLayout->addWidget( urlBox );
81 label =
new QLabel(urlLabel, urlBox);
82 d->m_urlRequester =
new KUrlRequester(urlBox);
83 d->m_urlRequester->setStartDir(startDir);
84 d->m_urlRequester->setMode( KFile::File | KFile::Directory );
86 d->m_urlRequester->setMinimumWidth( d->m_urlRequester->sizeHint().width() * 3 );
87 connect(d->m_urlRequester->lineEdit(), SIGNAL(textChanged(QString)),
88 SLOT(_k_slotURLTextChanged(QString)));
89 label->setBuddy(d->m_urlRequester);
91 connect(
this, SIGNAL(user1Clicked()),
this, SLOT(_k_slotClear()));
92 d->m_fileNameEdited =
false;
102 if ( result() == QDialog::Accepted ) {
103 return d->m_urlRequester->url();
111 if ( result() == QDialog::Accepted )
112 return d->m_leName->text();
117 void KonqNameAndUrlInputDialogPrivate::_k_slotClear()
120 m_urlRequester->clear();
121 m_fileNameEdited =
false;
124 void KonqNameAndUrlInputDialogPrivate::_k_slotNameTextChanged(
const QString& )
126 m_fileNameEdited =
true;
127 q->enableButtonOk(!m_leName->text().isEmpty() && !m_urlRequester->url().isEmpty());
130 void KonqNameAndUrlInputDialogPrivate::_k_slotURLTextChanged(
const QString& )
132 if (!m_fileNameEdited) {
136 KUrl url( m_urlRequester->url() );
137 if (KProtocolManager::supportsListing(url) && !url.fileName().isEmpty())
138 m_leName->setText( url.fileName() );
140 m_leName->setText( url.url() );
141 m_fileNameEdited =
false;
143 q->enableButtonOk(!m_leName->text().isEmpty() && !m_urlRequester->url().isEmpty());
148 d->m_leName->setText(name);
149 d->m_urlRequester->setFocus();
154 d->m_urlRequester->setUrl(url);
157 #include "konq_nameandurlinputdialog.moc"