]>
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::slotButtonClicked(int button
)
53 m_bookmark
= KBookmark::standaloneBookmark(m_name
->text(),
54 KUrl(m_location
->text()),
58 KDialog::slotButtonClicked(button
);
61 EditBookmarkDialog::EditBookmarkDialog(const QString
& title
,
64 const QString
& icon
) :
71 setButtons(Ok
|Cancel
);
74 QWidget
*page
= new QWidget(this);
77 Q3VBoxLayout
* topLayout
= new Q3VBoxLayout(page
, 0, spacingHint());
79 Q3Grid
* grid
= new Q3Grid(2, Qt::Horizontal
, page
);
80 grid
->setSpacing(spacingHint());
82 // create icon widgets
83 new QLabel(i18n("Icon:"), grid
);
85 m_iconButton
= new QPushButton(SmallIcon(m_iconName
), QString::null
, grid
);
86 m_iconButton
->setSizePolicy(QSizePolicy::Fixed
, QSizePolicy::Fixed
);
87 connect(m_iconButton
, SIGNAL(clicked()),
88 this, SLOT(selectIcon()));
90 // create name widgets
91 new QLabel(i18n("Name:"), grid
);
92 m_name
= new QLineEdit(name
, grid
);
96 // create location widgets
97 new QLabel(i18n("Location:"), grid
);
99 Q3HBox
* locationBox
= new Q3HBox(grid
);
100 locationBox
->setSizePolicy(QSizePolicy::Preferred
, QSizePolicy::Fixed
);
101 locationBox
->setSpacing(spacingHint());
102 m_location
= new QLineEdit(url
.prettyUrl(), locationBox
);
103 m_location
->setMinimumWidth(320);
105 QPushButton
* selectLocationButton
= new QPushButton(SmallIcon("folder"), QString::null
, locationBox
);
106 selectLocationButton
->setSizePolicy(QSizePolicy::Fixed
, QSizePolicy::Fixed
);
107 connect(selectLocationButton
, SIGNAL(clicked()),
108 this, SLOT(selectLocation()));
110 topLayout
->addWidget(grid
);
113 void EditBookmarkDialog::selectIcon()
115 const QString
iconName(KIconDialog::getIcon(K3Icon::Small
, K3Icon::FileSystem
));
116 if (!iconName
.isEmpty()) {
117 m_iconName
= iconName
;
118 m_iconButton
->setIconSet(SmallIcon(iconName
));
122 void EditBookmarkDialog::selectLocation()
124 const QString
location(m_location
->text());
125 KUrl
url(KFileDialog::getExistingUrl(location
));
126 if (!url
.isEmpty()) {
127 m_location
->setText(url
.prettyUrl());
131 #include "editbookmarkdialog.moc"