24 #include <tqtextedit.h>
26 #include <tdelocale.h>
28 #include "sendsmsdialog.h"
30 SendSMSDialog::SendSMSDialog(
const TQString &recipientName, TQWidget *parent,
const char *name )
31 : KDialogBase( Plain, i18n(
"Send SMS" ), Ok | Cancel, Ok, parent, name, true, true )
33 TQWidget *page = plainPage();
35 TQGridLayout *layout =
new TQGridLayout( page, 3, 3, marginHint(), spacingHint() );
37 layout->addWidget(
new TQLabel( i18n(
"Message" ), page ), 0, 0 );
39 mMessageLength =
new TQLabel(
"0/160", page );
40 mMessageLength->setAlignment( TQt::AlignRight );
41 layout->addWidget( mMessageLength, 0, 2 );
43 mText =
new TQTextEdit( page );
44 layout->addMultiCellWidget( mText, 1, 1, 0, 2 );
46 layout->addWidget(
new TQLabel( i18n(
"Recipient:" ), page ), 2, 0 );
47 layout->addWidget(
new TQLabel( recipientName, page ), 2, 2 );
49 setButtonText( Ok, i18n(
"Send" ) );
51 connect( mText, TQ_SIGNAL( textChanged() ),
52 this, TQ_SLOT( updateMessageLength() ) );
53 connect( mText, TQ_SIGNAL( textChanged() ),
54 this, TQ_SLOT( updateButtons() ) );
61 TQString SendSMSDialog::text()
const
66 void SendSMSDialog::updateMessageLength()
68 int length = mText->length();
71 mMessageLength->setText( TQString(
"%1/%2 (%3)" ).arg( length ).arg( 500 ).arg( 4 ) );
72 else if( length > 320 )
73 mMessageLength->setText( TQString(
"%1/%2 (%3)" ).arg( length ).arg( 480 ).arg( 3 ) );
74 else if( length > 160 )
75 mMessageLength->setText( TQString(
"%1/%2 (%3)" ).arg( length ).arg( 320 ).arg( 2 ) );
77 mMessageLength->setText( TQString(
"%1/%2" ).arg( length ).arg( 160 ) );
80 void SendSMSDialog::updateButtons()
82 enableButton( Ok, mText->length() > 0 );
85 #include "sendsmsdialog.moc"