aboutsummaryrefslogtreecommitdiffstats
path: root/src/modules
diff options
context:
space:
mode:
authorGravatar Fabio Bas2008-11-08 20:56:10 +0000
committerGravatar Fabio Bas2008-11-08 20:56:10 +0000
commit36a07453f18ef81bf02e3b15fea6da24dee68956 (patch)
treef23cea4fee7a12ffaf42a594ec663211599471c5 /src/modules
parenthopefully removed all the remaining noisy messages from gcc (diff)
downloadKVIrc-36a07453f18ef81bf02e3b15fea6da24dee68956.tar.gz
KVIrc-36a07453f18ef81bf02e3b15fea6da24dee68956.tar.bz2
KVIrc-36a07453f18ef81bf02e3b15fea6da24dee68956.zip
ported term module to kde4
git-svn-id: https://svn.kvirc.de/svn/trunk/kvirc@2842 17fca916-40b9-46aa-a4ea-0a15b648b75c
Diffstat (limited to 'src/modules')
-rw-r--r--src/modules/term/CMakeLists.txt7
-rw-r--r--src/modules/term/libkviterm.cpp64
-rw-r--r--src/modules/term/termwidget.cpp101
-rw-r--r--src/modules/term/termwidget.h10
-rw-r--r--src/modules/term/termwindow.cpp37
-rw-r--r--src/modules/term/termwindow.h6
6 files changed, 96 insertions, 129 deletions
diff --git a/src/modules/term/CMakeLists.txt b/src/modules/term/CMakeLists.txt
index 8f4d2c54a..3598ab444 100644
--- a/src/modules/term/CMakeLists.txt
+++ b/src/modules/term/CMakeLists.txt
@@ -1,5 +1,10 @@
# CMakeLists for src/modules/term
+SET(kviterm_MOC_HDRS
+ termwidget.h
+ termwindow.h
+)
+
SET(kviterm_SRCS
libkviterm.cpp
termwidget.cpp
@@ -7,7 +12,7 @@ SET(kviterm_SRCS
)
# After this call, files will be moc'ed to moc_kvi_*.cpp
-QT4_WRAP_CPP(kviterm_MOC_SRCS)
+QT4_WRAP_CPP(kviterm_MOC_SRCS ${kviterm_MOC_HDRS})
SET(kvi_module_name kviterm)
INCLUDE(${CMAKE_SOURCE_DIR}/cmake/module.rules.txt)
diff --git a/src/modules/term/libkviterm.cpp b/src/modules/term/libkviterm.cpp
index 3f7b8abe5..abdf6df92 100644
--- a/src/modules/term/libkviterm.cpp
+++ b/src/modules/term/libkviterm.cpp
@@ -30,24 +30,16 @@
#include <QSplitter>
-#ifdef COMPILE_KDE3_SUPPORT
+#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;
-
-#ifdef COMPILE_KDE3_SUPPORT
KviPointerList<KviTermWidget> * g_pTermWidgetList = 0;
KviPointerList<KviTermWindow> * g_pTermWindowList = 0;
- KviStr g_szKonsoleLibraryName = "";
#endif
+KviModule * g_pTermModule = 0;
+
/*
@doc: term.open
@type:
@@ -73,21 +65,15 @@ KviModule * g_pTermModule = 0;
static bool term_kvs_cmd_open(KviKvsModuleCommandCall * c)
{
-#ifdef COMPILE_KDE3_SUPPORT
- if(g_szKonsoleLibraryName.hasData())
+#ifdef COMPILE_KDE_SUPPORT
+ c->module()->lock(); // multiple locks are allowed
+ if(c->hasSwitch('m',"mdi"))
{
- c->module()->lock(); // multiple locks are allowed
- if(c->hasSwitch('m',"mdi"))
- {
- KviTermWindow *w = new KviTermWindow(c->window()->frame(),"Terminal emulator");
- c->window()->frame()->addWindow(w);
- } else {
- KviTermWidget *w = new KviTermWidget(c->window()->frame()->splitter(),
- c->window()->frame(),true);
- w->show();
- }
+ KviTermWindow *w = new KviTermWindow(c->window()->frame(),"Terminal emulator");
+ c->window()->frame()->addWindow(w);
} else {
- c->warning("No terminal emulation service available");
+ KviTermWidget *w = new KviTermWidget(c->window()->frame()->splitter(), c->window()->frame(),true);
+ w->show();
}
#else
c->warning("Terminal emulation service not supported (non-KDE compilation)");
@@ -99,46 +85,20 @@ static bool term_module_init(KviModule * m)
{
g_pTermModule = m;
-#ifdef COMPILE_KDE3_SUPPORT
+#ifdef COMPILE_KDE_SUPPORT
g_pTermWidgetList = new KviPointerList<KviTermWidget>;
g_pTermWidgetList->setAutoDelete(false);
g_pTermWindowList = new KviPointerList<KviTermWindow>;
g_pTermWindowList->setAutoDelete(false);
-
-// KTrader::OfferList offers = KTrader::self()->query("Browser/View","KonsolePart");
-// KTrader::OfferList offers = KTrader::self()->query("Browser/View","");
-// if(offers.count() > 0)
-// {
-// KTrader::OfferList::Iterator it = offers.begin();
-// while(it != offers.end())
-// {
-// KviStr tmp = (*it)->name();
-// KviStr tmp2 = (*it)->type();
-// KviStr tmp3 = (*it)->library();
-// debug("Got Service name:%s type:%s library:%s",tmp.ptr(),tmp2.ptr(),tmp3.ptr());
-// ++it;
-// }
-// }
-// KService::Ptr service = *offers.begin();
- KService::Ptr pKonsoleService = KService::serviceByName("Terminal Emulator");
- if(!pKonsoleService)pKonsoleService = KService::serviceByName("KonsolePart");
- if(!pKonsoleService)pKonsoleService = KService::serviceByName("Terminal *");
- if(pKonsoleService)
- {
- g_szKonsoleLibraryName = pKonsoleService->library();
-// debug("KONSOLE LIB %s",g_szKonsoleLibraryName.ptr());
- }
-// delete pKonsoleService;
#endif
-// m->registerCommand("open",term_module_cmd_open);
KVSM_REGISTER_SIMPLE_COMMAND(m,"open",term_kvs_cmd_open);
return true;
}
static bool term_module_cleanup(KviModule *)
{
-#ifdef COMPILE_KDE3_SUPPORT
+#ifdef COMPILE_KDE_SUPPORT
while(g_pTermWidgetList->first())delete g_pTermWidgetList->first();
delete g_pTermWidgetList;
g_pTermWidgetList = 0;
diff --git a/src/modules/term/termwidget.cpp b/src/modules/term/termwidget.cpp
index 3f948aadb..ea83e733f 100644
--- a/src/modules/term/termwidget.cpp
+++ b/src/modules/term/termwidget.cpp
@@ -35,34 +35,35 @@
#include <QToolTip>
#include <QTimer>
-#ifdef COMPILE_KDE3_SUPPORT
+#ifdef COMPILE_KDE_SUPPORT
#include "klibloader.h"
#include "kparts/part.h"
#include "kparts/factory.h"
-
- extern KviModule * g_pTermModule;
+ #include <kde_terminal_interface.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")
+
+ KviTermWidget::KviTermWidget(QWidget * par,KviFrame *,bool bIsStandalone)
+ : QFrame(par)
{
+ setObjectName("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_pTitleLabel->setFrameStyle(QFrame::Raised | QFrame::StyledPanel);
m_pCloseButton = new QPushButton("",m_pHBox);
- m_pCloseButton->setPixmap(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_CLOSE)));
- QToolTip::add(m_pCloseButton,__tr2qs("Close this window"));
+ m_pCloseButton->setIcon(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_CLOSE)));
+ m_pCloseButton->setToolTip(__tr2qs("Close this window"));
m_pHBox->setStretchFactor(m_pTitleLabel,2);
connect(m_pCloseButton,SIGNAL(clicked()),this,SLOT(closeClicked()));
} else {
@@ -70,68 +71,62 @@
m_pTitleLabel = 0;
m_pCloseButton = 0;
}
-
+
setFrameStyle(QFrame::Sunken | QFrame::Panel);
-
- KParts::Factory * pKonsoleFactory = static_cast<KParts::Factory *>(
- KLibLoader::self()->factory(g_szKonsoleLibraryName.ptr()));
-
+
+ KPluginFactory *pKonsoleFactory = KPluginLoader("libkonsolepart").factory();
+
if(pKonsoleFactory)
{
- // debug("FACTORY %d",pKonsoleFactory);
- m_pKonsolePart = static_cast<KParts::Part *>(pKonsoleFactory->createPart(
- this,"terminal emulator",this,"the konsole part"));
-
+ m_pKonsolePart = static_cast<KParts::ReadOnlyPart *>(pKonsoleFactory->create<QObject>(this, this));
+
if(m_pKonsolePart)
{
- // debug("PART %d",m_pKonsolePart);
+ // start the terminal
+ qobject_cast<TerminalInterface*>(m_pKonsolePart)->showShellInDir( QString() );
+
m_pKonsoleWidget = m_pKonsolePart->widget();
- connect(m_pKonsoleWidget,SIGNAL(destroyed()),this,SLOT(konsoleDestroyed()));
- // debug("Widget %d",m_pKonsoleWidget);
+
+ setFocusProxy(m_pKonsoleWidget);
+ m_pKonsoleWidget->show();
+
+ connect ( m_pKonsolePart, SIGNAL(destroyed()), this, SLOT(konsoleDestroyed()) );
} else {
- m_pKonsoleWidget = new QLabel(this,
- __tr2qs("Can't create the terminal emulation part"));
+ m_pKonsoleWidget = new QLabel(__tr2qs("Can't create the terminal emulation part"), this);
}
-
} else {
- m_pKonsoleWidget = new QLabel(this,
- __tr2qs("Can't retrieve the terminal emulation factory"));
+ m_pKonsoleWidget = new QLabel(__tr2qs("Can't retrieve the terminal emulation factory"), this);
}
}
-
+
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)
+
+ void KviTermWidget::resizeEvent(QResizeEvent *)
{
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_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;
@@ -139,26 +134,26 @@
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)
+
+ void KviTermWidget::changeTitle(int,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;
@@ -172,10 +167,12 @@
{
hght += m_pCloseButton->sizeHint().height();
}
-
+
return QSize(wdth + 2,hght + 2);
}
-
- #include "termwidget.moc"
+
+#ifndef COMPILE_USE_STANDALONE_MOC_SOURCES
+#include "termwidget.moc"
+#endif //!COMPILE_USE_STANDALONE_MOC_SOURCES
#endif //COMPILE_KDE_SUPPORT
diff --git a/src/modules/term/termwidget.h b/src/modules/term/termwidget.h
index 89c74a7e0..253322ece 100644
--- a/src/modules/term/termwidget.h
+++ b/src/modules/term/termwidget.h
@@ -26,16 +26,16 @@
#include "kvi_settings.h"
-#ifdef COMPILE_KDE3_SUPPORT
+#ifdef COMPILE_KDE_SUPPORT
#include <QFrame>
#include <QLabel>
#include <QPushButton>
#include "kvi_tal_hbox.h"
-
+
#include "kparts/part.h"
-
+
class KviFrame;
-
+
class KviTermWidget : public QFrame
{
Q_OBJECT
@@ -44,7 +44,7 @@
KviTermWidget(QWidget * par,KviFrame * lpFrm,bool bIsStandalone = false);
~KviTermWidget();
private:
- KviTalHBox * m_pHBox;
+ KviTalHBox * m_pHBox;
QLabel * m_pTitleLabel;
QPushButton * m_pCloseButton;
KParts::Part * m_pKonsolePart;
diff --git a/src/modules/term/termwindow.cpp b/src/modules/term/termwindow.cpp
index 9ae21552e..171ed6353 100644
--- a/src/modules/term/termwindow.cpp
+++ b/src/modules/term/termwindow.cpp
@@ -25,16 +25,17 @@
#include "termwindow.h"
#include "termwidget.h"
-#ifdef COMPILE_KDE3_SUPPORT
+#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;
-
+ extern KviIconManager * g_pIconManager;
+
KviTermWindow::KviTermWindow(KviFrame * lpFrm,const char * name)
: KviWindow(KVI_WINDOW_TYPE_TERM,lpFrm,name)
{
@@ -44,41 +45,45 @@
// 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)
+
+ void KviTermWindow::resizeEvent(QResizeEvent *)
{
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_szPlainTextCaption = __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());
+ KVI_OPTION_COLOR(KviOption_colorCaptionTextActive).name().toAscii().data(),
+ KVI_OPTION_COLOR(KviOption_colorCaptionTextActive2).name().toAscii().data());
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());
+ KVI_OPTION_COLOR(KviOption_colorCaptionTextInactive).name().toAscii().data(),
+ KVI_OPTION_COLOR(KviOption_colorCaptionTextInactive2).name().toAscii().data());
}
- #include "termwindow.moc"
+
+#ifndef COMPILE_USE_STANDALONE_MOC_SOURCES
+#include "termwindow.moc"
+#endif //!COMPILE_USE_STANDALONE_MOC_SOURCES
+
#endif
diff --git a/src/modules/term/termwindow.h b/src/modules/term/termwindow.h
index f269dfc45..c485f61a5 100644
--- a/src/modules/term/termwindow.h
+++ b/src/modules/term/termwindow.h
@@ -26,12 +26,12 @@
#include "kvi_settings.h"
-#ifdef COMPILE_KDE3_SUPPORT
+#ifdef COMPILE_KDE_SUPPORT
#include "kvi_window.h"
#include "kvi_string.h"
-
+
class KviTermWidget;
-
+
class KviTermWindow : public KviWindow
{
Q_OBJECT