]>
cloud.milkyroute.net Git - dolphin.git/blob - src/panels/places/placesitemeditdialog.cpp
1 /***************************************************************************
2 * Copyright (C) 2012 by Peter Penz <peter.penz19@gmail.com> *
4 * Based on KFilePlaceEditDialog from kdelibs: *
5 * Copyright (C) 2001,2002,2003 Carsten Pfeiffer <pfeiffer@kde.org> *
6 * Copyright (C) 2007 Kevin Ottens <ervin@kde.org> * *
8 * This program is free software; you can redistribute it and/or modify *
9 * it under the terms of the GNU General Public License as published by *
10 * the Free Software Foundation; either version 2 of the License, or *
11 * (at your option) any later version. *
13 * This program is distributed in the hope that it will be useful, *
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16 * GNU General Public License for more details. *
18 * You should have received a copy of the GNU General Public License *
19 * along with this program; if not, write to the *
20 * Free Software Foundation, Inc., *
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
22 ***************************************************************************/
24 #include "placesitemeditdialog.h"
27 #include <KComponentData>
29 #include <KIconButton>
33 #include <KUrlRequester>
36 #include <QFormLayout>
37 #include <QVBoxLayout>
39 PlacesItemEditDialog::PlacesItemEditDialog(QWidget
* parent
) :
50 setButtons( Ok
| Cancel
);
55 void PlacesItemEditDialog::setIcon(const QString
& icon
)
60 QString
PlacesItemEditDialog::icon() const
65 void PlacesItemEditDialog::setText(const QString
& text
)
70 QString
PlacesItemEditDialog::text() const
75 void PlacesItemEditDialog::setUrl(const KUrl
& url
)
80 KUrl
PlacesItemEditDialog::url() const
85 void PlacesItemEditDialog::setAllowGlobal(bool allow
)
87 m_allowGlobal
= allow
;
90 bool PlacesItemEditDialog::allowGlobal() const
95 bool PlacesItemEditDialog::event(QEvent
* event
)
97 if (event
->type() == QEvent::Polish
) {
100 return QWidget::event(event
);
103 PlacesItemEditDialog::~PlacesItemEditDialog()
107 void PlacesItemEditDialog::initialize()
109 QWidget
* mainWidget
= new QWidget(this);
110 QVBoxLayout
* vBox
= new QVBoxLayout(mainWidget
);
112 QFormLayout
* formLayout
= new QFormLayout();
113 vBox
->addLayout( formLayout
);
115 m_textEdit
= new KLineEdit(mainWidget
);
116 formLayout
->addRow(i18nc("@label", "Label:"), m_textEdit
);
117 m_textEdit
->setText(m_text
);
118 m_textEdit
->setClickMessage(i18n("Enter descriptive label here"));
120 m_urlEdit
= new KUrlRequester(m_url
.prettyUrl(), mainWidget
);
121 m_urlEdit
->setMode(KFile::Directory
);
122 formLayout
->addRow(i18nc("@label", "Location:"), m_urlEdit
);
123 // Provide room for at least 40 chars (average char width is half of height)
124 m_urlEdit
->setMinimumWidth(m_urlEdit
->fontMetrics().height() * (40 / 2));
126 m_iconButton
= new KIconButton(mainWidget
);
127 formLayout
->addRow(i18nc("@label", "Choose an icon:"), m_iconButton
);
128 m_iconButton
->setIconSize(KIconLoader::SizeLarge
);
129 m_iconButton
->setIconType(KIconLoader::NoGroup
, KIconLoader::Place
);
130 if (m_icon
.isEmpty()) {
131 m_iconButton
->setIcon(KMimeType::iconNameForUrl(m_url
));
133 m_iconButton
->setIcon(m_icon
);
138 if (KGlobal::mainComponent().aboutData()) {
139 appName
= KGlobal::mainComponent().aboutData()->programName();
141 if (appName
.isEmpty()) {
142 appName
= KGlobal::mainComponent().componentName();
144 m_appLocal
= new QCheckBox( i18n("&Only show when using this application (%1)", appName
), mainWidget
);
145 m_appLocal
->setChecked(false);
146 vBox
->addWidget(m_appLocal
);
149 if (m_text
.isEmpty()) {
150 m_urlEdit
->setFocus();
152 m_textEdit
->setFocus();
155 setMainWidget( mainWidget
);
158 #include "placesitemeditdialog.moc"