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.7 KB
Raw Blame
#pragma once
#include "ui/navigation/CommandBar.h"

#include <QLabel>
#include <QMenu>
#include <QMenuBar>
#include <QPushButton>
#include <QTimer>
#include <QWidget>

namespace fincept::ui {

class PushpinBar;

/// Combined toolbar: File/Navigate/View/Help menus + branding + clock + user
/// info (credits, plan badge → Plans & Pricing) + ENTERPRISE + chat + logout.
///
/// Internationalised: all menus and labels flow through tr(). Menus are
/// rebuilt on QEvent::LanguageChange so action labels pick up the new
/// translator; static labels and buttons retranslate via setText().
class ToolBar : public QWidget {
    Q_OBJECT
  public:
    explicit ToolBar(QWidget* parent = nullptr);

    void refresh_user_display();

    PushpinBar* pushpin_bar() const { return pushpin_bar_; }

  signals:
    void navigate_to(const QString& tab_id);
    void dock_command(const QString& action, const QString& primary, const QString& secondary);
    void action_triggered(const QString& action);
    void logout_clicked();
    void plan_clicked();
    void upgrade_clicked();
    void chat_mode_toggled();

  protected:
    void resizeEvent(QResizeEvent* e) override;
    void changeEvent(QEvent* e) override;
    // §P3: the 1 s clock ticks only while the toolbar is visible.
    void showEvent(QShowEvent* e) override;
    void hideEvent(QHideEvent* e) override;

  private slots:
    void update_clock();

  private:
    QMenuBar* menu_bar_ = nullptr;
    QLabel* clock_label_ = nullptr;
    QLabel* user_label_ = nullptr;
    QLabel* credits_label_ = nullptr;
    QLabel* subtitle_label_ = nullptr;
    QLabel* branding_label_ = nullptr;
    QLabel* live_dot_ = nullptr;
    QLabel* live_label_ = nullptr;
    /// Plan badge ("FREE" / "PRO" / legacy tier) → Plans & Pricing. Carries a
    /// "tier" property (free / paid) that the stylesheet outlines for free accounts.
    QPushButton* plan_btn_ = nullptr;
    /// Always-visible ENTERPRISE CTA for Fincept Terminal Enterprise (the private edition).
    QPushButton* upgrade_btn_ = nullptr;
    QPushButton* chat_mode_btn_ = nullptr;
    QPushButton* logout_btn_ = nullptr;
    QTimer* clock_timer_ = nullptr;
    QVector<QLabel*> separators_;
    QLabel* fincept_label_ = nullptr;

    CommandBar* command_bar_ = nullptr;
    PushpinBar* pushpin_bar_ = nullptr;

    void refresh_theme();
    void retranslateUi();
    /// Tear down and recreate every menu on the menu bar so action labels
    /// pick up the active QTranslator. Called from retranslateUi() so a
    /// LanguageChange event rebuilds menus alongside static labels.
    void rebuild_menus();
    void apply_responsive_layout(int width);

    QMenu* build_file_menu();
    QMenu* build_navigate_menu();
    QMenu* build_view_menu();
    QMenu* build_help_menu();
};

} // namespace fincept::ui