Skip to content

Commit

Permalink
Merge pull request #150 from dolphinoracle/gtk3
Browse files Browse the repository at this point in the history
hostname change function
  • Loading branch information
dolphinoracle authored Sep 22, 2024
2 parents 74396f4 + e3d19b1 commit 25a6d04
Show file tree
Hide file tree
Showing 5 changed files with 204 additions and 115 deletions.
45 changes: 45 additions & 0 deletions defaultlook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1501,6 +1501,12 @@ void defaultlook::setupEtc()
debianKernelUpdateFlag = false;
liqKernelUpdateFlag = false;

//hostname
ui->checkBoxComputerName->setChecked(false);
ui->lineEditHostname->setEnabled(false);
originalhostname = runCmd("hostname").output;
ui->lineEditHostname->setText(originalhostname);

//setup NOCSD GTK3 option
if (!QFileInfo::exists(QStringLiteral("/usr/bin/gtk3-nocsd"))) {
if (verbose) qDebug() << "gtk3-nocsd not found";
Expand Down Expand Up @@ -2550,6 +2556,16 @@ void defaultlook::on_ButtonApplyEtc_clicked()
}
}

//hostname setting
//if name doesn't validate, don't make any changes to any options, and don't reset gui.
if (ui->checkBoxComputerName->isChecked()){
if (validatecomputername(ui->lineEditHostname->text())){
changecomputername(ui->lineEditHostname->text());
} else {
return;
}
}
//checkbox options
if ( ! udisks_option.isEmpty() || ! sudo_override_option.isEmpty() || ! user_name_space_override_option.isEmpty() || ! intel_option.isEmpty() || ! lightdm_option.isEmpty() || ! amd_option.isEmpty() || ! radeon_option.isEmpty() || !bluetooth_option.isEmpty() || !recommends_option.isEmpty() || !debian_kernel_updates_option.isEmpty() || !liq_kernel_updates_option.isEmpty()){
runCmd("pkexec /usr/lib/mx-tweak/mx-tweak-lib.sh " + udisks_option + " " + sudo_override_option + " " + user_name_space_override_option + " " + intel_option + " " + amd_option + " " + radeon_option + " " + bluetooth_option + " " + recommends_option + " " + lightdm_option + " " + debian_kernel_updates_option + " " + liq_kernel_updates_option);

Expand All @@ -2558,6 +2574,23 @@ void defaultlook::on_ButtonApplyEtc_clicked()
setupEtc();
}

void defaultlook::changecomputername(QString hostname){
runCmd("pkexec /usr/lib/mx-tweak/mx-tweak-lib.sh hostname " + hostname);
}

bool defaultlook::validatecomputername(QString hostname){
// see if name is reasonable
if (hostname.isEmpty()) {
QMessageBox::critical(this, this->windowTitle(), tr("Please enter a computer name.", "question to enter a name for the computer hostname"));
return false;
} else if (hostname.contains(QRegularExpression("[^0-9a-zA-Z-.]|^[.-]|[.-]$|\\.\\."))) {
QMessageBox::critical(this, this->windowTitle(),
tr("Sorry, your computer name contains invalid characters.\nYou'll have to select a different\nname before proceeding.", "unacceptable characters are found in hostname, pick a new name"));
return false;
}
return true;
}

void defaultlook::on_checkBoxSingleClick_clicked()
{
ui->ButtonApplyMiscDefualts->setEnabled(true);
Expand Down Expand Up @@ -4204,3 +4237,15 @@ void defaultlook::on_checkBoxPlasmaDiscoverUpdater_clicked()
ui->ButtonApplyPlasma->setEnabled(true);
}


void defaultlook::on_checkBoxComputerName_clicked()
{
ui->ButtonApplyEtc->setEnabled(true);
if (ui->checkBoxComputerName->isChecked()){
ui->lineEditHostname->setEnabled(true);
} else {
ui->lineEditHostname->setEnabled(false);
}
}


5 changes: 5 additions & 0 deletions defaultlook.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ class defaultlook : public QDialog
QHash<QString, QString> theme_info;
QString pluginidsystray;
QString plugintasklist;
QString originalhostname;
QStringList undotheme;
bool verbose = false;
bool panelflag{};
Expand Down Expand Up @@ -183,6 +184,8 @@ class defaultlook : public QDialog
void setmissingxfconfvariables(const QString &activeprofile, const QString &resolution);
void fluxboxchangeinitvariable(const QString &initline, const QString &value) const;
void fluxboxchangedock() const;
void changecomputername(QString hostname);
bool validatecomputername(QString hostname);

private slots:
static void on_buttonCancel_clicked();
Expand Down Expand Up @@ -315,6 +318,8 @@ private slots:

void on_checkBoxPlasmaDiscoverUpdater_clicked();

void on_checkBoxComputerName_clicked();

private:
Ui::defaultlook *ui;
};
Expand Down
170 changes: 82 additions & 88 deletions defaultlook.ui
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>1109</width>
<height>746</height>
<height>829</height>
</rect>
</property>
<property name="minimumSize">
Expand Down Expand Up @@ -265,7 +265,7 @@
<enum>QTabWidget::North</enum>
</property>
<property name="currentIndex">
<number>6</number>
<number>8</number>
</property>
<widget class="QWidget" name="Panel">
<attribute name="title">
Expand Down Expand Up @@ -1936,62 +1936,49 @@
<layout class="QGridLayout" name="gridLayout_8">
<item row="0" column="0">
<layout class="QGridLayout" name="gridLayout_7">
<property name="sizeConstraint">
<enum>QLayout::SetNoConstraint</enum>
</property>
<item row="13" column="0" colspan="3">
<widget class="QCheckBox" name="checkboxRadeontearfree">
<item row="17" column="2">
<widget class="QRadioButton" name="radioSudoUser">
<property name="text">
<string>Use tearfree radeon driver option</string>
<string>&amp;User</string>
</property>
</widget>
</item>
<item row="14" column="0" colspan="3">
<widget class="QLabel" name="labelradeon">
<item row="11" column="0" colspan="4">
<widget class="QCheckBox" name="checkboxAMDtearfree">
<property name="text">
<string> NOTE: existing /etc/X11/xorg.conf.d/20-radeon.conf will be backed up to home folder</string>
<string>Use tearfree amdgpu option</string>
</property>
</widget>
</item>
<item row="18" column="0">
<item row="17" column="0" colspan="2">
<widget class="QLabel" name="label_11">
<property name="text">
<string>Password for administrative tasks:</string>
</property>
</widget>
</item>
<item row="20" column="0" colspan="3">
<widget class="QPushButton" name="ButtonApplyEtc">
<property name="minimumSize">
<size>
<width>0</width>
<height>32</height>
</size>
</property>
<item row="17" column="3">
<widget class="QRadioButton" name="radioSudoRoot">
<property name="text">
<string>Apply</string>
</property>
<property name="icon">
<iconset theme="dialog-ok">
<normaloff>.</normaloff>.</iconset>
<string>Root</string>
</property>
</widget>
</item>
<item row="5" column="0" colspan="3">
<widget class="QCheckBox" name="checkBoxDisableFluxboxMenuGeneration">
<item row="6" column="0" colspan="4">
<widget class="QCheckBox" name="checkBoxCSD">
<property name="text">
<string>Generate fluxbox All Apps menu after package installation, removal, and updates</string>
<string>Use Client Side Decorations (CSD) on GTK3 applications that support them (requires session restart)</string>
</property>
</widget>
</item>
<item row="0" column="0" colspan="3">
<widget class="QCheckBox" name="checkBoxLightdmReset">
<item row="10" column="0" colspan="3">
<widget class="QLabel" name="labelIntel">
<property name="text">
<string>Reset Lightdm (login screen) to system default theme</string>
<string> NOTE: existing /etc/X11/xorg.conf.d/20-intel.conf will be backed up to home folder</string>
</property>
</widget>
</item>
<item row="3" column="0" colspan="3">
<item row="3" column="0" colspan="4">
<widget class="QCheckBox" name="checkBoxbluetoothAutoEnable">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;requires reboot&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
Expand All @@ -2001,116 +1988,123 @@
</property>
</widget>
</item>
<item row="18" column="2">
<widget class="QRadioButton" name="radioSudoRoot">
<item row="4" column="0" colspan="4">
<widget class="QCheckBox" name="checkBoxInstallRecommends">
<property name="text">
<string>Root</string>
<string>Apt installs additional &quot;recommends&quot; packages as dependencies</string>
</property>
</widget>
</item>
<item row="11" column="0" colspan="3">
<widget class="QCheckBox" name="checkboxAMDtearfree">
<item row="2" column="0" colspan="4">
<widget class="QCheckBox" name="checkBoxSandbox">
<property name="text">
<string>Use tearfree amdgpu option</string>
<string>Enable kernel sandbox</string>
</property>
</widget>
</item>
<item row="12" column="0" colspan="3">
<widget class="QLabel" name="labelamdgpu">
<item row="14" column="0" colspan="3">
<widget class="QLabel" name="labelradeon">
<property name="text">
<string> NOTE: existing /etc/X11/xorg.conf.d/20-amd.conf will be backed up to home folder</string>
<string> NOTE: existing /etc/X11/xorg.conf.d/20-radeon.conf will be backed up to home folder</string>
</property>
</widget>
</item>
<item row="19" column="0" colspan="3">
<spacer name="verticalSpacer_6">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>77</height>
</size>
<item row="7" column="0" colspan="4">
<widget class="QCheckBox" name="checkBoxLiqKernelUpdates">
<property name="toolTip">
<string extracomment="toggle for apt hold action on update meta packages">put a hold or remove a hold on updates of Liquorix kernels</string>
</property>
</spacer>
</item>
<item row="4" column="0" colspan="3">
<widget class="QCheckBox" name="checkBoxInstallRecommends">
<property name="text">
<string>Apt installs additional &quot;recommends&quot; packages as dependencies</string>
<string extracomment="uses apt-mark to hold or unhold updates to kernel metapackages">Enable Automatic Liquorix Kernel Updates (MX ahs repository)</string>
</property>
</widget>
</item>
<item row="1" column="0" colspan="3">
<widget class="QCheckBox" name="checkBoxMountInternalDrivesNonRoot">
<item row="9" column="0" colspan="4">
<widget class="QCheckBox" name="checkboxIntelDriver">
<property name="text">
<string>Enable mounting of internal drives by non-root users</string>
<string>Use intel driver instead of default &quot;modesetting&quot; driver (requires restart)</string>
</property>
</widget>
</item>
<item row="10" column="0" colspan="3">
<widget class="QLabel" name="labelIntel">
<item row="8" column="0" colspan="4">
<widget class="QCheckBox" name="checkBoxDebianKernelUpdates">
<property name="toolTip">
<string extracomment="toggle for apt hold action on update meta packages">put a hold or remove a hold on updates of Debian kernels</string>
</property>
<property name="text">
<string> NOTE: existing /etc/X11/xorg.conf.d/20-intel.conf will be backed up to home folder</string>
<string extracomment="uses apt-mark to hold or unhold updates to kernel metapackages">Enable Automatic Debian Kernel Updates</string>
</property>
</widget>
</item>
<item row="18" column="1">
<widget class="QRadioButton" name="radioSudoUser">
<item row="5" column="0" colspan="4">
<widget class="QCheckBox" name="checkBoxDisableFluxboxMenuGeneration">
<property name="text">
<string>&amp;User</string>
<string>Generate fluxbox All Apps menu after package installation, removal, and updates</string>
</property>
</widget>
</item>
<item row="6" column="0" colspan="3">
<widget class="QCheckBox" name="checkBoxCSD">
<item row="13" column="0" colspan="4">
<widget class="QCheckBox" name="checkboxRadeontearfree">
<property name="text">
<string>Use Client Side Decorations (CSD) on GTK3 applications that support them (requires session restart)</string>
<string>Use tearfree radeon driver option</string>
</property>
</widget>
</item>
<item row="2" column="0" colspan="3">
<widget class="QCheckBox" name="checkBoxSandbox">
<item row="0" column="0" colspan="4">
<widget class="QCheckBox" name="checkBoxLightdmReset">
<property name="text">
<string>Enable kernel sandbox</string>
<string>Reset Lightdm (login screen) to system default theme</string>
</property>
</widget>
</item>
<item row="15" column="0" colspan="3">
<widget class="Line" name="line_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<item row="12" column="0" colspan="3">
<widget class="QLabel" name="labelamdgpu">
<property name="text">
<string> NOTE: existing /etc/X11/xorg.conf.d/20-amd.conf will be backed up to home folder</string>
</property>
</widget>
</item>
<item row="9" column="0" colspan="3">
<widget class="QCheckBox" name="checkboxIntelDriver">
<item row="1" column="0" colspan="4">
<widget class="QCheckBox" name="checkBoxMountInternalDrivesNonRoot">
<property name="text">
<string>Use intel driver instead of default &quot;modesetting&quot; driver (requires restart)</string>
<string>Enable mounting of internal drives by non-root users</string>
</property>
</widget>
</item>
<item row="7" column="0" colspan="3">
<widget class="QCheckBox" name="checkBoxLiqKernelUpdates">
<property name="toolTip">
<string extracomment="toggle for apt hold action on update meta packages">put a hold or remove a hold on updates of Liquorix kernels</string>
<item row="18" column="0" colspan="4">
<widget class="QPushButton" name="ButtonApplyEtc">
<property name="minimumSize">
<size>
<width>0</width>
<height>32</height>
</size>
</property>
<property name="text">
<string extracomment="uses apt-mark to hold or unhold updates to kernel metapackages">Enable Automatic Liquorix Kernel Updates (MX ahs repository)</string>
<string>Apply</string>
</property>
<property name="icon">
<iconset theme="dialog-ok">
<normaloff>.</normaloff>.</iconset>
</property>
</widget>
</item>
<item row="8" column="0" colspan="3">
<widget class="QCheckBox" name="checkBoxDebianKernelUpdates">
<property name="toolTip">
<string extracomment="toggle for apt hold action on update meta packages">put a hold or remove a hold on updates of Debian kernels</string>
<item row="16" column="0" colspan="4">
<widget class="Line" name="line_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="15" column="0">
<widget class="QCheckBox" name="checkBoxComputerName">
<property name="text">
<string extracomment="uses apt-mark to hold or unhold updates to kernel metapackages">Enable Automatic Debian Kernel Updates</string>
<string extracomment="option to change the system hostname, requires a reboot to be 100% effective">Change computer name (requires reboot)</string>
</property>
</widget>
</item>
<item row="15" column="2" colspan="2">
<widget class="QLineEdit" name="lineEditHostname"/>
</item>
</layout>
</item>
</layout>
Expand Down
Loading

0 comments on commit 25a6d04

Please sign in to comment.