snippetpanel.h 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #ifndef SNIPPETPANEL_H
  2. #define SNIPPETPANEL_H
  3. #include <QFrame>
  4. class QListWidget;
  5. class QListWidgetItem;
  6. namespace vnotex
  7. {
  8. class TitleBar;
  9. class SnippetPanel : public QFrame
  10. {
  11. Q_OBJECT
  12. public:
  13. explicit SnippetPanel(QWidget *p_parent = nullptr);
  14. signals:
  15. void applySnippetRequested(const QString &p_name);
  16. protected:
  17. void showEvent(QShowEvent *p_event) Q_DECL_OVERRIDE;
  18. private slots:
  19. void newSnippet();
  20. void handleContextMenuRequested(QPoint p_pos);
  21. void removeSelectedSnippets();
  22. void applySnippet(const QListWidgetItem *p_item);
  23. private:
  24. void setupUI();
  25. void setupTitleBar(const QString &p_title, QWidget *p_parent = nullptr);
  26. void updateItemsCountLabel();
  27. void updateSnippetList();
  28. QString getSnippetName(const QListWidgetItem *p_item);
  29. TitleBar *m_titleBar = nullptr;
  30. QListWidget *m_snippetList = nullptr;
  31. bool m_listInitialized = false;
  32. };
  33. }
  34. #endif // SNIPPETPANEL_H