|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0"" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 #include "cpprofilenameeditdialog.h" |
|
19 |
|
20 #include <hblineedit.h> |
|
21 #include <hblabel.h> |
|
22 #include <hbaction.h> |
|
23 |
|
24 #include <QGraphicsLinearLayout> |
|
25 |
|
26 CpProfileNameEditDialog::CpProfileNameEditDialog( QGraphicsItem *parent ) |
|
27 :HbDialog( parent ) |
|
28 { |
|
29 init(); |
|
30 } |
|
31 |
|
32 CpProfileNameEditDialog::~CpProfileNameEditDialog() |
|
33 { |
|
34 } |
|
35 |
|
36 void CpProfileNameEditDialog::init() |
|
37 { |
|
38 setDismissPolicy( HbPopup::NoDismiss ); |
|
39 setHeadingWidget( new HbLabel( hbTrId( "txt_cp_title_edit_name" ), this )); |
|
40 |
|
41 QGraphicsLinearLayout *vLayout = new QGraphicsLinearLayout(); |
|
42 vLayout->setOrientation( Qt::Vertical ); |
|
43 HbWidget *contentWidget = new HbWidget( this ); |
|
44 mTextEdit = new HbLineEdit( this ); |
|
45 mTextEdit->setFontSpec( HbFontSpec( HbFontSpec::Primary ) ); |
|
46 vLayout->addItem( mTextEdit ); |
|
47 contentWidget->setLayout( vLayout ); |
|
48 setContentWidget( contentWidget ); |
|
49 |
|
50 connect( mTextEdit, SIGNAL( contentsChanged() ), this, SLOT( checkPrimaryAction() ) ); |
|
51 |
|
52 setPrimaryAction( new HbAction( hbTrId( "txt_common_button_ok" ), this )); |
|
53 setSecondaryAction( new HbAction( hbTrId( "txt_common_button_cancel" ), this ) ); |
|
54 |
|
55 setTimeout( NoTimeout ); |
|
56 } |
|
57 |
|
58 void CpProfileNameEditDialog::setLineEditText( const QString &text ) |
|
59 { |
|
60 mTextEdit->setText( text ); |
|
61 mTextEdit->setSelection( 0, text.length() ); |
|
62 } |
|
63 |
|
64 QString CpProfileNameEditDialog::getLineEditText() |
|
65 { |
|
66 QString text = mTextEdit->text(); |
|
67 return text; |
|
68 } |
|
69 |
|
70 bool CpProfileNameEditDialog::launchProfileNameEditDialog( QString &profileName ) |
|
71 { |
|
72 CpProfileNameEditDialog * profileEditNameDialog = new CpProfileNameEditDialog(); |
|
73 profileEditNameDialog->setLineEditText( profileName ); |
|
74 profileEditNameDialog->checkPrimaryAction(); |
|
75 |
|
76 if( profileEditNameDialog->exec() == profileEditNameDialog->secondaryAction() ){ |
|
77 return false; |
|
78 } |
|
79 else{ |
|
80 profileName = profileEditNameDialog->getLineEditText(); |
|
81 return true; |
|
82 } |
|
83 } |
|
84 |
|
85 void CpProfileNameEditDialog::checkPrimaryAction() |
|
86 { |
|
87 if( !mTextEdit->text().isEmpty() ){ |
|
88 primaryAction()->setEnabled( true ); |
|
89 } else { |
|
90 primaryAction()->setEnabled( false ); |
|
91 } |
|
92 } |