]>
cloud.milkyroute.net Git - dolphin.git/blob - src/editbookmarkdialog.cpp
1 /***************************************************************************
2 * Copyright (C) 2006 by Peter Penz *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19 ***************************************************************************/
21 #include "editbookmarkdialog.h"
24 #include <Q3VBoxLayout>
26 #include <qlineedit.h>
29 #include <kiconloader.h>
30 #include <qpushbutton.h>
32 #include <kfiledialog.h>
33 #include <kicondialog.h>
36 EditBookmarkDialog::~EditBookmarkDialog()
40 KBookmark
EditBookmarkDialog::getBookmark(const QString
& title
,
45 EditBookmarkDialog
dialog(title
, name
, url
, icon
);
47 return dialog
.m_bookmark
;
50 void EditBookmarkDialog::slotOk()
52 m_bookmark
= KBookmark::standaloneBookmark(m_name
->text(),
53 KURL(m_location
->text()),
56 KDialogBase::slotOk();
59 EditBookmarkDialog::EditBookmarkDialog(const QString
& title
,
62 const QString
& icon
) :
63 KDialogBase(Plain
, title
, Ok
|Cancel
, Ok
),
68 Q3VBoxLayout
* topLayout
= new Q3VBoxLayout(plainPage(), 0, spacingHint());
70 Q3Grid
* grid
= new Q3Grid(2, Qt::Horizontal
, plainPage());
71 grid
->setSpacing(spacingHint());
73 // create icon widgets
74 new QLabel(i18n("Icon:"), grid
);
76 m_iconButton
= new QPushButton(SmallIcon(m_iconName
), QString::null
, grid
);
77 m_iconButton
->setSizePolicy(QSizePolicy::Fixed
, QSizePolicy::Fixed
);
78 connect(m_iconButton
, SIGNAL(clicked()),
79 this, SLOT(selectIcon()));
81 // create name widgets
82 new QLabel(i18n("Name:"), grid
);
83 m_name
= new QLineEdit(name
, grid
);
87 // create location widgets
88 new QLabel(i18n("Location:"), grid
);
90 Q3HBox
* locationBox
= new Q3HBox(grid
);
91 locationBox
->setSizePolicy(QSizePolicy::Preferred
, QSizePolicy::Fixed
);
92 locationBox
->setSpacing(spacingHint());
93 m_location
= new QLineEdit(url
.prettyURL(), locationBox
);
94 m_location
->setMinimumWidth(320);
96 QPushButton
* selectLocationButton
= new QPushButton(SmallIcon("folder"), QString::null
, locationBox
);
97 selectLocationButton
->setSizePolicy(QSizePolicy::Fixed
, QSizePolicy::Fixed
);
98 connect(selectLocationButton
, SIGNAL(clicked()),
99 this, SLOT(selectLocation()));
101 topLayout
->addWidget(grid
);
104 void EditBookmarkDialog::selectIcon()
106 const QString
iconName(KIconDialog::getIcon(KIcon::Small
, KIcon::FileSystem
));
107 if (!iconName
.isEmpty()) {
108 m_iconName
= iconName
;
109 m_iconButton
->setIconSet(SmallIcon(iconName
));
113 void EditBookmarkDialog::selectLocation()
115 const QString
location(m_location
->text());
116 KURL
url(KFileDialog::getExistingURL(location
));
117 if (!url
.isEmpty()) {
118 m_location
->setText(url
.prettyURL());
122 #include "editbookmarkdialog.moc"