27 #include <tqtoolbutton.h>
30 #include <tdefiledialog.h>
31 #include <tdeglobal.h>
32 #include <kiconloader.h>
33 #include <klineedit.h>
34 #include <tdelocale.h>
35 #include <tderecentdocument.h>
37 #include <kurlrequester.h>
39 #include "kurlrequesterdlg.h"
43 const char *name,
bool modal )
44 : KDialogBase( Plain, TQString::null, Ok|Cancel|User1, Ok, parent, name,
45 modal, true, KStdGuiItem::clear() )
47 initDialog(i18n(
"Location:" ), urlName);
51 : KDialogBase( Plain, TQString::null, Ok|Cancel|User1, Ok, parent, name,
52 modal, true, KStdGuiItem::clear() )
54 initDialog(_text, urlName);
61 void KURLRequesterDlg::initDialog(
const TQString &text,
const TQString &urlName)
63 TQVBoxLayout * topLayout =
new TQVBoxLayout( plainPage(), 0,
66 TQLabel * label =
new TQLabel( text , plainPage() );
67 topLayout->addWidget( label );
69 urlRequester_ =
new KURLRequester( urlName, plainPage(),
"urlRequester" );
70 urlRequester_->setMinimumWidth( urlRequester_->sizeHint().width() * 3 );
71 topLayout->addWidget( urlRequester_ );
72 urlRequester_->setFocus();
73 connect( urlRequester_->
lineEdit(), TQ_SIGNAL(textChanged(
const TQString&)),
74 TQ_SLOT(slotTextChanged(
const TQString&)) );
75 bool state = !urlName.isEmpty();
76 enableButtonOK( state );
77 enableButton( KDialogBase::User1, state );
83 connect(
this, TQ_SIGNAL( user1Clicked() ), TQ_SLOT( slotClear() ) );
86 void KURLRequesterDlg::slotTextChanged(
const TQString & text)
88 bool state = !text.stripWhiteSpace().isEmpty();
89 enableButtonOK( state );
90 enableButton( KDialogBase::User1, state );
93 void KURLRequesterDlg::slotClear()
95 urlRequester_->
clear();
100 if ( result() == TQDialog::Accepted )
101 return KURL::fromPathOrURL( urlRequester_->
url() );
108 const TQString& caption)
112 dlg.setCaption(caption.isNull() ? i18n(
"Open") : caption);
130 return urlRequester_;
133 #include "kurlrequesterdlg.moc"
Provides a user (and developer) friendly way to select files and directories.
Dialog in which a user can enter a filename or url.
KFileDialog * fileDialog()
Returns a pointer to the file dialog used by the KURLRequester.
~KURLRequesterDlg()
Destructs the dialog.
static KURL getURL(const TQString &url=TQString::null, TQWidget *parent=0, const TQString &caption=TQString::null)
Creates a modal dialog, executes it and returns the selected URL.
KURLRequesterDlg(const TQString &url, TQWidget *parent, const char *name, bool modal=true)
Constructs a KURLRequesterDlg.
KURL selectedURL() const
Returns the fully qualified filename.
KURLRequester * urlRequester()
Returns a pointer to the KURLRequester.
This class is a widget showing a lineedit and a button, which invokes a filedialog.
virtual KFileDialog * fileDialog() const
void clear()
Clears the lineedit/combobox.
KLineEdit * lineEdit() const
static void add(const KURL &url)
Add a new item to the Recent Document menu.