]>
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 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 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>
37 EditBookmarkDialog::~EditBookmarkDialog()
41 KBookmark
EditBookmarkDialog::getBookmark(const QString
& title
,
46 EditBookmarkDialog
dialog(title
, name
, url
, icon
);
48 return dialog
.m_bookmark
;
51 void EditBookmarkDialog::slotButtonClicked(int button
)
54 m_bookmark
= KBookmark::standaloneBookmark(m_name
->text(),
55 KUrl(m_location
->text()),
59 KDialog::slotButtonClicked(button
);
62 EditBookmarkDialog::EditBookmarkDialog(const QString
& title
,
65 const QString
& icon
) :
72 setButtons(Ok
|Cancel
);
75 QWidget
*page
= new QWidget(this);
78 Q3VBoxLayout
* topLayout
= new Q3VBoxLayout(page
, 0, spacingHint());
80 Q3Grid
* grid
= new Q3Grid(2, Qt::Horizontal
, page
);
81 grid
->setSpacing(spacingHint());
83 // create icon widgets
84 new QLabel(i18n("Icon:"), grid
);
86 m_iconButton
= new QPushButton(SmallIcon(m_iconName
), QString::null
, grid
);
87 m_iconButton
->setSizePolicy(QSizePolicy::Fixed
, QSizePolicy::Fixed
);
88 connect(m_iconButton
, SIGNAL(clicked()),
89 this, SLOT(selectIcon()));
91 // create name widgets
92 new QLabel(i18n("Name:"), grid
);
93 m_name
= new QLineEdit(name
, grid
);
97 // create location widgets
98 new QLabel(i18n("Location:"), grid
);
100 KHBox
* locationBox
= new KHBox(grid
);
101 locationBox
->setSizePolicy(QSizePolicy::Preferred
, QSizePolicy::Fixed
);
102 locationBox
->setSpacing(spacingHint());
103 m_location
= new QLineEdit(url
.prettyUrl(), locationBox
);
104 m_location
->setMinimumWidth(320);
106 QPushButton
* selectLocationButton
= new QPushButton(SmallIcon("folder"), QString::null
, locationBox
);
107 selectLocationButton
->setSizePolicy(QSizePolicy::Fixed
, QSizePolicy::Fixed
);
108 connect(selectLocationButton
, SIGNAL(clicked()),
109 this, SLOT(selectLocation()));
111 topLayout
->addWidget(grid
);
114 void EditBookmarkDialog::selectIcon()
116 const QString
iconName(KIconDialog::getIcon(K3Icon::Small
, K3Icon::FileSystem
));
117 if (!iconName
.isEmpty()) {
118 m_iconName
= iconName
;
119 m_iconButton
->setIconSet(SmallIcon(iconName
));
123 void EditBookmarkDialog::selectLocation()
125 const QString
location(m_location
->text());
126 KUrl
url(KFileDialog::getExistingUrl(location
));
127 if (!url
.isEmpty()) {
128 m_location
->setText(url
.prettyUrl());
132 #include "editbookmarkdialog.moc"