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 "buffermodel.h"
31 #include "bufferinfo.h"
35 #include "ui_inputwidget.h"
39 class InputWidget : public AbstractItemView
44 InputWidget(QWidget *parent = 0);
45 virtual ~InputWidget();
47 const Network *currentNetwork() const;
49 inline MultiLineEdit *inputLine() const { return ui.inputEdit; }
53 * Apply the active color to the selected or typed text
55 * Active color is chosen using the UI menu.
57 void applyFormatActiveColor();
60 * Apply the active fill color to the selected or typed text background
62 * Fill color is chosen using the UI menu.
64 void applyFormatActiveColorFill();
67 * Toggle the boldness of the selected or typed text
69 * Bold becomes normal, and normal becomes bold.
71 void toggleFormatBold();
74 * Toggle the italicness of the selected or typed text
76 * Italicized becomes normal, and normal becomes italicized.
78 void toggleFormatItalic();
81 * Toggle the underlining of the selected or typed text
83 * Underlined becomes normal, and normal becomes underlined.
85 void toggleFormatUnderline();
88 * Clear the formatting of the selected or typed text
90 * Clears the font weight (bold, italic, underline) and foreground/background coloring.
95 virtual bool eventFilter(QObject *watched, QEvent *event);
98 virtual void currentChanged(const QModelIndex ¤t, const QModelIndex &previous);
99 virtual void rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end);
100 virtual void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight);
103 void setCustomFont(const QVariant &font);
104 void setUseCustomFont(const QVariant &);
105 void setEnableEmacsMode(const QVariant &);
106 void setShowNickSelector(const QVariant &);
107 void setShowStyleButtons(const QVariant &);
108 void setEnablePerChatHistory(const QVariant &);
109 void setMaxLines(const QVariant &);
110 void setLineWrapEnabled(const QVariant &);
111 void setMultiLineEnabled(const QVariant &);
112 void setScrollBarsEnabled(const QVariant &);
113 void onTextEntered(const QString &text);
114 void changeNick(const QString &newNick) const;
116 void setNetwork(NetworkId networkId);
117 void setIdentity(IdentityId identityId);
118 void connectMyIrcUser();
119 void updateNickSelector() const;
120 void updateEnabledState();
122 BufferInfo currentBufferInfo() const;
125 * Set whether or not the style options frame is expanded
127 * @param visible If true, expand the style options frame, otherwise collapse it
129 void setStyleOptionsExpanded(const bool visible);
131 void currentCharFormatChanged(const QTextCharFormat &format);
132 void on_showStyleButton_toggled(bool checked);
133 void on_boldButton_clicked(bool checked);
134 void on_italicButton_clicked(bool checked);
135 void on_underlineButton_clicked(bool checked);
136 void colorChosen(QAction *action);
137 void colorHighlightChosen(QAction *action);
141 * Clear the formatting of the text, globally or selected text only
143 * Clears the font weight (bold, italic, underline) and foreground/background coloring.
145 * @param global If true, clear all text formatting, otherwise only clear selected text
147 void setFormatClear(const bool global = false);
150 * Sets the boldness of the selected or typed text
152 * @param bold If true, set text bold, otherwise set text normal
154 void setFormatBold(const bool bold);
157 * Sets the italicness of the selected or typed text
159 * @param bold If true, set text italic, otherwise set text normal
161 void setFormatItalic(const bool italic);
164 * Sets the underline of the selected or typed text
166 * @param bold If true, set text underlined, otherwise set text normal
168 void setFormatUnderline(const bool underline);
172 NetworkId _networkId;
173 IdentityId _identityId;
174 QMenu *_colorMenu, *_colorFillMenu;
176 void mergeFormatOnSelection(const QTextCharFormat &format);
177 void fontChanged(const QFont &f);
178 QIcon createColorToolButtonIcon(const QIcon &icon, const QColor &color);
179 QTextCharFormat getFormatOfWordOrSelection();
180 void setFormatOnSelection(const QTextCharFormat &format);
182 bool _perChatHistory;
183 struct HistoryState {
185 QHash<int, QString> tempHistory;
188 inline HistoryState() : idx(0) {};
191 QMap<BufferId, HistoryState> historyMap;
195 class MouseWheelFilter : public QObject
200 MouseWheelFilter(QObject *parent = 0);
201 virtual bool eventFilter(QObject *obj, QEvent *event);