1 /***************************************************************************
2 * Copyright (C) 2005-2020 by the Quassel Project *
3 * devel@quassel-irc.org *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) version 3. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
19 ***************************************************************************/
26 #include <QTextCharFormat>
28 #include "abstractitemview.h"
30 #include "bufferinfo.h"
31 #include "buffermodel.h"
35 #include "ui_inputwidget.h"
39 class InputWidget : public AbstractItemView
44 InputWidget(QWidget* parent = nullptr);
46 const Network* currentNetwork() const;
48 inline MultiLineEdit* inputLine() const { return ui.inputEdit; }
52 * Apply the active color to the selected or typed text
54 * Active color is chosen using the UI menu.
56 void applyFormatActiveColor();
59 * Apply the active fill color to the selected or typed text background
61 * Fill color is chosen using the UI menu.
63 void applyFormatActiveColorFill();
66 * Toggle the boldness of the selected or typed text
68 * Bold becomes normal, and normal becomes bold.
70 void toggleFormatBold();
73 * Toggle the italicness of the selected or typed text
75 * Italicized becomes normal, and normal becomes italicized.
77 void toggleFormatItalic();
80 * Toggle the underlining of the selected or typed text
82 * Underlined becomes normal, and normal becomes underlined.
84 void toggleFormatUnderline();
87 * Toggle the striking of the selected or typed text
89 * striking becomes normal, and normal becomes underlined.
91 void toggleFormatStrikethrough();
94 * Clear the formatting of the selected or typed text
96 * Clears the font weight (bold, italic, underline) and foreground/background coloring.
101 bool eventFilter(QObject* watched, QEvent* event) override;
104 void currentChanged(const QModelIndex& current, const QModelIndex& previous) override;
105 void rowsAboutToBeRemoved(const QModelIndex& parent, int start, int end) override;
106 void dataChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight) override;
109 void setCustomFont(const QVariant& font);
110 void setUseCustomFont(const QVariant&);
111 void setEnableEmacsMode(const QVariant&);
112 void setShowNickSelector(const QVariant&);
113 void setShowStyleButtons(const QVariant&);
114 void setEnablePerChatHistory(const QVariant&);
115 void setMaxLines(const QVariant&);
116 void setLineWrapEnabled(const QVariant&);
117 void setMultiLineEnabled(const QVariant&);
118 void setScrollBarsEnabled(const QVariant&);
119 void onTextEntered(const QString& text);
120 void changeNick(const QString& newNick) const;
122 void setNetwork(NetworkId networkId);
123 void setIdentity(IdentityId identityId);
124 void connectMyIrcUser();
125 void updateNickSelector() const;
126 void updateEnabledState();
128 BufferInfo currentBufferInfo() const;
131 * Set whether or not the style options frame is expanded
133 * @param visible If true, expand the style options frame, otherwise collapse it
135 void setStyleOptionsExpanded(const bool visible);
137 void currentCharFormatChanged(const QTextCharFormat& format);
138 void on_showStyleButton_toggled(bool checked);
139 void on_boldButton_clicked(bool checked);
140 void on_italicButton_clicked(bool checked);
141 void on_underlineButton_clicked(bool checked);
142 void on_strikethroughButton_clicked(bool checked);
143 void colorChosen(QAction* action);
144 void colorHighlightChosen(QAction* action);
148 * Clear the formatting of the text, globally or selected text only
150 * Clears the font weight (bold, italic, underline) and foreground/background coloring.
152 * @param global If true, clear all text formatting, otherwise only clear selected text
154 void setFormatClear(const bool global = false);
157 * Sets the boldness of the selected or typed text
159 * @param bold If true, set text bold, otherwise set text normal
161 void setFormatBold(const bool bold);
164 * Sets the italicness of the selected or typed text
166 * @param bold If true, set text italic, otherwise set text normal
168 void setFormatItalic(const bool italic);
171 * Sets the underline of the selected or typed text
173 * @param bold If true, set text underlined, otherwise set text normal
175 void setFormatUnderline(const bool underline);
178 * Sets the strikethrough of the selected or typed text
180 * @param strike If true, set text striked, otherwise set text normal
182 void setFormatStrikethrough(const bool strike);
186 NetworkId _networkId;
187 IdentityId _identityId;
188 QMenu *_colorMenu, *_colorFillMenu;
190 void mergeFormatOnSelection(const QTextCharFormat& format);
191 void fontChanged(const QFont& f);
192 QIcon createColorToolButtonIcon(const QIcon& icon, const QColor& color);
193 QTextCharFormat getFormatOfWordOrSelection();
194 void setFormatOnSelection(const QTextCharFormat& format);
196 bool _perChatHistory;
200 QHash<int, QString> tempHistory;
205 QMap<BufferId, HistoryState> historyMap;
208 class MouseWheelFilter : public QObject
213 MouseWheelFilter(QObject* parent = nullptr);
214 bool eventFilter(QObject* obj, QEvent* event) override;