12 setWindowTitle(
"Change Master Password" );
13 setAttribute( Qt::WA_DeleteOnClose );
19 QLabel* header =
us_banner(
"Change Master Password" );
20 header->setMinimumHeight( buttonh * 3 / 2 );
25 if ( ! oldPass.isEmpty() )
28 oldPW->setMinimumHeight( buttonh );
37 QLabel* passwd1 =
us_label(
"Enter New Password:" );
38 passwd1->setMinimumHeight( buttonh );
41 le_passwd1->setEchoMode( QLineEdit::Password );
45 QLabel* passwd2 =
us_label(
"Verify New Password:" );
46 passwd2->setMinimumHeight(buttonh);
50 le_passwd2->setEchoMode( QLineEdit::Password );
53 pb_help->setMinimumHeight( buttonh );
54 connect(
pb_help, SIGNAL( clicked() ), SLOT(
help() ) );
57 pb_save->setMinimumHeight( buttonh );
58 connect(
pb_save, SIGNAL( clicked() ), SLOT(
save() ) );
62 connect(
pb_cancel, SIGNAL( clicked() ), SLOT( close() ) );
65 QGridLayout* passwords =
new QGridLayout;
66 passwords->addWidget( header, 0, 0, 1, 2 );
69 if ( ! oldPass.isEmpty() )
71 passwords->addWidget( oldPW , row, 0 );
75 passwords->addWidget( passwd1 , row, 0 );
77 passwords->addWidget( passwd2 , row, 0 );
80 QHBoxLayout* buttonLine =
new QHBoxLayout;
81 buttonLine->addWidget(
pb_help );
82 buttonLine->addWidget(
pb_save );
85 QVBoxLayout*
main =
new QVBoxLayout;
86 main->setSpacing( 2 );
87 main->addLayout( passwords );
88 main->addLayout( buttonLine );
97 if ( ! oldPW.isEmpty() )
100 QCryptographicHash::hash(
le_oldPasswd->text().toAscii(),
101 QCryptographicHash::Sha1 );
103 if ( calcsha1 != oldPW )
105 QMessageBox::information(
this,
107 tr(
"The old password is incorrect. Please re-input.\n" ) );
117 QMessageBox::information(
this,
119 tr(
"The entered passwords are not same. Please re-input.\n" ) );
125 if ( newPW.isEmpty() )
127 QMessageBox::information(
this,
129 tr(
"The new password cannot be empty. Please re-input.\n" ) );
135 QByteArray sha1string =
136 QCryptographicHash::hash( newPW.toAscii(), QCryptographicHash::Sha1 );
149 if ( defaultDB.size() > 0 )
159 defaultDB.replace( 4, cipherText.at( 0 ) );
160 defaultDB.replace( 5, cipherText.at( 1 ) );
167 for (
int i = 0; i < databases.size(); i++ )
169 QStringList database = databases.at( i );
176 database.replace( 4, cipherText.at( 0 ) );
177 database.replace( 5, cipherText.at( 1 ) );
179 databases.replace( i, database );
182 if ( databases.size() > 0 )
192 online_help->
show_help(
"manual/administrator.html" );