All pastes #1708067 Raw Edit

kr_likekonsole-1.70.0.diff

public diff v1 · immutable
#1708067 ·published 2009-12-09 09:19 UTC
rendered paste body
diff -Nru krusader-1.70.0/krusader/krusaderview.cpp /home/ilya/opt/src/krusader-1.70.0/krusader/krusaderview.cpp--- krusader-1.70.0/krusader/krusaderview.cpp	2005-11-08 22:48:14.000000000 +0300+++ /home/ilya/opt/src/krusader-1.70.0/krusader/krusaderview.cpp	2006-04-13 05:22:30.000000000 +0400@@ -31,6 +31,15 @@ // Qt includes #include <qwhatsthis.h>  // Krusader includes++// Muravev+#include <qtooltip.h>+//#include <qimage.h>+#include <kiconloader.h>+#include <ktabwidget.h>+#include <qobjectlist.h>++ #include "krusaderview.h" #include "krusader.h" #include "krslots.h"@@ -45,7 +54,7 @@ #include "GUI/profilemanager.h"  KrusaderView::KrusaderView( QWidget *parent ) : QWidget( parent, "KrusaderView" ), activePanel(0), -								konsole_part( 0L ) {}+								term_tabwidget( 0L ), konsole_part( 0L ) {}  void KrusaderView::start( QStringList leftTabs, int leftActiveTab, QStringList rightTabs, int rightActiveTab ) {   ////////////////////////////////@@ -142,6 +151,104 @@ void KrusaderView::panelSwitch() { activePanel->otherPanel->slotFocusOnMe(); } void KrusaderView::slotSetActivePanel( ListPanel *p ) { activePanel = p; } +// void Print(const char* text)+// {+//    FILE* to;+//    to = fopen("/tmp/ttt", "a+");+//    fprintf(to, "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");+//    fprintf(to, "%s\n", text);+//    fprintf(to, "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");+//    fclose(to);+// }++KParts::ReadOnlyPart* KrusaderView::CreateTerm(const char* name, KLibFactory* factory)+{+   QHBox* embed_box = new QHBox;+   term_tabwidget->insertTab(embed_box, name);++   KParts::ReadOnlyPart* konsole = ( KParts::ReadOnlyPart * ) factory->create( embed_box, "konsolepart",+                                                              "KParts::ReadOnlyPart" );+   connect( konsole, SIGNAL( destroyed() ), this, SLOT( killTerminalEmulator() ) );+   term_tabwidget->showPage( embed_box );+   return konsole;+}++int FindNextNum(const char* name)+{+   //Print(name);+   return atoi(name+6); // size of "Shell " +}++void KrusaderView::slotNewSession()+{+   if( !term_tabwidget ) return;++   KLibFactory * factory = KLibLoader::self() ->factory( "libkonsolepart" );+   if ( factory ) {++      QString name(term_tabwidget->label(term_tabwidget->count()-1));+      int i = FindNextNum( name.ascii() );+      name = "Shell %1";+      name = name.arg(i+1);++      KParts::ReadOnlyPart* konsole = CreateTerm(name.ascii(), factory);+      konsole->widget()->setFocus();+   }+}++KParts::ReadOnlyPart* FindKonsolePart(QWidget* w)+{+   QObjectList *l = w->queryList( "KParts::ReadOnlyPart" );+   QObjectListIt it( *l );+   QObject *obj = it.current();+   delete l; // delete the list, not the objects++   return static_cast<KParts::ReadOnlyPart*>(obj);+}++void KrusaderView::slotCloseSession()+{+   KParts::ReadOnlyPart* k = FindKonsolePart( term_tabwidget->currentPage() );+   delete k;+}++void KrusaderView::slotOnMoveSession( QWidget* w )+{+   KParts::ReadOnlyPart* k = FindKonsolePart(w);+   if( k ) konsole_part = k;+}++void KrusaderView::CreateFirstTerm()+{+   KLibFactory * factory = KLibLoader::self() ->factory( "libkonsolepart" );+   if( !factory ) return;++   term_tabwidget = new KTabWidget(terminal_dock);+   term_tabwidget->setTabReorderingEnabled(true);+   term_tabwidget->setAutomaticResizeTabs( true );+   term_tabwidget->setTabPosition(QTabWidget::Bottom);+   term_tabwidget->show();++   konsole_part = CreateTerm("Shell 1", factory);++   QToolButton* m_newSessionButton = new QToolButton( term_tabwidget );+   QToolTip::add(m_newSessionButton,i18n("Click for new session"));+   m_newSessionButton->setIconSet( SmallIcon( "tab_new" ) );+   m_newSessionButton->adjustSize();+   connect(m_newSessionButton, SIGNAL(clicked()), SLOT(slotNewSession()));+   term_tabwidget->setCornerWidget( m_newSessionButton, Qt::BottomLeft );++   QToolButton* m_removeSessionButton = new QToolButton( term_tabwidget );+   QToolTip::add(m_removeSessionButton,i18n("Close the current session"));+   m_removeSessionButton->setIconSet( SmallIconSet( "tab_remove" ) );+   m_removeSessionButton->adjustSize();+   connect(m_removeSessionButton, SIGNAL(clicked()), SLOT(slotCloseSession()));+   term_tabwidget->setCornerWidget( m_removeSessionButton, Qt::BottomRight );++   // konsole_part is to be set active always+   connect(term_tabwidget,  SIGNAL(currentChanged(QWidget*)), SLOT(slotOnMoveSession(QWidget*)));+}+ void KrusaderView::slotTerminalEmulator( bool show ) {   if ( !show ) {  // hiding the terminal     activePanel->slotFocusOnMe();@@ -156,14 +263,15 @@   }   // else implied   if ( konsole_part == 0L ) {  // konsole part is not yet loaded-    KLibFactory * factory = KLibLoader::self() ->factory( "libkonsolepart" );-    if ( factory ) {-      // Create the part-      konsole_part = ( KParts::ReadOnlyPart * ) factory->create( terminal_dock, "konsolepart",-                                                                 "KParts::ReadOnlyPart" );-      connect( konsole_part, SIGNAL( destroyed() ), this, SLOT( killTerminalEmulator() ) );-    } else-      konsole_part = 0L;+//     KLibFactory * factory = KLibLoader::self() ->factory( "libkonsolepart" );+//     if ( factory ) {+//       // Create the part+//       konsole_part = ( KParts::ReadOnlyPart * ) factory->create( terminal_dock, "konsolepart",+//                                                                  "KParts::ReadOnlyPart" );+//       connect( konsole_part, SIGNAL( destroyed() ), this, SLOT( killTerminalEmulator() ) );+//     } else+//       konsole_part = 0L;+    CreateFirstTerm();   }   if ( konsole_part ) {      // if we succeeded in creating the konsole     if( !verticalSplitterSizes.empty() )@@ -188,9 +296,21 @@ }  void KrusaderView::killTerminalEmulator() {-  konsole_part = 0L;-  slotTerminalEmulator( false );  // hide the docking widget-  krToggleTerminal->setChecked( false );++   if( term_tabwidget )+   {+      term_tabwidget->removePage( term_tabwidget->currentPage() );+      // do nothing if some other tabs exist+      if( term_tabwidget->count() != 0 )+         return;+   }+   //delete term_tabwidget;+   term_tabwidget->deleteLater();+   term_tabwidget = 0L;+   konsole_part = 0L;++   slotTerminalEmulator( false );  // hide the docking widget+   krToggleTerminal->setChecked( false ); }  diff -Nru krusader-1.70.0/krusader/krusaderview.h /home/ilya/opt/src/krusader-1.70.0/krusader/krusaderview.h--- krusader-1.70.0/krusader/krusaderview.h	2005-11-08 22:48:14.000000000 +0300+++ /home/ilya/opt/src/krusader-1.70.0/krusader/krusaderview.h	2006-04-13 04:58:01.000000000 +0400@@ -39,6 +39,11 @@ #include <kapplication.h> #include <kparts/part.h> +// Muravev+#include <ktabwidget.h>+#include <klibloader.h>++ // QT includes #include <qlayout.h> #include <qsplitter.h>@@ -66,6 +71,10 @@   inline PanelManager *activeManager() const { return (activePanel==left ? leftMng : rightMng); }   inline PanelManager *inactiveManager() const { return (activePanel==left ? rightMng : leftMng); }   QValueList<int> getTerminalEmulatorSplitterSizes();++  // Muravev+  void CreateFirstTerm();+  KParts::ReadOnlyPart* CreateTerm(const char* name, KLibFactory* factory);    public slots:   void slotCurrentChanged(QString p);@@ -81,6 +90,11 @@   void loadPanelProfiles( QString group );   void savePanelProfiles( QString group ); +       // Muravev+  void slotNewSession();+  void slotCloseSession();+  void slotOnMoveSession( QWidget* w );+ protected slots:   void killTerminalEmulator(); @@ -91,6 +105,7 @@   KFnKeys			*fnKeys;										// function keys   KCMDLine    *cmdLine;                   // command line widget   QHBox       *terminal_dock;             // docking widget for terminal emulator+  KTabWidget  *term_tabwidget;            // Muravev - tab widget for multi terminals   KParts::ReadOnlyPart *konsole_part;     // the actual part pointer   QSplitter		*horiz_splitter, *vert_splitter;   QValueList<int> verticalSplitterSizes;