📝 docs(_explanation): in depth explanation

This commit is contained in:
eshanized
2024-12-20 18:38:07 +05:30
parent cd6240536b
commit fc3465c8c1

View File

@@ -1,50 +1,76 @@
#ifndef SNIGDHAOSBLACKBOX_H #ifndef SNIGDHAOSBLACKBOX_H // Start of include guard to prevent multiple inclusions of this header file.
#define SNIGDHAOSBLACKBOX_H #define SNIGDHAOSBLACKBOX_H // Define the include guard macro.
#include <QMainWindow> #include <QMainWindow> // Base class for the main window of a Qt application, providing menus, toolbars, etc.
#include <QAbstractButton> #include <QAbstractButton> // Abstract base class for button widgets such as QPushButton, QCheckBox, etc.
#include <QtNetwork/QNetworkAccessManager> #include <QtNetwork/QNetworkAccessManager> // Used for sending and managing network requests and responses.
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE // Marks the start of Qt's namespace, for compatibility with C++ namespaces.
namespace Ui { namespace Ui {
class SnigdhaOSBlackbox; class SnigdhaOSBlackbox; // Forward declaration of the `Ui::SnigdhaOSBlackbox` class, generated from the .ui file.
} }
QT_END_NAMESPACE QT_END_NAMESPACE // Marks the end of the Qt namespace.
class SnigdhaOSBlackbox : public QMainWindow class SnigdhaOSBlackbox : public QMainWindow // Inherits from QMainWindow to represent the application's main window.
{ {
Q_OBJECT Q_OBJECT // Qt's macro enabling signals, slots, and other meta-object features.
public: public:
// Enumeration for managing the application's various states.
enum class State { enum class State {
QUIT, QUIT, // Exit the application.
WELCOME, WELCOME, // Display the welcome screen.
INTERNET, INTERNET, // Check internet connectivity.
UPDATE, UPDATE, // Perform updates.
UPDATE_RETRY, UPDATE_RETRY, // Retry updating if the previous attempt failed.
SELECT, SELECT, // Allow the user to select options or tools.
APPLY, APPLY, // Apply the selected options or configurations.
APPLY_RETRY, APPLY_RETRY, // Retry applying changes if the first attempt fails.
SUCCESS SUCCESS // Indicate successful completion of operations.
}; };
// Constructor for the SnigdhaOSBlackbox class.
// Parameters:
// - parent: Pointer to the parent widget. Defaults to nullptr, meaning no parent.
// - state: The initial state of the application, defaulting to "WELCOME".
SnigdhaOSBlackbox(QWidget *parent = nullptr, QString state = "WELCOME"); SnigdhaOSBlackbox(QWidget *parent = nullptr, QString state = "WELCOME");
// Destructor to clean up resources.
~SnigdhaOSBlackbox(); ~SnigdhaOSBlackbox();
private slots:
private slots: // Qt slots, which respond to signals (e.g., button clicks).
// Slot to handle button clicks in the text widget.
void on_textWidget_buttonBox_clicked(QAbstractButton* button); void on_textWidget_buttonBox_clicked(QAbstractButton* button);
// Slot to handle button clicks in the select widget.
void on_selectWidget_buttonBox_Clicked(QAbstractButton* button); void on_selectWidget_buttonBox_Clicked(QAbstractButton* button);
private: private:
Ui::SnigdhaOSBlackbox *ui; Ui::SnigdhaOSBlackbox *ui; // Pointer to the UI object generated from the .ui file.
QDateTime executable_modify_date;
State currentState;
void doInternetUpRequest(); QDateTime executable_modify_date; // Stores the modification date of the application executable, possibly for update checks.
void doUpdate();
void doApply(); State currentState; // Keeps track of the current state of the application.
// Private member functions for internal operations:
void doInternetUpRequest(); // Checks for internet connectivity.
void doUpdate(); // Handles the update process.
void doApply(); // Applies the selected configuration or changes.
// Populates the selection widget with options.
void populateSelectWidget(); void populateSelectWidget();
// Overloaded version to populate the widget with specific files and labels.
void populateSelectWidget(QString filename, QString label); void populateSelectWidget(QString filename, QString label);
// Updates the application state using the `State` enum.
void updateState(State state); void updateState(State state);
// Overloaded version to update the application state using a QString.
void updateState(QString state); void updateState(QString state);
// Relaunches the application, possibly with additional parameters.
void relaunchSelf(QString param); void relaunchSelf(QString param);
}; };
#endif // SNIGDHAOSBLACKBOX_H
#endif // SNIGDHAOSBLACKBOX_H // End of the include guard.