summaryrefslogtreecommitdiff
path: root/noncore/apps/opie-console/dialdialog.cpp
blob: 526d55ef8801271e357fabbcf2cbac3de73b761f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98


#include <qlayout.h>
#include <qlabel.h>
#include <qpushbutton.h>
#include <qbuttongroup.h>

#include "dialdialog.h"



DialDialog::DialDialog(  QWidget* parent, const char* name, bool modal, WFlags fl )
    : QDialog( parent, name, modal, fl ) {

    setCaption( tr( "Enter number" ) );

    QVBoxLayout *mainLayout = new QVBoxLayout( this );

    QLabel *textLabel = new QLabel( this );
    textLabel->setTextFormat( QLabel::RichText );
    textLabel->setText( tr("Enter the number you want to dial. When finished, press ok") );

    m_dialLine = new QLineEdit( this );
    m_dialLine->setReadOnly( true );
    m_dialLine->setFrame( false );
    m_dialLine->setAlignment( Qt::AlignLeft );
    QFont dialLine_font( m_dialLine->font() );
    dialLine_font.setBold( TRUE );
    dialLine_font.setPointSize( 18 );
    m_dialLine->setFont( dialLine_font );

    QWidget* dialWidget = new QWidget( this );
    QGridLayout *layout = new QGridLayout( dialWidget , 4, 3 );

    QButtonGroup *dialButtons = new QButtonGroup( );

    QPushButton *number0 = new QPushButton( dialWidget );
    number0->setText( QString( "0" ) );
    QFont number0_font( number0->font() );
    number0_font.setBold( TRUE );
    number0->setFont( number0_font );
    layout->addWidget( number0, 4, 1 );
    dialButtons->insert( number0 );

    int x = 0, y = 0;
    for ( int i = 0 ; i < 9;  i++ ) {
        QPushButton *number = new QPushButton( dialWidget );
        number->setText( QString( "%1" ).arg( i + 1 ) );
        QFont number_font( number->font() );
        number_font.setBold( TRUE );
        number->setFont( number_font );

        dialButtons->insert( number );

        layout->addWidget( number, x, y );

        if ( y < 2 ) {
            y++;
        } else {
            x++;
            y = 0;
        }
    }

    connect( dialButtons, SIGNAL( clicked(int) ), this, SLOT( slotEnterNumber(int) ) );

    mainLayout->addStretch( 2 );
    mainLayout->addWidget( textLabel );
    mainLayout->addStretch( 1 );
    mainLayout->addWidget( m_dialLine );
    mainLayout->addStretch( 2 );
    mainLayout->addWidget( dialWidget );
    mainLayout->addStretch( 4 );
}


void DialDialog::slotEnterNumber( int number ) {

    // pretty stupid, just for testing .-)

	m_number.append(QString("%1").arg(number));

	setNumber(m_number);
}

DialDialog::~DialDialog() {
}

QString DialDialog::number() {
    return m_number;

}

void DialDialog::setNumber( QString number )
{
    m_dialLine->setText( QString("%1").arg( number ) );
}