diff options
author | A. Wilcox <AWilcox@Wilcox-Tech.com> | 2019-11-14 13:12:27 -0600 |
---|---|---|
committer | A. Wilcox <AWilcox@Wilcox-Tech.com> | 2019-11-14 13:12:27 -0600 |
commit | 7a73cba7ed274cc9f7b06ae1072bc4d790fbcb1d (patch) | |
tree | 2eae300036be0c05ee4db5b08fbbbdeab868897d /ui/qt5/hostnamepage.cc | |
parent | 03c55a5b314a8281270e461b16c2954aaa762ec7 (diff) | |
download | horizon-7a73cba7ed274cc9f7b06ae1072bc4d790fbcb1d.tar.gz horizon-7a73cba7ed274cc9f7b06ae1072bc4d790fbcb1d.tar.bz2 horizon-7a73cba7ed274cc9f7b06ae1072bc4d790fbcb1d.tar.xz horizon-7a73cba7ed274cc9f7b06ae1072bc4d790fbcb1d.zip |
Qt UI: Add UI.SysMeta.Hostname page
Diffstat (limited to 'ui/qt5/hostnamepage.cc')
-rw-r--r-- | ui/qt5/hostnamepage.cc | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/ui/qt5/hostnamepage.cc b/ui/qt5/hostnamepage.cc new file mode 100644 index 0000000..ca8f16d --- /dev/null +++ b/ui/qt5/hostnamepage.cc @@ -0,0 +1,68 @@ +/* + * hostnamepage.cc - Implementation of the UI.SysMeta.Hostname page + * horizon-qt5, the Qt 5 user interface for + * Project Horizon + * + * Copyright (c) 2019 Adélie Linux and contributors. All rights reserved. + * This code is licensed under the AGPL 3.0 license, as noted in the + * LICENSE-code file in the root directory of this repository. + * + * SPDX-License-Identifier: AGPL-3.0-only + */ + +#include "hostnamepage.hh" + +#include <QLabel> +#include <QRegExpValidator> +#include <QVBoxLayout> + +HostnamePage::HostnamePage(QWidget *parent) : HorizonWizardPage(parent) { + QLabel *descLabel; + QRegExpValidator *hostnameValidator = new QRegExpValidator(this); + hostnameValidator->setRegExp(QRegExp("[A-Za-z][A-Za-z0-9-_.]+")); + QVBoxLayout *layout; + + setTitle(tr("Computer Name")); + loadWatermark("intro"); + + descLabel = new QLabel(tr("<p>You need to provide a name for your computer. " + "You may accept the default, or choose your own. " + "If your computer participates in a network, make sure that the name is unique.</p>" + + "<p>Computer names may contain letters, numbers, dashes (-), and underscores (_). For example, <i>Living-Room-PC</i>.</p>" + + "<p>You may also specify your computer's domain name if necessary (not common). For example, <i>desktop1.my.network</i>.</p>"), this); + descLabel->setTextFormat(Qt::RichText); + descLabel->setWordWrap(true); + hostnameEdit = new QLineEdit(this); + hostnameEdit->setPlaceholderText(tr("Computer Name")); + hostnameEdit->setValidator(hostnameValidator); + hostnameEdit->setWhatsThis(tr("Enter the name of your computer here.")); + + registerField("hostname*", hostnameEdit); + + layout = new QVBoxLayout(this); + layout->addWidget(descLabel); + layout->addStretch(); + layout->addWidget(hostnameEdit); + layout->addStretch(); + setLayout(layout); +} + +void HostnamePage::initializePage() { +#ifndef HAS_INSTALL_ENV + hostnameEdit->setText("Adelie"); +#else /* HAS_INSTALL_ENV */ + QString name("Adelie"); + + if(horizonWizard()->interfaces.empty()) { + name += "-Banana"; + } else { + QString mac = horizonWizard()->interfaces.begin()->second.mac; + QStringList macparts = mac.split(":"); + name += "-" + macparts[3] + macparts[4] + macparts[5]; + } + + hostnameEdit->setText(name); +#endif /* !HAS_INSTALL_ENV */ +} |