Permalink
Browse files

On first-boot wizard, add ability to detect users timezone if internet

is connected
  • Loading branch information...
1 parent 688b57d commit 5a1d1a09d54238cf5d855ed0e1b14fbffa01367c @kmoore134 kmoore134 committed Oct 18, 2013
Showing with 28 additions and 6 deletions.
  1. +14 −0 src-qt4/pc-firstbootgui/backend.cpp
  2. +3 −2 src-qt4/pc-firstbootgui/backend.h
  3. +11 −4 src-qt4/pc-firstbootgui/firstboot.cpp
@@ -96,6 +96,20 @@ QStringList Backend::timezones()
return _zones;
}
+QString Backend::guessTimezone()
+{
+ QString code;
+
+ Process p(QStringList() << "detect-country");
+
+ if (p.waitForFinished()) {
+ code = p.readLine().simplified();
+ }
+ code = code.section(" ", 1, 1);
+ qDebug() << "Found timezone:" << code;
+ return code;
+}
+
QStringList Backend::languages()
{
QStringList _languages;
@@ -10,8 +10,8 @@
#include <QByteArray>
#include <QWidget>
-#define PCSYSINSTALL QString("/usr/sbin/pc-sysinstall")
-#define PCSYSINSTALLDIR QString("/usr/share/pc-sysinstall")
+#define PCSYSINSTALL QString("/usr/local/sbin/pc-sysinstall")
+#define PCSYSINSTALLDIR QString("/usr/local/share/pc-sysinstall")
#define PCSYSINSTALLCFG QString("/tmp/sys-install.cfg")
#define TMPLANGFILE QString("/tmp/.SysInstallLang")
@@ -50,6 +50,7 @@ class Backend {
static QStringList bootableMedia();
static QStringList networkDevices();
static QStringList timezones();
+ static QString guessTimezone();
static void changeKbMap(QString model, QString layout, QString variant);
static QList<QStringList> hardDrives();
static QList<QStringList> availComponents();
@@ -48,11 +48,18 @@ Installer::Installer(QWidget *parent) : QMainWindow(parent)
// Load the timezones
comboBoxTimezone->clear();
+ QString curZone = Scripts::Backend::guessTimezone();
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 ( ! curZone.isEmpty() ) {
+ int index = comboBoxTimezone->findText(curZone, Qt::MatchStartsWith);
+ if (index != -1)
+ comboBoxTimezone->setCurrentIndex(index);
+ } else {
+ // Set America/New_York to default
+ int index = comboBoxTimezone->findText("America/New_York", Qt::MatchStartsWith);
+ if (index != -1)
+ comboBoxTimezone->setCurrentIndex(index);
+ }
// Load the hostname
lineHostname->setText(pcbsd::Utils::getConfFileValue("/etc/rc.conf", "hostname=", 1));

0 comments on commit 5a1d1a0

Please sign in to comment.