1/* This file is part of the KDE project
2 Copyright 2000 Kurt Granroth <granroth@kde.org>
3 2008 David Faure <faure@kde.org>
4
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public
7 License version 2 or at your option version 3 as published by
8 the Free Software Foundation.
9
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 GNU
13 General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; see the file COPYING. If not, write to
17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
19*/
20
21// Own
22#include "newtypedlg.h"
23
24// Qt
25#include <QBoxLayout>
26#include <QComboBox>
27#include <QFrame>
28#include <QFormLayout>
29#include <QLabel>
30#include <QLayout>
31
32// KDE
33#include <klineedit.h>
34#include <klocale.h>
35
36
37NewTypeDialog::NewTypeDialog(const QStringList &groups, QWidget *parent)
38 : KDialog( parent )
39{
40 setModal( true );
41 setCaption( i18n( "Create New File Type" ) );
42 setButtons( Ok | Cancel );
43
44 QWidget* main = mainWidget();
45
46 QFormLayout *formLayout = new QFormLayout(main);
47
48 QLabel *l = new QLabel(i18n("Group:"), main);
49
50 m_groupCombo = new QComboBox(main);
51 m_groupCombo->setEditable(true);
52 m_groupCombo->addItems(groups);
53 m_groupCombo->setCurrentIndex(m_groupCombo->findText("application")); // certainly a better default than "all"
54 formLayout->addRow(l, m_groupCombo);
55
56 m_groupCombo->setWhatsThis( i18n("Select the category under which"
57 " the new file type should be added.") );
58
59 // Line 1: mimetype name
60
61 l = new QLabel(i18n("Type name:"), main);
62
63 m_typeEd = new KLineEdit(main);
64 formLayout->addRow(l, m_typeEd);
65
66 m_typeEd->setWhatsThis(i18n("Type the name of the file type. For instance, if you selected 'image' as category and you type 'custom' here, the file type 'image/custom' will be created."));
67
68 m_typeEd->setFocus();
69
70 // Set a minimum width so that caption is not half-hidden
71 setMinimumWidth(300);
72}
73
74QString NewTypeDialog::group() const
75{
76 return m_groupCombo->currentText();
77}
78
79QString NewTypeDialog::text() const
80{
81 return m_typeEd->text();
82}
83