]>
cloud.milkyroute.net Git - dolphin.git/blob - src/tagcloud/newtagdialog.cpp
8785d578c1c72126f413c7258f6e48c5a795d89a
2 Copyright (C) 2008 by Sebastian Trueg <trueg at kde.org>
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)
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.
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.
19 #include "newtagdialog.h"
21 #include <nepomuk/tag.h>
25 #include <KTitleWidget>
28 NewTagDialog::NewTagDialog( QWidget
* parent
)
31 setCaption( i18nc( "@title:window", "Create New Tag" ) );
32 setButtons( Ok
|Cancel
);
33 enableButtonOk( false );
35 setupUi( mainWidget() );
37 connect( m_editTagLabel
, SIGNAL( textChanged(const QString
&) ),
38 this, SLOT( slotLabelChanged(const QString
&) ) );
40 // TODO: use KGlobal::config() if NewTagDialog will be moved to kdelibs (KDE 4.2?)
41 KConfigGroup
group(KSharedConfig::openConfig("dolphinrc"), "NewTagDialog");
42 restoreDialogSize(group
);
46 NewTagDialog::~NewTagDialog()
48 // TODO: use KGlobal::config() if NewTagDialog will be moved to kdelibs (KDE 4.2?)
49 KConfigGroup
group(KSharedConfig::openConfig("dolphinrc"), "NewTagDialog");
50 saveDialogSize(group
, KConfigBase::Persistent
);
54 QSize
NewTagDialog::sizeHint() const
56 return QSize(400, 256);
59 void NewTagDialog::slotLabelChanged( const QString
& text
)
61 enableButtonOk( !text
.isEmpty() );
65 Nepomuk::Tag
NewTagDialog::createTag( QWidget
* parent
)
67 NewTagDialog
dlg( parent
);
68 dlg
.m_labelTitle
->setText( i18nc( "@title:window", "Create New Tag" ) );
69 dlg
.m_labelTitle
->setComment( i18nc( "@title:window subtitle to previous message", "with optional icon and description" ) );
70 dlg
.m_labelTitle
->setPixmap( KIcon( "nepomuk" ).pixmap( 32, 32 ) );
72 dlg
.m_editTagLabel
->setFocus();
75 QString name
= dlg
.m_editTagLabel
->text();
76 QString comment
= dlg
.m_editTagComment
->text();
77 QString icon
= dlg
.m_buttonTagIcon
->icon();
79 Nepomuk::Tag
newTag( name
);
80 newTag
.setLabel( name
);
81 newTag
.addIdentifier( name
);
82 if ( !comment
.isEmpty() ) {
83 newTag
.setDescription( comment
);
85 if ( !icon
.isEmpty() ) {
86 newTag
.addSymbol( icon
);
91 return Nepomuk::Tag();
95 #include "newtagdialog.moc"