Update of /cvsroot/krusader/krusader_kde3/krusader In directory sc8-pr-cvs1:/tmp/cvs-serv17264/krusader Modified Files: Makefile.am krusaderview.cpp Added Files: panelmanager.cpp panelmanager.h paneltabbar.cpp paneltabbar.h Log Message: pre-alpha code for tabbed browsing --- NEW FILE: panelmanager.cpp --- #include <qwidgetstack.h> #include "panelmanager.h" #include "Panel/listpanel.h" PanelManager::PanelManager(QWidget *parent, bool left): QWidget(parent), _layout(0), _left(left) { _layout = new QVBoxLayout( this ); _stack = new QWidgetStack(this); _tabbar = new PanelTabBar(this); _layout->addWidget(_stack); _layout->addWidget(_tabbar); } ListPanel* PanelManager::createPanel() { // create the panel and add it into the widgetstack ListPanel *p = new ListPanel( _stack, _left ); _stack->raiseWidget(p); // now, create the corrosponding tab _tabbar->addPanel(p); return p; } void PanelManager::startPanel(ListPanel *panel, QString path) { // check if panel is ours!!! panel->start( path ); } --- NEW FILE: panelmanager.h --- #ifndef _PANEL_MANAGER_H #define _PANEL_MANAGER_H #include <qwidget.h> #include <qlayout.h> #include "paneltabbar.h" class ListPanel; class QWidgetStack; class PanelManager: public QWidget { Q_OBJECT public: PanelManager( QWidget *parent, bool left ); ListPanel* createPanel(); void startPanel(ListPanel *panel, QString path); private: QVBoxLayout *_layout; bool _left; PanelTabBar *_tabbar; QWidgetStack *_stack; }; #endif // _PANEL_MANAGER_H --- NEW FILE: paneltabbar.cpp --- /*************************************************************************** paneltabbar.cpp - description ------------------- begin : Sun Jun 2 2002 copyright : (C) 2002 by Shie Erlich & Rafi Yanai email : ***************************************************************************/ /*************************************************************************** * * * 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. * * * ***************************************************************************/ #include "paneltabbar.h" #include "Panel/listpanel.h" #include "krusaderview.h" #include "krslots.h" #include <kaction.h> #include <klocale.h> #include <kshortcut.h> #include <qevent.h> #include <qwidgetstack.h> #include <qfontmetrics.h> PanelTabBar::PanelTabBar(QWidget *parent): QTabBar(parent) { _panelActionMenu = new KActionMenu( i18n("Panel"), this ); _closeAction = new KAction(i18n("Close tab"), KShortcut::null(), this, SLOT(closeTab()), krApp->actionCollection(), "close_tab"); _newTabSame = new KAction(i18n("Duplicate tab"), KShortcut::null(), this, SLOT(duplicateTab()), krApp->actionCollection(), "dup_tab"); insertAction(_newTabSame); insertAction(_closeAction); _closeAction->setEnabled(false); //can't close a single tab setShape(QTabBar::RoundedBelow); //addTab(new QTab("")); // ugly hack - don't remove if (HIDE_ON_SINGLE_TAB) hide(); } void PanelTabBar::mousePressEvent( QMouseEvent* e ) { QTab* clickedTab = selectTab( e->pos() ); if( !clickedTab ) { // clicked on nothing ... QTabBar::mousePressEvent(e); return; } // else implied setCurrentTab( clickedTab ); if ( e->button() == Qt::RightButton ) { // show the popup menu _panelActionMenu->popup( e->globalPos() ); } if ( e->button() == Qt::LeftButton ) { // we need to change tabs // first, find the correct panel to load int id = currentTab(); ListPanel *listpanel = 0L; //QValueList<PanelTab>::Iterator it; //for (it = _panelTabs.begin(); it != _panelTabs.end(); ++it) { // if ((*it).id == id) { // listpanel = (*it).panel; // break; // } //} // now, check if we're on the left or right /*bool needSetFocus = ((_master->_self) != (_master->_active)); _master->_self = listpanel; _master->_stack->raiseWidget(_master->_self); _master->_self->setOther(_master->_other); _master->_other->setOther(_master->_self); _master->_active = _master->_self; kapp->processEvents(); if (needSetFocus) _master->_active->slotFocusOnMe();*/ } // QTabBar::mousePressEvent(e); } void PanelTabBar::insertAction( KAction* action ) { _panelActionMenu->insert( action ); } int PanelTabBar::addPanel(ListPanel *panel) { int h = QFontMetrics(font()).height()+2; int newId = addTab(new PanelTab(panel->virtualPath)); PanelTab *ptab= dynamic_cast<PanelTab*>(tab(newId)); ptab->rect().setHeight(3); ptab->panel = panel; layoutTabs(); setCurrentTab(newId); // enable close-tab action if (count()>1) { _closeAction->setEnabled(true); show(); } connect(ptab->panel, SIGNAL(pathChanged(ListPanel*)), this, SLOT(updateTab(ListPanel*))); return newId; } void PanelTabBar::updateTab(ListPanel *panel) { // find which is the correct tab for (int i=0; i<count(); i++) { if (dynamic_cast<PanelTab*>(tab(i))->panel == panel) { tab(i)->setText(panel->virtualPath); break; } } //QValueList<PanelTab>::Iterator it; //for (it = _panelTabs.begin(); it!=_panelTabs.end(); ++it) { // if ( (*it).panel == panel ) { // tab((*it).id)->setText(panel->virtualPath); // break; // } //} } void PanelTabBar::duplicateTab() { /* int id = currentTab(); ListPanel *listpanel; QValueList<PanelTab>::Iterator it; for (it = _panelTabs.begin(); it != _panelTabs.end(); ++it) { if ((*it).id == id) { listpanel = (*it).panel; break; } }*/ //SLOTS->newTab(listpanel->virtualPath); } void PanelTabBar::closeTab() { // find the panel to kill /* int id = currentTab(); ListPanel *listpanel = 0L; QValueList<PanelTab>::Iterator it; for (it = _panelTabs.begin(); it != _panelTabs.end(); ++it) { if ((*it).id == id) { listpanel = (*it).panel; _panelTabs.remove(it); // remove from the list of tabs break; } } // now, remove the panel and the tab /*bool needSetFocus = ((_master->_self) != (_master->_active)); removeTab(tab(id)); id = currentTab(); // get the NEW current tab _master->removePanel(listpanel, id); kapp->processEvents(); if (needSetFocus) { _master->_active = _master->_self; _master->_active->slotFocusOnMe(); } if (count()==1) { _closeAction->setEnabled(false); if (HIDE_ON_SINGLE_TAB) hide(); }*/ } // -----------------------------> PanelTab <---------------------------- PanelTab::PanelTab(const QString & text): QTab(text) {} #include "paneltabbar.moc" --- NEW FILE: paneltabbar.h --- /* * The concept for this code was taken from the k3b project. k3b is an * excellent CD burning program for KDE, http://k3b.sourceforge.net * Anyway, original code is copyrighted by Sebastian Trueg. Thanks! */ /*************************************************************************** * * * 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. * * * ***************************************************************************/ #ifndef PANELTABBAR_H #define PANELTABBAR_H #include <qtabbar.h> #include <qvaluelist.h> class QMouseEvent; class KAction; class KActionMenu; class ListPanel; class KrMasterPanel; class PanelTab: public QTab { public: PanelTab(const QString & text); ListPanel *panel; }; #define HIDE_ON_SINGLE_TAB true class PanelTabBar : public QTabBar { Q_OBJECT public: //PanelTabBar( KrMasterPanel *_master, const char* name = 0 ); PanelTabBar( QWidget *parent ); void insertAction( KAction* ); public slots: // this class doesn't really use these functions int addPanel(ListPanel *panel); void updateTab(ListPanel *panel); protected: void mousePressEvent( QMouseEvent* ); protected slots: void closeTab(); void duplicateTab(); private: KrMasterPanel *_master; KActionMenu *_panelActionMenu; //QValueList<PanelTab> _panelTabs; bool _left; KAction *_closeAction, *_newTabSame, *_newTabRoot; }; #endif Index: Makefile.am =================================================================== RCS file: /cvsroot/krusader/krusader_kde3/krusader/Makefile.am,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Makefile.am 2 Aug 2003 21:03:55 -0000 1.5 --- Makefile.am 19 Sep 2003 16:21:21 -0000 1.6 *************** *** 4,8 **** ## INCLUDES were found outside kdevelop specific part ! krusader_SOURCES = krservices.cpp main.cpp krusaderview.cpp krusader.cpp krslots.cpp kicons.cpp krusader_LDADD = ./BookMan/libBookMan.a ./Dialogs/libDialogs.a ./GUI/libGUI.a ./Konfigurator/libKonfigurator.a ./KViewer/libKViewer.a ./MountMan/libMountMan.a ./Panel/libPanel.a ./RemoteMan/libRemoteMan.a ./VFS/libVFS.a ./Search/libSearch.a VFS/libVFS.a KViewer/libKViewer.a Dialogs/libDialogs.a BookMan/libBookMan.a -lm $(LIB_KPARTS) $(LIB_KFILE) $(LIB_KDEUI) $(LIB_KDECORE) $(LIB_QT) $(LIBSOCKET) --- 4,8 ---- ## INCLUDES were found outside kdevelop specific part ! krusader_SOURCES = krservices.cpp main.cpp krusaderview.cpp krusader.cpp krslots.cpp kicons.cpp panelmanager.cpp paneltabbar.cpp krusader_LDADD = ./BookMan/libBookMan.a ./Dialogs/libDialogs.a ./GUI/libGUI.a ./Konfigurator/libKonfigurator.a ./KViewer/libKViewer.a ./MountMan/libMountMan.a ./Panel/libPanel.a ./RemoteMan/libRemoteMan.a ./VFS/libVFS.a ./Search/libSearch.a VFS/libVFS.a KViewer/libKViewer.a Dialogs/libDialogs.a BookMan/libBookMan.a -lm $(LIB_KPARTS) $(LIB_KFILE) $(LIB_KDEUI) $(LIB_KDECORE) $(LIB_QT) $(LIBSOCKET) *************** *** 82,83 **** --- 82,84 ---- fi + noinst_HEADERS = panelmanager.h paneltabbar.h Index: krusaderview.cpp =================================================================== RCS file: /cvsroot/krusader/krusader_kde3/krusader/krusaderview.cpp,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** krusaderview.cpp 29 Aug 2003 23:33:16 -0000 1.8 --- krusaderview.cpp 19 Sep 2003 16:21:21 -0000 1.9 *************** *** 1,34 **** /*************************************************************************** ! krusaderview.cpp ! ------------------- ! copyright : (C) 2000 by Shie Erlich & Rafi Yanai ! e-mail : kru...@us... ! web site : http://krusader.sourceforge.net ! --------------------------------------------------------------------------- ! Description ! *************************************************************************** ! A ! db dD d8888b. db db .d8888. .d8b. d8888b. d88888b d8888b. ! 88 ,8P' 88 `8D 88 88 88' YP d8' `8b 88 `8D 88' 88 `8D ! 88,8P 88oobY' 88 88 `8bo. 88ooo88 88 88 88ooooo 88oobY' ! 88`8b 88`8b 88 88 `Y8b. 88~~~88 88 88 88~~~~~ 88`8b ! 88 `88. 88 `88. 88b d88 db 8D 88 88 88 .8D 88. 88 `88. ! YP YD 88 YD ~Y8888P' `8888Y' YP YP Y8888D' Y88888P 88 YD ! S o u r c e F i l e ! *************************************************************************** ! * * ! * 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. * ! * * ! ***************************************************************************/ // Qt includes ! #include <qwhatsthis.h> // Krusader includes #include "krusaderview.h" --- 1,34 ---- /*************************************************************************** ! krusaderview.cpp ! ------------------- ! copyright : (C) 2000 by Shie Erlich & Rafi Yanai ! e-mail : kru...@us... ! web site : http://krusader.sourceforge.net ! --------------------------------------------------------------------------- ! Description ! *************************************************************************** ! A ! db dD d8888b. db db .d8888. .d8b. d8888b. d88888b d8888b. ! 88 ,8P' 88 `8D 88 88 88' YP d8' `8b 88 `8D 88' 88 `8D ! 88,8P 88oobY' 88 88 `8bo. 88ooo88 88 88 88ooooo 88oobY' ! 88`8b 88`8b 88 88 `Y8b. 88~~~88 88 88 88~~~~~ 88`8b ! 88 `88. 88 `88. 88b d88 db 8D 88 88 88 .8D 88. 88 `88. ! YP YD 88 YD ~Y8888P' `8888Y' YP YP Y8888D' Y88888P 88 YD ! S o u r c e F i l e ! *************************************************************************** ! * * ! * 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. * ! * * ! ***************************************************************************/ // Qt includes ! #include <qwhatsthis.h> // Krusader includes #include "krusaderview.h" *************** *** 41,99 **** #include "GUI/kfnkeys.h" #include "resources.h" #include <klibloader.h> //<> ! KrusaderView::KrusaderView(QWidget *parent, const char *name ) : QWidget(parent,name), ! konsole_part(0L) {} ! void KrusaderView::start(QString leftPath, QString rightPath) { //////////////////////////////// // make a 1x1 mainLayout, it will auto-expand: ! mainLayout = new QGridLayout(this, 1, 1); ! // vertical splitter ! vert_splitter = new QSplitter(this); // splits between panels and terminal/cmdline ! vert_splitter->setOrientation(QObject::Vertical); ! // horizontal splitter ! horiz_splitter = new QSplitter( vert_splitter ); ! (terminal_dock = new QHBox(vert_splitter))->hide(); // create it hidden ! // create a command line thing ! cmdLine=new KCMDLine(this); ! // add 2 pseudo widgets and layouts to allow a smoother movement of the ! // whole screen, and allow the status bars to resize with the panels ! left=new ListPanel(horiz_splitter, true); ! right=new ListPanel(horiz_splitter, false); ! left->setOther(right); right->setOther(left); // create the function keys widget ! fnKeys=new KFnKeys(this); ! fnKeys->show(); ! QWhatsThis::add( fnKeys, i18n( "Function keys allow to perform fast " ! "operations on files." ) ); // and insert the whole thing into the main layout... at last ! mainLayout->addWidget(vert_splitter,0,0); //<> ! mainLayout->addWidget(cmdLine,1,0); ! mainLayout->addWidget(fnKeys,2,0); ! mainLayout->activate(); ! // get the last saved sizes of the splitter ! krConfig->setGroup("Private"); ! QValueList<int> lst = krConfig->readIntListEntry("Splitter Sizes"); ! if (!lst.isEmpty()) horiz_splitter->setSizes(lst); ! show(); qApp->processEvents(); // make the left panel focused at program start ! right->start(rightPath);left->start(leftPath); ! activePanel=left; activePanel->slotFocusOnMe(); // left starts out active } // updates the command line whenever current panel changes ////////////////////////////////////////////////////////// ! void KrusaderView::slotCurrentChanged(QString p) { ! cmdLine->setCurrent(p); ! if (konsole_part != 0L) { ! konsole_part->openURL(KURL(p)); } } --- 41,110 ---- #include "GUI/kfnkeys.h" #include "resources.h" + #include "panelmanager.h" #include <klibloader.h> //<> ! KrusaderView::KrusaderView( QWidget *parent, const char *name ) : QWidget( parent, name ), ! konsole_part( 0L ) {} ! void KrusaderView::start( QString leftPath, QString rightPath ) { //////////////////////////////// // make a 1x1 mainLayout, it will auto-expand: ! mainLayout = new QGridLayout( this, 1, 1 ); ! // vertical splitter ! vert_splitter = new QSplitter( this ); // splits between panels and terminal/cmdline ! vert_splitter->setOrientation( QObject::Vertical ); ! // horizontal splitter ! horiz_splitter = new QSplitter( vert_splitter ); ! ( terminal_dock = new QHBox( vert_splitter ) ) ->hide(); // create it hidden ! // create a command line thing ! cmdLine = new KCMDLine( this ); ! // add a panel manager for each side of the splitter ! PanelManager *leftMng = new PanelManager(horiz_splitter, true); ! PanelManager *rightMng = new PanelManager(horiz_splitter, false); ! // now, create the panels inside the manager ! //left = new ListPanel( leftMng, true ); ! //right = new ListPanel( rightMng, false ); ! left = leftMng->createPanel(); ! right = rightMng->createPanel(); ! ! left->setOther( right ); ! right->setOther( left ); // create the function keys widget ! fnKeys = new KFnKeys( this ); ! fnKeys->show(); ! QWhatsThis::add ! ( fnKeys, i18n( "Function keys allow to perform fast " ! "operations on files." ) ); // and insert the whole thing into the main layout... at last ! mainLayout->addWidget( vert_splitter, 0, 0 ); //<> ! mainLayout->addWidget( cmdLine, 1, 0 ); ! mainLayout->addWidget( fnKeys, 2, 0 ); ! mainLayout->activate(); ! // get the last saved sizes of the splitter ! krConfig->setGroup( "Private" ); ! QValueList<int> lst = krConfig->readIntListEntry( "Splitter Sizes" ); ! if ( !lst.isEmpty() ) ! horiz_splitter->setSizes( lst ); ! show(); qApp->processEvents(); // make the left panel focused at program start ! rightMng->startPanel( right, rightPath ); ! leftMng->startPanel( left, leftPath ); ! activePanel = left; ! activePanel->slotFocusOnMe(); // left starts out active } // updates the command line whenever current panel changes ////////////////////////////////////////////////////////// ! void KrusaderView::slotCurrentChanged( QString p ) { ! cmdLine->setCurrent( p ); ! if ( konsole_part != 0L ) { ! konsole_part->openURL( KURL( p ) ); } } *************** *** 108,135 **** // Tab - switch focus ! void KrusaderView::panelSwitch(){ activePanel->otherPanel->slotFocusOnMe(); } ! void KrusaderView::slotSetActivePanel(ListPanel *p) { activePanel=p; } ! void KrusaderView::slotTerminalEmulator(bool show) { ! if (!show) { // hiding the terminal terminal_dock->hide(); ! return; } // 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; } ! if (konsole_part) { // if we succeeded in creating the konsole terminal_dock->show(); ! krToggleTerminal->setChecked(true); } else { terminal_dock->hide(); ! krToggleTerminal->setChecked(false); } } --- 119,147 ---- // Tab - switch focus ! void KrusaderView::panelSwitch() { activePanel->otherPanel->slotFocusOnMe(); } ! void KrusaderView::slotSetActivePanel( ListPanel *p ) { activePanel = p; } ! void KrusaderView::slotTerminalEmulator( bool show ) { ! if ( !show ) { // hiding the terminal terminal_dock->hide(); ! return ; } // 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; } ! if ( konsole_part ) { // if we succeeded in creating the konsole terminal_dock->show(); ! krToggleTerminal->setChecked( true ); } else { terminal_dock->hide(); ! krToggleTerminal->setChecked( false ); } } *************** *** 137,142 **** void KrusaderView::killTerminalEmulator() { konsole_part = 0L; ! slotTerminalEmulator(false); // hide the docking widget ! krToggleTerminal->setChecked(false); } --- 149,154 ---- void KrusaderView::killTerminalEmulator() { konsole_part = 0L; ! slotTerminalEmulator( false ); // hide the docking widget ! krToggleTerminal->setChecked( false ); } |