summaryrefslogtreecommitdiffstats
path: root/src/libgui/console.cpp
blob: 99c996c46cf8875c1c14622a3a21d5cfcad00e67 (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
/***************************************************************************
 *   Copyright (C) 2007 Nicolas Hadacek <hadacek@kde.org>                  *
 *                                                                         *
 *   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.                                   *
 ***************************************************************************/
#include "console.h"

#include <qlayout.h>
#include <qlabel.h>
#include <qdir.h>
#include <klibloader.h>
#include <klocale.h>
#include <kparts/part.h>
#include <kde_terminal_interface.h>

ConsoleView::ConsoleView(QWidget *parent)
  : QWidget(parent, "console_view"), _initialized(false)
{}

void ConsoleView::showEvent(QShowEvent *e)
{
  if ( !_initialized ) {
    _initialized = true;
    KLibFactory *factory = KLibLoader::self()->factory("libkonsolepart");
    QVBoxLayout *top = new QVBoxLayout(this, 0, 10);
    if ( factory==0 ) {
      QLabel *label = new QLabel(i18n("Could not find \"konsolepart\"; please install kdebase."), this);
      label->show();
      top->addWidget(label);
      return;
    } else {
      QWidget *pwidget = static_cast<KParts::Part *>(factory->create(this, "konsole"))->widget();
      pwidget->show();
      top->addWidget(pwidget);
      setFocusProxy(pwidget);
    }
  }
  QWidget::showEvent(e);
}