| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131 |
- #pragma once
- #include <gtkmm/window.h>
- #include <gtkmm/headerbar.h>
- #include <gtkmm/button.h>
- #include <gtkmm/togglebutton.h>
- #include <gtkmm/box.h>
- #include <gtkmm/stack.h>
- #include <gtkmm/image.h>
- #include <gtkmm/label.h>
- #include <gtkmm/searchbar.h>
- #include <gtkmm/searchentry.h>
- #include <gtkmm/overlay.h>
- #include <gtkmm/revealer.h>
- #include <gtkmm/eventcontrollerkey.h>
- #include <gtkmm/popover.h>
- #include <gtkmm/entry.h>
- #include "BookList.hpp"
- #include "BookShelf.hpp"
- #include "BookDetails.hpp"
- #include "TagManagerDialog.hpp"
- #include "SettingsDialog.hpp"
- // Forward-declare the hash helper you already have.
- std::string sha256_file(const std::string& path);
- /**
- * @brief Top-level GTK window that wires the data model to the visual shelf.
- *
- * BibliothecaWindow owns the high-level widgets (header bar, search UI,
- * placeholder states) and orchestrates updates coming from @ref BookList.
- */
- class BibliothecaWindow : public Gtk::Window {
- public:
- explicit BibliothecaWindow(DatabaseManager& db, BookList& bookList);
- private:
- // UI setup helpers
- void buildHeaderBar();
- void buildPlaceholder();
- void buildToast();
- void buildBatchActionBar();
- void showPlaceholderIfEmpty();
- void updateVisibleView();
- void updateBatchActionBar();
- // Toast notification
- void showToast(const Glib::ustring& message, bool is_error = false);
- void hideToast();
- // Keyboard handling
- bool onKeyPressed(guint keyval, guint keycode, Gdk::ModifierType state);
- // Callbacks
- void onAddBookClicked();
- void onBookActivated(const Book& book);
- void onSearchChanged();
- void onSearchToggle();
- void onSearchModeChanged();
- // Batch operations
- void onBatchTagClicked();
- void onBatchDeleteClicked();
- void onBatchSelectAllClicked();
- void onBatchClearSelectionClicked();
- // Tag management
- void onManageTagsClicked();
- // Settings
- void onSettingsClicked();
- void applySettings();
- void onScanLibrary();
- // Model (not owned)
- DatabaseManager& m_db;
- BookList& m_bookList;
- // UI
- Gtk::HeaderBar m_headerBar;
- Gtk::Button m_addBookButton;
- Gtk::Button m_backButton;
- Gtk::Button m_tagsButton;
- Gtk::Button m_settingsButton;
- Gtk::ToggleButton m_searchButton;
- Gtk::Box m_mainBox {Gtk::Orientation::VERTICAL};
- Gtk::SearchBar m_searchBar;
- Gtk::SearchEntry m_searchEntry;
- Gtk::Overlay m_overlay;
- Gtk::Stack m_stack;
- // Toast notification widgets
- Gtk::Revealer m_toastRevealer;
- Gtk::Box m_toastBox {Gtk::Orientation::HORIZONTAL};
- Gtk::Label m_toastLabel;
- Gtk::Button m_toastCloseButton;
- sigc::connection m_toastTimeout;
- Gtk::Box m_placeholder {Gtk::Orientation::VERTICAL};
- Gtk::Image m_placeholderIcon;
- Gtk::Label m_placeholderLabel;
- Gtk::Box m_noResults {Gtk::Orientation::VERTICAL};
- Gtk::Label m_noResultsLabel;
- // Owned shelf view
- std::unique_ptr<BookShelf> m_shelf;
- std::unique_ptr<BookDetails> m_bookDetails;
- std::string m_lastQuery;
- // Batch action bar widgets
- Gtk::Revealer m_batchActionRevealer;
- Gtk::Box m_batchActionBox {Gtk::Orientation::HORIZONTAL};
- Gtk::Label m_batchSelectionLabel;
- Gtk::Button m_batchTagButton;
- Gtk::Button m_batchDeleteButton;
- Gtk::Button m_batchSelectAllButton;
- Gtk::Button m_batchClearButton;
- // Tag popover for batch tagging
- Gtk::Popover m_tagPopover;
- Gtk::Box m_tagPopoverBox {Gtk::Orientation::VERTICAL};
- Gtk::Entry m_tagPopoverEntry;
- Gtk::Button m_tagPopoverApplyButton;
- // Keyboard controller
- Glib::RefPtr<Gtk::EventControllerKey> m_keyController;
- };
|