diff options
Diffstat (limited to 'src/modules/term/termwidget.cpp')
| -rw-r--r-- | src/modules/term/termwidget.cpp | 262 |
1 files changed, 131 insertions, 131 deletions
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 |
