aboutsummaryrefslogtreecommitdiffstats
path: root/src/modules/term
diff options
context:
space:
mode:
authorGravatar Elvio Basello2008-04-05 17:34:00 +0000
committerGravatar Elvio Basello2008-04-05 17:34:00 +0000
commitbcfa1f6ef04d1ce00e1716d3e181a5e234cad51a (patch)
tree59fad5d5545e3bcccbc6c46a9ec2f31823d3cbbe /src/modules/term
parentCmakelists' fix on earlier fix (diff)
downloadKVIrc-bcfa1f6ef04d1ce00e1716d3e181a5e234cad51a.tar.gz
KVIrc-bcfa1f6ef04d1ce00e1716d3e181a5e234cad51a.tar.bz2
KVIrc-bcfa1f6ef04d1ce00e1716d3e181a5e234cad51a.zip
more code clean
git-svn-id: https://svn.kvirc.de/svn/trunk/kvirc@1400 17fca916-40b9-46aa-a4ea-0a15b648b75c
Diffstat (limited to 'src/modules/term')
-rw-r--r--src/modules/term/libkviterm.cpp14
-rw-r--r--src/modules/term/termwidget.cpp262
-rw-r--r--src/modules/term/termwidget.h80
-rw-r--r--src/modules/term/termwindow.cpp111
-rw-r--r--src/modules/term/termwindow.h44
5 files changed, 246 insertions, 265 deletions
diff --git a/src/modules/term/libkviterm.cpp b/src/modules/term/libkviterm.cpp
index a81a394f7..9cd217c18 100644
--- a/src/modules/term/libkviterm.cpp
+++ b/src/modules/term/libkviterm.cpp
@@ -21,27 +21,21 @@
//
#include "kvi_settings.h"
-
#include "kvi_module.h"
-
#include "kvi_window.h"
-
#include "kvi_frame.h"
-
-#include <qsplitter.h>
#include "kvi_pointerlist.h"
-#ifdef COMPILE_KDE_SUPPORT
+#include <QSplitter>
+#ifdef COMPILE_KDE_SUPPORT
#include "termwidget.h"
#include "termwindow.h"
#include "ktrader.h"
-
// #include "kparts/part.h"
// #include "kparts/factory.h"
// #include "klibloader.h"
-
#endif
KviModule * g_pTermModule = 0;
@@ -136,9 +130,7 @@ static bool term_module_init(KviModule * m)
#endif
// m->registerCommand("open",term_module_cmd_open);
-#ifdef COMPILE_NEW_KVS
KVSM_REGISTER_SIMPLE_COMMAND(m,"open",term_kvs_cmd_open);
-#endif
return true;
}
@@ -157,7 +149,7 @@ static bool term_module_cleanup(KviModule *m)
KVIRC_MODULE(
"Term", // module name
- "1.0.0", // module version
+ "4.0.0", // module version
"Copyright (C) 2000 Szymon Stefanek (pragma at kvirc dot net)", // author & (C)
"Terminal emulator extension based on the KonsolePart KDE class",
term_module_init,
diff --git a/src/modules/term/termwidget.cpp b/src/modules/term/termwidget.cpp
index 26ed7c3af..a972f0cc6 100644
--- a/src/modules/term/termwidget.cpp
+++ b/src/modules/term/termwidget.cpp
@@ -27,153 +27,153 @@
#include "kvi_frame.h"
#include "kvi_iconmanager.h"
#include "kvi_locale.h"
-
-#include <qlabel.h>
#include "kvi_pointerlist.h"
-#include <qtooltip.h>
-#include <qtimer.h>
-
-#ifdef COMPILE_KDE_SUPPORT
-
-#include "klibloader.h"
-#include "kparts/part.h"
-#include "kparts/factory.h"
-
-extern KviModule * g_pTermModule;
-extern KviPointerList<KviTermWidget> * g_pTermWidgetList;
-extern KviPointerList<KviTermWindow> * g_pTermWindowList;
-extern KviStr g_szKonsoleLibraryName;
-KviTermWidget::KviTermWidget(QWidget * par,KviFrame * lpFrm,bool bIsStandalone)
-: QFrame(par,"term_widget")
-{
- if(bIsStandalone)g_pTermWidgetList->append(this);
- m_bIsStandalone = bIsStandalone;
-
- m_pKonsolePart = 0;
- m_pKonsoleWidget = 0;
-
- if(bIsStandalone)
- {
- m_pHBox = new KviTalHBox(this);
- m_pTitleLabel = new QLabel(__tr2qs("Terminal emulator"),m_pHBox);
- m_pTitleLabel->setFrameStyle(QFrame::Raised | QFrame::WinPanel);
- m_pCloseButton = new QPushButton("",m_pHBox);
- m_pCloseButton->setPixmap(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_CLOSE)));
- QToolTip::add(m_pCloseButton,__tr2qs("Close this window"));
- m_pHBox->setStretchFactor(m_pTitleLabel,2);
- connect(m_pCloseButton,SIGNAL(clicked()),this,SLOT(closeClicked()));
- } else {
- m_pHBox = 0;
- m_pTitleLabel = 0;
- m_pCloseButton = 0;
- }
+#include <QLabel>
+#include <QToolTip>
+#include <QTimer>
- setFrameStyle(QFrame::Sunken | QFrame::Panel);
-
- KParts::Factory * pKonsoleFactory = static_cast<KParts::Factory *>(
- KLibLoader::self()->factory(g_szKonsoleLibraryName.ptr()));
+#ifdef COMPILE_KDE_SUPPORT
- if(pKonsoleFactory)
+ #include "klibloader.h"
+ #include "kparts/part.h"
+ #include "kparts/factory.h"
+
+ extern KviModule * g_pTermModule;
+ extern KviPointerList<KviTermWidget> * g_pTermWidgetList;
+ extern KviPointerList<KviTermWindow> * g_pTermWindowList;
+ extern KviStr g_szKonsoleLibraryName;
+
+ KviTermWidget::KviTermWidget(QWidget * par,KviFrame * lpFrm,bool bIsStandalone)
+ : QFrame(par,"term_widget")
{
-// debug("FACTORY %d",pKonsoleFactory);
- m_pKonsolePart = static_cast<KParts::Part *>(pKonsoleFactory->createPart(
- this,"terminal emulator",this,"the konsole part"));
-
- if(m_pKonsolePart)
+ if(bIsStandalone)g_pTermWidgetList->append(this);
+ m_bIsStandalone = bIsStandalone;
+
+ m_pKonsolePart = 0;
+ m_pKonsoleWidget = 0;
+
+ if(bIsStandalone)
+ {
+ m_pHBox = new KviTalHBox(this);
+ m_pTitleLabel = new QLabel(__tr2qs("Terminal emulator"),m_pHBox);
+ m_pTitleLabel->setFrameStyle(QFrame::Raised | QFrame::WinPanel);
+ m_pCloseButton = new QPushButton("",m_pHBox);
+ m_pCloseButton->setPixmap(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_CLOSE)));
+ QToolTip::add(m_pCloseButton,__tr2qs("Close this window"));
+ m_pHBox->setStretchFactor(m_pTitleLabel,2);
+ connect(m_pCloseButton,SIGNAL(clicked()),this,SLOT(closeClicked()));
+ } else {
+ m_pHBox = 0;
+ m_pTitleLabel = 0;
+ m_pCloseButton = 0;
+ }
+
+ setFrameStyle(QFrame::Sunken | QFrame::Panel);
+
+ KParts::Factory * pKonsoleFactory = static_cast<KParts::Factory *>(
+ KLibLoader::self()->factory(g_szKonsoleLibraryName.ptr()));
+
+ if(pKonsoleFactory)
{
-// debug("PART %d",m_pKonsolePart);
- m_pKonsoleWidget = m_pKonsolePart->widget();
- connect(m_pKonsoleWidget,SIGNAL(destroyed()),this,SLOT(konsoleDestroyed()));
-// debug("Widget %d",m_pKonsoleWidget);
+ // debug("FACTORY %d",pKonsoleFactory);
+ m_pKonsolePart = static_cast<KParts::Part *>(pKonsoleFactory->createPart(
+ this,"terminal emulator",this,"the konsole part"));
+
+ if(m_pKonsolePart)
+ {
+ // debug("PART %d",m_pKonsolePart);
+ m_pKonsoleWidget = m_pKonsolePart->widget();
+ connect(m_pKonsoleWidget,SIGNAL(destroyed()),this,SLOT(konsoleDestroyed()));
+ // debug("Widget %d",m_pKonsoleWidget);
+ } else {
+ m_pKonsoleWidget = new QLabel(this,
+ __tr2qs("Can't create the terminal emulation part"));
+ }
+
} else {
m_pKonsoleWidget = new QLabel(this,
- __tr2qs("Can't create the terminal emulation part"));
+ __tr2qs("Can't retrieve the terminal emulation factory"));
}
-
- } else {
- m_pKonsoleWidget = new QLabel(this,
- __tr2qs("Can't retrieve the terminal emulation factory"));
}
-}
-
-KviTermWidget::~KviTermWidget()
-{
- if(m_pKonsoleWidget)
- disconnect(m_pKonsoleWidget,SIGNAL(destroyed()),this,SLOT(konsoleDestroyed()));
-
- if(m_bIsStandalone)g_pTermWidgetList->removeRef(this);
- if(g_pTermWindowList->isEmpty() && g_pTermWidgetList->isEmpty())g_pTermModule->unlock();
-
-// debug("DELETING KONSOLE WIDGET");
-// if(m_pKonsoleWidget)delete m_pKonsoleWidget; <--// Qt will delete it
-// debug("DELETING KONSOLE PART");
-// if(m_pKonsolePart)delete m_pKonsolePart; <--// the part will delete self when the widget will die
-// debug("KONSOLE PART DELETED");
-}
-
-void KviTermWidget::resizeEvent(QResizeEvent *e)
-{
- int hght = 0;
- if(m_bIsStandalone)
+
+ KviTermWidget::~KviTermWidget()
{
- hght = m_pCloseButton->sizeHint().height();
- m_pHBox->setGeometry(1,1,width() - 2,hght + 1);
-
+ if(m_pKonsoleWidget)
+ disconnect(m_pKonsoleWidget,SIGNAL(destroyed()),this,SLOT(konsoleDestroyed()));
+
+ if(m_bIsStandalone)g_pTermWidgetList->removeRef(this);
+ if(g_pTermWindowList->isEmpty() && g_pTermWidgetList->isEmpty())g_pTermModule->unlock();
+
+ // debug("DELETING KONSOLE WIDGET");
+ // if(m_pKonsoleWidget)delete m_pKonsoleWidget; <--// Qt will delete it
+ // debug("DELETING KONSOLE PART");
+ // if(m_pKonsolePart)delete m_pKonsolePart; <--// the part will delete self when the widget will die
+ // debug("KONSOLE PART DELETED");
}
- if(m_pKonsoleWidget)m_pKonsoleWidget->setGeometry(1,hght + 1,width() - 2,height() - (hght + 2));
-}
-
-void KviTermWidget::closeClicked()
-{
- // this is called only in standalone mode
- delete this;
-}
-
-void KviTermWidget::konsoleDestroyed()
-{
- m_pKonsoleWidget = 0;
- m_pKonsolePart = 0;
- hide();
- QTimer::singleShot(0,this,SLOT(autoClose()));
-}
-
-void KviTermWidget::autoClose()
-{
- if(m_bIsStandalone)delete this;
- else ((KviWindow *)parent())->close();
-}
-
-void KviTermWidget::changeTitle(int i,const QString& str)
-{
- if(m_bIsStandalone)m_pTitleLabel->setText(str);
-}
-
-void KviTermWidget::notifySize(int,int)
-{
-}
-
-void KviTermWidget::changeColumns(int)
-{
-}
-
-QSize KviTermWidget::sizeHint() const
-{
- int hght = 0;
- int wdth = 0;
- if(m_pKonsoleWidget)
+
+ void KviTermWidget::resizeEvent(QResizeEvent *e)
{
- hght += m_pKonsoleWidget->sizeHint().height();
- wdth = m_pKonsoleWidget->sizeHint().width();
+ int hght = 0;
+ if(m_bIsStandalone)
+ {
+ hght = m_pCloseButton->sizeHint().height();
+ m_pHBox->setGeometry(1,1,width() - 2,hght + 1);
+
+ }
+ if(m_pKonsoleWidget)m_pKonsoleWidget->setGeometry(1,hght + 1,width() - 2,height() - (hght + 2));
}
- if(m_pCloseButton)
+
+ void KviTermWidget::closeClicked()
{
- hght += m_pCloseButton->sizeHint().height();
+ // this is called only in standalone mode
+ delete this;
}
- return QSize(wdth + 2,hght + 2);
-}
-
-#include "termwidget.moc"
+ void KviTermWidget::konsoleDestroyed()
+ {
+ m_pKonsoleWidget = 0;
+ m_pKonsolePart = 0;
+ hide();
+ QTimer::singleShot(0,this,SLOT(autoClose()));
+ }
+
+ void KviTermWidget::autoClose()
+ {
+ if(m_bIsStandalone)delete this;
+ else ((KviWindow *)parent())->close();
+ }
+
+ void KviTermWidget::changeTitle(int i,const QString& str)
+ {
+ if(m_bIsStandalone)m_pTitleLabel->setText(str);
+ }
+
+ void KviTermWidget::notifySize(int,int)
+ {
+ }
+
+ void KviTermWidget::changeColumns(int)
+ {
+ }
+
+ QSize KviTermWidget::sizeHint() const
+ {
+ int hght = 0;
+ int wdth = 0;
+ if(m_pKonsoleWidget)
+ {
+ hght += m_pKonsoleWidget->sizeHint().height();
+ wdth = m_pKonsoleWidget->sizeHint().width();
+ }
+ if(m_pCloseButton)
+ {
+ hght += m_pCloseButton->sizeHint().height();
+ }
+
+ return QSize(wdth + 2,hght + 2);
+ }
+
+ #include "termwidget.moc"
#endif //COMPILE_KDE_SUPPORT
diff --git a/src/modules/term/termwidget.h b/src/modules/term/termwidget.h
index 37e29b9f6..3ea54023f 100644
--- a/src/modules/term/termwidget.h
+++ b/src/modules/term/termwidget.h
@@ -25,48 +25,44 @@
#include "kvi_settings.h"
#ifdef COMPILE_KDE_SUPPORT
-
-#include <qframe.h>
-#include <qlabel.h>
-#include <qpushbutton.h>
-#include "kvi_tal_hbox.h"
-
-#include "kparts/part.h"
-
-
-class KviFrame;
-
-class KviTermWidget : public QFrame
-{
- Q_OBJECT
- Q_PROPERTY( int KviProperty_ChildFocusOwner READ dummy )
-public:
- KviTermWidget(QWidget * par,KviFrame * lpFrm,bool bIsStandalone = false);
- ~KviTermWidget();
-private:
- KviTalHBox * m_pHBox;
- QLabel * m_pTitleLabel;
- QPushButton * m_pCloseButton;
- KParts::Part * m_pKonsolePart;
- bool m_bIsStandalone;
- QWidget * m_pKonsoleWidget;
-protected:
- virtual void resizeEvent(QResizeEvent *e);
-protected slots:
- void closeClicked();
- void changeTitle(int i,const QString& str);
- void notifySize(int,int);
- void changeColumns(int);
-public:
- QWidget * konsoleWidget(){ return m_pKonsoleWidget ? m_pKonsoleWidget : this; };
- virtual QSize sizeHint() const;
- int dummy() const { return 0; };
-protected slots:
- void konsoleDestroyed();
- void autoClose();
-};
-
+ #include <QFrame>
+ #include <QLabel>
+ #include <QPushButton>
+ #include "kvi_tal_hbox.h"
+
+ #include "kparts/part.h"
+
+ class KviFrame;
+
+ class KviTermWidget : public QFrame
+ {
+ Q_OBJECT
+ Q_PROPERTY( int KviProperty_ChildFocusOwner READ dummy )
+ public:
+ KviTermWidget(QWidget * par,KviFrame * lpFrm,bool bIsStandalone = false);
+ ~KviTermWidget();
+ private:
+ KviTalHBox * m_pHBox;
+ QLabel * m_pTitleLabel;
+ QPushButton * m_pCloseButton;
+ KParts::Part * m_pKonsolePart;
+ bool m_bIsStandalone;
+ QWidget * m_pKonsoleWidget;
+ protected:
+ virtual void resizeEvent(QResizeEvent *e);
+ protected slots:
+ void closeClicked();
+ void changeTitle(int i,const QString& str);
+ void notifySize(int,int);
+ void changeColumns(int);
+ public:
+ QWidget * konsoleWidget(){ return m_pKonsoleWidget ? m_pKonsoleWidget : this; };
+ virtual QSize sizeHint() const;
+ int dummy() const { return 0; };
+ protected slots:
+ void konsoleDestroyed();
+ void autoClose();
+ };
#endif
-
#endif //_HELPWIDGET_H_
diff --git a/src/modules/term/termwindow.cpp b/src/modules/term/termwindow.cpp
index 04ab34643..0b8d08215 100644
--- a/src/modules/term/termwindow.cpp
+++ b/src/modules/term/termwindow.cpp
@@ -23,62 +23,59 @@
#include "termwidget.h"
#ifdef COMPILE_KDE_SUPPORT
+ #include "kvi_iconmanager.h"
+ #include "kvi_options.h"
+ #include "kvi_locale.h"
+ #include "kvi_module.h"
+
+ extern KviModule * g_pTermModule;
+ extern KviPointerList<KviTermWindow> * g_pTermWindowList;
+ extern KviPointerList<KviTermWidget> * g_pTermWidgetList;
+
+ KviTermWindow::KviTermWindow(KviFrame * lpFrm,const char * name)
+ : KviWindow(KVI_WINDOW_TYPE_TERM,lpFrm,name)
+ {
+ g_pTermWindowList->append(this);
+ m_pTermWidget = 0;
+ m_pTermWidget = new KviTermWidget(this,lpFrm);
+ // Ensure proper focusing
+ // setFocusHandler(m_pTermWidget->konsoleWidget(),this);
+ }
+
+ KviTermWindow::~KviTermWindow()
+ {
+ g_pTermWindowList->removeRef(this);
+ if(g_pTermWindowList->isEmpty() && g_pTermWidgetList->isEmpty())g_pTermModule->unlock();
+ }
+
+ QPixmap * KviTermWindow::myIconPtr()
+ {
+ return g_pIconManager->getSmallIcon(KVI_SMALLICON_RAW);
+ }
+
+ void KviTermWindow::resizeEvent(QResizeEvent *e)
+ {
+ if(m_pTermWidget)m_pTermWidget->setGeometry(0,0,width(),height());
+ }
+
+ QSize KviTermWindow::sizeHint() const
+ {
+ return m_pTermWidget ? m_pTermWidget->sizeHint() : KviWindow::sizeHint();
+ }
+
+ void KviTermWindow::fillCaptionBuffers()
+ {
+ m_szPlainTextCaption.sprintf(__tr("Terminal"));
+
+ m_szHtmlActiveCaption.sprintf(
+ __tr("<nobr><font color=\"%s\"><b>Terminal</b></font></nobr>"),
+ KVI_OPTION_COLOR(KviOption_colorCaptionTextActive).name().ascii(),
+ KVI_OPTION_COLOR(KviOption_colorCaptionTextActive2).name().ascii());
+ m_szHtmlInactiveCaption.sprintf(
+ __tr("<nobr><font color=\"%s\"><b>Terminal</b></font></nobr>"),
+ KVI_OPTION_COLOR(KviOption_colorCaptionTextInactive).name().ascii(),
+ KVI_OPTION_COLOR(KviOption_colorCaptionTextInactive2).name().ascii());
+ }
-
-#include "kvi_iconmanager.h"
-#include "kvi_options.h"
-#include "kvi_locale.h"
-#include "kvi_module.h"
-
-extern KviModule * g_pTermModule;
-extern KviPointerList<KviTermWindow> * g_pTermWindowList;
-extern KviPointerList<KviTermWidget> * g_pTermWidgetList;
-
-KviTermWindow::KviTermWindow(KviFrame * lpFrm,const char * name)
-: KviWindow(KVI_WINDOW_TYPE_TERM,lpFrm,name)
-{
- g_pTermWindowList->append(this);
- m_pTermWidget = 0;
- m_pTermWidget = new KviTermWidget(this,lpFrm);
- // Ensure proper focusing
-// setFocusHandler(m_pTermWidget->konsoleWidget(),this);
-}
-
-KviTermWindow::~KviTermWindow()
-{
- g_pTermWindowList->removeRef(this);
- if(g_pTermWindowList->isEmpty() && g_pTermWidgetList->isEmpty())g_pTermModule->unlock();
-}
-
-QPixmap * KviTermWindow::myIconPtr()
-{
- return g_pIconManager->getSmallIcon(KVI_SMALLICON_RAW);
-}
-
-void KviTermWindow::resizeEvent(QResizeEvent *e)
-{
- if(m_pTermWidget)m_pTermWidget->setGeometry(0,0,width(),height());
-}
-
-QSize KviTermWindow::sizeHint() const
-{
- return m_pTermWidget ? m_pTermWidget->sizeHint() : KviWindow::sizeHint();
-}
-
-void KviTermWindow::fillCaptionBuffers()
-{
- m_szPlainTextCaption.sprintf(__tr("Terminal"));
-
- m_szHtmlActiveCaption.sprintf(
- __tr("<nobr><font color=\"%s\"><b>Terminal</b></font></nobr>"),
- KVI_OPTION_COLOR(KviOption_colorCaptionTextActive).name().ascii(),
- KVI_OPTION_COLOR(KviOption_colorCaptionTextActive2).name().ascii());
- m_szHtmlInactiveCaption.sprintf(
- __tr("<nobr><font color=\"%s\"><b>Terminal</b></font></nobr>"),
- KVI_OPTION_COLOR(KviOption_colorCaptionTextInactive).name().ascii(),
- KVI_OPTION_COLOR(KviOption_colorCaptionTextInactive2).name().ascii());
-}
-
-#include "termwindow.moc"
-
+ #include "termwindow.moc"
#endif
diff --git a/src/modules/term/termwindow.h b/src/modules/term/termwindow.h
index 3b46d47b4..ec71c6b65 100644
--- a/src/modules/term/termwindow.h
+++ b/src/modules/term/termwindow.h
@@ -25,30 +25,26 @@
#include "kvi_settings.h"
#ifdef COMPILE_KDE_SUPPORT
-
-
-#include "kvi_window.h"
-#include "kvi_string.h"
-
-class KviTermWidget;
-
-class KviTermWindow : public KviWindow
-{
- Q_OBJECT
-public:
- KviTermWindow(KviFrame * lpFrm,const char * name);
- ~KviTermWindow();
-protected:
- KviTermWidget * m_pTermWidget;
-protected:
- virtual QPixmap * myIconPtr();
- virtual void fillCaptionBuffers();
- virtual void resizeEvent(QResizeEvent *e);
-public:
- virtual QSize sizeHint() const;
-};
-
-
+ #include "kvi_window.h"
+ #include "kvi_string.h"
+
+ class KviTermWidget;
+
+ class KviTermWindow : public KviWindow
+ {
+ Q_OBJECT
+ public:
+ KviTermWindow(KviFrame * lpFrm,const char * name);
+ ~KviTermWindow();
+ protected:
+ KviTermWidget * m_pTermWidget;
+ protected:
+ virtual QPixmap * myIconPtr();
+ virtual void fillCaptionBuffers();
+ virtual void resizeEvent(QResizeEvent *e);
+ public:
+ virtual QSize sizeHint() const;
+ };
#endif
#endif //_KVI_HELPWINDOW_H_