| 1 | /* |
| 2 | SPDX-FileCopyrightText: 2013 Dominik Haumann <dhaumann@kde.org> |
| 3 | |
| 4 | SPDX-License-Identifier: LGPL-2.0-or-later |
| 5 | */ |
| 6 | |
| 7 | #ifndef KATE_STATUS_BAR_H |
| 8 | #define KATE_STATUS_BAR_H |
| 9 | |
| 10 | #include "kateviewhelpers.h" |
| 11 | |
| 12 | #include <KLocalizedString> |
| 13 | #include <KSqueezedTextLabel> |
| 14 | |
| 15 | #include <QLabel> |
| 16 | #include <QMenu> |
| 17 | #include <QPushButton> |
| 18 | #include <QToolButton> |
| 19 | |
| 20 | namespace KTextEditor |
| 21 | { |
| 22 | class ViewPrivate; |
| 23 | } |
| 24 | |
| 25 | class WordCounter; |
| 26 | class KateStatusBar; |
| 27 | class ; |
| 28 | |
| 29 | class : public QMenu |
| 30 | { |
| 31 | public: |
| 32 | explicit (QWidget *parent); |
| 33 | void (bool) override; |
| 34 | }; |
| 35 | |
| 36 | /** |
| 37 | * For convenience an own button class to ensure a unified look&feel. |
| 38 | * Should someone dislike the QPushButton at all could he change it |
| 39 | * to a e.g. QLabel subclass |
| 40 | */ |
| 41 | class StatusBarButton : public QPushButton |
| 42 | { |
| 43 | public: |
| 44 | explicit StatusBarButton(KateStatusBar *parent, const QString &text = QString()); |
| 45 | QSize sizeHint() const override; |
| 46 | QSize minimumSizeHint() const override; |
| 47 | |
| 48 | protected: |
| 49 | void paintEvent(QPaintEvent *) override; |
| 50 | }; |
| 51 | |
| 52 | class KateStatusBar : public KateViewBarWidget |
| 53 | { |
| 54 | Q_OBJECT |
| 55 | friend class StatusBarButton; |
| 56 | |
| 57 | public: |
| 58 | explicit KateStatusBar(KTextEditor::ViewPrivate *view); |
| 59 | |
| 60 | KateModeMenuList *() const; |
| 61 | |
| 62 | public Q_SLOTS: |
| 63 | void updateStatus(); |
| 64 | |
| 65 | void viewModeChanged(); |
| 66 | |
| 67 | void cursorPositionChanged(); |
| 68 | |
| 69 | void updateDictionary(); |
| 70 | |
| 71 | void selectionChanged(); |
| 72 | |
| 73 | void documentConfigChanged(); |
| 74 | |
| 75 | void modeChanged(); |
| 76 | |
| 77 | void wordCountChanged(int, int, int, int); |
| 78 | |
| 79 | void toggleWordCount(bool on); |
| 80 | |
| 81 | void configChanged(); |
| 82 | |
| 83 | void changeDictionary(QAction *action); |
| 84 | |
| 85 | void updateEOL(); |
| 86 | |
| 87 | protected: |
| 88 | bool eventFilter(QObject *obj, QEvent *event) override; |
| 89 | void (QContextMenuEvent *event) override; |
| 90 | |
| 91 | private: |
| 92 | KTextEditor::ViewPrivate *const m_view; |
| 93 | StatusBarButton *m_cursorPosition = nullptr; |
| 94 | QString m_wordCount; |
| 95 | StatusBarButton *m_zoomLevel = nullptr; |
| 96 | StatusBarButton *m_inputMode = nullptr; |
| 97 | StatusBarButton *m_mode = nullptr; |
| 98 | StatusBarButton *m_encoding = nullptr; |
| 99 | StatusBarButton *m_tabsIndent = nullptr; |
| 100 | StatusBarButton *m_dictionary = nullptr; |
| 101 | StatusBarButton *m_eol = nullptr; |
| 102 | QActionGroup *m_dictionaryGroup = nullptr; |
| 103 | KateStatusBarOpenUpMenu * = nullptr; |
| 104 | QMenu *; |
| 105 | KateModeMenuList * = nullptr; |
| 106 | unsigned int m_selectionMode; |
| 107 | QActionGroup *m_tabGroup; |
| 108 | QActionGroup *m_indentGroup; |
| 109 | QAction *m_mixedAction; |
| 110 | QAction *m_hardAction; |
| 111 | QAction *m_softAction; |
| 112 | WordCounter *m_wordCounter; |
| 113 | |
| 114 | private: |
| 115 | void (QActionGroup *group, QMenu *, int data); |
| 116 | void updateGroup(QActionGroup *group, int w); |
| 117 | |
| 118 | public Q_SLOTS: |
| 119 | void slotTabGroup(QAction *); |
| 120 | void slotIndentGroup(QAction *); |
| 121 | void slotIndentTabMode(QAction *); |
| 122 | void toggleShowLines(bool checked); |
| 123 | void toggleShowWords(bool checked); |
| 124 | }; |
| 125 | |
| 126 | #endif |
| 127 | |