2 This file is part of libkdepim.
4 Copyright (C) 2005 Con Hennessy <cp.hennessy@iname.com>
5 Copyright (C) Tobias Koenig <tokoe@kde.org>
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Library General Public
9 License as published by the Free Software Foundation; either
10 version 2 of the License, or (at your option) any later version.
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Library General Public License for more details.
17 You should have received a copy of the GNU Library General Public License
18 along with this library; see the file COPYING.LIB. If not, write to
19 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 Boston, MA 02110-1301, USA.
23 #include "sendsmsdialog.h"
27 #include <QGridLayout>
32 SendSMSDialog::SendSMSDialog( const QString
&recipientName
, QWidget
*parent
)
35 setCaption( i18n( "Send SMS" ) );
36 setButtons( Ok
|Cancel
);
37 setDefaultButton( Ok
);
39 showButtonSeparator( true );
40 QWidget
*page
= new QWidget( this );
41 setMainWidget( page
);
43 QGridLayout
*layout
= new QGridLayout( page
);
44 layout
->setMargin( marginHint() );
45 layout
->setSpacing( spacingHint() );
47 layout
->addWidget( new QLabel( i18n( "Message" ), page
), 0, 0 );
49 mMessageLength
= new QLabel( "0/160", page
);
50 mMessageLength
->setAlignment( Qt::AlignRight
);
51 layout
->addWidget( mMessageLength
, 0, 2 );
53 mText
= new QTextEdit( page
);
54 layout
->addWidget( mText
, 1, 0, 1, 3 );
56 layout
->addWidget( new QLabel( i18n( "Recipient:" ), page
), 2, 0 );
57 layout
->addWidget( new QLabel( recipientName
, page
), 2, 2 );
59 setButtonText( Ok
, i18n( "Send" ) );
61 connect( mText
, SIGNAL(textChanged()),
62 this, SLOT(updateMessageLength()) );
63 connect( mText
, SIGNAL(textChanged()),
64 this, SLOT(updateButtons()) );
71 QString
SendSMSDialog::text() const
73 return mText
->toPlainText();
76 void SendSMSDialog::updateMessageLength()
78 int length
= mText
->toPlainText().length();
81 mMessageLength
->setText( QString( "%1/%2 (%3)" ).arg( length
).arg( 500 ).arg( 4 ) );
82 else if( length
> 320 )
83 mMessageLength
->setText( QString( "%1/%2 (%3)" ).arg( length
).arg( 480 ).arg( 3 ) );
84 else if( length
> 160 )
85 mMessageLength
->setText( QString( "%1/%2 (%3)" ).arg( length
).arg( 320 ).arg( 2 ) );
87 mMessageLength
->setText( QString( "%1/%2" ).arg( length
).arg( 160 ) );
90 void SendSMSDialog::updateButtons()
92 enableButton( Ok
, !mText
->toPlainText().isEmpty() );
95 #include "sendsmsdialog.moc"