summaryrefslogtreecommitdiff
path: root/noncore/apps/opie-console/dialdialog.cpp
Unidiff
Diffstat (limited to 'noncore/apps/opie-console/dialdialog.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-console/dialdialog.cpp95
1 files changed, 95 insertions, 0 deletions
diff --git a/noncore/apps/opie-console/dialdialog.cpp b/noncore/apps/opie-console/dialdialog.cpp
new file mode 100644
index 0000000..8bf32f9
--- a/dev/null
+++ b/noncore/apps/opie-console/dialdialog.cpp
@@ -0,0 +1,95 @@
1
2
3#include <qlayout.h>
4#include <qlabel.h>
5#include <qcombobox.h>
6#include <qscrollview.h>
7#include <qpushbutton.h>
8#include <qfont.h>
9#include <qbuttongroup.h>
10
11#include "dialdialog.h"
12
13
14
15DialDialog::DialDialog( QWidget* parent, const char* name, bool modal, WFlags fl )
16 : QDialog( parent, name, modal, fl ) {
17
18 m_number = 0;
19
20 setCaption( tr( "Enter number" ) );
21
22 QVBoxLayout *mainLayout = new QVBoxLayout( this );
23
24 QLabel *textLabel = new QLabel( this );
25 textLabel->setText( tr("Enter the number you want to dial. When finished, press ok") );
26
27 LCD = new QLCDNumber( this, "LCD" );
28 QFont LCD_font( LCD->font() );
29 LCD_font.setPointSize( 7 );
30 LCD->setFont( LCD_font );
31 LCD->setNumDigits( 25 );
32 LCD->setSegmentStyle( QLCDNumber::Flat );
33 LCD->setMaximumHeight( 30 );
34
35 QGridLayout *layout = new QGridLayout( this , 4, 3 );
36
37 QButtonGroup *dialButtons = new QButtonGroup( );
38
39 QPushButton *number0 = new QPushButton( this );
40 number0->setText( QString( "0" ) );
41 QFont number0_font( number0->font() );
42 number0_font.setBold( TRUE );
43 number0->setFont( number0_font );
44 layout->addWidget( number0, 4, 1 );
45 dialButtons->insert( number0 );
46
47 int x = 0, y = 0;
48 for ( int i = 0 ; i < 9; i++ ) {
49 QPushButton *number = new QPushButton( this );
50 number->setText( QString( "%1" ).arg( i + 1 ) );
51 QFont number_font( number->font() );
52 number_font.setBold( TRUE );
53 number->setFont( number_font );
54
55 dialButtons->insert( number );
56
57 layout->addWidget( number, x, y );
58
59 if ( y < 2 ) {
60 y++;
61 } else {
62 x++;
63 y = 0;
64 }
65 }
66
67 connect( dialButtons, SIGNAL( clicked( int ) ), this, SLOT( slotEnterNumber( int ) ) );
68
69 mainLayout->addStretch( 0 );
70 mainLayout->addWidget( textLabel );
71 mainLayout->addWidget( LCD );
72 mainLayout->addStretch( 0 );
73 mainLayout->addLayout( layout );
74 mainLayout->addStretch( 0 );
75
76
77}
78
79
80void DialDialog::slotEnterNumber( int number ) {
81
82 // pretty stupid, just for testing .-)
83
84 m_number = ( m_number * 10 ) + number;
85 qDebug( QString("%1").arg( m_number ) );
86 LCD->display( m_number );
87
88}
89
90DialDialog::~DialDialog() {
91}
92
93QString DialDialog::number() {
94 return QString( "%1").arg( m_number );
95}