Skip to content
This repository has been archived by the owner on Dec 4, 2020. It is now read-only.

Commit

Permalink
Merge branch 'master' of github.com:pcbsd/pcbsd
Browse files Browse the repository at this point in the history
  • Loading branch information
Ken Moore committed Oct 18, 2013
2 parents c69425e + 5a1d1a0 commit dca28eb
Show file tree
Hide file tree
Showing 13 changed files with 266 additions and 150 deletions.
14 changes: 14 additions & 0 deletions src-qt4/pc-firstbootgui/backend.cpp
Expand Up @@ -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;
Expand Down
5 changes: 3 additions & 2 deletions src-qt4/pc-firstbootgui/backend.h
Expand Up @@ -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")

Expand Down Expand Up @@ -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();
Expand Down
15 changes: 11 additions & 4 deletions src-qt4/pc-firstbootgui/firstboot.cpp
Expand Up @@ -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));
Expand Down
15 changes: 15 additions & 0 deletions src-qt4/pc-installgui/backend.cpp
Expand Up @@ -234,6 +234,21 @@ int Backend::systemMemory()
return -1;
}

QString Backend::detectCountryCode()
{
QString code;

Process p(QStringList() << "detect-country");

if (p.waitForFinished()) {
code = p.readLine().simplified();
}
code = code.section(" ", 0, 0);
qDebug() << "Found Country Code:" << code;
return code;
}


QStringList Backend::networkDevices()
{
QStringList nics;
Expand Down
1 change: 1 addition & 0 deletions src-qt4/pc-installgui/backend.h
Expand Up @@ -56,6 +56,7 @@ class Backend {
static QStringList bootableMedia();
static QStringList networkDevices();
static QStringList timezones();
static QString detectCountryCode();
static void changeKbMap(QString model, QString layout, QString variant);
static QList<QStringList> hardDrives();
static QList<QStringList> availComponents();
Expand Down
38 changes: 25 additions & 13 deletions src-qt4/pc-installgui/installer.cpp
Expand Up @@ -100,14 +100,30 @@ void Installer::slotPushKeyLayout()
void Installer::initInstall()
{
// load languages
QString langCode;
bool foundLang = false;
comboLanguage->clear();
languages = Scripts::Backend::languages();
QString curLang = Scripts::Backend::detectCountryCode();
for (int i=0; i < languages.count(); ++i) {
QString languageStr = languages.at(i);
QString language = languageStr.split("-").at(0);
comboLanguage->addItem(language.trimmed());

// Grab the language code
langCode = languageStr;
langCode.truncate(langCode.lastIndexOf(")"));
langCode.remove(0, langCode.lastIndexOf("(") + 1);
if ( curLang == langCode ) {
comboLanguage->setCurrentIndex(i);
foundLang = true;
}
}
connect(comboLanguage, SIGNAL(currentIndexChanged(QString)), this, SLOT(slotChangeLanguage()));
// If we found a language from geo-loication, change UI now
if ( foundLang )
slotChangeLanguage();


// Load any package scheme data
listDeskPkgs = Scripts::Backend::getPackageData(availDesktopPackageData, QString());
Expand Down Expand Up @@ -775,20 +791,16 @@ void Installer::slotChangeLanguage()
QCoreApplication::installTranslator(translator);
this->retranslateUi(this);
}
}

void Installer::changeLang(QString code)
{
// Change the language in the combobox with the current running one
comboLanguage->disconnect();

for (int i=0; i < languages.count(); ++i) {
if ( languages.at(i).indexOf("(" + code + ")" ) != -1 ) {
comboLanguage->setCurrentIndex(i);
}
}

connect(comboLanguage, SIGNAL(currentIndexChanged(QString)), this, SLOT(slotChangeLanguage()));
// Change the default keyboard layout
if ( langCode == "en" ) {
Scripts::Backend::changeKbMap("pc104", "us", "");
} else {
// TODO - At some point, add additional tests here and set more specific layouts
// based upon the language selected
Scripts::Backend::changeKbMap("pc105", langCode, "" );
}

}

QStringList Installer::getGlobalCfgSettings()
Expand Down
1 change: 0 additions & 1 deletion src-qt4/pc-installgui/installer.h
Expand Up @@ -34,7 +34,6 @@ class Installer : public QMainWindow, private Ui::Installer
public:
Installer(QWidget *parent = 0);
~Installer();
void changeLang(QString code);
void initInstall();

private slots:
Expand Down
27 changes: 20 additions & 7 deletions src-qt4/pc-installgui/wizardDisk.cpp
Expand Up @@ -152,6 +152,11 @@ int wizardDisk::nextId() const
}
break;
case Page_BasicDisk:
if (checkSSD->isChecked())
pushSwapSize->setVisible(false);
else
pushSwapSize->setVisible(true);

if (radioBasic->isChecked())
return Page_Confirmation;
if (comboPartition->currentIndex() != 0 ) {
Expand Down Expand Up @@ -413,15 +418,21 @@ void wizardDisk::generateDiskLayout()
{
fsType= "ZFS";

QString rootOpts="";
if ( checkSSD->isChecked() )
rootOpts="(atime=off)";

// This lets the user do nifty stuff like a mirror/raid post-install with a single zpool command
fileSystem << targetDisk << targetSlice << "/,/tmp(compress=lz4),/usr(canmount=off),/usr/home,/usr/jails,/usr/obj(compress=lz4),/usr/pbi,/usr/ports(compress=lz4),/usr/ports/distfiles(compress=lz4),/usr/src(compress=lz4),/var(canmount=off),/var/audit(compress=lz4),/var/log(compress=lz4),/var/tmp(compress=lz4)" << fsType << tmp.setNum(totalSize) << "" << tmpPass;
fileSystem << targetDisk << targetSlice << "/" + rootOpts + ",/tmp(compress=lz4),/usr(canmount=off),/usr/home,/usr/jails,/usr/obj(compress=lz4),/usr/pbi,/usr/ports(compress=lz4),/usr/ports/distfiles(compress=lz4),/usr/src(compress=lz4),/var(canmount=off),/var/audit(compress=lz4),/var/log(compress=lz4),/var/tmp(compress=lz4)" << fsType << tmp.setNum(totalSize) << "" << tmpPass;
sysFinalDiskLayout << fileSystem;
fileSystem.clear();

// Now add swap space
fileSystem << targetDisk << targetSlice << "SWAP" << "SWAP" << tmp.setNum(swapsize) << "" << "";
sysFinalDiskLayout << fileSystem;
fileSystem.clear();
// Now add swap space if NOT on a SSD
if ( ! checkSSD->isChecked() ) {
fileSystem << targetDisk << targetSlice << "SWAP" << "SWAP" << tmp.setNum(swapsize) << "" << "";
sysFinalDiskLayout << fileSystem;
fileSystem.clear();
}

//qDebug() << "Auto-Gen FS:" << fileSystem;
}
Expand Down Expand Up @@ -899,8 +910,10 @@ void wizardDisk::generateCustomDiskLayout()
sysFinalDiskLayout << fileSystem;

fileSystem.clear();
fileSystem << targetDisk << targetSlice << "SWAP" << "SWAP" << tmp.setNum(swapsize) << "" << "";
sysFinalDiskLayout << fileSystem;
if ( ! checkSSD->isChecked() ) {
fileSystem << targetDisk << targetSlice << "SWAP" << "SWAP" << tmp.setNum(swapsize) << "" << "";
sysFinalDiskLayout << fileSystem;
}

qDebug() <<"AutoLayout:" << sysFinalDiskLayout;
}
Expand Down

0 comments on commit dca28eb

Please sign in to comment.