aboutsummaryrefslogtreecommitdiffstats
path: root/src/modules/term/TermWidget.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/modules/term/TermWidget.cpp')
-rw-r--r--src/modules/term/TermWidget.cpp218
1 files changed, 114 insertions, 104 deletions
diff --git a/src/modules/term/TermWidget.cpp b/src/modules/term/TermWidget.cpp
index 7687f7647..60efec2e6 100644
--- a/src/modules/term/TermWidget.cpp
+++ b/src/modules/term/TermWidget.cpp
@@ -37,139 +37,149 @@
#ifdef COMPILE_KDE4_SUPPORT
- #include "klibloader.h"
- #include "kparts/part.h"
- #include "kparts/factory.h"
- #include <kde_terminal_interface.h>
+#include "klibloader.h"
+#include "kparts/part.h"
+#include "kparts/factory.h"
+#include <kde_terminal_interface.h>
- extern KviModule * g_pTermModule;
- extern KviPointerList<TermWidget> * g_pTermWidgetList;
- extern KviPointerList<TermWindow> * g_pTermWindowList;
+extern KviModule * g_pTermModule;
+extern KviPointerList<TermWidget> * g_pTermWidgetList;
+extern KviPointerList<TermWindow> * g_pTermWindowList;
- TermWidget::TermWidget(QWidget * par,bool bIsStandalone)
- : QFrame(par)
- {
- setObjectName("term_widget");
- if(bIsStandalone)g_pTermWidgetList->append(this);
- m_bIsStandalone = bIsStandalone;
+TermWidget::TermWidget(QWidget * par, bool bIsStandalone)
+ : QFrame(par)
+{
+ setObjectName("term_widget");
+ if(bIsStandalone)
+ g_pTermWidgetList->append(this);
+ m_bIsStandalone = bIsStandalone;
- m_pKonsolePart = 0;
- m_pKonsoleWidget = 0;
+ 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::StyledPanel);
- m_pCloseButton = new QPushButton("",m_pHBox);
- m_pCloseButton->setIcon(*(g_pIconManager->getSmallIcon(KviIconManager::Close)));
- m_pCloseButton->setToolTip(__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;
- }
+ if(bIsStandalone)
+ {
+ m_pHBox = new KviTalHBox(this);
+ m_pTitleLabel = new QLabel(__tr2qs("Terminal Emulator"), m_pHBox);
+ m_pTitleLabel->setFrameStyle(QFrame::Raised | QFrame::StyledPanel);
+ m_pCloseButton = new QPushButton("", m_pHBox);
+ m_pCloseButton->setIcon(*(g_pIconManager->getSmallIcon(KviIconManager::Close)));
+ m_pCloseButton->setToolTip(__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);
+ setFrameStyle(QFrame::Sunken | QFrame::Panel);
- KPluginFactory *pKonsoleFactory = KPluginLoader("libkonsolepart").factory();
+ KPluginFactory * pKonsoleFactory = KPluginLoader("libkonsolepart").factory();
- if(pKonsoleFactory)
- {
- m_pKonsolePart = static_cast<KParts::ReadOnlyPart *>(pKonsoleFactory->create<QObject>(this, this));
+ if(pKonsoleFactory)
+ {
+ m_pKonsolePart = static_cast<KParts::ReadOnlyPart *>(pKonsoleFactory->create<QObject>(this, this));
- if(m_pKonsolePart)
- {
- // start the terminal
- qobject_cast<TerminalInterface*>(m_pKonsolePart)->showShellInDir( QString() );
+ if(m_pKonsolePart)
+ {
+ // start the terminal
+ qobject_cast<TerminalInterface *>(m_pKonsolePart)->showShellInDir(QString());
- m_pKonsoleWidget = m_pKonsolePart->widget();
+ m_pKonsoleWidget = m_pKonsolePart->widget();
- setFocusProxy(m_pKonsoleWidget);
- m_pKonsoleWidget->show();
+ setFocusProxy(m_pKonsoleWidget);
+ m_pKonsoleWidget->show();
- connect ( m_pKonsolePart, SIGNAL(destroyed()), this, SLOT(konsoleDestroyed()) );
- } else {
- m_pKonsoleWidget = new QLabel(__tr2qs("Can't create the terminal emulation part"), this);
- }
- } else {
- m_pKonsoleWidget = new QLabel(__tr2qs("Can't retrieve the terminal emulation factory"), this);
+ connect(m_pKonsolePart, SIGNAL(destroyed()), this, SLOT(konsoleDestroyed()));
+ }
+ else
+ {
+ m_pKonsoleWidget = new QLabel(__tr2qs("Can't create the terminal emulation part"), this);
}
}
-
- TermWidget::~TermWidget()
+ else
{
- 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();
+ m_pKonsoleWidget = new QLabel(__tr2qs("Can't retrieve the terminal emulation factory"), this);
}
+}
- void TermWidget::resizeEvent(QResizeEvent *)
- {
- int hght = 0;
- if(m_bIsStandalone)
- {
- hght = m_pCloseButton->sizeHint().height();
- m_pHBox->setGeometry(1,1,width() - 2,hght + 1);
+TermWidget::~TermWidget()
+{
+ if(m_pKonsoleWidget)
+ disconnect(m_pKonsoleWidget, SIGNAL(destroyed()), this, SLOT(konsoleDestroyed()));
- }
- if(m_pKonsoleWidget)
- m_pKonsoleWidget->setGeometry(1,hght + 1,width() - 2,height() - (hght + 2));
- }
+ if(m_bIsStandalone)
+ g_pTermWidgetList->removeRef(this);
+ if(g_pTermWindowList->isEmpty() && g_pTermWidgetList->isEmpty())
+ g_pTermModule->unlock();
+}
- void TermWidget::closeClicked()
+void TermWidget::resizeEvent(QResizeEvent *)
+{
+ int hght = 0;
+ if(m_bIsStandalone)
{
- // this is called only in standalone mode
- delete this;
+ 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));
+}
- void TermWidget::konsoleDestroyed()
- {
- m_pKonsoleWidget = 0;
- m_pKonsolePart = 0;
- hide();
- QTimer::singleShot(0,this,SLOT(autoClose()));
- }
+void TermWidget::closeClicked()
+{
+ // this is called only in standalone mode
+ delete this;
+}
- void TermWidget::autoClose()
- {
- if(m_bIsStandalone)delete this;
- else ((KviWindow *)parent())->close();
- }
+void TermWidget::konsoleDestroyed()
+{
+ m_pKonsoleWidget = 0;
+ m_pKonsolePart = 0;
+ hide();
+ QTimer::singleShot(0, this, SLOT(autoClose()));
+}
- void TermWidget::changeTitle(int,const QString& str)
- {
- if(m_bIsStandalone)m_pTitleLabel->setText(str);
- }
+void TermWidget::autoClose()
+{
+ if(m_bIsStandalone)
+ delete this;
+ else
+ ((KviWindow *)parent())->close();
+}
- void TermWidget::notifySize(int,int)
- {
- }
+void TermWidget::changeTitle(int, const QString & str)
+{
+ if(m_bIsStandalone)
+ m_pTitleLabel->setText(str);
+}
+
+void TermWidget::notifySize(int, int)
+{
+}
+
+void TermWidget::changeColumns(int)
+{
+}
- void TermWidget::changeColumns(int)
+QSize TermWidget::sizeHint() const
+{
+ int hght = 0;
+ int wdth = 0;
+ if(m_pKonsoleWidget)
{
+ hght += m_pKonsoleWidget->sizeHint().height();
+ wdth = m_pKonsoleWidget->sizeHint().width();
}
-
- QSize TermWidget::sizeHint() const
+ if(m_pCloseButton)
{
- 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);
+ hght += m_pCloseButton->sizeHint().height();
}
+ return QSize(wdth + 2, hght + 2);
+}
#endif //COMPILE_KDE4_SUPPORT