[PC-BSD Commits] r15291 - users/kris/pc-firstbootgui
svn at pcbsd.org
svn at pcbsd.org
Mon Feb 13 11:41:45 PST 2012
Author: kris
Date: 2012-02-13 19:41:45 +0000 (Mon, 13 Feb 2012)
New Revision: 15291
Modified:
users/kris/pc-firstbootgui/firstboot.cpp
users/kris/pc-firstbootgui/firstboot.h
users/kris/pc-firstbootgui/firstboot.ui
Log:
Add validation to user / root pw, add check for wifi, and next / back / finish logic
Modified: users/kris/pc-firstbootgui/firstboot.cpp
===================================================================
--- users/kris/pc-firstbootgui/firstboot.cpp 2012-02-13 19:27:50 UTC (rev 15290)
+++ users/kris/pc-firstbootgui/firstboot.cpp 2012-02-13 19:41:45 UTC (rev 15291)
@@ -18,10 +18,32 @@
connect(pushTouchKeyboard, SIGNAL(clicked()), this, SLOT(slotPushVirtKeyboard()));
connect(pushChangeKeyLayout, SIGNAL(clicked()), this, SLOT(slotPushKeyLayout()));
+ connect(lineRootPW, SIGNAL(textChanged ( const QString &)), this, SLOT(slotCheckRootPW()));
+ connect(lineRootPW2, SIGNAL(textChanged ( const QString &)), this, SLOT(slotCheckRootPW()));
+
+ connect(lineName,SIGNAL(textChanged(const QString)),this,SLOT(slotCheckUser()));
+ connect(lineName,SIGNAL(editingFinished()),this,SLOT(slotSuggestUsername()));
+ connect(lineUsername,SIGNAL(textChanged(const QString)),this,SLOT(slotCheckUser()));
+ connect(linePW,SIGNAL(textChanged(const QString)),this,SLOT(slotCheckUser()));
+ connect(linePW2,SIGNAL(textChanged(const QString)),this,SLOT(slotCheckUser()));
+
// Load the keyboard info
keyModels = Scripts::Backend::keyModels();
keyLayouts = Scripts::Backend::keyLayouts();
+ // Load the timezones
+ comboBoxTimezone->clear();
+ comboBoxTimezone->addItems(Scripts::Backend::timezones());
+ // Set America/New_York to default
+ int index = comboBoxTimezone->findText("America/New_York", Qt::MatchStartsWith);
+ if (index != -1)
+ comboBoxTimezone->setCurrentIndex(index);
+
+ if ( system("ifconfig wlan0") == 0 )
+ haveWifi = true;
+ else
+ haveWifi = false;
+
// Start on the first screen
installStackWidget->setCurrentIndex(0);
backButton->setVisible(false);
@@ -32,6 +54,17 @@
//delete ui;
}
+void Installer::slotSuggestUsername()
+{
+ if ( ! lineUsername->text().isEmpty() || lineName->text().isEmpty() )
+ return;
+ QString name;
+ name = lineName->text().section(' ', 0, 0).toLower();
+ name.truncate(1);
+ name = name + lineName->text().section(' ', -1, -1).toLower();
+ lineUsername->setText(name);
+}
+
void Installer::slotPushKeyLayout()
{
wKey = new widgetKeyboard();
@@ -77,6 +110,37 @@
installStackWidget->setCurrentIndex(index);
}
+// Check root pw
+void Installer::slotCheckRootPW()
+{
+ nextButton->setEnabled(false);
+
+ if ( lineRootPW->text().isEmpty() )
+ return;
+ if ( lineRootPW2->text().isEmpty() )
+ return;
+ if ( lineRootPW->text() != lineRootPW2->text() )
+ return;
+ // if we get this far, all the fields are filled in
+ nextButton->setEnabled(true);
+}
+
+void Installer::slotCheckUser()
+{
+ nextButton->setEnabled(false);
+ if ( lineName->text().isEmpty() )
+ return;
+ if ( lineUsername->text().isEmpty() )
+ return;
+ if ( linePW->text().isEmpty() )
+ return;
+ if ( linePW2->text().isEmpty() )
+ return;
+ if ( linePW->text() != linePW2->text() )
+ return;
+ nextButton->setEnabled(true);
+}
+
// Slot which is called when the Finish button is clicked
void Installer::slotFinished()
{
@@ -87,23 +151,37 @@
{
QString tmp;
- // If no pkgs on media
- if ( installStackWidget->currentIndex() == 0) {
- installStackWidget->setCurrentIndex(2);
- return;
+ // Check rootPW match
+ if ( installStackWidget->currentIndex() == 1)
+ slotCheckRootPW();
+ // Check user info
+ if ( installStackWidget->currentIndex() == 2)
+ slotCheckUser();
+
+ if ( installStackWidget->currentIndex() == 3 && ! haveWifi) {
+ installStackWidget->setCurrentIndex(5);
+ // Save the settings
+ nextButton->setText("Finish");
+ backButton->setVisible(false);
+ nextButton->disconnect();
+ connect(nextButton, SIGNAL(clicked()), this, SLOT(slotFinished()));
+ return;
}
+ // Finished screen
+ if ( installStackWidget->currentIndex() == 4 ) {
+ // Save the settings
+ nextButton->setText("Finish");
+ backButton->setVisible(false);
+ nextButton->disconnect();
+ connect(nextButton, SIGNAL(clicked()), this, SLOT(slotFinished()));
+ }
+
proceed(true);
}
void Installer::slotBack()
{
- // If no pkgs on media
- if ( installStackWidget->currentIndex() == 2 ) {
- installStackWidget->setCurrentIndex(0);
- return;
- }
-
proceed(false);
}
@@ -162,3 +240,4 @@
}
pcHelp->show();
}
+
Modified: users/kris/pc-firstbootgui/firstboot.h
===================================================================
--- users/kris/pc-firstbootgui/firstboot.h 2012-02-13 19:27:50 UTC (rev 15290)
+++ users/kris/pc-firstbootgui/firstboot.h 2012-02-13 19:41:45 UTC (rev 15291)
@@ -35,9 +35,17 @@
// Keyboard selector
void slotPushKeyLayout();
+
+ // Root PW validator
+ void slotCheckRootPW();
+ // User validators
+ void slotCheckUser();
+ void slotSuggestUsername();
+
private:
void proceed(bool);
+ bool haveWifi;
QStringList languages;
Modified: users/kris/pc-firstbootgui/firstboot.ui
===================================================================
(Binary files differ)
More information about the Commits
mailing list