Commit 13ba2637 authored by Robert Knight's avatar Robert Knight

* It is time to bite the bullet. This is the beginnings of an attempt to rewrite

  the Konsole front-end, the design is partly based on Kate.

* Everything kicks off in the kdemain function in start.cpp
* KonsoleApp encapsulates the main application as a unique single-instance application.
* KonsoleMainWindow is the main program window.


svn path=/branches/work/konsole-split-view/; revision=616847
parent 83490dfc
......@@ -23,30 +23,51 @@ endif(KONSOLE_GENERATE_LINEFONT)
########### next target ###############
set(konsole_KDEINIT_SRCS
${konsoleadaptors_SRCS}
${sessionadaptors_SRCS}
TEPty.cpp
BlockArray.cpp
main.cpp
konsole.cpp
schema.cpp
TESession.cpp
TEWidget.cpp
TEmuVt102.cpp
TEScreen.cpp
TEmulation.cpp
TEHistory.cpp
keytrans.cpp
konsole_wcwidth.cpp
konsolebookmarkhandler.cpp
zmodem_dialog.cpp
printsettings.cpp
TerminalCharacterDecoder.cpp
SessionManager.cpp
ViewSplitter.cpp
ViewContainer.cpp
NavigationItem.cpp )
#set(konsole_KDEINIT_SRCS
# ${konsoleadaptors_SRCS}
# ${sessionadaptors_SRCS}
# TEPty.cpp
# BlockArray.cpp
# main.cpp
# konsole.cpp
# schema.cpp
# TESession.cpp
# TEWidget.cpp
# TEmuVt102.cpp
# TEScreen.cpp
# TEmulation.cpp
# TEHistory.cpp
# keytrans.cpp
# konsole_wcwidth.cpp
# konsolebookmarkhandler.cpp
# zmodem_dialog.cpp
# printsettings.cpp
# TerminalCharacterDecoder.cpp
# SessionManager.cpp
# ViewSplitter.cpp
# ViewContainer.cpp
# NavigationItem.cpp )
set(konsole_KDEINIT_SRCS
${sessionadaptors_SRCS}
start.cpp
KonsoleApp.cpp
KonsoleMainWindow.cpp
SessionManager.cpp
TESession.cpp
TEPty.cpp
TEmulation.cpp
TEmuVt102.cpp
TEHistory.cpp
TEScreen.cpp
TEWidget.cpp
zmodem_dialog.cpp
keytrans.cpp
BlockArray.cpp
TerminalCharacterDecoder.cpp
schema.cpp
konsole_wcwidth.cpp
)
kde4_automoc(${konsole_KDEINIT_SRCS})
......@@ -87,8 +108,7 @@ set(konsolepart_PART_SRCS
TEHistory.cpp
keytrans.cpp
TerminalCharacterDecoder.cpp
SessionManager.cpp
NavigationItem.cpp )
SessionManager.cpp )
kde4_automoc(${konsolepart_PART_SRCS})
......
/*
Copyright (C) 2006 by Robert Knight <robertknight@gmail.com>
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.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.
*/
#include "SessionManager.h"
#include "keytrans.h"
#include "KonsoleApp.h"
#include "KonsoleMainWindow.h"
// global variable to determine whether or not true transparency should be used
// this should be made into a static class variable of KonsoleApp
int true_transparency = true;
KonsoleApp::KonsoleApp()
{
// create session manager
_sessionManager = new SessionManager();
// load keyboard layouts
KeyTrans::loadAll();
};
KonsoleApp* KonsoleApp::self()
{
return (KonsoleApp*)KApp;
}
int KonsoleApp::newInstance()
{
KonsoleMainWindow* window = new KonsoleMainWindow();
window->show();
return 0;
}
SessionManager* KonsoleApp::sessionManager()
{
return _sessionManager;
}
/*
Copyright (C) 2006 by Robert Knight <robertknight@gmail.com>
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.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.
*/
// KDE
#include <KUniqueApplication>
class KCmdLineArgs;
class SessionManager;
/**
* The Konsole Application
*/
class KonsoleApp : public KUniqueApplication
{
public:
/** Constructs a new Konsole application. */
KonsoleApp();
/** Creates a new main window and opens a default terminal session */
virtual int newInstance();
/** Returns the KonsoleApp instance */
static KonsoleApp* self();
/** Returns the session manager */
SessionManager* sessionManager();
private:
KCmdLineArgs* _arguments;
SessionManager* _sessionManager;
};
/*
Copyright (C) 2006 by Robert Knight <robertknight@gmail.com>
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.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.
*/
#include "KonsoleMainWindow.h"
KonsoleMainWindow::KonsoleMainWindow()
: KMainWindow()
{
}
#include <KMainWindow>
class ViewSplitter;
class KonsoleMainWindow : public KMainWindow
{
public:
KonsoleMainWindow();
protected:
void setupActions();
private:
ViewSplitter* m_viewSplitter;
};
#ifndef NAVIGATIONITEM_H
#define NAVIGATIONITEM_H
// Qt
#include <QIcon>
#include <QList>
#include <QString>
// KDE
#include <kactioncollection.h>
class QAction;
//Terminal Session Navigation
class TESession;
/**
* A class which provides information about particular views in a ViewContainer
* for use in the ViewContainer's navigation widget.
*
* This includes a title and an icon associated with a particular view,
* as well as a list of actions which can should be shown when the entry
* for that view is right-clicked in the navigation widget.
*
* NavigationItem instances also provide signals which are emitted
* when the title or icon associated with the view changes.
*/
class NavigationItem : public QObject
{
Q_OBJECT
public:
NavigationItem();
QString title() const;
QIcon icon() const;
virtual QList<QAction*> contextMenuActions( QList<QAction*> viewActions ) ;
signals:
void titleChanged( NavigationItem* item );
void iconChanged( NavigationItem* item );
protected:
void setTitle( const QString& title );
void setIcon( const QIcon& icon );
private:
QString _title;
QIcon _icon;
};
/**
* A navigation item class which provides information about views
* of terminal sessions.
*/
class SessionNavigationItem : public NavigationItem
{
Q_OBJECT
public:
/**
* Constructs a new SessionNavigationItem.
*
* @param session The terminal session from which the title, icon
* and other information should be obtained.
*/
SessionNavigationItem(TESession* session);
virtual QList<QAction*> contextMenuActions( QList<QAction*> viewActions ) ;
TESession* session() { return _session; }
private slots:
void updateTitle();
void sessionStateChange(TESession* session , int state);
//context menu action receivers
void closeSession();
void renameSession();
void toggleMonitorActivity(bool monitor);
void toggleMonitorSilence(bool monitor);
private:
void buildContextMenuActions();
//session for which this item provides navigation info
TESession* _session;
//list of actions for a context menu
QList<QAction*> _actionList;
//used by contextMenuActions() to locate the position in _actionList
//to insert the view actions
QAction* _viewSeparator;
//the name of the icon for the session in its current state (eg. active , silent , normal )
QString _stateIconName;
KActionCollection _collection;
};
#endif //NAVIGATIONITEM_H
#ifndef SESSIONCONTROLLER_H
#define SESSIONCONTROLLER_H
// Qt
#include <QIcon>
#include <QList>
#include <QString>
// KDE
#include <kactioncollection.h>
class QAction;
class TESession;
/**
*
*/
class SessionController : public QObject
{
Q_OBJECT
public:
enum MonitorType
{
Silence,
Activity
};
SessionController();
/** Returns the current title of the session */
QString title() const;
/** Returns the icon currently associated with the session */
QIcon icon() const;
/**
* Attempt to rename the session, prompting the user for a new name
* Returns the new name of the session, or the previous name if the session name was not changed
*/
QString rename();
/**
* Enable monitoring for certain types of events in the session
* @param type The type of event to monitor in the session
*/
void monitor(MonitorType type);
void sendToAllSessions();
signals:
/** Emitted whenever the title of the session changes */
void titleChanged( Controller* item );
/** Emitted whenver the icon associated with the session changes */
void iconChanged( Controller* item );
protected:
/** Sets the title returned by title() */
void setTitle( const QString& title );
/** Sets the icon returned by icon() */
void setIcon( const QIcon& icon );
private:
QString _title;
QIcon _icon;
};
#endif //SESSIONCONTROLLER_H
......@@ -22,11 +22,13 @@
#ifndef SESSIONMANAGER_H
#define SESSIONMANAGER_H
#include <QVariant>
#include <QHash>
#include <QList>
#include <QPair>
#include <QVariant>
class KSimpleConfig;
class KConfig;
class TESession;
/**
......
......@@ -44,7 +44,6 @@
// Konsole
#include <config-konsole.h>
#include "NavigationItem.h"
#include "schema.h"
#include "sessionadaptor.h"
#include "sessionscriptingadaptor.h"
......@@ -218,11 +217,13 @@ TEWidget* TESession::primaryView()
NavigationItem* TESession::navigationItem()
{
if (!_navigationItem)
/*if (!_navigationItem)
{
_navigationItem = new SessionNavigationItem(this);
}
return _navigationItem;
return _navigationItem;*/
assert(0);
return 0;
}
void TESession::addView(TEWidget* widget)
......@@ -599,7 +600,6 @@ TESession::~TESession()
{
delete _emulation;
delete _shellProcess;
delete _navigationItem;
delete zmodemProc;
QListIterator<TEWidget*> viewIter(_views);
......
......@@ -130,9 +130,20 @@ public:
void setSelection(const QString &t);
/**
* Reimplemented. Has no effect. Use setVTFont() to change the font
* used to draw characters in the display.
*/
virtual void setFont(const QFont &);
/** Returns the font used to draw characters in the display */
QFont getVTFont() { return font(); }
void setVTFont(const QFont &);
/**
* Sets the font used to draw the display. Has no effect if @p font
* is larger than the size of the display itself.
*/
void setVTFont(const QFont& font);
void setMouseMarks(bool on);
static void setAntialias( bool enable ) { s_antialias = enable; }
......
/*
Copyright (C) 2006 by Robert Knight <robertknight@gmail.com>
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.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.
*/
// KDE
#include <KAboutData>
#include <KCmdLineArgs>
#include <KLocale>
#include "KonsoleApp.h"
#define KONSOLE_VERSION "2.0"
extern "C" int KDE_EXPORT kdemain(int argc,char** argv)
{
KAboutData about("konsole",i18n("Konsole").toLocal8Bit().data(),KONSOLE_VERSION);
KCmdLineArgs::init(argc,argv,&about);
KUniqueApplication::addCmdLineOptions();
// create a new application instance if there are no running Konsole instances,
// otherwise inform the existing Konsole instance and exit
if ( !KUniqueApplication::start() )
{
exit(0);
}
KonsoleApp app;
return app.exec();
}
These are some notes on the existing implementation of the Konsole front-end:
TODO: Remove me when the new Konsole front-end is in-place
This is the absolute barebones code needed to start a terminal session and display it
in a new window on screen.
KonsoleMainWindow* window = new KonsoleMainWindow();
TESession* s = _sessionManager->createSession();
TEWidget* display = new TEWidget(0);
s->setConnect(true);
s->run();
display->setMinimumSize(200,200);
display->setBellMode(0);
display->setVTFont( QFont("Monospace") );
display->setTerminalSizeHint(true);
display->setSize(80,40);
s->addView(display);
window->setCentralWidget(display);
window->show();
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment