2
Copyright (c) 2011 Laurent Montel <montel@kde.org>
4
This library is free software; you can redistribute it and/or modify it
5
under the terms of the GNU Library General Public License as published by
6
the Free Software Foundation; either version 2 of the License, or (at your
7
option) any later version.
9
This library is distributed in the hope that it will be useful, but WITHOUT
10
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
12
License for more details.
14
You should have received a copy of the GNU Library General Public License
15
along with this library; see the file COPYING.LIB. If not, write to the
16
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21
#include "renamefavoritedialog.h"
24
#include <KStandardGuiItem>
26
#include <QVBoxLayout>
28
RenameFavoriteDialog::RenameFavoriteDialog(const QString& caption, const QString& text, const QString& value, const QString& defaultName, QWidget *parent )
30
m_defaultName( defaultName )
33
setButtons(Ok | Cancel | User1);
34
setButtonGuiItem(User1, KGuiItem(i18n("Default Name")));
38
QWidget *frame = new QWidget(this);
39
QVBoxLayout *layout = new QVBoxLayout(frame);
42
m_label = new QLabel(text, frame);
43
m_label->setWordWrap(true);
44
layout->addWidget(m_label);
46
m_lineEdit = new KLineEdit(value, frame);
47
m_lineEdit->setClearButtonShown(true);
48
layout->addWidget(m_lineEdit);
50
m_lineEdit->setFocus();
51
m_label->setBuddy(m_lineEdit);
55
connect(m_lineEdit, SIGNAL(textChanged(QString)),
56
SLOT(slotEditTextChanged(QString)));
57
connect(this, SIGNAL(user1Clicked()), this, SLOT(slotDefaultName()));
61
slotEditTextChanged(value);
66
RenameFavoriteDialog::~RenameFavoriteDialog()
70
void RenameFavoriteDialog::slotDefaultName()
72
m_lineEdit->setText( m_defaultName );
75
void RenameFavoriteDialog::slotEditTextChanged(const QString& text)
77
enableButton( Ok, !text.trimmed().isEmpty() );
81
QString RenameFavoriteDialog::newName() const
83
return m_lineEdit->text();