Skip to content

FinceptTerminal is a modern finance application offering advanced market analytics, investment research, and economic data tools, designed for interactive exploration and data-driven decision-making in a user-friendly environment.

2.8 KB
Raw Blame
#pragma once
#include "screens/dashboard/DashboardStatusBar.h"
#include "screens/dashboard/DashboardToolBar.h"
#include "screens/dashboard/MarketPulsePanel.h"
#include "screens/dashboard/TickerBar.h"
#include "screens/dashboard/canvas/DashboardCanvas.h"
#include "services/markets/MarketDataService.h"

namespace fincept::ui {
class NotifToast;
} // namespace fincept::ui

class QLabel;

#include <QHash>
#include <QHideEvent>
#include <QScrollArea>
#include <QShowEvent>
#include <QSplitter>
#include <QTimer>
#include <QWidget>

namespace fincept::screens {

/// Main dashboard screen — toolbar, ticker, draggable widget grid, market pulse, status bar.
///
/// The ticker driver subscribes to `market:quote:<sym>` on the DataHub for
/// every user-configured ticker symbol. A cached per-symbol QuoteData is
/// pushed to the TickerBar on each delivery via `rebuild_ticker_from_cache()`.
/// `symbols_changed` wipes old subscriptions and re-subscribes to the new
/// set. Cadence is owned by the hub scheduler, not a local refresh timer.
class DashboardScreen : public QWidget {
    Q_OBJECT
  public:
    explicit DashboardScreen(QWidget* parent = nullptr);

  protected:
    void showEvent(QShowEvent* event) override;
    void hideEvent(QHideEvent* event) override;
    bool eventFilter(QObject* obj, QEvent* event) override;

  private slots:
    // A slot (not a plain method) so WindowFrame's F5 / View ▸ Refresh probe,
    // which looks the handler up by name, can reach it.
    void on_refresh_clicked();

  private:
    void refresh_theme();
    void build_default_layout();
    void save_layout();
    void restore_layout();
    void refresh_ticker();

    void hub_resubscribe_ticker(bool force_fetch);
    void hub_unsubscribe_ticker();
    void rebuild_ticker_from_cache();
    /// Slim, dismissible Fincept Terminal Enterprise strip under the ticker.
    /// Fixed height; dismissal lasts until the next release.
    QWidget* build_enterprise_strip();

    DashboardToolBar* toolbar_ = nullptr;
    TickerBar* ticker_bar_ = nullptr;
    QWidget* ent_strip_ = nullptr;
    QLabel* ent_strip_text_ = nullptr;
    QScrollArea* scroll_area_ = nullptr;
    DashboardCanvas* canvas_ = nullptr;
    QSplitter* content_split_ = nullptr;
    MarketPulsePanel* market_pulse_ = nullptr;
    DashboardStatusBar* status_bar_ = nullptr;
    fincept::ui::NotifToast* notif_toast_ = nullptr;
    QTimer* save_timer_ = nullptr;
    bool pulse_visible_ = true;
    bool layout_restored_ = false;
    bool split_sized_ = false;
    /// COMPACT toggle state. Was a function-local `static bool` in the lambda,
    /// i.e. shared by every DashboardScreen instance and out of sync with the
    /// canvas after a screen rebuild.
    bool compact_rows_ = false;

    QHash<QString, services::QuoteData> ticker_cache_;
    QStringList ticker_subscribed_;
    bool hub_active_ = false;
};

} // namespace fincept::screens