1 /***************************************************************************
2 * Copyright (C) 2005-2018 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 * Clear the formatting of the selected or typed text
89 * Clears the font weight (bold, italic, underline) and foreground/background coloring.
94 bool eventFilter(QObject* watched, QEvent* event) override;
97 void currentChanged(const QModelIndex& current, const QModelIndex& previous) override;
98 void rowsAboutToBeRemoved(const QModelIndex& parent, int start, int end) override;
99 void dataChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight) override;
102 void setCustomFont(const QVariant& font);
103 void setUseCustomFont(const QVariant&);
104 void setEnableEmacsMode(const QVariant&);
105 void setShowNickSelector(const QVariant&);
106 void setShowStyleButtons(const QVariant&);
107 void setEnablePerChatHistory(const QVariant&);
108 void setMaxLines(const QVariant&);
109 void setLineWrapEnabled(const QVariant&);
110 void setMultiLineEnabled(const QVariant&);
111 void setScrollBarsEnabled(const QVariant&);
112 void onTextEntered(const QString& text);
113 void changeNick(const QString& newNick) const;
115 void setNetwork(NetworkId networkId);
116 void setIdentity(IdentityId identityId);
117 void connectMyIrcUser();
118 void updateNickSelector() const;
119 void updateEnabledState();
121 BufferInfo currentBufferInfo() const;
124 * Set whether or not the style options frame is expanded
126 * @param visible If true, expand the style options frame, otherwise collapse it
128 void setStyleOptionsExpanded(const bool visible);
130 void currentCharFormatChanged(const QTextCharFormat& format);
131 void on_showStyleButton_toggled(bool checked);
132 void on_boldButton_clicked(bool checked);
133 void on_italicButton_clicked(bool checked);
134 void on_underlineButton_clicked(bool checked);
135 void colorChosen(QAction* action);
136 void colorHighlightChosen(QAction* action);
140 * Clear the formatting of the text, globally or selected text only
142 * Clears the font weight (bold, italic, underline) and foreground/background coloring.
144 * @param global If true, clear all text formatting, otherwise only clear selected text
146 void setFormatClear(const bool global = false);
149 * Sets the boldness of the selected or typed text
151 * @param bold If true, set text bold, otherwise set text normal
153 void setFormatBold(const bool bold);
156 * Sets the italicness of the selected or typed text
158 * @param bold If true, set text italic, otherwise set text normal
160 void setFormatItalic(const bool italic);
163 * Sets the underline of the selected or typed text
165 * @param bold If true, set text underlined, otherwise set text normal
167 void setFormatUnderline(const bool underline);
171 NetworkId _networkId;
172 IdentityId _identityId;
173 QMenu *_colorMenu, *_colorFillMenu;
175 void mergeFormatOnSelection(const QTextCharFormat& format);
176 void fontChanged(const QFont& f);
177 QIcon createColorToolButtonIcon(const QIcon& icon, const QColor& color);
178 QTextCharFormat getFormatOfWordOrSelection();
179 void setFormatOnSelection(const QTextCharFormat& format);
181 bool _perChatHistory;
185 QHash<int, QString> tempHistory;
190 QMap<BufferId, HistoryState> historyMap;
193 class MouseWheelFilter : public QObject
198 MouseWheelFilter(QObject* parent = nullptr);
199 bool eventFilter(QObject* obj, QEvent* event) override;