• Skip to content
  • Skip to link menu
KDE 4.1 API Reference
  • KDE API Reference
  • API Reference
  • Sitemap
  • Contact Us
 

Konsole

TabTitleFormatAction.cpp

Go to the documentation of this file.
00001 /*
00002     Copyright 2007-2008 by Robert Knight <robertknight@gmail.com>
00003 
00004     This program is free software; you can redistribute it and/or modify
00005     it under the terms of the GNU General Public License as published by
00006     the Free Software Foundation; either version 2 of the License, or
00007     (at your option) any later version.
00008 
00009     This program is distributed in the hope that it will be useful,
00010     but WITHOUT ANY WARRANTY; without even the implied warranty of
00011     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012     GNU General Public License for more details.
00013 
00014     You should have received a copy of the GNU General Public License
00015     along with this program; if not, write to the Free Software
00016     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00017     02110-1301  USA.
00018 */
00019 
00020 // Own
00021 #include "TabTitleFormatAction.h"
00022 
00023 // Qt
00024 #include <QList>
00025 #include <QMenu>
00026 
00027 // KDE
00028 #include <KLocale>
00029 
00030 using namespace Konsole;
00031 
00032 const TabTitleFormatAction::Element TabTitleFormatAction::_localElements[] = 
00033 {
00034     { "%n" , I18N_NOOP("Program Name") },
00035     { "%d" , I18N_NOOP("Current Directory (Short)") },
00036     { "%D" , I18N_NOOP("Current Directory (Long)") },
00037     { "%w" , I18N_NOOP("Window Title Set by Shell") },
00038     { "%#" , I18N_NOOP("Session number") }
00039 };
00040 const int TabTitleFormatAction::_localElementCount = 5;
00041 const TabTitleFormatAction::Element TabTitleFormatAction::_remoteElements[] =
00042 {
00043     { "%u" , I18N_NOOP("User Name") },
00044     { "%h" , I18N_NOOP("Remote Host (Short)") },
00045     { "%H" , I18N_NOOP("Remote Host (Long)") },
00046     { "%w" , I18N_NOOP("Window Title Set by Shell") },
00047     { "%#" , I18N_NOOP("Session number") }
00048 };
00049 const int TabTitleFormatAction::_remoteElementCount = 5;
00050 
00051 TabTitleFormatAction::TabTitleFormatAction(QObject* parent)
00052     : QAction(parent)
00053     , _context(Session::LocalTabTitle)
00054 {
00055     setMenu( new QMenu() );
00056     connect( menu() , SIGNAL(triggered(QAction*)) , this , SLOT(fireElementSelected(QAction*)) );
00057 }
00058 TabTitleFormatAction::~TabTitleFormatAction()
00059 {
00060     menu()->deleteLater();
00061 }
00062 void TabTitleFormatAction::fireElementSelected(QAction* action)
00063 {
00064     emit dynamicElementSelected(action->data().value<QString>());
00065 }
00066 void TabTitleFormatAction::setContext(Session::TabTitleContext context)
00067 {
00068     _context = context;
00069 
00070     menu()->clear();
00071 
00072     QList<QAction*> list;
00073     
00074     int count = 0;
00075     const Element* array = 0;
00076 
00077     if ( context == Session::LocalTabTitle )
00078     {
00079         count = _localElementCount;
00080         array = _localElements;    
00081     }
00082     else if ( context == Session::RemoteTabTitle )
00083     {
00084         count = _remoteElementCount;
00085         array = _remoteElements;
00086     }
00087      
00088     for ( int i = 0 ; i < count ; i++ )
00089     {
00090         QAction* action = new QAction(i18n(array[i].description),this);
00091         action->setData(array[i].element);
00092         list << action;
00093     }
00094 
00095     menu()->addActions(list);
00096 }
00097 Session::TabTitleContext TabTitleFormatAction::context() const
00098 {
00099     return _context;
00100 }
00101 
00102 #include "TabTitleFormatAction.moc"
00103 

Konsole

Skip menu "Konsole"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

API Reference

Skip menu "API Reference"
  • Konsole
  • Libraries
  •   libkonq
Generated for API Reference by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal