diff options
| author | 2016-04-29 23:57:30 +0100 | |
|---|---|---|
| committer | 2016-04-29 23:57:48 +0100 | |
| commit | 690dd7a33ddc90678367d73adf313533536e10f2 (patch) | |
| tree | 2276fe7c384ebbc222b40a19c536d5c3c5606ce8 /src/modules/term | |
| parent | Add config for clang-format. (diff) | |
| download | KVIrc-690dd7a33ddc90678367d73adf313533536e10f2.tar.gz KVIrc-690dd7a33ddc90678367d73adf313533536e10f2.tar.bz2 KVIrc-690dd7a33ddc90678367d73adf313533536e10f2.zip | |
Apply clang-format
Diffstat (limited to 'src/modules/term')
| -rw-r--r-- | src/modules/term/TermWidget.cpp | 218 | ||||
| -rw-r--r-- | src/modules/term/TermWidget.h | 95 | ||||
| -rw-r--r-- | src/modules/term/TermWindow.cpp | 78 | ||||
| -rw-r--r-- | src/modules/term/TermWindow.h | 59 | ||||
| -rw-r--r-- | src/modules/term/libkviterm.cpp | 42 |
5 files changed, 254 insertions, 238 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 diff --git a/src/modules/term/TermWidget.h b/src/modules/term/TermWidget.h index f1c2b3851..78d1b89c4 100644 --- a/src/modules/term/TermWidget.h +++ b/src/modules/term/TermWidget.h @@ -27,57 +27,60 @@ #include "kvi_settings.h" #ifdef COMPILE_KDE4_SUPPORT - #include <QFrame> - #include <QLabel> - #include <QPushButton> - #include "KviTalHBox.h" +#include <QFrame> +#include <QLabel> +#include <QPushButton> +#include "KviTalHBox.h" - #include "kparts/part.h" +#include "kparts/part.h" - class KviMainWindow; +class KviMainWindow; - class TermWidget : public QFrame - { - Q_OBJECT - Q_PROPERTY( int KviProperty_ChildFocusOwner READ dummy ) - public: - TermWidget(QWidget * par,bool bIsStandalone = false); - ~TermWidget(); - 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(); - }; +class TermWidget : public QFrame +{ + Q_OBJECT + Q_PROPERTY(int KviProperty_ChildFocusOwner READ dummy) +public: + TermWidget(QWidget * par, bool bIsStandalone = false); + ~TermWidget(); + +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(); +}; #else - // Dummy, to make moc happy - #include <QObject> - - class TermWidget : public QObject +// Dummy, to make moc happy +#include <QObject> + +class TermWidget : public QObject +{ + Q_OBJECT +public: + TermWidget() + : QObject() { - Q_OBJECT - public: - TermWidget() - : QObject() - { - } - }; + } +}; #endif #endif //_HELPWIDGET_H_ diff --git a/src/modules/term/TermWindow.cpp b/src/modules/term/TermWindow.cpp index 606f91696..8ea32d0e7 100644 --- a/src/modules/term/TermWindow.cpp +++ b/src/modules/term/TermWindow.cpp @@ -26,52 +26,52 @@ #include "TermWidget.h" #ifdef COMPILE_KDE4_SUPPORT - #include "KviIconManager.h" - #include "KviOptions.h" - #include "KviLocale.h" - #include "KviModule.h" +#include "KviIconManager.h" +#include "KviOptions.h" +#include "KviLocale.h" +#include "KviModule.h" - extern KviModule * g_pTermModule; - extern KviPointerList<TermWindow> * g_pTermWindowList; - extern KviPointerList<TermWidget> * g_pTermWidgetList; - extern KviIconManager * g_pIconManager; +extern KviModule * g_pTermModule; +extern KviPointerList<TermWindow> * g_pTermWindowList; +extern KviPointerList<TermWidget> * g_pTermWidgetList; +extern KviIconManager * g_pIconManager; - TermWindow::TermWindow(const char * name) - : KviWindow(KviWindow::Terminal,name) - { - g_pTermWindowList->append(this); - m_pTermWidget = 0; - m_pTermWidget = new TermWidget(this); - // Ensure proper focusing +TermWindow::TermWindow(const char * name) + : KviWindow(KviWindow::Terminal, name) +{ + g_pTermWindowList->append(this); + m_pTermWidget = 0; + m_pTermWidget = new TermWidget(this); + // Ensure proper focusing // setFocusHandler(m_pTermWidget->konsoleWidget(),this); - } +} - TermWindow::~TermWindow() - { - g_pTermWindowList->removeRef(this); - if(g_pTermWindowList->isEmpty() && g_pTermWidgetList->isEmpty())g_pTermModule->unlock(); - } +TermWindow::~TermWindow() +{ + g_pTermWindowList->removeRef(this); + if(g_pTermWindowList->isEmpty() && g_pTermWidgetList->isEmpty()) + g_pTermModule->unlock(); +} - QPixmap * TermWindow::myIconPtr() - { - return g_pIconManager->getSmallIcon(KviIconManager::Raw); - } +QPixmap * TermWindow::myIconPtr() +{ + return g_pIconManager->getSmallIcon(KviIconManager::Raw); +} - void TermWindow::resizeEvent(QResizeEvent *) - { - if(m_pTermWidget)m_pTermWidget->setGeometry(0,0,width(),height()); - } - - QSize TermWindow::sizeHint() const - { - return m_pTermWidget ? m_pTermWidget->sizeHint() : KviWindow::sizeHint(); - } - - void TermWindow::fillCaptionBuffers() - { - m_szPlainTextCaption = __tr("Terminal"); - } +void TermWindow::resizeEvent(QResizeEvent *) +{ + if(m_pTermWidget) + m_pTermWidget->setGeometry(0, 0, width(), height()); +} +QSize TermWindow::sizeHint() const +{ + return m_pTermWidget ? m_pTermWidget->sizeHint() : KviWindow::sizeHint(); +} +void TermWindow::fillCaptionBuffers() +{ + m_szPlainTextCaption = __tr("Terminal"); +} #endif diff --git a/src/modules/term/TermWindow.h b/src/modules/term/TermWindow.h index d488df959..954d9dc6f 100644 --- a/src/modules/term/TermWindow.h +++ b/src/modules/term/TermWindow.h @@ -27,39 +27,42 @@ #include "kvi_settings.h" #ifdef COMPILE_KDE4_SUPPORT - #include "KviWindow.h" - #include "KviCString.h" +#include "KviWindow.h" +#include "KviCString.h" - class TermWidget; +class TermWidget; - class TermWindow : public KviWindow - { - Q_OBJECT - public: - TermWindow(const char * name); - ~TermWindow(); - protected: - TermWidget * m_pTermWidget; - protected: - virtual QPixmap * myIconPtr(); - virtual void fillCaptionBuffers(); - virtual void resizeEvent(QResizeEvent *e); - public: - virtual QSize sizeHint() const; - }; +class TermWindow : public KviWindow +{ + Q_OBJECT +public: + TermWindow(const char * name); + ~TermWindow(); + +protected: + TermWidget * m_pTermWidget; + +protected: + virtual QPixmap * myIconPtr(); + virtual void fillCaptionBuffers(); + virtual void resizeEvent(QResizeEvent * e); + +public: + virtual QSize sizeHint() const; +}; #else - #include <QObject> +#include <QObject> - // Dummy, to make moc happy - class TermWindow : public QObject +// Dummy, to make moc happy +class TermWindow : public QObject +{ + Q_OBJECT +public: + TermWindow() + : QObject() { - Q_OBJECT - public: - TermWindow() - : QObject() - { - } - }; + } +}; #endif #endif //_KVI_HELPWINDOW_H_ diff --git a/src/modules/term/libkviterm.cpp b/src/modules/term/libkviterm.cpp index 54361b0f3..f08890bd1 100644 --- a/src/modules/term/libkviterm.cpp +++ b/src/modules/term/libkviterm.cpp @@ -31,11 +31,11 @@ #include <QSplitter> #ifdef COMPILE_KDE4_SUPPORT - #include "TermWidget.h" - #include "TermWindow.h" +#include "TermWidget.h" +#include "TermWindow.h" - KviPointerList<TermWidget> * g_pTermWidgetList = 0; - KviPointerList<TermWindow> * g_pTermWindowList = 0; +KviPointerList<TermWidget> * g_pTermWidgetList = 0; +KviPointerList<TermWindow> * g_pTermWindowList = 0; #endif KviModule * g_pTermModule = 0; @@ -68,14 +68,15 @@ static bool term_kvs_cmd_open(KviKvsModuleCommandCall * c) #ifdef COMPILE_KDE4_SUPPORT c->module()->lock(); // multiple locks are allowed if( - c->hasSwitch('m',"mdi") || // compat only - c->hasSwitch('d',"dockable") - ) + c->hasSwitch('m', "mdi") || // compat only + c->hasSwitch('d', "dockable")) { - TermWindow *w = new TermWindow("Terminal emulator"); + TermWindow * w = new TermWindow("Terminal emulator"); g_pMainWindow->addWindow(w); - } else { - TermWidget *w = new TermWidget(g_pMainWindow->splitter(), true); + } + else + { + TermWidget * w = new TermWidget(g_pMainWindow->splitter(), true); w->show(); } #else @@ -95,7 +96,7 @@ static bool term_module_init(KviModule * m) g_pTermWindowList->setAutoDelete(false); #endif - KVSM_REGISTER_SIMPLE_COMMAND(m,"open",term_kvs_cmd_open); + KVSM_REGISTER_SIMPLE_COMMAND(m, "open", term_kvs_cmd_open); return true; } @@ -115,13 +116,12 @@ static bool term_module_cleanup(KviModule *) } KVIRC_MODULE( - "Term", // module name - "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, - 0, - 0, - term_module_cleanup, - 0 -) + "Term", // module name + "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, + 0, + 0, + term_module_cleanup, + 0) |
