Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Utilities
Konsole
Commits
2e6e657f
Commit
2e6e657f
authored
Apr 06, 2007
by
Robert Knight
Browse files
Add Remote Connection dialog. More explanation later. Some more Q_UINT* -> quint* porting.
svn path=/branches/work/konsole-split-view/; revision=651051
parent
83491d35
Changes
10
Hide whitespace changes
Inline
Side-by-side
konsole/CMakeLists.txt
View file @
2e6e657f
...
...
@@ -77,6 +77,7 @@ set(konsole_KDEINIT_SRCS
TerminalDisplay.cpp
Vt102Emulation.cpp
Emulation.cpp
RemoteConnectionDialog.cpp
TerminalCharacterDecoder.cpp
ViewContainer.cpp
ViewManager.cpp
...
...
@@ -89,8 +90,10 @@ set(konsole_KDEINIT_SRCS
XKB.cpp
)
set_source_files_properties
(
${
konsole_KDEINIT_SRCS
}
PROPERTIES COMPILE_FLAGS
"-Wuninitialized"
)
kde4_add_ui_files
(
konsole_KDEINIT_SRCS
RemoteConnectionDialog.ui
)
kde4_automoc
(
${
konsole_KDEINIT_SRCS
}
)
kde4_add_kdeinit_executable
(
konsole
${
konsole_KDEINIT_SRCS
}
)
...
...
konsole/MainWindow.cpp
View file @
2e6e657f
...
...
@@ -34,10 +34,11 @@
#include
<KXMLGUIFactory>
// Konsole
#include
"IncrementalSearchBar.h"
#include
"Application.h"
#include
"BookmarkHandler.h"
#include
"IncrementalSearchBar.h"
#include
"MainWindow.h"
#include
"RemoteConnectionDialog.h"
#include
"SessionList.h"
#include
"ViewManager.h"
#include
"ViewSplitter.h"
...
...
@@ -87,15 +88,22 @@ void MainWindow::setupActions()
newTabAction
->
setIcon
(
KIcon
(
"openterm"
)
);
newTabAction
->
setText
(
i18n
(
"New &Tab"
)
);
newTabAction
->
setShortcut
(
QKeySequence
(
Qt
::
CTRL
+
Qt
::
SHIFT
+
Qt
::
Key_N
)
);
connect
(
newTabAction
,
SIGNAL
(
triggered
())
,
this
,
SLOT
(
newTab
())
);
QAction
*
newWindowAction
=
collection
->
addAction
(
"new-window"
);
newWindowAction
->
setIcon
(
KIcon
(
"window-new"
)
);
newWindowAction
->
setText
(
i18n
(
"New &Window"
)
);
newWindowAction
->
setShortcut
(
QKeySequence
(
Qt
::
CTRL
+
Qt
::
SHIFT
+
Qt
::
Key_M
)
);
connect
(
newTabAction
,
SIGNAL
(
triggered
())
,
this
,
SLOT
(
newTab
())
);
connect
(
newWindowAction
,
SIGNAL
(
triggered
())
,
this
,
SLOT
(
newWindow
())
);
QAction
*
remoteConnectionAction
=
collection
->
addAction
(
"remote-connection"
);
remoteConnectionAction
->
setText
(
i18n
(
"Remote Connection..."
)
);
remoteConnectionAction
->
setIcon
(
KIcon
(
"network"
)
);
remoteConnectionAction
->
setShortcut
(
QKeySequence
(
Qt
::
CTRL
+
Qt
::
SHIFT
+
Qt
::
Key_R
)
);
connect
(
remoteConnectionAction
,
SIGNAL
(
triggered
())
,
this
,
SLOT
(
showRemoteConnectionDialog
())
);
QAction
*
customSessionAction
=
collection
->
addAction
(
"custom-session"
);
customSessionAction
->
setText
(
i18n
(
"Custom Session..."
)
);
KStandardAction
::
quit
(
Application
::
self
()
,
SLOT
(
quit
())
,
collection
);
// Bookmark Menu
...
...
@@ -153,6 +161,13 @@ void MainWindow::showPreferencesDialog()
KToolInvocation
::
startServiceByDesktopName
(
"konsole"
,
QString
());
}
void
MainWindow
::
showRemoteConnectionDialog
()
{
RemoteConnectionDialog
dialog
(
this
);
if
(
dialog
.
exec
()
==
QDialog
::
Accepted
)
emit
requestSession
(
dialog
.
sessionKey
(),
_viewManager
);
}
void
MainWindow
::
mergeWindows
()
{
// merges all of the open Konsole windows into this window
...
...
konsole/MainWindow.h
View file @
2e6e657f
...
...
@@ -93,6 +93,7 @@ class MainWindow : public KMainWindow
void
newTab
();
void
newWindow
();
void
showPreferencesDialog
();
void
showRemoteConnectionDialog
();
void
showShortcutsDialog
();
void
sessionSelected
(
const
QString
&
);
...
...
konsole/RemoteConnectionDialog.cpp
0 → 100644
View file @
2e6e657f
/*
Copyright (C) 2007 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.
*/
// Qt
#include
<QtDebug>
// KDE
#include
<KLocale>
// Konsole
#include
"Application.h"
#include
"SessionManager.h"
#include
"ui_RemoteConnectionDialog.h"
#include
"RemoteConnectionDialog.h"
using
namespace
Konsole
;
RemoteConnectionDialog
::
RemoteConnectionDialog
(
QWidget
*
parent
)
:
KDialog
(
parent
)
{
setCaption
(
"New Remote Connection"
);
setButtons
(
KDialog
::
Ok
|
KDialog
::
Cancel
);
setButtonText
(
KDialog
::
Ok
,
i18n
(
"Connect"
)
);
_ui
=
new
Ui
::
RemoteConnectionDialog
();
_ui
->
setupUi
(
mainWidget
());
// set initial UI state
_ui
->
userEdit
->
setFocus
(
Qt
::
OtherFocusReason
);
}
QString
RemoteConnectionDialog
::
user
()
const
{
return
_ui
->
userEdit
->
text
();
}
QString
RemoteConnectionDialog
::
host
()
const
{
return
_ui
->
hostEdit
->
text
();
}
QString
RemoteConnectionDialog
::
service
()
const
{
return
"ssh"
;
}
QString
RemoteConnectionDialog
::
sessionKey
()
const
{
SessionManager
*
manager
=
Application
::
self
()
->
sessionManager
();
CustomCommandSessionInfo
*
customSession
=
new
CustomCommandSessionInfo
(
manager
->
defaultSessionType
()
->
path
());
customSession
->
setCommand
(
service
()
);
customSession
->
setName
(
i18n
(
"%1 at %2"
,
user
(),
host
())
);
customSession
->
setArguments
(
QStringList
()
<<
customSession
->
command
(
true
,
true
)
<<
user
()
+
'@'
+
host
()
);
QString
key
=
manager
->
addSessionType
(
customSession
);
qDebug
()
<<
"session key = "
<<
key
;
return
key
;
}
konsole/RemoteConnectionDialog.h
0 → 100644
View file @
2e6e657f
/*
Copyright (C) 2007 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.
*/
#ifndef REMOTECONNECTIONDIALOG_H
#define REMOTECONNECTIONDIALOG_H
// KDE
#include
<KDialog>
namespace
Ui
{
class
RemoteConnectionDialog
;
};
namespace
Konsole
{
class
RemoteConnectionDialog
:
public
KDialog
{
public:
RemoteConnectionDialog
(
QWidget
*
parent
=
0
);
QString
user
()
const
;
QString
host
()
const
;
QString
service
()
const
;
QString
sessionKey
()
const
;
private:
Ui
::
RemoteConnectionDialog
*
_ui
;
};
};
#endif // REMOTECONNECTIONDIALOG_H
konsole/RemoteConnectionDialog.ui
0 → 100644
View file @
2e6e657f
<ui version="4.0" >
<class>RemoteConnectionDialog</class>
<widget class="QWidget" name="RemoteConnectionDialog" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>610</width>
<height>160</height>
</rect>
</property>
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Preferred" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize" >
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="windowTitle" >
<string>Remote Connection</string>
</property>
<layout class="QVBoxLayout" >
<item>
<layout class="QHBoxLayout" >
<item>
<widget class="QLabel" name="userLabel" >
<property name="text" >
<string>User:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="userEdit" />
</item>
<item>
<widget class="QLabel" name="hostLabel" >
<property name="text" >
<string>Host:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="hostEdit" >
<property name="minimumSize" >
<size>
<width>180</width>
<height>0</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="lookupHostButton" >
<property name="text" >
<string>Lookup...</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" >
<item>
<widget class="QLabel" name="backgroundColorLabel" >
<property name="text" >
<string>Background color:</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="selectBackgroundButton" >
<property name="text" >
<string>Select...</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QCheckBox" name="saveAsCustomCheckBox" >
<property name="text" >
<string>Save as custom session</string>
</property>
</widget>
</item>
<item>
<widget class="QWidget" native="1" name="sessionWidget" >
<layout class="QHBoxLayout" >
<property name="leftMargin" >
<number>0</number>
</property>
<property name="topMargin" >
<number>0</number>
</property>
<property name="rightMargin" >
<number>0</number>
</property>
<property name="bottomMargin" >
<number>0</number>
</property>
<item>
<widget class="QLabel" name="sessionNameLabel" >
<property name="enabled" >
<bool>false</bool>
</property>
<property name="text" >
<string>Name:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="sessionNameEdit" >
<property name="enabled" >
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="sessionEditButton" >
<property name="enabled" >
<bool>false</bool>
</property>
<property name="text" >
<string>Edit...</string>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" >
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<layoutdefault spacing="6" margin="0" />
<includes/>
<resources/>
<connections>
<connection>
<sender>saveAsCustomCheckBox</sender>
<signal>toggled(bool)</signal>
<receiver>sessionNameEdit</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel" >
<x>252</x>
<y>76</y>
</hint>
<hint type="destinationlabel" >
<x>141</x>
<y>104</y>
</hint>
</hints>
</connection>
<connection>
<sender>saveAsCustomCheckBox</sender>
<signal>toggled(bool)</signal>
<receiver>sessionEditButton</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel" >
<x>252</x>
<y>76</y>
</hint>
<hint type="destinationlabel" >
<x>275</x>
<y>104</y>
</hint>
</hints>
</connection>
<connection>
<sender>saveAsCustomCheckBox</sender>
<signal>toggled(bool)</signal>
<receiver>sessionNameLabel</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel" >
<x>304</x>
<y>89</y>
</hint>
<hint type="destinationlabel" >
<x>28</x>
<y>128</y>
</hint>
</hints>
</connection>
</connections>
</ui>
konsole/SessionList.cpp
View file @
2e6e657f
...
...
@@ -19,16 +19,17 @@ SessionList::SessionList(SessionManager* manager , QObject* parent)
_group
=
new
QActionGroup
(
this
);
QListIterator
<
SessionInfo
*
>
iter
(
manager
->
availableSessionTypes
());
QListIterator
<
QString
>
iter
(
manager
->
availableSessionTypes
());
while
(
iter
.
hasNext
())
{
SessionInfo
*
info
=
iter
.
next
();
const
QString
&
key
=
iter
.
next
();
SessionInfo
*
info
=
manager
->
sessionType
(
key
);
QAction
*
action
=
new
QAction
(
_group
);
action
->
setText
(
info
->
name
()
);
action
->
setIcon
(
KIcon
(
info
->
icon
())
);
action
->
setData
(
info
->
path
()
);
action
->
setData
(
key
);
}
connect
(
_group
,
SIGNAL
(
triggered
(
QAction
*
))
,
this
,
SLOT
(
triggered
(
QAction
*
))
);
...
...
konsole/SessionManager.cpp
View file @
2e6e657f
...
...
@@ -168,6 +168,41 @@ QString SessionInfo::defaultWorkingDirectory() const
return
_config
->
readPathEntry
(
"Cwd"
);
}
CustomCommandSessionInfo
::
CustomCommandSessionInfo
(
const
QString
&
path
)
:
SessionInfo
(
path
)
{
}
void
CustomCommandSessionInfo
::
setName
(
const
QString
&
name
)
{
_name
=
name
;
}
QString
CustomCommandSessionInfo
::
name
()
const
{
return
_name
;
}
void
CustomCommandSessionInfo
::
setCommand
(
const
QString
&
command
)
{
_command
=
command
;
}
QString
CustomCommandSessionInfo
::
command
(
bool
,
bool
)
const
{
return
_command
;
}
void
CustomCommandSessionInfo
::
setArguments
(
const
QStringList
&
arguments
)
{
_arguments
=
arguments
;
}
QStringList
CustomCommandSessionInfo
::
arguments
()
const
{
return
_arguments
;
}
SessionManager
::
SessionManager
()
:
_defaultSessionType
(
0
),
_colorSchemeList
(
0
)
...
...
@@ -193,7 +228,7 @@ SessionManager::SessionManager()
QString
configFile
=
fileIter
.
next
();
SessionInfo
*
newType
=
new
SessionInfo
(
configFile
);
_types
<<
newType
;
addSessionType
(
newType
)
;
if
(
QFileInfo
(
configFile
).
fileName
()
==
defaultSessionFilename
)
_defaultSessionType
=
newType
;
...
...
@@ -208,7 +243,7 @@ SessionManager::SessionManager()
SessionManager
::~
SessionManager
()
{
QListIterator
<
SessionInfo
*>
infoIter
(
_types
);
QListIterator
<
SessionInfo
*>
infoIter
(
_types
.
values
()
);
while
(
infoIter
.
hasNext
())
delete
infoIter
.
next
();
...
...
@@ -227,22 +262,18 @@ void SessionManager::pushSessionSettings( const SessionInfo* info )
addSetting
(
ColorScheme
,
SessionConfig
,
info
->
colorScheme
()
);
}
Session
*
SessionManager
::
createSession
(
QString
configPath
)
Session
*
SessionManager
::
createSession
(
QString
key
)
{
Session
*
session
=
0
;
const
SessionInfo
*
info
=
0
;
//select default session type if not specified
if
(
configPath
.
isEmpty
()
)
configPath
=
_defaultSessionType
->
path
();
//search for SessionInfo object built from this config path
QListIterator
<
SessionInfo
*>
iter
(
_types
);
while
(
iter
.
hasNext
())
{
const
SessionInfo
*
const
info
=
iter
.
next
();
if
(
key
.
isEmpty
()
)
info
=
_defaultSessionType
;
else
info
=
_types
[
key
];
if
(
info
->
path
()
==
configPath
)
if
(
true
)
{
//supply settings from session config
pushSessionSettings
(
info
);
...
...
@@ -272,9 +303,7 @@ Session* SessionManager::createSession(QString configPath )
//add session to active list
_sessions
<<
session
;
break
;
}
}
Q_ASSERT
(
session
);
...
...
@@ -287,9 +316,17 @@ void SessionManager::sessionTerminated(Session* session)
session
->
deleteLater
();
}
QList
<
SessionInfo
*
>
SessionManager
::
availableSessionTypes
()
QList
<
QString
>
SessionManager
::
availableSessionTypes
()
{
return
_types
;
return
_types
.
keys
();
}
SessionInfo
*
SessionManager
::
sessionType
(
const
QString
&
key
)
const
{
if
(
_types
.
contains
(
key
)
)
return
_types
[
key
];
else
return
0
;
}
SessionInfo
*
SessionManager
::
defaultSessionType
()
...
...
@@ -325,4 +362,22 @@ QVariant SessionManager::activeSetting( Setting setting ) const
return
value
;
}
QString
SessionManager
::
addSessionType
(
SessionInfo
*
type
)
{
QString
key
;
for
(
int
counter
=
0
;;
counter
++
)
{
if
(
!
_types
.
contains
(
type
->
path
()
+
QString
::
number
(
counter
))
)
{
key
=
type
->
path
()
+
QString
::
number
(
counter
);
break
;
}
}
_types
.
insert
(
key
,
type
);
return
key
;
}
#include
<SessionManager.moc>
konsole/SessionManager.h
View file @
2e6e657f
...
...
@@ -24,6 +24,7 @@
#include
<QHash>
#include
<QList>
#include
<QStringList>
#include
<QPair>
#include
<QVariant>
class
KConfigGroup
;
...
...
@@ -58,8 +59,8 @@ public:
* for this type of session
*/
SessionInfo
(
const
QString
&
path
);
~
SessionInfo
();
virtual
~
SessionInfo
();
/**
* Returns the path to the session's
...
...
@@ -68,12 +69,12 @@ public:
QString
path
()
const
;
/** Returns the title of the session type */
QString
name
()
const
;
virtual
QString
name
()
const
;
/**
* Returns the path of an icon associated
* with this session type
*/
QString
icon
()
const
;
virtual
QString
icon
()
const
;
/**
* Returns the command that will be executed
* when the session is run
...
...
@@ -91,19 +92,19 @@ public:
* removed from the returned string. Anything after the first space
* character in the command string is considered an argument
*/
QString
command
(
bool
stripSu
,
bool
stripArguments
=
true
)
const
;
virtual
QString
command
(
bool
stripSu
,
bool
stripArguments
=
true
)
const
;
/**
* Extracts the arguments from the command string for this session. The first
* argument is always the command name
*/
QStringList
arguments
()
const
;
virtual
QStringList
arguments
()
const
;
/**
* Returns true if the session will run as
* root
*/
bool
isRootSession
()
const
;