BibliothecaWindow.hpp 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. #pragma once
  2. #include <gtkmm/window.h>
  3. #include <gtkmm/headerbar.h>
  4. #include <gtkmm/button.h>
  5. #include <gtkmm/togglebutton.h>
  6. #include <gtkmm/box.h>
  7. #include <gtkmm/stack.h>
  8. #include <gtkmm/image.h>
  9. #include <gtkmm/label.h>
  10. #include <gtkmm/searchbar.h>
  11. #include <gtkmm/searchentry.h>
  12. #include <gtkmm/overlay.h>
  13. #include <gtkmm/revealer.h>
  14. #include <gtkmm/eventcontrollerkey.h>
  15. #include <gtkmm/popover.h>
  16. #include <gtkmm/entry.h>
  17. #include "BookList.hpp"
  18. #include "BookShelf.hpp"
  19. #include "BookDetails.hpp"
  20. #include "TagManagerDialog.hpp"
  21. #include "SettingsDialog.hpp"
  22. // Forward-declare the hash helper you already have.
  23. std::string sha256_file(const std::string& path);
  24. /**
  25. * @brief Top-level GTK window that wires the data model to the visual shelf.
  26. *
  27. * BibliothecaWindow owns the high-level widgets (header bar, search UI,
  28. * placeholder states) and orchestrates updates coming from @ref BookList.
  29. */
  30. class BibliothecaWindow : public Gtk::Window {
  31. public:
  32. explicit BibliothecaWindow(DatabaseManager& db, BookList& bookList);
  33. private:
  34. // UI setup helpers
  35. void buildHeaderBar();
  36. void buildPlaceholder();
  37. void buildToast();
  38. void buildBatchActionBar();
  39. void showPlaceholderIfEmpty();
  40. void updateVisibleView();
  41. void updateBatchActionBar();
  42. // Toast notification
  43. void showToast(const Glib::ustring& message, bool is_error = false);
  44. void hideToast();
  45. // Keyboard handling
  46. bool onKeyPressed(guint keyval, guint keycode, Gdk::ModifierType state);
  47. // Callbacks
  48. void onAddBookClicked();
  49. void onBookActivated(const Book& book);
  50. void onSearchChanged();
  51. void onSearchToggle();
  52. void onSearchModeChanged();
  53. // Batch operations
  54. void onBatchTagClicked();
  55. void onBatchDeleteClicked();
  56. void onBatchSelectAllClicked();
  57. void onBatchClearSelectionClicked();
  58. // Tag management
  59. void onManageTagsClicked();
  60. // Settings
  61. void onSettingsClicked();
  62. void applySettings();
  63. void onScanLibrary();
  64. // Model (not owned)
  65. DatabaseManager& m_db;
  66. BookList& m_bookList;
  67. // UI
  68. Gtk::HeaderBar m_headerBar;
  69. Gtk::Button m_addBookButton;
  70. Gtk::Button m_backButton;
  71. Gtk::Button m_tagsButton;
  72. Gtk::Button m_settingsButton;
  73. Gtk::ToggleButton m_searchButton;
  74. Gtk::Box m_mainBox {Gtk::Orientation::VERTICAL};
  75. Gtk::SearchBar m_searchBar;
  76. Gtk::SearchEntry m_searchEntry;
  77. Gtk::Overlay m_overlay;
  78. Gtk::Stack m_stack;
  79. // Toast notification widgets
  80. Gtk::Revealer m_toastRevealer;
  81. Gtk::Box m_toastBox {Gtk::Orientation::HORIZONTAL};
  82. Gtk::Label m_toastLabel;
  83. Gtk::Button m_toastCloseButton;
  84. sigc::connection m_toastTimeout;
  85. Gtk::Box m_placeholder {Gtk::Orientation::VERTICAL};
  86. Gtk::Image m_placeholderIcon;
  87. Gtk::Label m_placeholderLabel;
  88. Gtk::Box m_noResults {Gtk::Orientation::VERTICAL};
  89. Gtk::Label m_noResultsLabel;
  90. // Owned shelf view
  91. std::unique_ptr<BookShelf> m_shelf;
  92. std::unique_ptr<BookDetails> m_bookDetails;
  93. std::string m_lastQuery;
  94. // Batch action bar widgets
  95. Gtk::Revealer m_batchActionRevealer;
  96. Gtk::Box m_batchActionBox {Gtk::Orientation::HORIZONTAL};
  97. Gtk::Label m_batchSelectionLabel;
  98. Gtk::Button m_batchTagButton;
  99. Gtk::Button m_batchDeleteButton;
  100. Gtk::Button m_batchSelectAllButton;
  101. Gtk::Button m_batchClearButton;
  102. // Tag popover for batch tagging
  103. Gtk::Popover m_tagPopover;
  104. Gtk::Box m_tagPopoverBox {Gtk::Orientation::VERTICAL};
  105. Gtk::Entry m_tagPopoverEntry;
  106. Gtk::Button m_tagPopoverApplyButton;
  107. // Keyboard controller
  108. Glib::RefPtr<Gtk::EventControllerKey> m_keyController;
  109. };