--------------Boundary-00=_W4APQ8OMZX46CMPH43ZB Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8bit Hi, I finally found a sane solution, could you please verify that this patch is Ok and working? And cullmann or other, as i am starting doing some post 3.0.1 stuff for the file selector, could oyu commit it to the release branch? -anders --------------Boundary-00=_W4APQ8OMZX46CMPH43ZB Content-Type: text/x-diff; charset="us-ascii"; name="katefileselector.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="katefileselector.diff" Index: app/katefileselector.cpp =================================================================== RCS file: /home/kde/kdebase/kate/app/katefileselector.cpp,v retrieving revision 1.5 diff -u -r1.5 katefileselector.cpp --- app/katefileselector.cpp 2002/02/23 19:38:52 1.5 +++ app/katefileselector.cpp 2002/03/28 20:22:44 @@ -27,6 +27,8 @@ #include #include #include +#include +#include #include #include @@ -36,9 +38,14 @@ #include #include #include - +#include #include +#include + + +static void silenceQToolBar(QtMsgType, const char *){} + KateFileSelector::KateFileSelector( KateMainWindow *mainWindow, KateViewManager *viewManager, QWidget * parent, const char * name ) : QWidget(parent, name), @@ -46,31 +53,13 @@ viewmanager(viewManager) { QVBoxLayout* lo = new QVBoxLayout(this); - - QHBox *hlow = new QHBox (this); - lo->addWidget(hlow); - home = new QToolButton( hlow ); - home->setIconSet(SmallIconSet("gohome")); - QToolTip::add(home, i18n("Home directory")); - up = new QToolButton( hlow ); - up->setIconSet(SmallIconSet("up")); - QToolTip::add(up, i18n("Up one level")); - back = new QToolButton( hlow ); - back->setIconSet(SmallIconSet("back")); - QToolTip::add(back, i18n("Previous directory")); - forward = new QToolButton( hlow ); - forward->setIconSet(SmallIconSet("forward")); - QToolTip::add(forward, i18n("Next Directory")); - - // HACK - QWidget* spacer = new QWidget(hlow); - hlow->setStretchFactor(spacer, 1); - hlow->setMaximumHeight(up->height()); - - cfdir = new QToolButton( hlow ); - cfdir->setIconSet(SmallIconSet("curfiledir")); - QToolTip::add(cfdir, i18n("Current Document Directory")); + tbparent = new TBContainer( this ); + lo->addWidget( tbparent ); + QtMsgHandler oldHandler = qInstallMsgHandler( silenceQToolBar ); + toolbar = new KToolBar( tbparent, "Kate FileSelector Toolbar", false ); + qInstallMsgHandler( oldHandler ); + tbparent->setTb( toolbar ); cmbPath = new KURLComboBox( KURLComboBox::Directories, true, this, "path combo" ); cmbPath->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed )); @@ -80,11 +69,28 @@ dir = new KDirOperator(QString::null, this, "operator"); dir->setView(KFile::/*Simple*/Detail); - dir->actionCollection()->action( "delete" )->setShortcut (KShortcut (ALT+Key_Delete)); + + KActionCollection *coll = dir->actionCollection(); + // some shortcuts of diroperator that clashes with Kate + coll->action( "delete" )->setShortcut( KShortcut( ALT + Key_Delete ) ); + coll->action( "reload" )->setShortcut( KShortcut( ALT + Key_F5 ) ); + coll->action( "back" )->setShortcut( KShortcut( ALT + SHIFT + Key_Left ) ); + coll->action( "forward" )->setShortcut( KShortcut( ALT + SHIFT + Key_Right ) ); + // some consistency - reset up for dir too + coll->action( "up" )->setShortcut( KShortcut( ALT + SHIFT + Key_Up ) ); + coll->action( "home" )->setShortcut( KShortcut( CTRL + ALT + Key_Home ) ); + + coll->action( "up" )->plug( toolbar ); + coll->action( "back" )->plug( toolbar ); + coll->action( "forward" )->plug( toolbar ); + coll->action( "home" )->plug( toolbar ); + coll->action( "reload" )->plug( toolbar ); + coll->action( "short view" )->plug( toolbar ); + coll->action( "detailed view" )->plug( toolbar ); + lo->addWidget(dir); lo->setStretchFactor(dir, 2); - QHBox* filterBox = new QHBox(this); filterIcon = new QLabel(filterBox); filterIcon->setPixmap( BarIcon("filter") ); @@ -96,11 +102,13 @@ connect( filter, SIGNAL( activated(const QString&) ), SLOT( slotFilterChange(const QString&) ) ); connect( filter, SIGNAL( returnPressed(const QString&) ),filter, SLOT( addToHistory(const QString&) ) ); - connect( home, SIGNAL( clicked() ), dir, SLOT( home() ) ); - connect( up, SIGNAL( clicked() ), dir, SLOT( cdUp() ) ); - connect( back, SIGNAL( clicked() ), dir, SLOT( back() ) ); - connect( forward, SIGNAL( clicked() ), dir, SLOT( forward() ) ); - connect( cfdir, SIGNAL( clicked() ), this, SLOT( setCurrentDocDir() ) ); + // kaction for the dir sync method + acSyncDir = new KAction( i18n("Current Document Directory"), "curfiledir", 0, this, SLOT( setCurrentDocDir() ), this, "sync_dir" ); + acSyncDir->plug( toolbar ); + + toolbar->setIconText( KToolBar::IconOnly ); + toolbar->setIconSize( 16 ); + toolbar->setEnableContextMenu( false ); connect( cmbPath, SIGNAL( urlActivated( const KURL& )), this, SLOT( cmbPathActivated( const KURL& ) )); @@ -121,6 +129,7 @@ { } + void KateFileSelector::readConfig(KConfig *config, const QString & name) { dir->readConfig(config, name + ":dir"); @@ -186,12 +195,6 @@ void KateFileSelector::dirFinishedLoading() { - // HACK - enable the nav buttons - // have to wait for diroperator... - up->setEnabled( dir->actionCollection()->action( "up" )->isEnabled() ); - back->setEnabled( dir->actionCollection()->action( "back" )->isEnabled() ); - forward->setEnabled( dir->actionCollection()->action( "forward" )->isEnabled() ); - home->setEnabled( dir->actionCollection()->action( "home" )->isEnabled() ); } void KateFileSelector::focusInEvent(QFocusEvent*) @@ -215,6 +218,7 @@ { // TODO: make sure the button is disabled if the directory is unreadable, eg the document URL // has protocol http - cfdir->setEnabled( ! mainwin->currentDocUrl().directory().isEmpty() ); + //cfdir->setEnabled( ! mainwin->currentDocUrl().directory().isEmpty() ); + acSyncDir->setEnabled( ! mainwin->currentDocUrl().directory().isEmpty() ); } Index: app/katefileselector.h =================================================================== RCS file: /home/kde/kdebase/kate/app/katefileselector.h,v retrieving revision 1.5 diff -u -r1.5 katefileselector.h --- app/katefileselector.h 2002/01/22 12:04:30 1.5 +++ app/katefileselector.h 2002/03/28 20:22:44 @@ -2,8 +2,8 @@ katefileselector.h - description ------------------- begin : Mon Feb 5 2001 - copyright : (C) 2001 by Matt Newell - email : newellm@proaxis.com + copyright : (C) 2001 by Matt Newell, 2002 by Anders Lund + email : newellm@proaxis.com, anders@alweb.dk ***************************************************************************/ /*************************************************************************** @@ -27,6 +27,14 @@ class KateMainWindow; class KateViewManager; +/* + The kate file selector presents a directory view, in which the default action is + to open the activated file. + Additinally, a toolbar for managing the kdiroperator widget + sync that to + the directory of the current file is available, as well as a filter widget + allowing to filter the displayed files using a name filter. +*/ + class KateFileSelector : public QWidget { Q_OBJECT @@ -36,10 +44,10 @@ QWidget * parent = 0, const char * name = 0 ); ~KateFileSelector(); - void readConfig(KConfig *, const QString &); - void writeConfig(KConfig *, const QString &); - void setView(KFile::FileView); - KDirOperator * dirOperator(){return dir;} + void readConfig( KConfig *, const QString & ); + void writeConfig( KConfig *, const QString & ); + void setView( KFile::FileView ); + KDirOperator * dirOperator(){ return dir; } public slots: void slotFilterChange(const QString&); @@ -54,17 +62,61 @@ void kateViewChanged(); protected: - void focusInEvent(QFocusEvent*); + void focusInEvent( QFocusEvent* ); private: KURLComboBox *cmbPath; KHistoryCombo * filter; QLabel* filterIcon; KDirOperator * dir; - class QToolButton *home, *up, *back, *forward, *cfdir; - + class KAction *acSyncDir; + class TBContainer *tbparent; + class KToolBar *toolbar; KateMainWindow *mainwin; KateViewManager *viewmanager; }; + +/* + KFSFilterHelper + A popup widget presenting a listbox with checkable items + representing the mime types available in the current directory, and + providing a name filter based on those. +*/ + +/* + This is a hack to allow to have the toolbar without a resize + handle. + As it seems QMainWindow(?) recursively sets all toolbars + movable according to the global setting in it's polish() method, + this class is there mainly to reset that, and to handle resizing. + It is required to setTB() before the widget is shown, that is in + the parent constructor, or add the toolbar in the constructor, + but there is no access to it (which could easily be changed;) +*/ +#include +#include +class TBContainer : public QFrame { + Q_OBJECT + public: + TBContainer( QWidget *parent=0, KToolBar *toolbar=0 ) + : QFrame( parent, "toolbar container hack" ), tb( toolbar ){}; + void setTb( KToolBar *toolbar) { tb = toolbar; }; + public slots: + void polish() { + if (tb) { + setMinimumHeight( tb->sizeHint().height() ); + tb->setMovingEnabled( false ); + } + }; + protected: + void resizeEvent( QResizeEvent *e ) { + if( tb ) { + tb->resize( e->size() ); + } + } + private: + KToolBar *tb; +}; + -#endif //KANTFILESELECTOR_H +#endif //__KATE_FILESELECTOR_H__ --------------Boundary-00=_W4APQ8OMZX46CMPH43ZB-- _______________________________________________ kwrite-devel mailing list kwrite-devel@mail.kde.org http://mail.kde.org/mailman/listinfo/kwrite-devel