File indexing completed on 2024-03-24 15:43:26
0001 // 0002 // C++ Implementation: cmxpconsole 0003 // 0004 // Description: 0005 // 0006 /* 0007 Copyright 2004-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 #include "cmxpconsole.h" 0024 0025 #ifdef HAVE_MXP 0026 0027 #include "cactionmanager.h" 0028 #include "dialogs/dlgmxpconsole.h" 0029 0030 #include <kmainwindow.h> 0031 0032 cMXPConsole *cMXPConsole::_self = 0; 0033 0034 cMXPConsole::cMXPConsole () 0035 { 0036 createDialog (); 0037 } 0038 0039 cMXPConsole::~cMXPConsole () 0040 { 0041 delete dlgmxpconsole; 0042 } 0043 0044 cMXPConsole *cMXPConsole::self () 0045 { 0046 if (!_self) 0047 _self = new cMXPConsole; 0048 return _self; 0049 } 0050 0051 QDockWidget *cMXPConsole::dialog () 0052 { 0053 return dlgmxpconsole; 0054 } 0055 0056 void cMXPConsole::createDialog () 0057 { 0058 KMainWindow *wnd = cActionManager::self()->mainWindow(); 0059 dlgmxpconsole = new dlgMXPConsole (wnd); 0060 dlgmxpconsole->hide(); // hidden by default 0061 dlgmxpconsole->setObjectName ("mxpconsole"); 0062 wnd->addDockWidget (Qt::RightDockWidgetArea, dlgmxpconsole); 0063 dlgmxpconsole->setFloating (true); 0064 } 0065 0066 #endif //HAVE_MXP 0067 0068 //slots - these need to exist even if HAVE_MXP is off 0069 0070 void cMXPConsole::addError (int sess, const QString &text) 0071 { 0072 #ifdef HAVE_MXP 0073 0074 if (!dlgmxpconsole) 0075 createDialog (); 0076 0077 QString name = cActionManager::self()->callAction ("session", "name", sess); 0078 dlgmxpconsole->addLine ("[ error ] (" + name + ") " + text); 0079 0080 #endif //HAVE_MXP 0081 } 0082 0083 void cMXPConsole::addWarning (int sess, const QString &text) 0084 { 0085 #ifdef HAVE_MXP 0086 0087 if (!dlgmxpconsole) 0088 createDialog (); 0089 0090 QString name = cActionManager::self()->callAction ("session", "name", sess); 0091 dlgmxpconsole->addLine ("[ warning ] (" + name + ") " + text); 0092 0093 #endif //HAVE_MXP 0094 } 0095 0096 #include "moc_cmxpconsole.cpp"