view MainWindow.h @ 2:177f640940f2

Update exception class and cleanup redifinitions During firmware download and exception caused the application to stop. Rootcause was the defference between QT5 and QT6 exception and string handling which is updated now. In addition some old definitions were removed to avoid compiler warnings.
author Ideenmodellierer
date Fri, 28 Nov 2025 19:57:35 +0100
parents 0b3630a29ad8
children
line wrap: on
line source

//////////////////////////////////////////////////////////////////////////////
/// \file   MainWindow.h
/// \brief  GUI for OSTC Companion.
/// \author JD Gascuel.
///
/// \copyright (c) 2011-2014 JD Gascuel. All rights reserved.
/// $Id$
//////////////////////////////////////////////////////////////////////////////
//
// BSD 2-Clause License:
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
//
// 1. Redistributions of source code must retain the above copyright notice,
//    this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright notice,
//    this list of conditions and the following disclaimer in the documentation
//    and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
// THE POSSIBILITY OF SUCH DAMAGE.
//
//////////////////////////////////////////////////////////////////////////////
// HISTORY
//  2013-03-17 : [jDG] Initial version.
//  2013-03-26 : [jDG] Added scan feature for HW factory programming.
//  2014-07-07 : [jDG] Cleanups for Subsurface google-summer-of-code.
//  2014-07-25 : [jDG] BSD 2-clause license.

#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>

namespace Ui {
class MainWindow;
}
class HardwareOperations;
class QProgressBar;

//////////////////////////////////////////////////////////////////////////////
/// \brief  GUI for OSTC Companion.
///
/// Implement the *Companion* user interface.
///
class MainWindow : public QMainWindow
{
    Q_OBJECT
    Ui::MainWindow*     _ui;    ///< Compiled interface.
    HardwareOperations* _op;    ///< Driver for the connected dive computer.

    //------------------------------------------------------------------------
    /// \brief Update buttons enable/disable state.
    /// According to connection status (not/normal/service), and high level
    /// commands supported by a given computer model.
    void updateStatus();

    //------------------------------------------------------------------------
    /// \brief Display a message on the embedded console.
    ///
    void statusMessage(const QString &msg);
    friend class LogWindow;

    //------------------------------------------------------------------------
    /// \brief Manage asynchronous ProgressEvent events.
    ///
    bool event(QEvent *e) override;

public:
    //////////////////////////////////////////////////////////////////////////
    /// \brief Constructor.
    ///
    /// Starts everything, and instanciate the driver found in settings.
    MainWindow();

    //------------------------------------------------------------------------
    /// \brief Destructor.
    /// Release interface and driver.
    ~MainWindow();

    //------------------------------------------------------------------------
    /// \brief Handle Language changes.
    /// Re-apply translations to all interface elements.
    void retranslate();

public slots:
    /// \brief User changed computer model.
    void changeTypeSlot();

    /// \brief Pop SettingsDialog preferences interface.
    void settingsSlot();

    /// \brief Try to connect to the device.
    void connectSlot();

    /// \brief Try to set Date & Time on the connected device.
    void dateSlot();

    /// \brief Try to change custom text on the connected device.
    void nameSlot();

    /// \brief Try to set custom image on the connected device.
    void iconSlot();

    /// \brief Try to upgrade firmware of the connected device.
    void upgradeSlot();

    /// \brief Close current connection to the device.
    void closeSlot();
private slots:
    void on_signalButton_clicked();
    void on_editLog_clicked();
};

#endif // MAINWINDOW_H