]> cloud.milkyroute.net Git - dolphin.git/blob - src/search/searchoptiondialogbox.cpp
Use the member variable
[dolphin.git] / src / search / searchoptiondialogbox.cpp
1 /*****************************************************************************
2 * Copyright (C) 2010 by Laurent Montel <montel@kde.org> *
3 * *
4 * This library is free software; you can redistribute it and/or *
5 * modify it under the terms of the GNU Library General Public *
6 * License version 2 as published by the Free Software Foundation. *
7 * *
8 * This library is distributed in the hope that it will be useful, *
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
11 * Library General Public License for more details. *
12 * *
13 * You should have received a copy of the GNU Library General Public License *
14 * along with this library; see the file COPYING.LIB. If not, write to *
15 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, *
16 * Boston, MA 02110-1301, USA. *
17 *****************************************************************************/
18
19 #include "searchoptiondialogbox.h"
20
21 #include <KConfigGroup>
22 #include <KLineEdit>
23 #include <KLocale>
24 #include <QLabel>
25 #include <QHBoxLayout>
26
27 SearchOptionDialogBox::SearchOptionDialogBox(QWidget* parent) :
28 KDialog(parent, Qt::Dialog)
29 {
30 QWidget* container = new QWidget(this);
31
32 QLabel* label = new QLabel(i18nc("@label", "Name:"), container);
33 mLineEdit = new KLineEdit(container);
34 mLineEdit->setMinimumWidth(250);
35 mLineEdit->setClearButtonShown(true);
36
37 connect(mLineEdit, SIGNAL(textChanged(const QString&)), SLOT(slotTextChanged(const QString&)));
38 QHBoxLayout* layout = new QHBoxLayout(container);
39 layout->addWidget(label, Qt::AlignRight);
40 layout->addWidget(mLineEdit);
41
42 setMainWidget(container);
43 setCaption(i18nc("@title:window", "Save Search Options"));
44 setButtons(KDialog::Ok | KDialog::Cancel);
45 setDefaultButton(KDialog::Ok);
46 setButtonText(KDialog::Ok, i18nc("@action:button", "Save"));
47
48 KConfigGroup dialogConfig(KSharedConfig::openConfig("dolphinrc"),
49 "SaveSearchOptionsDialog");
50 restoreDialogSize(dialogConfig);
51 enableButtonOk(false);
52 }
53
54 SearchOptionDialogBox::~SearchOptionDialogBox()
55 {
56 KConfigGroup dialogConfig(KSharedConfig::openConfig("dolphinrc"),
57 "SaveSearchOptionsDialog");
58 saveDialogSize(dialogConfig);
59 }
60
61 QString SearchOptionDialogBox::text() const
62 {
63 return mLineEdit->text();
64 }
65
66 void SearchOptionDialogBox::slotTextChanged(const QString& text)
67 {
68 enableButtonOk(!text.isEmpty());
69 }
70
71 #include "searchoptiondialogbox.moc"