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 8, 2023
1 parent 2209e76 commit 581448c
Show file tree
Hide file tree
Showing 8 changed files with 82 additions and 4 deletions.
4 changes: 4 additions & 0 deletions source/console/computer_dialog.cc
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ ComputerDialog::~ComputerDialog()
//--------------------------------------------------------------------------------------------------
void ComputerDialog::closeEvent(QCloseEvent* event)
{
LOG(LS_INFO) << "Close event";
settings_.setComputerDialogGeometry(saveGeometry());
settings_.setComputerDialogState(ui.splitter->saveState());
QDialog::closeEvent(event);
Expand Down Expand Up @@ -192,13 +193,16 @@ void ComputerDialog::buttonBoxClicked(QAbstractButton* button)
{
if (ui.button_box->standardButton(button) == QDialogButtonBox::Ok)
{
LOG(LS_INFO) << "[ACTION] Accepted by user";

if (!saveChanges())
return;

accept();
}
else
{
LOG(LS_INFO) << "[ACTION] Rejected by user";
reject();
}

Expand Down
24 changes: 22 additions & 2 deletions source/console/computer_dialog_desktop.cc
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,21 @@ void serializePixelFormat(const base::PixelFormat& from, proto::PixelFormat* to)
to->set_blue_shift(from.blueShift());
}

const char* videoEncodingToString(proto::VideoEncoding encoding)
{
switch (encoding)
{
case proto::VIDEO_ENCODING_ZSTD:
return "VIDEO_ENCODING_ZSTD";
case proto::VIDEO_ENCODING_VP8:
return "VIDEO_ENCODING_VP8";
case proto::VIDEO_ENCODING_VP9:
return "VIDEO_ENCODING_VP9";
default:
return "Unknown";
}
}

} // namespace

//--------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -285,8 +300,12 @@ void ComputerDialogDesktop::saveSettings(
//--------------------------------------------------------------------------------------------------
void ComputerDialogDesktop::onCodecChanged(int item_index)
{
bool has_pixel_format =
(ui.combo_codec->itemData(item_index).toInt() == proto::VIDEO_ENCODING_ZSTD);
proto::VideoEncoding encoding =
static_cast<proto::VideoEncoding>(ui.combo_codec->itemData(item_index).toInt());

LOG(LS_INFO) << "[ACTION] Video encoding changed: " << videoEncodingToString(encoding);

bool has_pixel_format = (encoding == proto::VIDEO_ENCODING_ZSTD);

ui.label_color_depth->setEnabled(has_pixel_format);
ui.combobox_color_depth->setEnabled(has_pixel_format);
Expand All @@ -299,6 +318,7 @@ void ComputerDialogDesktop::onCodecChanged(int item_index)
//--------------------------------------------------------------------------------------------------
void ComputerDialogDesktop::onCompressionRatioChanged(int value)
{
LOG(LS_INFO) << "[ACTION] Compression ratio changed: " << value;
ui.label_compress_ratio->setText(tr("Compression ratio: %1").arg(value));
}

Expand Down
7 changes: 7 additions & 0 deletions source/console/computer_dialog_general.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

#include "console/computer_dialog_general.h"

#include "base/logging.h"
#include "base/net/address.h"
#include "base/peer/user.h"
#include "base/strings/unicode.h"
Expand Down Expand Up @@ -130,6 +131,7 @@ bool ComputerDialogGeneral::saveSettings(proto::address_book::Computer* computer
QString name = ui.edit_name->text();
if (name.length() > kMaxNameLength)
{
LOG(LS_ERROR) << "Too long name: " << name.length();
showError(tr("Too long name. The maximum length of the name is %n characters.",
"", kMaxNameLength));
ui.edit_name->setFocus();
Expand All @@ -138,6 +140,7 @@ bool ComputerDialogGeneral::saveSettings(proto::address_book::Computer* computer
}
else if (name.length() < kMinNameLength)
{
LOG(LS_ERROR) << "Name can not be empty";
showError(tr("Name can not be empty."));
ui.edit_name->setFocus();
return false;
Expand All @@ -148,6 +151,7 @@ bool ComputerDialogGeneral::saveSettings(proto::address_book::Computer* computer

if (!username.empty() && !base::User::isValidUserName(username))
{
LOG(LS_ERROR) << "Invalid user name: " << username;
showError(tr("The user name can not be empty and can contain only"
" alphabet characters, numbers and ""_"", ""-"", ""."" characters."));
ui.edit_username->setFocus();
Expand All @@ -158,6 +162,7 @@ bool ComputerDialogGeneral::saveSettings(proto::address_book::Computer* computer
QString comment = ui.edit_comment->toPlainText();
if (comment.length() > kMaxCommentLength)
{
LOG(LS_ERROR) << "Too long comment: " << comment.length();
showError(tr("Too long comment. The maximum length of the comment is %n characters.",
"", kMaxCommentLength));
ui.edit_comment->setFocus();
Expand All @@ -175,6 +180,7 @@ bool ComputerDialogGeneral::saveSettings(proto::address_book::Computer* computer
ui.edit_address->text().toStdU16String(), DEFAULT_HOST_TCP_PORT);
if (!address.isValid())
{
LOG(LS_ERROR) << "Invalid address: " << ui.edit_address->text().toStdString();
showError(tr("An invalid computer address was entered."));
ui.edit_address->setFocus();
ui.edit_address->selectAll();
Expand All @@ -196,6 +202,7 @@ bool ComputerDialogGeneral::saveSettings(proto::address_book::Computer* computer
//--------------------------------------------------------------------------------------------------
void ComputerDialogGeneral::showPasswordButtonToggled(bool checked)
{
LOG(LS_INFO) << "[ACTION] Show password: " << checked;
if (checked)
{
ui.edit_password->setEchoMode(QLineEdit::Normal);
Expand Down
7 changes: 7 additions & 0 deletions source/console/computer_group_dialog.cc
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ ComputerGroupDialog::~ComputerGroupDialog()
//--------------------------------------------------------------------------------------------------
void ComputerGroupDialog::closeEvent(QCloseEvent* event)
{
LOG(LS_INFO) << "Close event";
settings_.setComputerGroupDialogGeometry(saveGeometry());
QDialog::closeEvent(event);
}
Expand Down Expand Up @@ -180,13 +181,16 @@ void ComputerGroupDialog::buttonBoxClicked(QAbstractButton* button)
{
if (ui.button_box->standardButton(button) == QDialogButtonBox::Ok)
{
LOG(LS_INFO) << "[ACTION] Accepted by user";

if (!saveChanges())
return;

accept();
}
else
{
LOG(LS_INFO) << "[ACTION] Rejected by user";
reject();
}

Expand Down Expand Up @@ -225,6 +229,7 @@ bool ComputerGroupDialog::saveChanges()
QString name = ui.edit_name->text();
if (name.length() > kMaxNameLength)
{
LOG(LS_ERROR) << "Too long name: " << name.length();
showError(tr("Too long name. The maximum length of the name is %n characters.",
"", kMaxNameLength));
ui.edit_name->setFocus();
Expand All @@ -233,6 +238,7 @@ bool ComputerGroupDialog::saveChanges()
}
else if (name.length() < kMinNameLength)
{
LOG(LS_ERROR) << "Name can not be empty";
showError(tr("Name can not be empty."));
ui.edit_name->setFocus();
return false;
Expand All @@ -241,6 +247,7 @@ bool ComputerGroupDialog::saveChanges()
QString comment = ui.edit_comment->toPlainText();
if (comment.length() > kMaxCommentLength)
{
LOG(LS_ERROR) << "Too long comment: " << comment.length();
showError(tr("Too long comment. The maximum length of the comment is %n characters.",
"", kMaxCommentLength));
ui.edit_comment->setFocus();
Expand Down
24 changes: 22 additions & 2 deletions source/console/computer_group_dialog_desktop.cc
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,21 @@ void serializePixelFormat(const base::PixelFormat& from, proto::PixelFormat* to)
to->set_blue_shift(from.blueShift());
}

const char* videoEncodingToString(proto::VideoEncoding encoding)
{
switch (encoding)
{
case proto::VIDEO_ENCODING_ZSTD:
return "VIDEO_ENCODING_ZSTD";
case proto::VIDEO_ENCODING_VP8:
return "VIDEO_ENCODING_VP8";
case proto::VIDEO_ENCODING_VP9:
return "VIDEO_ENCODING_VP9";
default:
return "Unknown";
}
}

} // namespace

//--------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -301,8 +316,12 @@ void ComputerGroupDialogDesktop::saveSettings(
//--------------------------------------------------------------------------------------------------
void ComputerGroupDialogDesktop::onCodecChanged(int item_index)
{
bool has_pixel_format =
(ui.combo_codec->itemData(item_index).toInt() == proto::VIDEO_ENCODING_ZSTD);
proto::VideoEncoding encoding =
static_cast<proto::VideoEncoding>(ui.combo_codec->itemData(item_index).toInt());

LOG(LS_INFO) << "[ACTION] Video encoding changed: " << videoEncodingToString(encoding);

bool has_pixel_format = (encoding == proto::VIDEO_ENCODING_ZSTD);

ui.label_color_depth->setEnabled(has_pixel_format);
ui.combobox_color_depth->setEnabled(has_pixel_format);
Expand All @@ -315,6 +334,7 @@ void ComputerGroupDialogDesktop::onCodecChanged(int item_index)
//--------------------------------------------------------------------------------------------------
void ComputerGroupDialogDesktop::onCompressionRatioChanged(int value)
{
LOG(LS_INFO) << "[ACTION] Compression ratio changed: " << value;
ui.label_compress_ratio->setText(tr("Compression ratio: %1").arg(value));
}

Expand Down
2 changes: 2 additions & 0 deletions source/console/computer_group_dialog_general.cc
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ bool ComputerGroupDialogGeneral::saveSettings(proto::address_book::ComputerGroup

if (!username.empty() && !base::User::isValidUserName(username))
{
LOG(LS_INFO) << "Invalid user name: " << username;
showError(tr("The user name can not be empty and can contain only"
" alphabet characters, numbers and ""_"", ""-"", ""."" characters."));
ui.edit_username->setFocus();
Expand All @@ -119,6 +120,7 @@ bool ComputerGroupDialogGeneral::saveSettings(proto::address_book::ComputerGroup
//--------------------------------------------------------------------------------------------------
void ComputerGroupDialogGeneral::showPasswordButtonToggled(bool checked)
{
LOG(LS_INFO) << "[ACTION] Show password: " << checked;
if (checked)
{
ui.edit_password->setEchoMode(QLineEdit::Normal);
Expand Down
12 changes: 12 additions & 0 deletions source/console/fast_connect_dialog.cc
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,9 @@ void FastConnectDialog::sessionTypeChanged(int item_index)
state_.session_type = static_cast<proto::SessionType>(
ui.combo_session_type->itemData(item_index).toInt());

LOG(LS_INFO) << "[ACTION] Session type changed: "
<< common::sessionTypeToString(state_.session_type);

if (ui.checkbox_use_session_params->isChecked())
{
ui.button_session_config->setEnabled(false);
Expand All @@ -171,6 +174,8 @@ void FastConnectDialog::sessionTypeChanged(int item_index)
//--------------------------------------------------------------------------------------------------
void FastConnectDialog::sessionConfigButtonPressed()
{
LOG(LS_INFO) << "[ACTION] Session config button pressed";

proto::SessionType session_type = static_cast<proto::SessionType>(
ui.combo_session_type->currentData().toInt());

Expand Down Expand Up @@ -210,11 +215,14 @@ void FastConnectDialog::onButtonBoxClicked(QAbstractButton* button)
{
if (ui.button_box->standardButton(button) == QDialogButtonBox::Cancel)
{
LOG(LS_INFO) << "[ACTION] Rejected by user";
reject();
close();
return;
}

LOG(LS_INFO) << "[ACTION] Accepted by user";

QComboBox* combo_address = ui.combo_address;
QString current_address = combo_address->currentText();
bool host_id_entered = true;
Expand All @@ -230,6 +238,7 @@ void FastConnectDialog::onButtonBoxClicked(QAbstractButton* button)

if (host_id_entered && !router_config_.has_value())
{
LOG(LS_ERROR) << "Router not configured";
QMessageBox::warning(this,
tr("Warning"),
tr("Connection by ID is specified but the router is not configured. "
Expand All @@ -250,6 +259,7 @@ void FastConnectDialog::onButtonBoxClicked(QAbstractButton* button)

if (!address.isValid())
{
LOG(LS_ERROR) << "Invalid address entered";
QMessageBox::warning(this,
tr("Warning"),
tr("An invalid computer address was entered."),
Expand Down Expand Up @@ -344,10 +354,12 @@ void FastConnectDialog::onButtonBoxClicked(QAbstractButton* button)
session_window->setAttribute(Qt::WA_DeleteOnClose);
if (!session_window->connectToHost(client_config))
{
LOG(LS_ERROR) << "Unable to connect";
session_window->close();
}
else
{
LOG(LS_INFO) << "Close fast connect dialog";
accept();
close();
}
Expand Down
6 changes: 6 additions & 0 deletions source/console/update_settings_dialog.cc
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,16 @@ UpdateSettingsDialog::UpdateSettingsDialog(QWidget* parent)
{
if (ui.button_box->standardButton(button) == QDialogButtonBox::Ok)
{
LOG(LS_INFO) << "[ACTION] Accepted by user";

Settings settings;
settings.setCheckUpdates(ui.checkbox_check_updates->isChecked());
settings.setUpdateServer(ui.edit_server->text());
}
else
{
LOG(LS_INFO) << "[ACTION] Rejected by user";
}

close();
});
Expand Down

0 comments on commit 581448c

Please sign in to comment.