lib

KoCreateStyleDia.cpp
1/* This file is part of the KDE project
2 Copyright (C) 2002 Montel Laurent <lmontel@mandrakesoft.com>
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 as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
8
9 This library 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 GNU
12 Library General Public License for more details.
13
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
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18*/
19
20#include <tdelocale.h>
21
22#include <tqvbox.h>
23#include <tqlabel.h>
24#include <tqlineedit.h>
25#include "KoCreateStyleDia.h"
26#include <tdemessagebox.h>
27
28KoCreateStyleDia::KoCreateStyleDia( const TQStringList & _list, TQWidget *parent, const char *name )
29 : KDialogBase( parent, name , true, "", Ok|Cancel, Ok, true )
30{
31 styleList=_list;
32 setCaption( i18n("Create New Style") );
33 TQVBox *page = makeVBoxMainWidget();
34 new TQLabel(i18n("Please specify a new style name:"), page);
35 m_styleName = new TQLineEdit( page );
36 m_styleName->setMinimumWidth( m_styleName->sizeHint().width() * 3 );
37
38 connect( m_styleName, TQ_SIGNAL(textChanged ( const TQString & )), this, TQ_SLOT(nameChanged( const TQString &)));
39 m_styleName->setFocus();
40 enableButtonOK( false );
41}
42
43void KoCreateStyleDia::slotOk()
44{
45 if ( styleList.findIndex(m_styleName->text() ) != -1 )
46 {
47 KMessageBox::error(this, i18n("Name already exists! Please choose another name"));
48 m_styleName->clear();
49 }
50 else
52}
53
54TQString KoCreateStyleDia::nameOfNewStyle()const
55{
56 return m_styleName->text();
57}
58
59void KoCreateStyleDia::nameChanged( const TQString &text)
60{
61 enableButtonOK( !text.isEmpty() );
62}
63#include "KoCreateStyleDia.moc"
virtual void slotOk()
static void error(TQWidget *parent, const TQString &text, const TQString &caption=TQString::null, int options=Notify)
const char * name(StdAction id)