File indexing completed on 2025-01-12 06:47:28
0001 // 0002 // C++ Interface: cOutput 0003 // 0004 // Description: wrapper for cConsole 0005 // 0006 /* 0007 Copyright 2005-2011 Tomas Mecir <kmuddy@kmuddy.com> 0008 0009 This program is free software; you can redistribute it and/or 0010 modify it under the terms of the GNU General Public License as 0011 published by the Free Software Foundation; either version 2 of 0012 the License, or (at your option) any later version. 0013 0014 This program is distributed in the hope that it will be useful, 0015 but WITHOUT ANY WARRANTY; without even the implied warranty of 0016 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0017 GNU General Public License for more details. 0018 0019 You should have received a copy of the GNU General Public License 0020 along with this program. If not, see <http://www.gnu.org/licenses/>. 0021 */ 0022 0023 #ifndef COUTPUT_H 0024 #define COUTPUT_H 0025 0026 #include <qcolor.h> 0027 #include <QScrollArea> 0028 0029 #include <cactionbase.h> 0030 #include <kmuddy_export.h> 0031 0032 class cConsole; 0033 0034 /** 0035 This class serves as a wrapper for the main cConsole widget. It translates its signal-slot mechanism to the cAction-based approach. This is necessary, because cConsole is used in other places as well. 0036 It also handles scrollbars. 0037 0038 @author Tomas Mecir 0039 */ 0040 0041 class KMUDDY_EXPORT cOutput : public QWidget, public cActionBase 0042 { 0043 Q_OBJECT 0044 public: 0045 /** constructor */ 0046 cOutput (int sess, QWidget *parent); 0047 /** destructor */ 0048 ~cOutput() override; 0049 cConsole *console () { return con; }; 0050 0051 void addText (cTextChunk *chunk); 0052 void addLine (cTextChunk *chunk); 0053 /** add command to console, if allowed */ 0054 void addCommand (const QString &command); 0055 /** adds a new system message to the widget - calls addText and also 0056 does some extra things*/ 0057 void systemMessage (const QString &text); 0058 /** decision message (Tools/Decide). The same as systemMessage, but 0059 it is shown even if system messages are off*/ 0060 void decisionMessage (const QString &text); 0061 /** this is my decision helper similar to one found in zmud */ 0062 void makeDecision (); 0063 0064 void setDefaultBkColor (QColor color); 0065 QColor defaultBkColor () { return bgcolor; }; 0066 /** change color of local echo (typed commands etc.) */ 0067 void setEchoColor (QColor color); 0068 /** change color of system messages */ 0069 void setSystemColor (QColor color); 0070 /** this function returns all the colors - well, actually, only echo and system color... */ 0071 void getAllColors (QColor &_echo, QColor &_system); 0072 void setEnableEcho (bool value); 0073 void setEnableMessages (bool value); 0074 0075 /** resizing aconsole (CTRL+keys) */ 0076 void aconUp (); 0077 void aconDown (); 0078 0079 protected slots: 0080 void dimensionsChanged (int x, int y); 0081 void sendCommand (const QString &command); 0082 void promptCommand (const QString &command); 0083 protected: 0084 void eventStringHandler (QString event, int, QString &par1, const QString &) override; 0085 void eventChunkHandler (QString event, int, cTextChunk *chunk) override; 0086 void eventNothingHandler (QString event, int session) override; 0087 0088 /** show commands / messages ? */ 0089 bool cmdecho, messages; 0090 0091 QColor echocolor; 0092 QColor systemcolor; 0093 0094 //default bg color 0095 QColor bgcolor; 0096 0097 /** stored cConsole widget */ 0098 cConsole *con; 0099 /** size of auxiliary console (in percents) */ 0100 int aconsize; 0101 }; 0102 0103 #endif