blob: f6777e354637d7d6422e330f91a40d9c91eed007 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
/*
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
*/
/*
Copyright (C) 2005 Francois Chazal <neptune3k@free.fr>
Copyright (C) 2006-2007 Eike Hein <hein@kde.org>
*/
#include "terminal.h"
#include "terminal.moc"
int Terminal::available_terminal_id = 0;
Terminal::Terminal(QWidget* parent, const char* name) : QObject(parent, name)
{
terminal_id = available_terminal_id;
available_terminal_id++;
setenv("DCOP_YAKUAKE_TERMINAL", QString::number(terminal_id).ascii(), 1);
putenv((char*)"COLORTERM="); // Trigger mc's color detection.
KLibFactory* factory = NULL;
terminal_part = NULL;
terminal_title = "";
terminal_widget = NULL;
terminal_interface = NULL;
if ((factory = KLibLoader::self()->factory("libkonsolepart")) != NULL)
terminal_part = (KParts::Part *) (factory->create(parent));
if (terminal_part != NULL)
{
terminal_widget = terminal_part->widget();
terminal_widget->setFocusPolicy(QWidget::WheelFocus);
terminal_interface = (TerminalInterface *) (terminal_part->qt_cast("TerminalInterface"));
connect(terminal_part, SIGNAL(destroyed()), this, SLOT(deleteLater()));
connect(terminal_part, SIGNAL(setWindowCaption(const QString &)), this, SLOT(slotUpdateSessionTitle(const QString &)));
}
}
Terminal::~Terminal()
{
emit destroyed(terminal_id);
}
QWidget* Terminal::widget()
{
return terminal_widget;
}
TerminalInterface* Terminal::terminal()
{
return terminal_interface;
}
const QString Terminal::title()
{
return terminal_title;
}
void Terminal::setTitle(const QString& title)
{
slotUpdateSessionTitle(title);
}
void Terminal::slotUpdateSessionTitle(const QString& title)
{
terminal_title = title;
// Remove trailing " -" from the caption. If needed this is
// handled later in TitleBar.
if (terminal_title.endsWith(" - "))
terminal_title.truncate(terminal_title.length() - 3);
emit titleChanged(terminal_widget, terminal_title);
}
|