Skip to content
GitLab
Menu
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
35792c6f
Commit
35792c6f
authored
May 11, 2007
by
Robert Knight
Browse files
Use inline editing for the tab title formats.
svn path=/trunk/KDE/kdebase/apps/konsole/; revision=663372
parent
33e1a53c
Changes
7
Hide whitespace changes
Inline
Side-by-side
src/CMakeLists.txt
View file @
35792c6f
...
...
@@ -59,7 +59,6 @@ set(konsole_KDEINIT_SRCS
ColorScheme.cpp
ColorSchemeEditor.cpp
EditProfileDialog.cpp
EditTabTitleFormatDialog.cpp
Filter.cpp
HistorySizeDialog.cpp
IncrementalSearchBar.cpp
...
...
@@ -81,6 +80,7 @@ set(konsole_KDEINIT_SRCS
Pty.cpp
Screen.cpp
Session.cpp
TabTitleFormatAction.cpp
TerminalDisplay.cpp
Vt102Emulation.cpp
Emulation.cpp
...
...
@@ -100,7 +100,6 @@ set(konsole_KDEINIT_SRCS
kde4_add_ui_files
(
konsole_KDEINIT_SRCS
ColorSchemeEditor.ui
EditProfileDialog.ui
EditTabTitleFormatDialog.ui
KeyBindingEditor.ui
ManageProfilesDialog.ui
RemoteConnectionDialog.ui
...
...
@@ -135,7 +134,6 @@ set(konsolepart_PART_SRCS
ColorScheme.cpp
ColorSchemeEditor.cpp
EditProfileDialog.cpp
EditTabTitleFormatDialog.cpp
Emulation.cpp
Filter.cpp
History.cpp
...
...
@@ -158,6 +156,7 @@ set(konsolepart_PART_SRCS
ProfileListWidget.cpp
SessionManager.cpp
ManageProfilesDialog.cpp
TabTitleFormatAction.cpp
TerminalCharacterDecoder.cpp
TerminalDisplay.cpp
ViewContainer.cpp
...
...
src/EditProfileDialog.cpp
View file @
35792c6f
...
...
@@ -38,11 +38,11 @@
#include "ColorScheme.h"
#include "ColorSchemeEditor.h"
#include "ui_EditProfileDialog.h"
#include "EditTabTitleFormatDialog.h"
#include "KeyBindingEditor.h"
#include "KeyboardTranslator.h"
#include "SessionManager.h"
#include "ShellCommand.h"
#include "TabTitleFormatAction.h"
using
namespace
Konsole
;
...
...
@@ -168,14 +168,31 @@ void EditProfileDialog::setupGeneralPage(const Profile* info)
SLOT
(
tabTitleFormatChanged
(
const
QString
&
))
);
connect
(
_ui
->
remoteTabTitleEdit
,
SIGNAL
(
textChanged
(
const
QString
&
))
,
this
,
SLOT
(
remoteTabTitleFormatChanged
(
const
QString
&
)));
connect
(
_ui
->
tabTitleEditButton
,
SIGNAL
(
clicked
())
,
this
,
SLOT
(
editTabTitle
())
);
connect
(
_ui
->
remoteTabTitleEditButton
,
SIGNAL
(
clicked
())
,
this
,
SLOT
(
editRemoteTabTitle
())
);
// menus for local and remote tab title dynamic elements
TabTitleFormatAction
*
localTabTitleAction
=
new
TabTitleFormatAction
(
this
);
localTabTitleAction
->
setContext
(
Session
::
LocalTabTitle
);
_ui
->
tabTitleEditButton
->
setMenu
(
localTabTitleAction
->
menu
());
connect
(
localTabTitleAction
,
SIGNAL
(
dynamicElementSelected
(
const
QString
&
))
,
this
,
SLOT
(
insertTabTitleText
(
const
QString
&
))
);
TabTitleFormatAction
*
remoteTabTitleAction
=
new
TabTitleFormatAction
(
this
);
remoteTabTitleAction
->
setContext
(
Session
::
RemoteTabTitle
);
_ui
->
remoteTabTitleEditButton
->
setMenu
(
remoteTabTitleAction
->
menu
());
connect
(
remoteTabTitleAction
,
SIGNAL
(
dynamicElementSelected
(
const
QString
&
))
,
this
,
SLOT
(
insertRemoteTabTitleText
(
const
QString
&
))
);
connect
(
_ui
->
showMenuBarButton
,
SIGNAL
(
toggled
(
bool
))
,
this
,
SLOT
(
showMenuBar
(
bool
))
);
}
void
EditProfileDialog
::
insertTabTitleText
(
const
QString
&
text
)
{
_ui
->
tabTitleEdit
->
insert
(
text
);
}
void
EditProfileDialog
::
insertRemoteTabTitleText
(
const
QString
&
text
)
{
_ui
->
remoteTabTitleEdit
->
insert
(
text
);
}
void
EditProfileDialog
::
showMenuBar
(
bool
show
)
{
_tempProfile
->
setProperty
(
Profile
::
ShowMenuBar
,
show
);
...
...
@@ -192,28 +209,6 @@ void EditProfileDialog::showTabBarAsNeeded()
{
_tempProfile
->
setProperty
(
Profile
::
TabBarMode
,
Profile
::
ShowTabBarAsNeeded
);
}
void
EditProfileDialog
::
editTabTitle
()
{
EditTabTitleFormatDialog
dialog
(
this
);
dialog
.
setContext
(
Session
::
LocalTabTitle
);
dialog
.
setTabTitleFormat
(
_ui
->
tabTitleEdit
->
text
());
if
(
dialog
.
exec
()
==
QDialog
::
Accepted
)
{
_ui
->
tabTitleEdit
->
setText
(
dialog
.
tabTitleFormat
());
}
}
void
EditProfileDialog
::
editRemoteTabTitle
()
{
EditTabTitleFormatDialog
dialog
(
this
);
dialog
.
setContext
(
Session
::
RemoteTabTitle
);
dialog
.
setTabTitleFormat
(
_ui
->
remoteTabTitleEdit
->
text
());
if
(
dialog
.
exec
()
==
QDialog
::
Accepted
)
{
_ui
->
remoteTabTitleEdit
->
setText
(
dialog
.
tabTitleFormat
());
}
}
void
EditProfileDialog
::
tabTitleFormatChanged
(
const
QString
&
format
)
{
_tempProfile
->
setProperty
(
Profile
::
LocalTabTitleFormat
,
format
);
...
...
src/EditProfileDialog.h
View file @
35792c6f
...
...
@@ -99,8 +99,8 @@ private slots:
void
tabTitleFormatChanged
(
const
QString
&
text
);
void
remoteTabTitleFormatChanged
(
const
QString
&
text
);
void
edi
tTabTitle
(
);
void
edi
tRemoteTabTitle
(
);
void
inser
tTabTitle
Text
(
const
QString
&
text
);
void
inser
tRemoteTabTitle
Text
(
const
QString
&
text
);
void
showMenuBar
(
bool
);
void
alwaysHideTabBar
();
...
...
src/EditProfileDialog.ui
View file @
35792c6f
...
...
@@ -188,7 +188,7 @@
<string>Edit normal tab title format</string>
</property>
<property name="text" >
<string>
Edit...
</string>
<string>
Insert
</string>
</property>
</widget>
</item>
...
...
@@ -215,7 +215,7 @@
<string>Edit tab title format used when executing remote commands</string>
</property>
<property name="text" >
<string>
Edit..
</string>
<string>
Insert
</string>
</property>
</widget>
</item>
...
...
src/EditTabTitleFormatDialog.ui
deleted
100644 → 0
View file @
33e1a53c
<ui version="4.0" >
<class>EditTabTitleFormatDialog</class>
<widget class="QWidget" name="EditTabTitleFormatDialog" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>138</height>
</rect>
</property>
<property name="windowTitle" >
<string>Edit Tab Format</string>
</property>
<layout class="QGridLayout" >
<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 row="1" column="0" >
<widget class="QLabel" name="label_2" >
<property name="text" >
<string>Insert element:</string>
</property>
</widget>
</item>
<item row="1" column="1" >
<widget class="QComboBox" name="elementComboBox" />
</item>
<item row="2" column="0" >
<widget class="QLabel" name="label" >
<property name="text" >
<string>Tab title format:</string>
</property>
</widget>
</item>
<item row="2" column="1" >
<widget class="KLineEdit" name="tabTitleFormatEdit" />
</item>
<item row="0" column="0" colspan="2" >
<widget class="QLabel" name="label_3" >
<property name="minimumSize" >
<size>
<width>380</width>
<height>0</height>
</size>
</property>
<property name="text" >
<string>Tab titles can contain a mixture of plain text and dynamic elements which update automatically as the programs running in the terminal change.</string>
</property>
<property name="wordWrap" >
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>KLineEdit</class>
<extends>QLineEdit</extends>
<header location="global" >klineedit.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>
src/
Edit
TabTitleFormat
Dialog
.cpp
→
src/TabTitleFormat
Action
.cpp
View file @
35792c6f
...
...
@@ -18,86 +18,84 @@
*/
// Own
#include "EditTabTitleFormatDialog.h"
#include "TabTitleFormatAction.h"
// Qt
#include <QList>
#include <QMenu>
// KDE
#include <KLocale>
// Konsole
#include "ui_EditTabTitleFormatDialog.h"
using
namespace
Konsole
;
const
Edit
TabTitleFormat
Dialog
::
Element
Edit
TabTitleFormat
Dialog
::
_localElements
[]
=
const
TabTitleFormat
Action
::
Element
TabTitleFormat
Action
::
_localElements
[]
=
{
{
"%n"
,
i18n
(
"Program Name"
)
},
{
"%p"
,
i18n
(
"Profile Name"
)
},
{
"%d"
,
i18n
(
"Current Directory (Short)"
)
},
{
"%D"
,
i18n
(
"Current Directory (Long)"
)
}
};
const
int
Edit
TabTitleFormat
Dialog
::
_localElementCount
=
4
;
const
Edit
TabTitleFormat
Dialog
::
Element
Edit
TabTitleFormat
Dialog
::
_remoteElements
[]
=
const
int
TabTitleFormat
Action
::
_localElementCount
=
4
;
const
TabTitleFormat
Action
::
Element
TabTitleFormat
Action
::
_remoteElements
[]
=
{
{
"%p"
,
i18n
(
"Profile Name"
)
},
{
"%u"
,
i18n
(
"User Name"
)
},
{
"%h"
,
i18n
(
"Remote Host (Short)"
)
},
{
"%H"
,
i18n
(
"Remote Host (Long)"
)
}
};
const
int
Edit
TabTitleFormat
Dialog
::
_remoteElementCount
=
4
;
const
int
TabTitleFormat
Action
::
_remoteElementCount
=
4
;
Edit
TabTitleFormat
Dialog
::
Edit
TabTitleFormat
Dialog
(
QWidge
t
*
parent
)
:
KDialog
(
parent
)
TabTitleFormat
Action
::
TabTitleFormat
Action
(
QObjec
t
*
parent
)
:
QAction
(
parent
)
,
_context
(
Session
::
LocalTabTitle
)
{
setCaption
(
i18n
(
"Edit Tab Title Format"
));
_ui
=
new
Ui
::
EditTabTitleFormatDialog
();
_ui
->
setupUi
(
mainWidget
());
_ui
->
tabTitleFormatEdit
->
setClearButtonShown
(
true
);
connect
(
_ui
->
elementComboBox
,
SIGNAL
(
activated
(
int
))
,
this
,
SLOT
(
insertElement
(
int
))
);
}
EditTabTitleFormatDialog
::~
EditTabTitleFormatDialog
()
{
delete
_ui
;
}
void
EditTabTitleFormatDialog
::
insertElement
(
int
index
)
{
if
(
_context
==
Session
::
LocalTabTitle
)
_ui
->
tabTitleFormatEdit
->
insert
(
_localElements
[
index
].
element
);
else
if
(
_context
==
Session
::
RemoteTabTitle
)
_ui
->
tabTitleFormatEdit
->
insert
(
_remoteElements
[
index
].
element
);
setMenu
(
new
QMenu
()
);
connect
(
menu
()
,
SIGNAL
(
triggered
(
QAction
*
))
,
this
,
SLOT
(
fireElementSelected
(
QAction
*
))
);
}
void
Edit
TabTitleFormat
Dialog
::
set
TabTitleFormat
(
const
QString
&
format
)
TabTitleFormat
Action
::~
TabTitleFormat
Action
(
)
{
_ui
->
tabTitleFormatEdit
->
setText
(
format
);
_ui
->
tabTitleFormatEdit
->
selectAll
();
menu
()
->
deleteLater
();
}
QString
Edit
TabTitleFormat
Dialog
::
tabTitleFormat
()
const
void
TabTitleFormat
Action
::
fireElementSelected
(
QAction
*
action
)
{
return
_ui
->
tabTitleFormatEdit
->
text
(
);
emit
dynamicElementSelected
(
action
->
data
().
value
<
QString
>
()
);
}
void
Edit
TabTitleFormat
Dialog
::
setContext
(
Session
::
TabTitleContext
context
)
void
TabTitleFormat
Action
::
setContext
(
Session
::
TabTitleContext
context
)
{
_context
=
context
;
_ui
->
elementComboBox
->
clear
();
menu
()
->
clear
();
QList
<
QAction
*>
list
;
int
count
=
0
;
const
Element
*
array
=
0
;
QStringList
list
;
if
(
context
==
Session
::
LocalTabTitle
)
{
for
(
int
i
=
0
;
i
<
_localElementCount
;
i
++
)
list
<<
_localElements
[
i
].
description
;
count
=
_localElementCount
;
array
=
_localElements
;
}
else
if
(
context
==
Session
::
RemoteTabTitle
)
{
for
(
int
i
=
0
;
i
<
_remoteElementCount
;
i
++
)
list
<<
_remoteElements
[
i
].
description
;
count
=
_remoteElementCount
;
array
=
_remoteElements
;
}
for
(
int
i
=
0
;
i
<
count
;
i
++
)
{
QAction
*
action
=
new
QAction
(
array
[
i
].
description
,
this
);
action
->
setData
(
array
[
i
].
element
);
list
<<
action
;
}
_ui
->
elementComboBox
->
addItems
(
list
);
menu
()
->
addActions
(
list
);
}
Session
::
TabTitleContext
TabTitleFormatAction
::
context
()
const
{
return
_context
;
}
#include "EditTabTitleFormatDialog.moc"
#include "TabTitleFormatAction.moc"
src/
Edit
TabTitleFormat
Dialog
.h
→
src/TabTitleFormat
Action
.h
View file @
35792c6f
...
...
@@ -17,43 +17,38 @@
02110-1301 USA.
*/
#ifndef
EDIT
TABTITLEFORMAT
DIALOG
_H
#define
EDIT
TABTITLEFORMAT
DIALOG
_H
#ifndef TABTITLEFORMAT
ACTION
_H
#define TABTITLEFORMAT
ACTION
_H
//
KDE
#include <
KDialog
>
//
Qt
#include <
QAction
>
// Konsole
#include "Session.h"
namespace
Ui
{
class
EditTabTitleFormatDialog
;
}
namespace
Konsole
{
class
Edit
TabTitleFormat
Dialog
:
public
KDialog
class
TabTitleFormat
Action
:
public
QAction
{
Q_OBJECT
public:
Edit
TabTitleFormat
Dialog
(
QWidge
t
*
parent
=
0
);
virtual
~
Edit
TabTitleFormat
Dialog
();
TabTitleFormat
Action
(
QObjec
t
*
parent
);
~
TabTitleFormat
Action
();
void
setContext
(
Session
::
TabTitleContext
context
);
Session
::
TabTitleContext
context
()
const
;
void
setTabTitleFormat
(
const
QString
&
format
);
QString
tabTitleFormat
()
const
;
signals:
void
dynamicElementSelected
(
const
QString
&
)
;
private
slots
:
void
insert
Element
(
int
index
);
void
fire
Element
Selected
(
QAction
*
);
private:
Ui
::
EditTabTitleFormatDialog
*
_ui
;
Session
::
TabTitleContext
_context
;
struct
Element
{
QString
element
;
...
...
@@ -63,8 +58,9 @@ private:
static
const
int
_localElementCount
;
static
const
Element
_remoteElements
[];
static
const
int
_remoteElementCount
;
};
}
#endif //
EDIT
TABTITLEFORMAT
DIALOG
_H
#endif // TABTITLEFORMAT
ACTION
_H
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment