Skip to content

Commit

Permalink
Added debug messages.
Browse files Browse the repository at this point in the history
  • Loading branch information
dchapyshev committed Nov 17, 2023
1 parent ddf05a8 commit 78cb0b0
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 19 deletions.
6 changes: 6 additions & 0 deletions source/host/ui/change_password_dialog.cc
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ void ChangePasswordDialog::onButtonBoxClicked(QAbstractButton* button)

if (new_password.isEmpty())
{
LOG(LS_ERROR) << "Password cannot be empty";
QMessageBox::warning(this,
tr("Warning"),
tr("Password cannot be empty."),
Expand All @@ -103,6 +104,7 @@ void ChangePasswordDialog::onButtonBoxClicked(QAbstractButton* button)

if (new_password != new_password_repeat)
{
LOG(LS_ERROR) << "Password entered do not match";
QMessageBox::warning(this,
tr("Warning"),
tr("The passwords entered do not match."),
Expand All @@ -122,6 +124,7 @@ void ChangePasswordDialog::onButtonBoxClicked(QAbstractButton* button)

if (old_password.isEmpty())
{
LOG(LS_ERROR) << "Old password not entered";
QMessageBox::warning(this,
tr("Warning"),
tr("You must enter your old password."),
Expand All @@ -132,6 +135,7 @@ void ChangePasswordDialog::onButtonBoxClicked(QAbstractButton* button)

if (!SystemSettings::isValidPassword(old_password.toStdString()))
{
LOG(LS_ERROR) << "Incorrect password entered";
QMessageBox::warning(this,
tr("Warning"),
tr("You entered an incorrect old password."),
Expand All @@ -143,6 +147,7 @@ void ChangePasswordDialog::onButtonBoxClicked(QAbstractButton* button)

if (new_password.isEmpty())
{
LOG(LS_ERROR) << "New password cannot be empty";
QMessageBox::warning(this,
tr("Warning"),
tr("New password cannot be empty."),
Expand All @@ -153,6 +158,7 @@ void ChangePasswordDialog::onButtonBoxClicked(QAbstractButton* button)

if (new_password != new_password_repeat)
{
LOG(LS_ERROR) << "Password entered do not match";
QMessageBox::warning(this,
tr("Warning"),
tr("The passwords entered do not match."),
Expand Down
38 changes: 20 additions & 18 deletions source/host/ui/config_dialog.cc
Original file line number Diff line number Diff line change
Expand Up @@ -89,20 +89,20 @@ ConfigDialog::ConfigDialog(QWidget* parent)
connect(ui.combobox_update_check_freq, QOverload<int>::of(&QComboBox::currentIndexChanged),
this, [this](int /* index */)
{
setConfigChanged(true);
setConfigChanged(FROM_HERE, true);
});

connect(ui.checkbox_auto_update, &QCheckBox::toggled, this, [this](bool checked)
{
setConfigChanged(true);
setConfigChanged(FROM_HERE, true);

ui.label_update_check_freq->setEnabled(checked);
ui.combobox_update_check_freq->setEnabled(checked);
});

connect(ui.checkbox_use_custom_server, &QCheckBox::toggled, this, [this](bool checked)
{
setConfigChanged(true);
setConfigChanged(FROM_HERE, true);

ui.label_update_server->setEnabled(checked);
ui.edit_update_server->setEnabled(checked);
Expand Down Expand Up @@ -147,7 +147,7 @@ ConfigDialog::ConfigDialog(QWidget* parent)
connect(ui.combobox_onetime_pass_change, QOverload<int>::of(&QComboBox::currentIndexChanged),
this, [this]()
{
setConfigChanged(true);
setConfigChanged(FROM_HERE, true);
});

ui.combobox_onetime_pass_chars->addItem(tr("Letters and digits"),
Expand All @@ -161,7 +161,7 @@ ConfigDialog::ConfigDialog(QWidget* parent)
connect(ui.combobox_onetime_pass_chars, QOverload<int>::of(&QComboBox::currentIndexChanged),
this, [this]()
{
setConfigChanged(true);
setConfigChanged(FROM_HERE, true);
});

connect(ui.spinbox_onetime_pass_char_count, QOverload<int>::of(&QSpinBox::valueChanged),
Expand All @@ -181,7 +181,7 @@ ConfigDialog::ConfigDialog(QWidget* parent)
connect(ui.combobox_conn_confirm_auto, QOverload<int>::of(&QComboBox::currentIndexChanged),
this, [this]()
{
setConfigChanged(true);
setConfigChanged(FROM_HERE, true);
});

ui.combobox_no_user_action->addItem(tr("Accept connection"),
Expand All @@ -192,14 +192,14 @@ ConfigDialog::ConfigDialog(QWidget* parent)
connect(ui.combobox_no_user_action, QOverload<int>::of(&QComboBox::currentIndexChanged),
this, [this]()
{
setConfigChanged(true);
setConfigChanged(FROM_HERE, true);
});

//---------------------------------------------------------------------------------------------
// Other
connect(ui.checkbox_disable_shutdown, &QCheckBox::toggled, [=]()
{
setConfigChanged(true);
setConfigChanged(FROM_HERE, true);
});

//---------------------------------------------------------------------------------------------
Expand All @@ -208,7 +208,7 @@ ConfigDialog::ConfigDialog(QWidget* parent)

connect(ui.checkbox_enable_router, &QCheckBox::toggled, this, [this](bool checked)
{
setConfigChanged(true);
setConfigChanged(FROM_HERE, true);
ui.label_router_address->setEnabled(checked);
ui.edit_router_address->setEnabled(checked);
ui.label_router_public_key->setEnabled(checked);
Expand Down Expand Up @@ -271,7 +271,7 @@ ConfigDialog::ConfigDialog(QWidget* parent)

connect(ui.combo_video_capturer, QOverload<int>::of(&QComboBox::currentIndexChanged), this, [this]()
{
setConfigChanged(true);
setConfigChanged(FROM_HERE, true);
});

ui.tab_bar->setTabVisible(4, QApplication::keyboardModifiers().testFlag(Qt::ShiftModifier));
Expand Down Expand Up @@ -304,7 +304,7 @@ void ConfigDialog::onOneTimeStateChanged(int state)
ui.label_onetime_pass_char_count->setEnabled(enable);
ui.spinbox_onetime_pass_char_count->setEnabled(enable);

setConfigChanged(true);
setConfigChanged(FROM_HERE, true);
}

//--------------------------------------------------------------------------------------------------
Expand All @@ -317,7 +317,7 @@ void ConfigDialog::onConnConfirmStateChanged(int state)
ui.label_no_user_action->setEnabled(enable);
ui.combobox_no_user_action->setEnabled(enable);

setConfigChanged(true);
setConfigChanged(FROM_HERE, true);
}

//--------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -364,7 +364,7 @@ void ConfigDialog::onAddUser()
if (dialog.exec() == QDialog::Accepted)
{
ui.tree_users->addTopLevelItem(new UserTreeItem(dialog.user()));
setConfigChanged(true);
setConfigChanged(FROM_HERE, true);
}
}

Expand Down Expand Up @@ -394,7 +394,7 @@ void ConfigDialog::onModifyUser()
if (dialog.exec() == QDialog::Accepted)
{
current_item->setUser(dialog.user());
setConfigChanged(true);
setConfigChanged(FROM_HERE, true);
}
}

Expand Down Expand Up @@ -423,7 +423,7 @@ void ConfigDialog::onDeleteUser()
{
LOG(LS_INFO) << "[ACTION] Accepted by user";
delete user_item;
setConfigChanged(true);
setConfigChanged(FROM_HERE, true);
}
else
{
Expand Down Expand Up @@ -724,7 +724,7 @@ void ConfigDialog::onButtonBoxClicked(QAbstractButton* button)

settings.flush();

setConfigChanged(false);
setConfigChanged(FROM_HERE, false);

if (service_restart_required)
restartService();
Expand All @@ -748,8 +748,10 @@ void ConfigDialog::onButtonBoxClicked(QAbstractButton* button)
}

//--------------------------------------------------------------------------------------------------
void ConfigDialog::setConfigChanged(bool changed)
void ConfigDialog::setConfigChanged(const base::Location& location, bool changed)
{
LOG(LS_INFO) << "Config changed (from=" << location.toString() << "changed=" << changed << ")";

QPushButton* apply_button = ui.button_box->button(QDialogButtonBox::Apply);
if (!apply_button)
{
Expand Down Expand Up @@ -859,7 +861,7 @@ void ConfigDialog::reloadAll()

ui.checkbox_disable_shutdown->setChecked(settings.isApplicationShutdownDisabled());

setConfigChanged(false);
setConfigChanged(FROM_HERE, false);
}

//--------------------------------------------------------------------------------------------------
Expand Down
3 changes: 2 additions & 1 deletion source/host/ui/config_dialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#define HOST_UI_CONFIG_DIALOG_H

#include "build/build_config.h"
#include "base/location.h"
#include "base/peer/user_list.h"
#include "qt_base/locale_loader.h"
#include "ui_config_dialog.h"
Expand Down Expand Up @@ -52,7 +53,7 @@ private slots:
void onButtonBoxClicked(QAbstractButton* button);

private:
void setConfigChanged(bool changed);
void setConfigChanged(const base::Location& location, bool changed);
bool isConfigChanged() const;
void reloadAll();
void reloadUserList(const base::UserList& user_list);
Expand Down

0 comments on commit 78cb0b0

Please sign in to comment.