controlpanelui/src/cpplugins/personalizationplugin/src/cpprofilenameeditdialog.cpp
equal
deleted
inserted
replaced
20 #include <hblineedit.h> |
20 #include <hblineedit.h> |
21 #include <hblabel.h> |
21 #include <hblabel.h> |
22 #include <hbaction.h> |
22 #include <hbaction.h> |
23 |
23 |
24 #include <QGraphicsLinearLayout> |
24 #include <QGraphicsLinearLayout> |
|
25 #include <QScopedPointer> |
25 |
26 |
26 CpProfileNameEditDialog::CpProfileNameEditDialog( QGraphicsItem *parent ) |
27 CpProfileNameEditDialog::CpProfileNameEditDialog( QGraphicsItem *parent ) |
27 :HbDialog( parent ) |
28 :HbDialog( parent ) |
28 { |
29 { |
29 init(); |
30 init(); |
47 contentWidget->setLayout( vLayout ); |
48 contentWidget->setLayout( vLayout ); |
48 setContentWidget( contentWidget ); |
49 setContentWidget( contentWidget ); |
49 |
50 |
50 connect( mTextEdit, SIGNAL( contentsChanged() ), this, SLOT( checkPrimaryAction() ) ); |
51 connect( mTextEdit, SIGNAL( contentsChanged() ), this, SLOT( checkPrimaryAction() ) ); |
51 |
52 |
52 setPrimaryAction( new HbAction( hbTrId( "txt_common_button_ok" ), this )); |
53 addAction( new HbAction( hbTrId( "txt_common_button_ok" ), this )); |
53 setSecondaryAction( new HbAction( hbTrId( "txt_common_button_cancel" ), this ) ); |
54 addAction( new HbAction( hbTrId( "txt_common_button_cancel" ), this ) ); |
54 |
55 |
55 setTimeout( NoTimeout ); |
56 setTimeout( NoTimeout ); |
56 } |
57 } |
57 |
58 |
58 void CpProfileNameEditDialog::setLineEditText( const QString &text ) |
59 void CpProfileNameEditDialog::setLineEditText( const QString &text ) |
67 return text; |
68 return text; |
68 } |
69 } |
69 |
70 |
70 bool CpProfileNameEditDialog::launchProfileNameEditDialog( QString &profileName ) |
71 bool CpProfileNameEditDialog::launchProfileNameEditDialog( QString &profileName ) |
71 { |
72 { |
72 CpProfileNameEditDialog * profileEditNameDialog = new CpProfileNameEditDialog(); |
73 CpProfileNameEditDialog *profileEditNameDialog = new CpProfileNameEditDialog(); |
|
74 |
73 profileEditNameDialog->setLineEditText( profileName ); |
75 profileEditNameDialog->setLineEditText( profileName ); |
74 profileEditNameDialog->checkPrimaryAction(); |
76 profileEditNameDialog->checkPrimaryAction(); |
75 |
77 |
76 if( profileEditNameDialog->exec() == profileEditNameDialog->secondaryAction() ){ |
78 HbAction *secondAction = qobject_cast<HbAction *> |
77 return false; |
79 (profileEditNameDialog->actions().at(1)); |
78 } |
80 profileEditNameDialog->show(); |
79 else{ |
81 return false; |
80 profileName = profileEditNameDialog->getLineEditText(); |
|
81 return true; |
|
82 } |
|
83 } |
82 } |
84 |
83 |
85 void CpProfileNameEditDialog::checkPrimaryAction() |
84 void CpProfileNameEditDialog::checkPrimaryAction() |
86 { |
85 { |
87 if( !mTextEdit->text().isEmpty() ){ |
86 HbAction *const primaryAction = qobject_cast<HbAction *> |
88 primaryAction()->setEnabled( true ); |
87 (actions().at(0)); |
89 } else { |
88 if (primaryAction) { |
90 primaryAction()->setEnabled( false ); |
89 if ( !mTextEdit->text().isEmpty() ) { |
|
90 primaryAction->setEnabled(true); |
|
91 } else { |
|
92 primaryAction->setEnabled(false); |
|
93 } |
91 } |
94 } |
92 } |
95 } |