Skip to content

Commit

Permalink
Merge pull request #165 from electux/dev
Browse files Browse the repository at this point in the history
[microhil] Preparing migration to gtkmm 4.0 #159
  • Loading branch information
vroncevic authored Aug 1, 2024
2 parents b014567 + 1bfee6b commit ed84959
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 11 deletions.
2 changes: 1 addition & 1 deletion sw/microhildesk/com/serial_com.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ namespace Electux::App::Com
{
public:
//////////////////////////////////////////////////////////////////////
/// @brief MicroHILCom constructor
/// @brief SerialCom constructor
explicit SerialCom();

//////////////////////////////////////////////////////////////////////
Expand Down
15 changes: 13 additions & 2 deletions sw/microhildesk/view/settings/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,14 @@
#include <gtkmm/label.h>
#include <gtkmm/entry.h>
#include <gtkmm/comboboxtext.h>
#include <sigc++/sigc++.h>
#include "settings_setup.h"

namespace Electux::App::View::Settings
{
//////////////////////////////////////////////////////////////////////////
/// @brief Serial port parameters type
using SerialParams = std::vector<unsigned int>;
/// @brief Signal type for serial settings
using SigSetup = sigc::signal<void(SettingsSetup &)>;

//////////////////////////////////////////////////////////////////////////
/// @brief Application settings window definition
Expand All @@ -42,6 +44,11 @@ namespace Electux::App::View::Settings
/// @brief AppSettings constructor
explicit AppSettings();

//////////////////////////////////////////////////////////////////////
/// @brief Signal for serial settings
/// @return Signal for changed serial settings
SigSetup setup_changed();

private:
//////////////////////////////////////////////////////////////////////
/// @brief Maps channels (signals and slots)
Expand All @@ -55,6 +62,10 @@ namespace Electux::App::View::Settings
/// @brief On action Cancel button
void on_button_cancel_clicked();

//////////////////////////////////////////////////////////////////////
/// @brief Signal for the serial settings
SigSetup m_setup{};

//////////////////////////////////////////////////////////////////////
/// @brief Vertical box as root container
Gtk::Box m_box_root;
Expand Down
51 changes: 51 additions & 0 deletions sw/microhildesk/view/settings/settings_setup.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/* -*- Mode: H; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
/*
* settings_setup.h
* Copyright (C) 2024 Vladimir Roncevic <elektron.ronca@gmail.com>
*
* microhildesk is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* microhildesk is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once

#include <glibmm/ustring.h>
#include <vector>

namespace Electux::App::View::Settings
{
//////////////////////////////////////////////////////////////////////////
/// @brief Setup settings for collected parameters
class SettingsSetup
{
public:
//////////////////////////////////////////////////////////////////////
/// @brief SettingsSetup constructor
inline SettingsSetup() noexcept = default;

//////////////////////////////////////////////////////////////////////
/// @brief SettingsSetup destructor
inline ~SettingsSetup() noexcept = default;

//////////////////////////////////////////////////////////////////////
/// @brief Settings parameters
/// m_serial_device_path - absolute path for serial device file
/// m_serial_params - baud, data, parity, stop parameters
/// m_log_file_path - absolute path for log file
/// m_log_level - log level
Glib::ustring m_serial_device_path;
std::vector<int> m_serial_params;
Glib::ustring m_log_file_path;
int m_log_level;
};
};

35 changes: 27 additions & 8 deletions sw/microhildesk/view/settings/settings_slots.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,38 @@ using namespace Electux::App::View::Settings;
void AppSettings::on_button_ok_clicked()
{
//////////////////////////////////////////////////////////////////////////
/// Perform action on OK button
auto device_path = m_entry_serial_path.get_text();
SerialParams serialParams{};
serialParams.push_back(m_combo_serial_baud.get_active_row_number());
serialParams.push_back(m_combo_serial_data.get_active_row_number());
serialParams.push_back(m_combo_serial_parity.get_active_row_number());
serialParams.push_back(m_combo_serial_stop.get_active_row_number());
/// Performs action on OK button
SettingsSetup setup;
setup.m_serial_device_path = m_entry_serial_path.get_text();
setup.m_serial_params.push_back(
m_combo_serial_baud.get_active_row_number()
);
setup.m_serial_params.push_back(
m_combo_serial_data.get_active_row_number()
);
setup.m_serial_params.push_back(
m_combo_serial_parity.get_active_row_number()
);
setup.m_serial_params.push_back(
m_combo_serial_stop.get_active_row_number()
);
setup.m_log_file_path = m_entry_log_path.get_text();
setup.m_log_level = m_combo_log_level.get_active_row_number();

//////////////////////////////////////////////////////////////////////////
/// Emits new serial/log settings setup
m_setup.emit(setup);

//////////////////////////////////////////////////////////////////////////
/// Hide settings window
hide();
}

void AppSettings::on_button_cancel_clicked()
{
//////////////////////////////////////////////////////////////////////////
/// Perform action on Cancel button
/// Performs action on Cancel button
hide();
}

SigSetup AppSettings::setup_changed() { return m_setup; }

0 comments on commit ed84959

Please sign in to comment.