]> cloud.milkyroute.net Git - dolphin.git/blob - src/tagcloud/newtagdialog.cpp
This is the first step towards a better looking and more usable metadata GUI.
[dolphin.git] / src / tagcloud / newtagdialog.cpp
1 /*
2 Copyright (C) 2008 by Sebastian Trueg <trueg at kde.org>
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2, or (at your option)
7 any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 */
18
19 #include "newtagdialog.h"
20
21 #include <nepomuk/tag.h>
22
23 #include <KDebug>
24 #include <KLocale>
25 #include <KTitleWidget>
26
27
28 NewTagDialog::NewTagDialog( QWidget* parent )
29 : KDialog( parent )
30 {
31 setCaption( i18n( "Create new Tag" ) );
32 setButtons( Ok|Cancel );
33 enableButtonOk( false );
34
35 setupUi( mainWidget() );
36
37 connect( m_editTagLabel, SIGNAL( textChanged(const QString&) ),
38 this, SLOT( slotLabelChanged(const QString&) ) );
39 }
40
41
42 NewTagDialog::~NewTagDialog()
43 {
44 }
45
46
47 void NewTagDialog::slotLabelChanged( const QString& text )
48 {
49 enableButtonOk( !text.isEmpty() );
50 }
51
52
53 Nepomuk::Tag NewTagDialog::createTag( QWidget* parent )
54 {
55 NewTagDialog dlg( parent );
56 dlg.m_labelTitle->setText( i18n( "Create New Tag" ) );
57 dlg.m_labelTitle->setComment( i18n( "with optional icon and description" ) );
58 dlg.m_labelTitle->setPixmap( KIcon( "nepomuk" ).pixmap( 32, 32 ) );
59
60 dlg.m_editTagLabel->setFocus();
61
62 if ( dlg.exec() ) {
63 QString name = dlg.m_editTagLabel->text();
64 QString comment = dlg.m_editTagComment->text();
65 QString icon = dlg.m_buttonTagIcon->icon();
66
67 Nepomuk::Tag newTag( name );
68 newTag.setLabel( name );
69 newTag.addIdentifier( name );
70 if ( !comment.isEmpty() ) {
71 newTag.setDescription( comment );
72 }
73 if ( !icon.isEmpty() ) {
74 newTag.addSymbol( icon );
75 }
76 return newTag;
77 }
78 else {
79 return Nepomuk::Tag();
80 }
81 }
82
83 #include "newtagdialog.moc"