summaryrefslogtreecommitdiff
path: root/noncore/settings/netsystemtime/ntptabwidget.cpp
blob: d0107a4fc1de7dff0b011914949a3d67ea26215b (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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
/*
                             This file is part of the Opie Project

                             Copyright (C) Opie Team <opie-devel@handhelds.org>
              =.
            .=l.
           .>+-=
 _;:,     .>    :=|.         This program is free software; you can
.> <`_,   >  .   <=          redistribute it and/or  modify it under
:`=1 )Y*s>-.--   :           the terms of the GNU Library General Public
.="- .-=="i,     .._         License as published by the Free Software
 - .   .-<_>     .<>         Foundation; either version 2 of the License,
     ._= =}       :          or (at your option) any later version.
    .%`+i>       _;_.
    .i_,=:_.      -<s.       This program is distributed in the hope that
     +  .  -:.       =       it will be useful,  but WITHOUT ANY WARRANTY;
    : ..    .:,     . . .    without even the implied warranty of
    =_        +     =;=|`    MERCHANTABILITY or FITNESS FOR A
  _.=:.       :    :=>`:     PARTICULAR PURPOSE. See the GNU
..}^=.=       =       ;      Library General Public License for more
++=   -.     .`     .:       details.
:     =  ...= . :.=-
 -.   .:....=;==+<;          You should have received a copy of the GNU
  -_. . .   )=.  =           Library General Public License along with
    --        :-=`           this library; see the file COPYING.LIB.
                             If not, write to the Free Software Foundation,
                             Inc., 59 Temple Place - Suite 330,
                             Boston, MA 02111-1307, USA.
*/

#include "ntptabwidget.h"

#include <opie2/oresource.h>

#include <qpe/applnk.h>

#include <qlabel.h>
#include <qlayout.h>
#include <qmultilineedit.h>
#include <qpushbutton.h>
#include <qscrollview.h>

NTPTabWidget::NTPTabWidget( QWidget *parent )
	: QWidget( parent, 0x0, 0 )
{
	QVBoxLayout *tmpvb = new QVBoxLayout( this );
	QScrollView *sv = new QScrollView( this );
	tmpvb->addWidget( sv, 0, 0 );
	sv->setResizePolicy( QScrollView::AutoOneFit );
	sv->setFrameStyle( QFrame::NoFrame );
	QWidget *container = new QWidget( sv->viewport() );
	sv->addChild( container );

	QGridLayout *layout = new QGridLayout( container );
	layout->setMargin( 2 );
	layout->setSpacing( 4 );

	// Start time
	layout->addWidget( new QLabel( tr( "Start time" ), container ), 0, 0 );
	lblStartTime = new QLabel( tr( "n/a" ), container );
	layout->addWidget( lblStartTime, 0, 1 );

	// Time shift
	layout->addWidget( new QLabel( tr( "Time shift" ), container ), 1, 0 );
	lblTimeShift = new QLabel( tr( "n/a" ), container );
	layout->addWidget( lblTimeShift, 1, 1 );

	// New time
	layout->addWidget( new QLabel( tr( "New time" ), container ), 2, 0 );
	lblNewTime = new QLabel( tr( "n/a" ), container );
	layout->addWidget( lblNewTime, 2, 1 );

	// NTP output display
	mleNtpOutput = new QMultiLineEdit( container );
	QFont font(  mleNtpOutput->font() );
	font.setPointSize( font.pointSize() - 2 );
	mleNtpOutput->setFont( font );
	mleNtpOutput->setWordWrap( QMultiLineEdit::WidgetWidth );
	layout->addMultiCellWidget( mleNtpOutput, 3, 3, 0, 1 );

	// Set NTP time button
    m_ntpBtn = new QPushButton( Opie::Core::OResource::loadPixmap( "netsystemtime/ntptab", Opie::Core::OResource::SmallIcon ),
                                tr( "Get time from the network" ), container );
    m_ntpBtn->setMinimumHeight( AppLnk::smallIconSize()+4 );
	connect( m_ntpBtn, SIGNAL(clicked()), this, SIGNAL(getNTPTime()) );
	layout->addMultiCellWidget( m_ntpBtn, 4, 4, 0, 1 );
}

NTPTabWidget::~NTPTabWidget()
{
}

void NTPTabWidget::setStartTime( const QString &str )
{
	lblStartTime->setText( str );
}

void NTPTabWidget::setTimeShift( const QString &str )
{
	lblTimeShift->setText( str );
}

void NTPTabWidget::setNewTime( const QString &str )
{
	lblNewTime->setText( str );
}

void NTPTabWidget::addNtpOutput( const QString &str )
{
	mleNtpOutput->append( str );
	mleNtpOutput->setCursorPosition( mleNtpOutput->numLines() + 1, 0, FALSE );
}

void NTPTabWidget::setNTPBtnEnabled( bool enabled )
{
    m_ntpBtn->setEnabled( enabled );
}