2 Copyright 2007-2008 by Robert Knight <robertknight@gmail.com>
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21 #include "TabTitleFormatAction.h"
30 using namespace Konsole
;
32 const TabTitleFormatAction::Element
TabTitleFormatAction::_localElements
[] =
34 { "%n" , I18N_NOOP("Program Name") },
35 { "%d" , I18N_NOOP("Current Directory (Short)") },
36 { "%D" , I18N_NOOP("Current Directory (Long)") },
37 { "%w" , I18N_NOOP("Window Title Set by Shell") },
38 { "%#" , I18N_NOOP("Session number") }
40 const int TabTitleFormatAction::_localElementCount
= 5;
41 const TabTitleFormatAction::Element
TabTitleFormatAction::_remoteElements
[] =
43 { "%u" , I18N_NOOP("User Name") },
44 { "%h" , I18N_NOOP("Remote Host (Short)") },
45 { "%H" , I18N_NOOP("Remote Host (Long)") },
46 { "%w" , I18N_NOOP("Window Title Set by Shell") },
47 { "%#" , I18N_NOOP("Session number") }
49 const int TabTitleFormatAction::_remoteElementCount
= 5;
51 TabTitleFormatAction::TabTitleFormatAction(QObject
* parent
)
53 , _context(Session::LocalTabTitle
)
55 setMenu( new QMenu() );
56 connect( menu() , SIGNAL(triggered(QAction
*)) , this , SLOT(fireElementSelected(QAction
*)) );
58 TabTitleFormatAction::~TabTitleFormatAction()
60 menu()->deleteLater();
62 void TabTitleFormatAction::fireElementSelected(QAction
* action
)
64 emit
dynamicElementSelected(action
->data().value
<QString
>());
66 void TabTitleFormatAction::setContext(Session::TabTitleContext context
)
75 const Element
* array
= 0;
77 if ( context
== Session::LocalTabTitle
)
79 count
= _localElementCount
;
80 array
= _localElements
;
82 else if ( context
== Session::RemoteTabTitle
)
84 count
= _remoteElementCount
;
85 array
= _remoteElements
;
88 for ( int i
= 0 ; i
< count
; i
++ )
90 QAction
* action
= new QAction(i18n(array
[i
].description
),this);
91 action
->setData(array
[i
].element
);
95 menu()->addActions(list
);
97 Session::TabTitleContext
TabTitleFormatAction::context() const
102 #include "TabTitleFormatAction.moc"