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 ***************************************************************************/
24 #include "ui_inputwidget.h"
26 #include "abstractitemview.h"
27 #include "buffermodel.h"
28 #include "bufferinfo.h"
35 class InputWidget : public AbstractItemView
40 InputWidget(QWidget *parent = 0);
41 virtual ~InputWidget();
43 const Network *currentNetwork() const;
45 inline MultiLineEdit *inputLine() const { return ui.inputEdit; }
49 * Apply the active color to the selected or typed text
51 * Active color is chosen using the UI menu.
53 void applyFormatActiveColor();
56 * Apply the active fill color to the selected or typed text background
58 * Fill color is chosen using the UI menu.
60 void applyFormatActiveColorFill();
63 * Toggle the boldness of the selected or typed text
65 * Bold becomes normal, and normal becomes bold.
67 void toggleFormatBold();
70 * Toggle the italicness of the selected or typed text
72 * Italicized becomes normal, and normal becomes italicized.
74 void toggleFormatItalic();
77 * Toggle the underlining of the selected or typed text
79 * Underlined becomes normal, and normal becomes underlined.
81 void toggleFormatUnderline();
84 * Clear the formatting of the selected or typed text
86 * Clears the font weight (bold, italic, underline) and foreground/background coloring.
91 virtual bool eventFilter(QObject *watched, QEvent *event);
94 virtual void currentChanged(const QModelIndex ¤t, const QModelIndex &previous);
95 virtual void rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end);
96 virtual void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight);
99 void setCustomFont(const QVariant &font);
100 void setUseCustomFont(const QVariant &);
101 void setEnableSpellCheck(const QVariant &);
102 void setEnableEmacsMode(const QVariant &);
103 void setShowNickSelector(const QVariant &);
104 void setShowStyleButtons(const QVariant &);
105 void setEnablePerChatHistory(const QVariant &);
106 void setMaxLines(const QVariant &);
107 void setLineWrapEnabled(const QVariant &);
108 void setMultiLineEnabled(const QVariant &);
109 void setScrollBarsEnabled(const QVariant &);
110 void onTextEntered(const QString &text);
111 void changeNick(const QString &newNick) const;
113 void setNetwork(NetworkId networkId);
114 void setIdentity(IdentityId identityId);
115 void connectMyIrcUser();
116 void updateNickSelector() const;
117 void updateEnabledState();
119 BufferInfo currentBufferInfo() const;
122 * Set whether or not the style options frame is expanded
124 * @param visible If true, expand the style options frame, otherwise collapse it
126 void setStyleOptionsExpanded(const bool visible);
128 void currentCharFormatChanged(const QTextCharFormat &format);
129 void on_showStyleButton_toggled(bool checked);
130 void on_boldButton_clicked(bool checked);
131 void on_italicButton_clicked(bool checked);
132 void on_underlineButton_clicked(bool checked);
133 void colorChosen(QAction *action);
134 void colorHighlightChosen(QAction *action);
138 * Clear the formatting of the text, globally or selected text only
140 * Clears the font weight (bold, italic, underline) and foreground/background coloring.
142 * @param global If true, clear all text formatting, otherwise only clear selected text
144 void setFormatClear(const bool global = false);
147 * Sets the boldness of the selected or typed text
149 * @param bold If true, set text bold, otherwise set text normal
151 void setFormatBold(const bool bold);
154 * Sets the italicness of the selected or typed text
156 * @param bold If true, set text italic, otherwise set text normal
158 void setFormatItalic(const bool italic);
161 * Sets the underline of the selected or typed text
163 * @param bold If true, set text underlined, otherwise set text normal
165 void setFormatUnderline(const bool underline);
169 NetworkId _networkId;
170 IdentityId _identityId;
171 QMenu *_colorMenu, *_colorFillMenu;
173 void mergeFormatOnSelection(const QTextCharFormat &format);
174 void fontChanged(const QFont &f);
175 QIcon createColorToolButtonIcon(const QIcon &icon, const QColor &color);
176 QTextCharFormat getFormatOfWordOrSelection();
177 void setFormatOnSelection(const QTextCharFormat &format);
179 bool _perChatHistory;
180 struct HistoryState {
182 QHash<int, QString> tempHistory;
185 inline HistoryState() : idx(0) {};
188 QMap<BufferId, HistoryState> historyMap;
192 class MouseWheelFilter : public QObject
197 MouseWheelFilter(QObject *parent = 0);
198 virtual bool eventFilter(QObject *obj, QEvent *event);
202 #endif // INPUTWIDGET_H