1 //=============================================================================
2 //
3 // File : KviDebugWindow.cpp
4 // Creation date : Sun Jul 18 2005 14:12:22 by Szymon Stefanek
5 //
6 // This file is part of the KVIrc IRC client distribution
7 // Copyright (C) 2005-2010 Szymon Stefanek (pragma at kvirc dot net)
8 //
9 // This program is FREE software. You can redistribute it and/or
10 // modify it under the terms of the GNU General Public License
11 // as published by the Free Software Foundation; either version 2
12 // of the License, or (at your option) any later version.
13 //
14 // This program is distributed in the HOPE that it will be USEFUL,
15 // but WITHOUT ANY WARRANTY; without even the implied warranty of
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
17 // See the GNU General Public License for more details.
18 //
19 // You should have received a copy of the GNU General Public License
20 // along with this program. If not, write to the Free Software Foundation,
21 // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22 //
23 //=============================================================================
24
25 #include "KviDebugWindow.h"
26 #include "KviConsoleWindow.h"
27 #include "KviIconManager.h"
28 #include "KviIrcView.h"
29 #include "KviInput.h"
30 #include "KviOptions.h"
31 #include "KviLocale.h"
32 #include "KviConfigurationFile.h"
33
34 #include "KviMainWindow.h"
35
36 #include <QList>
37 #include <QPixmap>
38
39 KviDebugWindow * KviDebugWindow::m_pInstance = nullptr;
40
KviDebugWindow()41 KviDebugWindow::KviDebugWindow()
42 : KviWindow(KviWindow::Debug, __tr2qs("Debug Messages"), nullptr)
43 {
44 m_pInstance = this;
45 m_pSplitter = new KviTalSplitter(Qt::Horizontal, this);
46 m_pSplitter->setObjectName("main_splitter");
47 m_pIrcView = new KviIrcView(m_pSplitter, this);
48 m_pInput = new KviInput(this, nullptr);
49 updateCaption();
50 }
51
~KviDebugWindow()52 KviDebugWindow::~KviDebugWindow()
53 {
54 m_pInstance = nullptr;
55 }
56
getInstance()57 KviDebugWindow * KviDebugWindow::getInstance()
58 {
59 if(m_pInstance)
60 return m_pInstance;
61 m_pInstance = new KviDebugWindow();
62 g_pMainWindow->addWindow(m_pInstance, !KVI_OPTION_BOOL(KviOption_boolShowMinimizedDebugWindow));
63 //if(KVI_OPTION_BOOL(KviOption_boolShowMinimizedDebugWindow))
64 // m_pInstance->minimize();
65 return m_pInstance;
66 }
67
getBaseLogFileName(QString & buffer)68 void KviDebugWindow::getBaseLogFileName(QString & buffer)
69 {
70 buffer = "debug";
71 }
72
saveProperties(KviConfigurationFile * cfg)73 void KviDebugWindow::saveProperties(KviConfigurationFile * cfg)
74 {
75 KviWindow::saveProperties(cfg);
76 cfg->writeEntry("Splitter", m_pSplitter->sizes());
77 }
78
loadProperties(KviConfigurationFile * cfg)79 void KviDebugWindow::loadProperties(KviConfigurationFile * cfg)
80 {
81 int w = width();
82 KviWindow::loadProperties(cfg);
83 QList<int> def;
84 def.append((w * 80) / 100);
85 def.append((w * 20) / 100);
86 m_pSplitter->setSizes(cfg->readIntListEntry("Splitter", def));
87 }
88
fillCaptionBuffers()89 void KviDebugWindow::fillCaptionBuffers()
90 {
91 m_szPlainTextCaption = windowName();
92 }
93
myIconPtr()94 QPixmap * KviDebugWindow::myIconPtr()
95 {
96 return g_pIconManager->getSmallIcon(KviIconManager::Bug);
97 }
98
resizeEvent(QResizeEvent *)99 void KviDebugWindow::resizeEvent(QResizeEvent *)
100 {
101 int hght = m_pInput->heightHint();
102 m_pSplitter->setGeometry(0, 0, width(), height() - hght);
103 m_pInput->setGeometry(0, height() - hght, width(), hght);
104 }
105
sizeHint() const106 QSize KviDebugWindow::sizeHint() const
107 {
108 QSize ret(m_pSplitter->sizeHint().width(), m_pIrcView->sizeHint().height() + m_pInput->heightHint());
109 return ret;
110 }
111