2007-04-01 18:36:23 +00:00
/***************************************************************************
* Copyright ( C ) 2006 by Peter Penz < peter . penz @ gmx . at > *
* Copyright ( C ) 2006 by Stefan Monov < logixoul @ gmail . com > *
* Copyright ( C ) 2006 by Cvetoslav Ludmiloff < ludmiloff @ gmail . com > *
* *
* 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 . *
* *
* This program is distributed in the hope that it will be useful , *
* but WITHOUT ANY WARRANTY ; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the *
* GNU General Public License for more details . *
* *
* You should have received a copy of the GNU General Public License *
* along with this program ; if not , write to the *
* Free Software Foundation , Inc . , *
* 51 Franklin Street , Fifth Floor , Boston , MA 02110 - 1301 USA *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
# include "dolphinmainwindow.h"
2007-06-19 19:17:32 +00:00
# include <config-nepomuk.h>
2007-05-18 23:51:03 +00:00
2007-04-01 18:36:23 +00:00
# include "dolphinapplication.h"
# include "dolphinnewmenu.h"
# include "dolphinsettings.h"
# include "dolphinsettingsdialog.h"
# include "dolphinstatusbar.h"
2007-06-07 21:10:48 +00:00
# include "dolphinviewcontainer.h"
2007-04-01 18:36:23 +00:00
# include "infosidebarpage.h"
# include "metadatawidget.h"
# include "mainwindowadaptor.h"
2007-05-06 21:50:24 +00:00
# include "terminalsidebarpage.h"
2007-04-01 18:36:23 +00:00
# include "treeviewsidebarpage.h"
2007-04-02 19:20:07 +00:00
# include "kurlnavigator.h"
2007-04-01 18:36:23 +00:00
# include "viewpropertiesdialog.h"
# include "viewproperties.h"
2007-04-01 22:28:03 +00:00
# include "kfileplacesmodel.h"
2007-04-02 08:51:57 +00:00
# include "kfileplacesview.h"
2007-04-01 18:36:23 +00:00
# include "dolphin_generalsettings.h"
# include <kaction.h>
# include <kactioncollection.h>
# include <kconfig.h>
# include <kdesktopfile.h>
# include <kdeversion.h>
# include <kfiledialog.h>
# include <kglobal.h>
# include <kicon.h>
# include <kiconloader.h>
# include <kio/netaccess.h>
# include <kio/deletejob.h>
# include <kio/renamedialog.h>
# include <kinputdialog.h>
# include <klocale.h>
# include <kmenu.h>
# include <kmessagebox.h>
# include <konqmimedata.h>
# include <konq_operations.h>
# include <kpropertiesdialog.h>
# include <kprotocolinfo.h>
# include <ktoggleaction.h>
# include <krun.h>
# include <kshell.h>
# include <kstandarddirs.h>
# include <kstatusbar.h>
# include <kstandardaction.h>
# include <kurl.h>
2007-05-09 22:23:52 +00:00
# include <QtGui/QKeyEvent>
# include <QtGui/QClipboard>
# include <QtGui/QSplitter>
# include <QtGui/QDockWidget>
2007-04-01 18:36:23 +00:00
DolphinMainWindow : : DolphinMainWindow ( int id ) :
2007-05-06 17:41:49 +00:00
KXmlGuiWindow ( 0 ) ,
m_newMenu ( 0 ) ,
m_splitter ( 0 ) ,
2007-06-07 21:10:48 +00:00
m_activeViewContainer ( 0 ) ,
2007-05-06 17:41:49 +00:00
m_id ( id )
2007-04-01 18:36:23 +00:00
{
setObjectName ( " Dolphin " ) ;
2007-06-12 21:45:22 +00:00
m_viewContainer [ PrimaryView ] = 0 ;
m_viewContainer [ SecondaryView ] = 0 ;
2007-04-01 18:36:23 +00:00
new MainWindowAdaptor ( this ) ;
QDBusConnection : : sessionBus ( ) . registerObject ( QString ( " /dolphin/MainWindow%1 " ) . arg ( m_id ) , this ) ;
KonqUndoManager : : incRef ( ) ;
KonqUndoManager * undoManager = KonqUndoManager : : self ( ) ;
undoManager - > setUiInterface ( new UndoUiInterface ( this ) ) ;
connect ( undoManager , SIGNAL ( undoAvailable ( bool ) ) ,
this , SLOT ( slotUndoAvailable ( bool ) ) ) ;
connect ( undoManager , SIGNAL ( undoTextChanged ( const QString & ) ) ,
this , SLOT ( slotUndoTextChanged ( const QString & ) ) ) ;
2007-06-15 00:52:25 +00:00
connect ( DolphinSettings : : instance ( ) . placesModel ( ) , SIGNAL ( errorMessage ( const QString & ) ) ,
this , SLOT ( slotHandlePlacesError ( const QString & ) ) ) ;
2007-04-01 18:36:23 +00:00
}
DolphinMainWindow : : ~ DolphinMainWindow ( )
{
KonqUndoManager : : decRef ( ) ;
DolphinApplication : : app ( ) - > removeMainWindow ( this ) ;
}
2007-06-12 21:45:22 +00:00
void DolphinMainWindow : : toggleViews ( )
2007-04-01 18:36:23 +00:00
{
2007-06-12 21:45:22 +00:00
if ( m_viewContainer [ SecondaryView ] = = 0 ) {
2007-04-01 18:36:23 +00:00
return ;
}
2007-06-12 21:45:22 +00:00
// move secondary view from the last position of the splitter
// to the first position
m_splitter - > insertWidget ( 0 , m_viewContainer [ SecondaryView ] ) ;
2007-04-01 18:36:23 +00:00
2007-06-12 21:45:22 +00:00
DolphinViewContainer * container = m_viewContainer [ PrimaryView ] ;
m_viewContainer [ PrimaryView ] = m_viewContainer [ SecondaryView ] ;
m_viewContainer [ SecondaryView ] = container ;
}
2007-04-01 18:36:23 +00:00
2007-06-12 21:45:22 +00:00
void DolphinMainWindow : : rename ( const KUrl & oldUrl , const KUrl & newUrl )
{
clearStatusBar ( ) ;
KonqOperations : : rename ( this , oldUrl , newUrl ) ;
m_undoCommandTypes . append ( KonqUndoManager : : RENAME ) ;
}
2007-04-01 18:36:23 +00:00
2007-06-12 21:45:22 +00:00
void DolphinMainWindow : : refreshViews ( )
{
Q_ASSERT ( m_viewContainer [ PrimaryView ] ! = 0 ) ;
// remember the current active view, as because of
// the refreshing the active view might change to
// the secondary view
DolphinViewContainer * activeViewContainer = m_activeViewContainer ;
m_viewContainer [ PrimaryView ] - > view ( ) - > refresh ( ) ;
if ( m_viewContainer [ SecondaryView ] ! = 0 ) {
m_viewContainer [ SecondaryView ] - > view ( ) - > refresh ( ) ;
}
setActiveViewContainer ( activeViewContainer ) ;
2007-04-01 18:36:23 +00:00
}
void DolphinMainWindow : : dropUrls ( const KUrl : : List & urls ,
const KUrl & destination )
{
Qt : : DropAction action = Qt : : CopyAction ;
Qt : : KeyboardModifiers modifier = QApplication : : keyboardModifiers ( ) ;
const bool shiftPressed = modifier & Qt : : ShiftModifier ;
const bool controlPressed = modifier & Qt : : ControlModifier ;
if ( shiftPressed & & controlPressed ) {
// shortcut for 'Link Here' is used
action = Qt : : LinkAction ;
2007-04-09 19:12:54 +00:00
} else if ( shiftPressed ) {
2007-04-01 18:36:23 +00:00
// shortcut for 'Move Here' is used
action = Qt : : MoveAction ;
2007-04-09 19:12:54 +00:00
} else if ( controlPressed ) {
2007-04-01 18:36:23 +00:00
// shortcut for 'Copy Here' is used
action = Qt : : CopyAction ;
2007-04-09 19:12:54 +00:00
} else {
2007-04-01 18:36:23 +00:00
// open a context menu which offers the following actions:
// - Move Here
// - Copy Here
// - Link Here
// - Cancel
KMenu popup ( this ) ;
QString seq = QKeySequence ( Qt : : ShiftModifier ) . toString ( ) ;
seq . chop ( 1 ) ; // chop superfluous '+'
QAction * moveAction = popup . addAction ( KIcon ( " goto-page " ) ,
i18n ( " &Move Here " ) + ' \t ' + seq ) ;
seq = QKeySequence ( Qt : : ControlModifier ) . toString ( ) ;
seq . chop ( 1 ) ;
QAction * copyAction = popup . addAction ( KIcon ( " edit-copy " ) ,
i18n ( " &Copy Here " ) + ' \t ' + seq ) ;
seq = QKeySequence ( Qt : : ControlModifier + Qt : : ShiftModifier ) . toString ( ) ;
seq . chop ( 1 ) ;
QAction * linkAction = popup . addAction ( KIcon ( " www " ) ,
i18n ( " &Link Here " ) + ' \t ' + seq ) ;
popup . addSeparator ( ) ;
popup . addAction ( KIcon ( " process-stop " ) , i18n ( " Cancel " ) ) ;
QAction * activatedAction = popup . exec ( QCursor : : pos ( ) ) ;
if ( activatedAction = = moveAction ) {
action = Qt : : MoveAction ;
2007-04-09 19:12:54 +00:00
} else if ( activatedAction = = copyAction ) {
2007-04-01 18:36:23 +00:00
action = Qt : : CopyAction ;
2007-04-09 19:12:54 +00:00
} else if ( activatedAction = = linkAction ) {
2007-04-01 18:36:23 +00:00
action = Qt : : LinkAction ;
2007-04-09 19:12:54 +00:00
} else {
2007-04-01 18:36:23 +00:00
return ;
}
}
switch ( action ) {
2007-04-09 19:12:54 +00:00
case Qt : : MoveAction :
moveUrls ( urls , destination ) ;
break ;
2007-04-01 18:36:23 +00:00
2007-04-09 19:12:54 +00:00
case Qt : : CopyAction :
copyUrls ( urls , destination ) ;
break ;
2007-04-01 18:36:23 +00:00
2007-04-09 19:12:54 +00:00
case Qt : : LinkAction :
linkUrls ( urls , destination ) ;
break ;
2007-04-01 18:36:23 +00:00
2007-04-09 19:12:54 +00:00
default :
break ;
2007-04-01 18:36:23 +00:00
}
}
void DolphinMainWindow : : changeUrl ( const KUrl & url )
{
2007-06-13 17:08:39 +00:00
DolphinViewContainer * view = activeViewContainer ( ) ;
if ( view ! = 0 ) {
view - > setUrl ( url ) ;
2007-04-01 18:36:23 +00:00
updateEditActions ( ) ;
updateViewActions ( ) ;
updateGoActions ( ) ;
setCaption ( url . fileName ( ) ) ;
emit urlChanged ( url ) ;
}
}
void DolphinMainWindow : : changeSelection ( const KFileItemList & selection )
{
2007-06-07 21:10:48 +00:00
activeViewContainer ( ) - > view ( ) - > changeSelection ( selection ) ;
2007-04-01 18:36:23 +00:00
}
void DolphinMainWindow : : slotViewModeChanged ( )
{
updateViewActions ( ) ;
}
void DolphinMainWindow : : slotShowPreviewChanged ( )
{
// It is not enough to update the 'Show Preview' action, also
// the 'Zoom In' and 'Zoom Out' actions must be adapted.
updateViewActions ( ) ;
}
void DolphinMainWindow : : slotShowHiddenFilesChanged ( )
{
KToggleAction * showHiddenFilesAction =
static_cast < KToggleAction * > ( actionCollection ( ) - > action ( " show_hidden_files " ) ) ;
2007-06-07 21:10:48 +00:00
const DolphinView * view = m_activeViewContainer - > view ( ) ;
showHiddenFilesAction - > setChecked ( view - > showHiddenFiles ( ) ) ;
2007-04-01 18:36:23 +00:00
}
2007-04-10 11:22:56 +00:00
void DolphinMainWindow : : slotCategorizedSortingChanged ( )
{
2007-06-19 16:00:21 +00:00
KToggleAction * showInGroupsAction =
static_cast < KToggleAction * > ( actionCollection ( ) - > action ( " show_in_groups " ) ) ;
2007-06-07 21:10:48 +00:00
const DolphinView * view = m_activeViewContainer - > view ( ) ;
2007-06-19 16:00:21 +00:00
showInGroupsAction - > setChecked ( view - > categorizedSorting ( ) ) ;
showInGroupsAction - > setEnabled ( view - > supportsCategorizedSorting ( ) ) ;
2007-04-10 11:22:56 +00:00
}
2007-04-01 18:36:23 +00:00
void DolphinMainWindow : : slotSortingChanged ( DolphinView : : Sorting sorting )
{
QAction * action = 0 ;
switch ( sorting ) {
2007-04-09 19:12:54 +00:00
case DolphinView : : SortByName :
action = actionCollection ( ) - > action ( " by_name " ) ;
break ;
case DolphinView : : SortBySize :
action = actionCollection ( ) - > action ( " by_size " ) ;
break ;
case DolphinView : : SortByDate :
action = actionCollection ( ) - > action ( " by_date " ) ;
break ;
case DolphinView : : SortByPermissions :
action = actionCollection ( ) - > action ( " by_permissions " ) ;
break ;
case DolphinView : : SortByOwner :
action = actionCollection ( ) - > action ( " by_owner " ) ;
break ;
case DolphinView : : SortByGroup :
action = actionCollection ( ) - > action ( " by_group " ) ;
break ;
2007-04-22 21:04:46 +00:00
case DolphinView : : SortByType :
action = actionCollection ( ) - > action ( " by_type " ) ;
2007-06-22 10:18:46 +00:00
break ;
# ifdef HAVE_NEPOMUK
case DolphinView : : SortByRating :
action = actionCollection ( ) - > action ( " by_rating " ) ;
break ;
case DolphinView : : SortByTags :
action = actionCollection ( ) - > action ( " by_tags " ) ;
break ;
# endif
2007-04-09 19:12:54 +00:00
default :
break ;
2007-04-01 18:36:23 +00:00
}
if ( action ! = 0 ) {
KToggleAction * toggleAction = static_cast < KToggleAction * > ( action ) ;
toggleAction - > setChecked ( true ) ;
}
}
void DolphinMainWindow : : slotSortOrderChanged ( Qt : : SortOrder order )
{
KToggleAction * descending = static_cast < KToggleAction * > ( actionCollection ( ) - > action ( " descending " ) ) ;
2007-04-04 13:02:52 +00:00
const bool sortDescending = ( order = = Qt : : DescendingOrder ) ;
2007-04-01 18:36:23 +00:00
descending - > setChecked ( sortDescending ) ;
}
void DolphinMainWindow : : slotAdditionalInfoChanged ( KFileItemDelegate : : AdditionalInformation info )
{
QAction * action = 0 ;
switch ( info ) {
2007-04-09 19:12:54 +00:00
case KFileItemDelegate : : FriendlyMimeType :
action = actionCollection ( ) - > action ( " show_mime_info " ) ;
break ;
case KFileItemDelegate : : Size :
action = actionCollection ( ) - > action ( " show_size_info " ) ;
break ;
case KFileItemDelegate : : ModificationTime :
action = actionCollection ( ) - > action ( " show_date_info " ) ;
break ;
case KFileItemDelegate : : NoInformation :
default :
action = actionCollection ( ) - > action ( " clear_info " ) ;
break ;
2007-04-01 18:36:23 +00:00
}
if ( action ! = 0 ) {
KToggleAction * toggleAction = static_cast < KToggleAction * > ( action ) ;
toggleAction - > setChecked ( true ) ;
QActionGroup * group = toggleAction - > actionGroup ( ) ;
Q_ASSERT ( group ! = 0 ) ;
2007-06-07 21:10:48 +00:00
const DolphinView * view = m_activeViewContainer - > view ( ) ;
group - > setEnabled ( view - > mode ( ) = = DolphinView : : IconsView ) ;
2007-04-01 18:36:23 +00:00
}
}
void DolphinMainWindow : : slotSelectionChanged ( const KFileItemList & selection )
{
updateEditActions ( ) ;
2007-06-12 21:45:22 +00:00
Q_ASSERT ( m_viewContainer [ PrimaryView ] ! = 0 ) ;
int selectedUrlsCount = m_viewContainer [ PrimaryView ] - > view ( ) - > selectedUrls ( ) . count ( ) ;
if ( m_viewContainer [ SecondaryView ] ! = 0 ) {
selectedUrlsCount + = m_viewContainer [ SecondaryView ] - > view ( ) - > selectedUrls ( ) . count ( ) ;
2007-04-01 18:36:23 +00:00
}
QAction * compareFilesAction = actionCollection ( ) - > action ( " compare_files " ) ;
compareFilesAction - > setEnabled ( selectedUrlsCount = = 2 ) ;
2007-06-07 21:10:48 +00:00
m_activeViewContainer - > updateStatusBar ( ) ;
2007-04-01 18:36:23 +00:00
emit selectionChanged ( selection ) ;
}
2007-05-17 14:51:54 +00:00
void DolphinMainWindow : : slotRequestItemInfo ( const KUrl & url )
{
emit requestItemInfo ( url ) ;
}
2007-04-01 18:36:23 +00:00
void DolphinMainWindow : : slotHistoryChanged ( )
{
updateHistory ( ) ;
}
void DolphinMainWindow : : updateFilterBarAction ( bool show )
{
KToggleAction * showFilterBarAction =
static_cast < KToggleAction * > ( actionCollection ( ) - > action ( " show_filter_bar " ) ) ;
showFilterBarAction - > setChecked ( show ) ;
}
void DolphinMainWindow : : openNewMainWindow ( )
{
DolphinApplication : : app ( ) - > createMainWindow ( ) - > show ( ) ;
}
2007-06-07 21:10:48 +00:00
void DolphinMainWindow : : toggleActiveView ( )
{
2007-06-27 15:15:29 +00:00
if ( m_viewContainer [ SecondaryView ] = = 0 ) {
// only one view is available
return ;
2007-06-07 21:10:48 +00:00
}
2007-06-27 15:15:29 +00:00
Q_ASSERT ( m_activeViewContainer ! = 0 ) ;
Q_ASSERT ( m_viewContainer [ PrimaryView ] ! = 0 ) ;
DolphinViewContainer * left = m_viewContainer [ PrimaryView ] ;
DolphinViewContainer * right = m_viewContainer [ SecondaryView ] ;
setActiveViewContainer ( m_activeViewContainer = = right ? left : right ) ;
2007-06-07 21:10:48 +00:00
}
2007-04-01 18:36:23 +00:00
void DolphinMainWindow : : closeEvent ( QCloseEvent * event )
{
DolphinSettings & settings = DolphinSettings : : instance ( ) ;
GeneralSettings * generalSettings = settings . generalSettings ( ) ;
generalSettings - > setFirstRun ( false ) ;
settings . save ( ) ;
2007-04-16 20:44:36 +00:00
KXmlGuiWindow : : closeEvent ( event ) ;
2007-04-01 18:36:23 +00:00
}
void DolphinMainWindow : : saveProperties ( KConfig * config )
{
KConfigGroup primaryView = config - > group ( " Primary view " ) ;
2007-06-12 21:45:22 +00:00
primaryView . writeEntry ( " Url " , m_viewContainer [ PrimaryView ] - > url ( ) . url ( ) ) ;
primaryView . writeEntry ( " Editable Url " , m_viewContainer [ PrimaryView ] - > isUrlEditable ( ) ) ;
if ( m_viewContainer [ SecondaryView ] ! = 0 ) {
2007-04-01 18:36:23 +00:00
KConfigGroup secondaryView = config - > group ( " Secondary view " ) ;
2007-06-12 21:45:22 +00:00
secondaryView . writeEntry ( " Url " , m_viewContainer [ SecondaryView ] - > url ( ) . url ( ) ) ;
secondaryView . writeEntry ( " Editable Url " , m_viewContainer [ SecondaryView ] - > isUrlEditable ( ) ) ;
2007-04-01 18:36:23 +00:00
}
}
void DolphinMainWindow : : readProperties ( KConfig * config )
{
2007-06-07 21:10:48 +00:00
const KConfigGroup primaryViewGroup = config - > group ( " Primary view " ) ;
2007-06-12 21:45:22 +00:00
m_viewContainer [ PrimaryView ] - > setUrl ( primaryViewGroup . readEntry ( " Url " ) ) ;
2007-06-07 21:10:48 +00:00
bool editable = primaryViewGroup . readEntry ( " Editable Url " , false ) ;
2007-06-12 21:45:22 +00:00
m_viewContainer [ PrimaryView ] - > urlNavigator ( ) - > setUrlEditable ( editable ) ;
2007-06-07 21:10:48 +00:00
2007-04-01 18:36:23 +00:00
if ( config - > hasGroup ( " Secondary view " ) ) {
2007-06-07 21:10:48 +00:00
const KConfigGroup secondaryViewGroup = config - > group ( " Secondary view " ) ;
2007-06-12 21:45:22 +00:00
if ( m_viewContainer [ PrimaryView ] = = 0 ) {
2007-04-01 18:36:23 +00:00
toggleSplitView ( ) ;
}
2007-06-12 21:45:22 +00:00
m_viewContainer [ PrimaryView ] - > setUrl ( secondaryViewGroup . readEntry ( " Url " ) ) ;
2007-06-07 21:10:48 +00:00
editable = secondaryViewGroup . readEntry ( " Editable Url " , false ) ;
2007-06-12 21:45:22 +00:00
m_viewContainer [ PrimaryView ] - > urlNavigator ( ) - > setUrlEditable ( editable ) ;
} else if ( m_viewContainer [ SecondaryView ] ! = 0 ) {
2007-04-01 18:36:23 +00:00
toggleSplitView ( ) ;
}
}
void DolphinMainWindow : : updateNewMenu ( )
{
m_newMenu - > slotCheckUpToDate ( ) ;
2007-06-07 21:10:48 +00:00
m_newMenu - > setPopupFiles ( activeViewContainer ( ) - > url ( ) ) ;
2007-04-01 18:36:23 +00:00
}
void DolphinMainWindow : : rename ( )
{
clearStatusBar ( ) ;
2007-06-07 21:10:48 +00:00
m_activeViewContainer - > renameSelectedItems ( ) ;
2007-04-01 18:36:23 +00:00
}
void DolphinMainWindow : : moveToTrash ( )
{
clearStatusBar ( ) ;
2007-06-07 21:10:48 +00:00
const KUrl : : List selectedUrls = m_activeViewContainer - > view ( ) - > selectedUrls ( ) ;
2007-04-01 18:36:23 +00:00
KonqOperations : : del ( this , KonqOperations : : TRASH , selectedUrls ) ;
m_undoCommandTypes . append ( KonqUndoManager : : TRASH ) ;
}
void DolphinMainWindow : : deleteItems ( )
{
clearStatusBar ( ) ;
2007-06-07 21:10:48 +00:00
const KUrl : : List list = m_activeViewContainer - > view ( ) - > selectedUrls ( ) ;
2007-04-01 19:08:49 +00:00
const bool del = KonqOperations : : askDeleteConfirmation ( list ,
2007-04-09 19:12:54 +00:00
KonqOperations : : DEL ,
KonqOperations : : DEFAULT_CONFIRMATION ,
this ) ;
2007-04-01 18:36:23 +00:00
if ( del ) {
KIO : : Job * job = KIO : : del ( list ) ;
connect ( job , SIGNAL ( result ( KJob * ) ) ,
this , SLOT ( slotHandleJobError ( KJob * ) ) ) ;
connect ( job , SIGNAL ( result ( KJob * ) ) ,
this , SLOT ( slotDeleteFileFinished ( KJob * ) ) ) ;
}
}
void DolphinMainWindow : : properties ( )
{
2007-06-07 21:10:48 +00:00
const KFileItemList list = m_activeViewContainer - > view ( ) - > selectedItems ( ) ;
2007-05-28 04:32:57 +00:00
KPropertiesDialog dialog ( list , this ) ;
dialog . exec ( ) ;
2007-04-01 18:36:23 +00:00
}
void DolphinMainWindow : : quit ( )
{
close ( ) ;
}
2007-06-15 00:52:25 +00:00
void DolphinMainWindow : : slotHandlePlacesError ( const QString & message )
{
if ( ! message . isEmpty ( ) ) {
DolphinStatusBar * statusBar = m_activeViewContainer - > statusBar ( ) ;
statusBar - > setMessage ( message , DolphinStatusBar : : Error ) ;
}
}
2007-04-01 18:36:23 +00:00
void DolphinMainWindow : : slotHandleJobError ( KJob * job )
{
if ( job - > error ( ) ! = 0 ) {
2007-06-07 21:10:48 +00:00
DolphinStatusBar * statusBar = m_activeViewContainer - > statusBar ( ) ;
2007-04-01 18:36:23 +00:00
statusBar - > setMessage ( job - > errorString ( ) ,
DolphinStatusBar : : Error ) ;
}
}
void DolphinMainWindow : : slotDeleteFileFinished ( KJob * job )
{
if ( job - > error ( ) = = 0 ) {
2007-06-07 21:10:48 +00:00
DolphinStatusBar * statusBar = m_activeViewContainer - > statusBar ( ) ;
2007-04-01 18:36:23 +00:00
statusBar - > setMessage ( i18n ( " Delete operation completed. " ) ,
DolphinStatusBar : : OperationCompleted ) ;
}
}
void DolphinMainWindow : : slotUndoAvailable ( bool available )
{
QAction * undoAction = actionCollection ( ) - > action ( KStandardAction : : stdName ( KStandardAction : : Undo ) ) ;
if ( undoAction ! = 0 ) {
undoAction - > setEnabled ( available ) ;
}
if ( available & & ( m_undoCommandTypes . count ( ) > 0 ) ) {
const KonqUndoManager : : CommandType command = m_undoCommandTypes . takeFirst ( ) ;
2007-06-07 21:10:48 +00:00
DolphinStatusBar * statusBar = m_activeViewContainer - > statusBar ( ) ;
2007-04-01 18:36:23 +00:00
switch ( command ) {
2007-04-09 19:12:54 +00:00
case KonqUndoManager : : COPY :
statusBar - > setMessage ( i18n ( " Copy operation completed. " ) ,
DolphinStatusBar : : OperationCompleted ) ;
break ;
case KonqUndoManager : : MOVE :
statusBar - > setMessage ( i18n ( " Move operation completed. " ) ,
DolphinStatusBar : : OperationCompleted ) ;
break ;
case KonqUndoManager : : LINK :
statusBar - > setMessage ( i18n ( " Link operation completed. " ) ,
DolphinStatusBar : : OperationCompleted ) ;
break ;
case KonqUndoManager : : TRASH :
statusBar - > setMessage ( i18n ( " Move to trash operation completed. " ) ,
DolphinStatusBar : : OperationCompleted ) ;
break ;
case KonqUndoManager : : RENAME :
statusBar - > setMessage ( i18n ( " Renaming operation completed. " ) ,
DolphinStatusBar : : OperationCompleted ) ;
break ;
case KonqUndoManager : : MKDIR :
2007-04-11 05:42:11 +00:00
statusBar - > setMessage ( i18n ( " Created folder. " ) ,
2007-04-09 19:12:54 +00:00
DolphinStatusBar : : OperationCompleted ) ;
break ;
default :
break ;
2007-04-01 18:36:23 +00:00
}
}
}
void DolphinMainWindow : : slotUndoTextChanged ( const QString & text )
{
QAction * undoAction = actionCollection ( ) - > action ( KStandardAction : : stdName ( KStandardAction : : Undo ) ) ;
if ( undoAction ! = 0 ) {
undoAction - > setText ( text ) ;
}
}
void DolphinMainWindow : : undo ( )
{
clearStatusBar ( ) ;
KonqUndoManager : : self ( ) - > undo ( ) ;
}
void DolphinMainWindow : : cut ( )
{
QMimeData * mimeData = new QMimeData ( ) ;
2007-06-07 21:10:48 +00:00
const KUrl : : List kdeUrls = m_activeViewContainer - > view ( ) - > selectedUrls ( ) ;
2007-04-01 18:36:23 +00:00
const KUrl : : List mostLocalUrls ;
KonqMimeData : : populateMimeData ( mimeData , kdeUrls , mostLocalUrls , true ) ;
QApplication : : clipboard ( ) - > setMimeData ( mimeData ) ;
}
void DolphinMainWindow : : copy ( )
{
QMimeData * mimeData = new QMimeData ( ) ;
2007-06-07 21:10:48 +00:00
const KUrl : : List kdeUrls = m_activeViewContainer - > view ( ) - > selectedUrls ( ) ;
2007-04-01 18:36:23 +00:00
const KUrl : : List mostLocalUrls ;
KonqMimeData : : populateMimeData ( mimeData , kdeUrls , mostLocalUrls , false ) ;
QApplication : : clipboard ( ) - > setMimeData ( mimeData ) ;
}
void DolphinMainWindow : : paste ( )
{
QClipboard * clipboard = QApplication : : clipboard ( ) ;
const QMimeData * mimeData = clipboard - > mimeData ( ) ;
clearStatusBar ( ) ;
const KUrl : : List sourceUrls = KUrl : : List : : fromMimeData ( mimeData ) ;
// per default the pasting is done into the current Url of the view
2007-06-07 21:10:48 +00:00
KUrl destUrl ( m_activeViewContainer - > url ( ) ) ;
2007-04-01 18:36:23 +00:00
// check whether the pasting should be done into a selected directory
2007-06-07 21:10:48 +00:00
KUrl : : List selectedUrls = m_activeViewContainer - > view ( ) - > selectedUrls ( ) ;
2007-04-01 18:36:23 +00:00
if ( selectedUrls . count ( ) = = 1 ) {
const KFileItem fileItem ( S_IFDIR ,
KFileItem : : Unknown ,
selectedUrls . first ( ) ,
true ) ;
if ( fileItem . isDir ( ) ) {
// only one item is selected which is a directory, hence paste
// into this directory
destUrl = selectedUrls . first ( ) ;
}
}
if ( KonqMimeData : : decodeIsCutSelection ( mimeData ) ) {
moveUrls ( sourceUrls , destUrl ) ;
clipboard - > clear ( ) ;
2007-04-09 19:12:54 +00:00
} else {
2007-04-01 18:36:23 +00:00
copyUrls ( sourceUrls , destUrl ) ;
}
}
void DolphinMainWindow : : updatePasteAction ( )
{
QAction * pasteAction = actionCollection ( ) - > action ( KStandardAction : : stdName ( KStandardAction : : Paste ) ) ;
if ( pasteAction = = 0 ) {
return ;
}
QString text ( i18n ( " Paste " ) ) ;
QClipboard * clipboard = QApplication : : clipboard ( ) ;
const QMimeData * mimeData = clipboard - > mimeData ( ) ;
KUrl : : List urls = KUrl : : List : : fromMimeData ( mimeData ) ;
if ( ! urls . isEmpty ( ) ) {
pasteAction - > setEnabled ( true ) ;
pasteAction - > setText ( i18np ( " Paste One File " , " Paste %1 Files " , urls . count ( ) ) ) ;
2007-04-09 19:12:54 +00:00
} else {
2007-04-01 18:36:23 +00:00
pasteAction - > setEnabled ( false ) ;
pasteAction - > setText ( i18n ( " Paste " ) ) ;
}
if ( pasteAction - > isEnabled ( ) ) {
2007-06-07 21:10:48 +00:00
KUrl : : List urls = m_activeViewContainer - > view ( ) - > selectedUrls ( ) ;
2007-04-01 18:36:23 +00:00
const uint count = urls . count ( ) ;
if ( count > 1 ) {
// pasting should not be allowed when more than one file
// is selected
pasteAction - > setEnabled ( false ) ;
2007-04-09 19:12:54 +00:00
} else if ( count = = 1 ) {
2007-04-01 18:36:23 +00:00
// Only one file is selected. Pasting is only allowed if this
// file is a directory.
// TODO: this doesn't work with remote protocols; instead we need a
2007-06-07 21:10:48 +00:00
// m_activeViewContainer->selectedFileItems() to get the real KFileItems
2007-04-01 18:36:23 +00:00
const KFileItem fileItem ( S_IFDIR ,
KFileItem : : Unknown ,
urls . first ( ) ,
true ) ;
pasteAction - > setEnabled ( fileItem . isDir ( ) ) ;
}
}
}
void DolphinMainWindow : : selectAll ( )
{
clearStatusBar ( ) ;
2007-06-07 21:10:48 +00:00
m_activeViewContainer - > view ( ) - > selectAll ( ) ;
2007-04-01 18:36:23 +00:00
}
void DolphinMainWindow : : invertSelection ( )
{
clearStatusBar ( ) ;
2007-06-07 21:10:48 +00:00
m_activeViewContainer - > view ( ) - > invertSelection ( ) ;
2007-04-01 18:36:23 +00:00
}
void DolphinMainWindow : : setIconsView ( )
{
2007-06-07 21:10:48 +00:00
m_activeViewContainer - > view ( ) - > setMode ( DolphinView : : IconsView ) ;
2007-04-01 18:36:23 +00:00
}
void DolphinMainWindow : : setDetailsView ( )
{
2007-06-07 21:10:48 +00:00
m_activeViewContainer - > view ( ) - > setMode ( DolphinView : : DetailsView ) ;
2007-04-01 18:36:23 +00:00
}
void DolphinMainWindow : : setColumnView ( )
{
2007-06-07 21:10:48 +00:00
m_activeViewContainer - > view ( ) - > setMode ( DolphinView : : ColumnView ) ;
2007-04-01 18:36:23 +00:00
}
void DolphinMainWindow : : sortByName ( )
{
2007-06-07 21:10:48 +00:00
m_activeViewContainer - > view ( ) - > setSorting ( DolphinView : : SortByName ) ;
2007-04-01 18:36:23 +00:00
}
void DolphinMainWindow : : sortBySize ( )
{
2007-06-07 21:10:48 +00:00
m_activeViewContainer - > view ( ) - > setSorting ( DolphinView : : SortBySize ) ;
2007-04-01 18:36:23 +00:00
}
void DolphinMainWindow : : sortByDate ( )
{
2007-06-07 21:10:48 +00:00
m_activeViewContainer - > view ( ) - > setSorting ( DolphinView : : SortByDate ) ;
2007-04-01 18:36:23 +00:00
}
void DolphinMainWindow : : sortByPermissions ( )
{
2007-06-07 21:10:48 +00:00
m_activeViewContainer - > view ( ) - > setSorting ( DolphinView : : SortByPermissions ) ;
2007-04-01 18:36:23 +00:00
}
void DolphinMainWindow : : sortByOwner ( )
{
2007-06-07 21:10:48 +00:00
m_activeViewContainer - > view ( ) - > setSorting ( DolphinView : : SortByOwner ) ;
2007-04-01 18:36:23 +00:00
}
void DolphinMainWindow : : sortByGroup ( )
{
2007-06-07 21:10:48 +00:00
m_activeViewContainer - > view ( ) - > setSorting ( DolphinView : : SortByGroup ) ;
2007-04-01 18:36:23 +00:00
}
2007-04-22 21:04:46 +00:00
void DolphinMainWindow : : sortByType ( )
{
2007-06-07 21:10:48 +00:00
m_activeViewContainer - > view ( ) - > setSorting ( DolphinView : : SortByType ) ;
2007-04-22 21:04:46 +00:00
}
2007-06-22 10:18:46 +00:00
void DolphinMainWindow : : sortByRating ( )
{
2007-06-23 13:12:21 +00:00
# ifdef HAVE_NEPOMUK
2007-06-22 10:18:46 +00:00
m_activeViewContainer - > view ( ) - > setSorting ( DolphinView : : SortByRating ) ;
2007-06-23 13:12:21 +00:00
# endif
2007-06-22 10:18:46 +00:00
}
void DolphinMainWindow : : sortByTags ( )
{
2007-06-23 13:12:21 +00:00
# ifdef HAVE_NEPOMUK
2007-06-22 10:18:46 +00:00
m_activeViewContainer - > view ( ) - > setSorting ( DolphinView : : SortByTags ) ;
2007-06-23 13:12:21 +00:00
# endif
2007-06-22 10:18:46 +00:00
}
2007-04-01 18:36:23 +00:00
void DolphinMainWindow : : toggleSortOrder ( )
{
2007-06-07 21:10:48 +00:00
DolphinView * view = m_activeViewContainer - > view ( ) ;
const Qt : : SortOrder order = ( view - > sortOrder ( ) = = Qt : : AscendingOrder ) ?
2007-04-04 13:02:52 +00:00
Qt : : DescendingOrder :
Qt : : AscendingOrder ;
2007-06-07 21:10:48 +00:00
view - > setSortOrder ( order ) ;
2007-04-01 18:36:23 +00:00
}
2007-04-10 11:22:56 +00:00
void DolphinMainWindow : : toggleSortCategorization ( )
{
2007-06-07 21:10:48 +00:00
DolphinView * view = m_activeViewContainer - > view ( ) ;
const bool categorizedSorting = view - > categorizedSorting ( ) ;
view - > setCategorizedSorting ( ! categorizedSorting ) ;
2007-04-10 11:22:56 +00:00
}
2007-04-01 18:36:23 +00:00
void DolphinMainWindow : : clearInfo ( )
{
2007-06-07 21:10:48 +00:00
m_activeViewContainer - > view ( ) - > setAdditionalInfo ( KFileItemDelegate : : NoInformation ) ;
2007-04-01 18:36:23 +00:00
}
void DolphinMainWindow : : showMimeInfo ( )
{
clearStatusBar ( ) ;
2007-06-07 21:10:48 +00:00
m_activeViewContainer - > view ( ) - > setAdditionalInfo ( KFileItemDelegate : : FriendlyMimeType ) ;
2007-04-01 18:36:23 +00:00
}
void DolphinMainWindow : : showSizeInfo ( )
{
clearStatusBar ( ) ;
2007-06-07 21:10:48 +00:00
m_activeViewContainer - > view ( ) - > setAdditionalInfo ( KFileItemDelegate : : Size ) ;
2007-04-01 18:36:23 +00:00
}
void DolphinMainWindow : : showDateInfo ( )
{
clearStatusBar ( ) ;
2007-06-07 21:10:48 +00:00
m_activeViewContainer - > view ( ) - > setAdditionalInfo ( KFileItemDelegate : : ModificationTime ) ;
2007-04-01 18:36:23 +00:00
}
void DolphinMainWindow : : toggleSplitView ( )
{
2007-06-12 21:45:22 +00:00
if ( m_viewContainer [ SecondaryView ] = = 0 ) {
const int newWidth = ( m_viewContainer [ PrimaryView ] - > width ( ) - m_splitter - > handleWidth ( ) ) / 2 ;
2007-04-01 18:36:23 +00:00
// create a secondary view
2007-06-12 21:45:22 +00:00
const DolphinView * view = m_viewContainer [ PrimaryView ] - > view ( ) ;
m_viewContainer [ SecondaryView ] = new DolphinViewContainer ( this ,
2007-06-07 21:10:48 +00:00
0 ,
2007-06-19 16:35:52 +00:00
view - > rootUrl ( ) ) ;
2007-06-12 21:45:22 +00:00
connectViewSignals ( SecondaryView ) ;
m_splitter - > addWidget ( m_viewContainer [ SecondaryView ] ) ;
2007-04-01 18:36:23 +00:00
m_splitter - > setSizes ( QList < int > ( ) < < newWidth < < newWidth ) ;
2007-06-12 21:45:22 +00:00
m_viewContainer [ SecondaryView ] - > view ( ) - > reload ( ) ;
m_viewContainer [ SecondaryView ] - > setActive ( false ) ;
m_viewContainer [ SecondaryView ] - > show ( ) ;
2007-04-09 19:12:54 +00:00
} else {
2007-04-01 18:36:23 +00:00
// remove secondary view
2007-06-12 21:45:22 +00:00
m_viewContainer [ SecondaryView ] - > close ( ) ;
m_viewContainer [ SecondaryView ] - > deleteLater ( ) ;
m_viewContainer [ SecondaryView ] = 0 ;
2007-04-01 18:36:23 +00:00
}
2007-06-07 21:41:22 +00:00
2007-06-12 21:45:22 +00:00
setActiveViewContainer ( m_viewContainer [ PrimaryView ] ) ;
2007-06-07 21:41:22 +00:00
updateViewActions ( ) ;
2007-04-01 18:36:23 +00:00
emit activeViewChanged ( ) ;
}
void DolphinMainWindow : : reloadView ( )
{
clearStatusBar ( ) ;
2007-06-07 21:10:48 +00:00
m_activeViewContainer - > view ( ) - > reload ( ) ;
2007-04-01 18:36:23 +00:00
}
void DolphinMainWindow : : stopLoading ( )
2007-06-12 21:45:22 +00:00
{
}
2007-04-01 18:36:23 +00:00
void DolphinMainWindow : : togglePreview ( )
{
clearStatusBar ( ) ;
const KToggleAction * showPreviewAction =
static_cast < KToggleAction * > ( actionCollection ( ) - > action ( " show_preview " ) ) ;
const bool show = showPreviewAction - > isChecked ( ) ;
2007-06-07 21:10:48 +00:00
m_activeViewContainer - > view ( ) - > setShowPreview ( show ) ;
2007-04-01 18:36:23 +00:00
}
void DolphinMainWindow : : toggleShowHiddenFiles ( )
{
clearStatusBar ( ) ;
const KToggleAction * showHiddenFilesAction =
static_cast < KToggleAction * > ( actionCollection ( ) - > action ( " show_hidden_files " ) ) ;
const bool show = showHiddenFilesAction - > isChecked ( ) ;
2007-06-07 21:10:48 +00:00
m_activeViewContainer - > view ( ) - > setShowHiddenFiles ( show ) ;
2007-04-01 18:36:23 +00:00
}
2007-05-06 21:50:24 +00:00
void DolphinMainWindow : : toggleFilterBarVisibility ( )
2007-04-01 18:36:23 +00:00
{
const KToggleAction * showFilterBarAction =
static_cast < KToggleAction * > ( actionCollection ( ) - > action ( " show_filter_bar " ) ) ;
const bool show = showFilterBarAction - > isChecked ( ) ;
2007-06-07 21:10:48 +00:00
m_activeViewContainer - > showFilterBar ( show ) ;
2007-04-01 18:36:23 +00:00
}
void DolphinMainWindow : : zoomIn ( )
{
2007-06-07 21:10:48 +00:00
m_activeViewContainer - > view ( ) - > zoomIn ( ) ;
2007-04-01 18:36:23 +00:00
updateViewActions ( ) ;
}
void DolphinMainWindow : : zoomOut ( )
{
2007-06-07 21:10:48 +00:00
m_activeViewContainer - > view ( ) - > zoomOut ( ) ;
2007-04-01 18:36:23 +00:00
updateViewActions ( ) ;
}
void DolphinMainWindow : : toggleEditLocation ( )
{
clearStatusBar ( ) ;
KToggleAction * action = static_cast < KToggleAction * > ( actionCollection ( ) - > action ( " editable_location " ) ) ;
bool editOrBrowse = action - > isChecked ( ) ;
2007-06-07 21:10:48 +00:00
KUrlNavigator * urlNavigator = m_activeViewContainer - > urlNavigator ( ) ;
urlNavigator - > setUrlEditable ( editOrBrowse ) ;
2007-04-01 18:36:23 +00:00
}
void DolphinMainWindow : : editLocation ( )
{
2007-06-07 21:10:48 +00:00
m_activeViewContainer - > urlNavigator ( ) - > setUrlEditable ( true ) ;
2007-04-01 18:36:23 +00:00
}
void DolphinMainWindow : : adjustViewProperties ( )
{
clearStatusBar ( ) ;
2007-06-07 21:10:48 +00:00
ViewPropertiesDialog dlg ( m_activeViewContainer - > view ( ) ) ;
2007-04-01 18:36:23 +00:00
dlg . exec ( ) ;
}
void DolphinMainWindow : : goBack ( )
{
clearStatusBar ( ) ;
2007-06-07 21:10:48 +00:00
m_activeViewContainer - > urlNavigator ( ) - > goBack ( ) ;
2007-04-01 18:36:23 +00:00
}
void DolphinMainWindow : : goForward ( )
{
clearStatusBar ( ) ;
2007-06-07 21:10:48 +00:00
m_activeViewContainer - > urlNavigator ( ) - > goForward ( ) ;
2007-04-01 18:36:23 +00:00
}
void DolphinMainWindow : : goUp ( )
{
clearStatusBar ( ) ;
2007-06-07 21:10:48 +00:00
m_activeViewContainer - > urlNavigator ( ) - > goUp ( ) ;
2007-04-01 18:36:23 +00:00
}
void DolphinMainWindow : : goHome ( )
{
clearStatusBar ( ) ;
2007-06-07 21:10:48 +00:00
m_activeViewContainer - > urlNavigator ( ) - > goHome ( ) ;
2007-04-01 18:36:23 +00:00
}
void DolphinMainWindow : : findFile ( )
{
2007-06-07 21:10:48 +00:00
KRun : : run ( " kfind " , m_activeViewContainer - > url ( ) , this ) ;
2007-04-01 18:36:23 +00:00
}
void DolphinMainWindow : : compareFiles ( )
{
// The method is only invoked if exactly 2 files have
// been selected. The selected files may be:
// - both in the primary view
// - both in the secondary view
// - one in the primary view and the other in the secondary
// view
2007-06-12 21:45:22 +00:00
Q_ASSERT ( m_viewContainer [ PrimaryView ] ! = 0 ) ;
2007-04-01 18:36:23 +00:00
KUrl urlA ;
KUrl urlB ;
2007-06-12 21:45:22 +00:00
KUrl : : List urls = m_viewContainer [ PrimaryView ] - > view ( ) - > selectedUrls ( ) ;
2007-04-01 18:36:23 +00:00
switch ( urls . count ( ) ) {
2007-04-09 19:12:54 +00:00
case 0 : {
2007-06-12 21:45:22 +00:00
Q_ASSERT ( m_viewContainer [ SecondaryView ] ! = 0 ) ;
urls = m_viewContainer [ SecondaryView ] - > view ( ) - > selectedUrls ( ) ;
2007-04-09 19:12:54 +00:00
Q_ASSERT ( urls . count ( ) = = 2 ) ;
urlA = urls [ 0 ] ;
urlB = urls [ 1 ] ;
break ;
}
2007-04-01 18:36:23 +00:00
2007-04-09 19:12:54 +00:00
case 1 : {
urlA = urls [ 0 ] ;
2007-06-12 21:45:22 +00:00
Q_ASSERT ( m_viewContainer [ SecondaryView ] ! = 0 ) ;
urls = m_viewContainer [ SecondaryView ] - > view ( ) - > selectedUrls ( ) ;
2007-04-09 19:12:54 +00:00
Q_ASSERT ( urls . count ( ) = = 1 ) ;
urlB = urls [ 0 ] ;
break ;
}
2007-04-01 18:36:23 +00:00
2007-04-09 19:12:54 +00:00
case 2 : {
urlA = urls [ 0 ] ;
urlB = urls [ 1 ] ;
break ;
}
2007-04-01 18:36:23 +00:00
2007-04-09 19:12:54 +00:00
default : {
// may not happen: compareFiles may only get invoked if 2
// files are selected
Q_ASSERT ( false ) ;
}
2007-04-01 18:36:23 +00:00
}
QString command ( " kompare -c \" " ) ;
command . append ( urlA . pathOrUrl ( ) ) ;
command . append ( " \" \" " ) ;
command . append ( urlB . pathOrUrl ( ) ) ;
command . append ( ' \" ' ) ;
2007-05-07 15:10:51 +00:00
KRun : : runCommand ( command , " Kompare " , " kompare " , this ) ;
2007-04-01 18:36:23 +00:00
}
void DolphinMainWindow : : editSettings ( )
{
2007-05-05 21:02:04 +00:00
DolphinSettingsDialog dialog ( this ) ;
dialog . exec ( ) ;
2007-04-01 18:36:23 +00:00
}
void DolphinMainWindow : : init ( )
{
// Check whether Dolphin runs the first time. If yes then
// a proper default window size is given at the end of DolphinMainWindow::init().
GeneralSettings * generalSettings = DolphinSettings : : instance ( ) . generalSettings ( ) ;
const bool firstRun = generalSettings - > firstRun ( ) ;
if ( firstRun ) {
generalSettings - > setViewPropsTimestamp ( QDateTime : : currentDateTime ( ) ) ;
}
setAcceptDrops ( true ) ;
m_splitter = new QSplitter ( this ) ;
DolphinSettings & settings = DolphinSettings : : instance ( ) ;
setupActions ( ) ;
const KUrl & homeUrl = settings . generalSettings ( ) - > homeUrl ( ) ;
setCaption ( homeUrl . fileName ( ) ) ;
ViewProperties props ( homeUrl ) ;
2007-06-12 21:45:22 +00:00
m_viewContainer [ PrimaryView ] = new DolphinViewContainer ( this ,
2007-06-19 16:35:52 +00:00
m_splitter ,
homeUrl ) ;
2007-04-01 18:36:23 +00:00
2007-06-12 21:45:22 +00:00
m_activeViewContainer = m_viewContainer [ PrimaryView ] ;
connectViewSignals ( PrimaryView ) ;
m_viewContainer [ PrimaryView ] - > view ( ) - > reload ( ) ;
m_viewContainer [ PrimaryView ] - > show ( ) ;
2007-04-01 18:36:23 +00:00
setCentralWidget ( m_splitter ) ;
setupDockWidgets ( ) ;
2007-04-09 19:12:54 +00:00
setupGUI ( Keys | Save | Create | ToolBar ) ;
2007-04-01 18:36:23 +00:00
createGUI ( ) ;
stateChanged ( " new_file " ) ;
setAutoSaveSettings ( ) ;
QClipboard * clipboard = QApplication : : clipboard ( ) ;
connect ( clipboard , SIGNAL ( dataChanged ( ) ) ,
this , SLOT ( updatePasteAction ( ) ) ) ;
updatePasteAction ( ) ;
updateGoActions ( ) ;
2007-06-20 15:46:57 +00:00
const bool split = generalSettings - > splitView ( ) ;
if ( split ) {
toggleSplitView ( ) ;
}
updateSplitAction ( split ) ;
updateViewActions ( ) ;
2007-04-01 18:36:23 +00:00
if ( firstRun ) {
// assure a proper default size if Dolphin runs the first time
2007-06-07 21:10:48 +00:00
resize ( 700 , 500 ) ;
2007-04-01 18:36:23 +00:00
}
2007-06-11 21:46:04 +00:00
# ifdef HAVE_NEPOMUK
2007-04-09 19:12:54 +00:00
if ( ! MetaDataWidget : : metaDataAvailable ( ) )
2007-06-07 21:10:48 +00:00
activeViewContainer ( ) - > statusBar ( ) - > setMessage ( i18n ( " Failed to contact Nepomuk service, annotation and tagging are disabled. " ) , DolphinStatusBar : : Error ) ;
2007-04-09 19:12:54 +00:00
# endif
2007-04-01 18:36:23 +00:00
emit urlChanged ( homeUrl ) ;
}
2007-06-12 21:45:22 +00:00
void DolphinMainWindow : : setActiveViewContainer ( DolphinViewContainer * view )
{
2007-06-27 15:15:29 +00:00
Q_ASSERT ( view ! = 0 ) ;
2007-06-12 21:45:22 +00:00
Q_ASSERT ( ( view = = m_viewContainer [ PrimaryView ] ) | | ( view = = m_viewContainer [ SecondaryView ] ) ) ;
2007-06-27 15:15:29 +00:00
if ( m_activeViewContainer = = view ) {
2007-06-12 21:45:22 +00:00
return ;
}
m_activeViewContainer - > setActive ( false ) ;
m_activeViewContainer = view ;
m_activeViewContainer - > setActive ( true ) ;
updateHistory ( ) ;
updateEditActions ( ) ;
updateViewActions ( ) ;
updateGoActions ( ) ;
2007-06-13 17:08:39 +00:00
const KUrl & url = m_activeViewContainer - > url ( ) ;
setCaption ( url . fileName ( ) ) ;
2007-06-12 21:45:22 +00:00
emit activeViewChanged ( ) ;
2007-06-13 17:08:39 +00:00
emit urlChanged ( url ) ;
2007-06-12 21:45:22 +00:00
}
2007-04-01 18:36:23 +00:00
void DolphinMainWindow : : setupActions ( )
{
// setup 'File' menu
m_newMenu = new DolphinNewMenu ( this ) ;
KMenu * menu = m_newMenu - > menu ( ) ;
2007-04-04 21:11:21 +00:00
menu - > setTitle ( i18n ( " Create New " ) ) ;
2007-04-01 18:36:23 +00:00
menu - > setIcon ( KIcon ( " document-new " ) ) ;
connect ( menu , SIGNAL ( aboutToShow ( ) ) ,
this , SLOT ( updateNewMenu ( ) ) ) ;
QAction * newWindow = actionCollection ( ) - > addAction ( " new_window " ) ;
newWindow - > setIcon ( KIcon ( " window-new " ) ) ;
newWindow - > setText ( i18n ( " New &Window " ) ) ;
newWindow - > setShortcut ( Qt : : CTRL | Qt : : Key_N ) ;
connect ( newWindow , SIGNAL ( triggered ( ) ) , this , SLOT ( openNewMainWindow ( ) ) ) ;
QAction * rename = actionCollection ( ) - > addAction ( " rename " ) ;
2007-04-04 21:11:21 +00:00
rename - > setText ( i18n ( " Rename... " ) ) ;
2007-04-01 18:36:23 +00:00
rename - > setShortcut ( Qt : : Key_F2 ) ;
connect ( rename , SIGNAL ( triggered ( ) ) , this , SLOT ( rename ( ) ) ) ;
QAction * moveToTrash = actionCollection ( ) - > addAction ( " move_to_trash " ) ;
moveToTrash - > setText ( i18n ( " Move to Trash " ) ) ;
moveToTrash - > setIcon ( KIcon ( " edit-trash " ) ) ;
moveToTrash - > setShortcut ( QKeySequence : : Delete ) ;
connect ( moveToTrash , SIGNAL ( triggered ( ) ) , this , SLOT ( moveToTrash ( ) ) ) ;
QAction * deleteAction = actionCollection ( ) - > addAction ( " delete " ) ;
deleteAction - > setText ( i18n ( " Delete " ) ) ;
deleteAction - > setShortcut ( Qt : : SHIFT | Qt : : Key_Delete ) ;
deleteAction - > setIcon ( KIcon ( " edit-delete " ) ) ;
connect ( deleteAction , SIGNAL ( triggered ( ) ) , this , SLOT ( deleteItems ( ) ) ) ;
QAction * properties = actionCollection ( ) - > addAction ( " properties " ) ;
properties - > setText ( i18n ( " Properties " ) ) ;
properties - > setShortcut ( Qt : : ALT | Qt : : Key_Return ) ;
connect ( properties , SIGNAL ( triggered ( ) ) , this , SLOT ( properties ( ) ) ) ;
KStandardAction : : quit ( this , SLOT ( quit ( ) ) , actionCollection ( ) ) ;
// setup 'Edit' menu
KStandardAction : : undo ( this ,
SLOT ( undo ( ) ) ,
actionCollection ( ) ) ;
KStandardAction : : cut ( this , SLOT ( cut ( ) ) , actionCollection ( ) ) ;
KStandardAction : : copy ( this , SLOT ( copy ( ) ) , actionCollection ( ) ) ;
KStandardAction : : paste ( this , SLOT ( paste ( ) ) , actionCollection ( ) ) ;
QAction * selectAll = actionCollection ( ) - > addAction ( " select_all " ) ;
selectAll - > setText ( i18n ( " Select All " ) ) ;
selectAll - > setShortcut ( Qt : : CTRL + Qt : : Key_A ) ;
connect ( selectAll , SIGNAL ( triggered ( ) ) , this , SLOT ( selectAll ( ) ) ) ;
QAction * invertSelection = actionCollection ( ) - > addAction ( " invert_selection " ) ;
invertSelection - > setText ( i18n ( " Invert Selection " ) ) ;
invertSelection - > setShortcut ( Qt : : CTRL | Qt : : SHIFT | Qt : : Key_A ) ;
connect ( invertSelection , SIGNAL ( triggered ( ) ) , this , SLOT ( invertSelection ( ) ) ) ;
// setup 'View' menu
KStandardAction : : zoomIn ( this ,
2007-04-09 19:12:54 +00:00
SLOT ( zoomIn ( ) ) ,
actionCollection ( ) ) ;
2007-04-01 18:36:23 +00:00
KStandardAction : : zoomOut ( this ,
2007-04-09 19:12:54 +00:00
SLOT ( zoomOut ( ) ) ,
actionCollection ( ) ) ;
2007-04-01 18:36:23 +00:00
KToggleAction * iconsView = actionCollection ( ) - > add < KToggleAction > ( " icons " ) ;
iconsView - > setText ( i18n ( " Icons " ) ) ;
iconsView - > setShortcut ( Qt : : CTRL | Qt : : Key_1 ) ;
2007-06-03 13:31:16 +00:00
iconsView - > setIcon ( KIcon ( " fileview-icon " ) ) ;
2007-04-01 18:36:23 +00:00
connect ( iconsView , SIGNAL ( triggered ( ) ) , this , SLOT ( setIconsView ( ) ) ) ;
KToggleAction * detailsView = actionCollection ( ) - > add < KToggleAction > ( " details " ) ;
detailsView - > setText ( i18n ( " Details " ) ) ;
detailsView - > setShortcut ( Qt : : CTRL | Qt : : Key_2 ) ;
2007-06-03 13:56:06 +00:00
detailsView - > setIcon ( KIcon ( " fileview-detailed " ) ) ;
2007-04-01 18:36:23 +00:00
connect ( detailsView , SIGNAL ( triggered ( ) ) , this , SLOT ( setDetailsView ( ) ) ) ;
KToggleAction * columnView = actionCollection ( ) - > add < KToggleAction > ( " columns " ) ;
columnView - > setText ( i18n ( " Columns " ) ) ;
columnView - > setShortcut ( Qt : : CTRL | Qt : : Key_3 ) ;
2007-04-16 20:08:09 +00:00
columnView - > setIcon ( KIcon ( " fileview-column " ) ) ;
2007-04-01 18:36:23 +00:00
connect ( columnView , SIGNAL ( triggered ( ) ) , this , SLOT ( setColumnView ( ) ) ) ;
QActionGroup * viewModeGroup = new QActionGroup ( this ) ;
viewModeGroup - > addAction ( iconsView ) ;
viewModeGroup - > addAction ( detailsView ) ;
viewModeGroup - > addAction ( columnView ) ;
KToggleAction * sortByName = actionCollection ( ) - > add < KToggleAction > ( " by_name " ) ;
sortByName - > setText ( i18n ( " By Name " ) ) ;
connect ( sortByName , SIGNAL ( triggered ( ) ) , this , SLOT ( sortByName ( ) ) ) ;
KToggleAction * sortBySize = actionCollection ( ) - > add < KToggleAction > ( " by_size " ) ;
sortBySize - > setText ( i18n ( " By Size " ) ) ;
connect ( sortBySize , SIGNAL ( triggered ( ) ) , this , SLOT ( sortBySize ( ) ) ) ;
KToggleAction * sortByDate = actionCollection ( ) - > add < KToggleAction > ( " by_date " ) ;
sortByDate - > setText ( i18n ( " By Date " ) ) ;
connect ( sortByDate , SIGNAL ( triggered ( ) ) , this , SLOT ( sortByDate ( ) ) ) ;
KToggleAction * sortByPermissions = actionCollection ( ) - > add < KToggleAction > ( " by_permissions " ) ;
sortByPermissions - > setText ( i18n ( " By Permissions " ) ) ;
connect ( sortByPermissions , SIGNAL ( triggered ( ) ) , this , SLOT ( sortByPermissions ( ) ) ) ;
KToggleAction * sortByOwner = actionCollection ( ) - > add < KToggleAction > ( " by_owner " ) ;
sortByOwner - > setText ( i18n ( " By Owner " ) ) ;
connect ( sortByOwner , SIGNAL ( triggered ( ) ) , this , SLOT ( sortByOwner ( ) ) ) ;
KToggleAction * sortByGroup = actionCollection ( ) - > add < KToggleAction > ( " by_group " ) ;
sortByGroup - > setText ( i18n ( " By Group " ) ) ;
connect ( sortByGroup , SIGNAL ( triggered ( ) ) , this , SLOT ( sortByGroup ( ) ) ) ;
2007-04-22 21:04:46 +00:00
KToggleAction * sortByType = actionCollection ( ) - > add < KToggleAction > ( " by_type " ) ;
sortByType - > setText ( i18n ( " By Type " ) ) ;
connect ( sortByType , SIGNAL ( triggered ( ) ) , this , SLOT ( sortByType ( ) ) ) ;
2007-06-22 10:18:46 +00:00
KToggleAction * sortByRating = actionCollection ( ) - > add < KToggleAction > ( " by_rating " ) ;
sortByRating - > setText ( i18n ( " By Rating " ) ) ;
KToggleAction * sortByTags = actionCollection ( ) - > add < KToggleAction > ( " by_tags " ) ;
sortByTags - > setText ( i18n ( " By Tags " ) ) ;
# ifdef HAVE_NEPOMUK
if ( MetaDataWidget : : metaDataAvailable ( ) ) {
connect ( sortByRating , SIGNAL ( triggered ( ) ) , this , SLOT ( sortByRating ( ) ) ) ;
connect ( sortByTags , SIGNAL ( triggered ( ) ) , this , SLOT ( sortByTags ( ) ) ) ;
}
else {
sortByRating - > setEnabled ( false ) ;
sortByTags - > setEnabled ( false ) ;
}
# else
sortByRating - > setEnabled ( false ) ;
sortByTags - > setEnabled ( false ) ;
# endif
2007-04-01 18:36:23 +00:00
QActionGroup * sortGroup = new QActionGroup ( this ) ;
sortGroup - > addAction ( sortByName ) ;
sortGroup - > addAction ( sortBySize ) ;
sortGroup - > addAction ( sortByDate ) ;
sortGroup - > addAction ( sortByPermissions ) ;
sortGroup - > addAction ( sortByOwner ) ;
sortGroup - > addAction ( sortByGroup ) ;
2007-04-22 21:04:46 +00:00
sortGroup - > addAction ( sortByType ) ;
2007-06-22 10:18:46 +00:00
sortGroup - > addAction ( sortByRating ) ;
sortGroup - > addAction ( sortByTags ) ;
2007-04-01 18:36:23 +00:00
KToggleAction * sortDescending = actionCollection ( ) - > add < KToggleAction > ( " descending " ) ;
sortDescending - > setText ( i18n ( " Descending " ) ) ;
connect ( sortDescending , SIGNAL ( triggered ( ) ) , this , SLOT ( toggleSortOrder ( ) ) ) ;
2007-06-19 16:00:21 +00:00
KToggleAction * showInGroups = actionCollection ( ) - > add < KToggleAction > ( " show_in_groups " ) ;
showInGroups - > setText ( i18n ( " Show in Groups " ) ) ;
connect ( showInGroups , SIGNAL ( triggered ( ) ) , this , SLOT ( toggleSortCategorization ( ) ) ) ;
2007-04-10 11:22:56 +00:00
2007-04-01 18:36:23 +00:00
KToggleAction * clearInfo = actionCollection ( ) - > add < KToggleAction > ( " clear_info " ) ;
clearInfo - > setText ( i18n ( " No Information " ) ) ;
connect ( clearInfo , SIGNAL ( triggered ( ) ) , this , SLOT ( clearInfo ( ) ) ) ;
KToggleAction * showMimeInfo = actionCollection ( ) - > add < KToggleAction > ( " show_mime_info " ) ;
showMimeInfo - > setText ( i18n ( " Type " ) ) ;
connect ( showMimeInfo , SIGNAL ( triggered ( ) ) , this , SLOT ( showMimeInfo ( ) ) ) ;
KToggleAction * showSizeInfo = actionCollection ( ) - > add < KToggleAction > ( " show_size_info " ) ;
showSizeInfo - > setText ( i18n ( " Size " ) ) ;
connect ( showSizeInfo , SIGNAL ( triggered ( ) ) , this , SLOT ( showSizeInfo ( ) ) ) ;
KToggleAction * showDateInfo = actionCollection ( ) - > add < KToggleAction > ( " show_date_info " ) ;
showDateInfo - > setText ( i18n ( " Date " ) ) ;
connect ( showDateInfo , SIGNAL ( triggered ( ) ) , this , SLOT ( showDateInfo ( ) ) ) ;
QActionGroup * infoGroup = new QActionGroup ( this ) ;
infoGroup - > addAction ( clearInfo ) ;
infoGroup - > addAction ( showMimeInfo ) ;
infoGroup - > addAction ( showSizeInfo ) ;
infoGroup - > addAction ( showDateInfo ) ;
KToggleAction * showPreview = actionCollection ( ) - > add < KToggleAction > ( " show_preview " ) ;
showPreview - > setText ( i18n ( " Preview " ) ) ;
2007-06-03 15:19:52 +00:00
showPreview - > setIcon ( KIcon ( " fileview-preview " ) ) ;
2007-04-01 18:36:23 +00:00
connect ( showPreview , SIGNAL ( triggered ( ) ) , this , SLOT ( togglePreview ( ) ) ) ;
KToggleAction * showHiddenFiles = actionCollection ( ) - > add < KToggleAction > ( " show_hidden_files " ) ;
showHiddenFiles - > setText ( i18n ( " Show Hidden Files " ) ) ;
showHiddenFiles - > setShortcut ( Qt : : ALT | Qt : : Key_Period ) ;
connect ( showHiddenFiles , SIGNAL ( triggered ( ) ) , this , SLOT ( toggleShowHiddenFiles ( ) ) ) ;
2007-06-03 15:50:52 +00:00
QAction * split = actionCollection ( ) - > addAction ( " split_view " ) ;
2007-04-01 18:36:23 +00:00
split - > setShortcut ( Qt : : Key_F10 ) ;
2007-06-03 14:07:45 +00:00
updateSplitAction ( false ) ;
2007-04-01 18:36:23 +00:00
connect ( split , SIGNAL ( triggered ( ) ) , this , SLOT ( toggleSplitView ( ) ) ) ;
QAction * reload = actionCollection ( ) - > addAction ( " reload " ) ;
reload - > setText ( i18n ( " Reload " ) ) ;
reload - > setShortcut ( Qt : : Key_F5 ) ;
reload - > setIcon ( KIcon ( " view-refresh " ) ) ;
connect ( reload , SIGNAL ( triggered ( ) ) , this , SLOT ( reloadView ( ) ) ) ;
QAction * stop = actionCollection ( ) - > addAction ( " stop " ) ;
stop - > setText ( i18n ( " Stop " ) ) ;
stop - > setIcon ( KIcon ( " process-stop " ) ) ;
connect ( stop , SIGNAL ( triggered ( ) ) , this , SLOT ( stopLoading ( ) ) ) ;
// TODO: the URL navigator must emit a signal if the editable state has been
// changed, so that the corresponding showFullLocation action is updated. Also
// the naming "Show full Location" is currently confusing...
KToggleAction * showFullLocation = actionCollection ( ) - > add < KToggleAction > ( " editable_location " ) ;
showFullLocation - > setText ( i18n ( " Show Full Location " ) ) ;
showFullLocation - > setShortcut ( Qt : : CTRL | Qt : : Key_L ) ;
connect ( showFullLocation , SIGNAL ( triggered ( ) ) , this , SLOT ( toggleEditLocation ( ) ) ) ;
QAction * editLocation = actionCollection ( ) - > addAction ( " edit_location " ) ;
editLocation - > setText ( i18n ( " Edit Location " ) ) ;
editLocation - > setShortcut ( Qt : : Key_F6 ) ;
connect ( editLocation , SIGNAL ( triggered ( ) ) , this , SLOT ( editLocation ( ) ) ) ;
QAction * adjustViewProps = actionCollection ( ) - > addAction ( " view_properties " ) ;
adjustViewProps - > setText ( i18n ( " Adjust View Properties... " ) ) ;
connect ( adjustViewProps , SIGNAL ( triggered ( ) ) , this , SLOT ( adjustViewProperties ( ) ) ) ;
// setup 'Go' menu
KStandardAction : : back ( this , SLOT ( goBack ( ) ) , actionCollection ( ) ) ;
KStandardAction : : forward ( this , SLOT ( goForward ( ) ) , actionCollection ( ) ) ;
KStandardAction : : up ( this , SLOT ( goUp ( ) ) , actionCollection ( ) ) ;
KStandardAction : : home ( this , SLOT ( goHome ( ) ) , actionCollection ( ) ) ;
// setup 'Tools' menu
QAction * findFile = actionCollection ( ) - > addAction ( " find_file " ) ;
findFile - > setText ( i18n ( " Find File... " ) ) ;
2007-04-14 17:21:53 +00:00
findFile - > setShortcut ( Qt : : CTRL | Qt : : Key_F ) ;
2007-04-01 18:36:23 +00:00
findFile - > setIcon ( KIcon ( " file-find " ) ) ;
connect ( findFile , SIGNAL ( triggered ( ) ) , this , SLOT ( findFile ( ) ) ) ;
KToggleAction * showFilterBar = actionCollection ( ) - > add < KToggleAction > ( " show_filter_bar " ) ;
showFilterBar - > setText ( i18n ( " Show Filter Bar " ) ) ;
2007-05-07 05:33:20 +00:00
showFilterBar - > setShortcut ( Qt : : CTRL | Qt : : Key_I ) ;
2007-05-06 21:50:24 +00:00
connect ( showFilterBar , SIGNAL ( triggered ( ) ) , this , SLOT ( toggleFilterBarVisibility ( ) ) ) ;
2007-04-01 18:36:23 +00:00
QAction * compareFiles = actionCollection ( ) - > addAction ( " compare_files " ) ;
compareFiles - > setText ( i18n ( " Compare Files " ) ) ;
compareFiles - > setIcon ( KIcon ( " kompare " ) ) ;
compareFiles - > setEnabled ( false ) ;
connect ( compareFiles , SIGNAL ( triggered ( ) ) , this , SLOT ( compareFiles ( ) ) ) ;
// setup 'Settings' menu
KStandardAction : : preferences ( this , SLOT ( editSettings ( ) ) , actionCollection ( ) ) ;
}
void DolphinMainWindow : : setupDockWidgets ( )
{
// setup "Information"
2007-04-13 14:44:18 +00:00
QDockWidget * infoDock = new QDockWidget ( i18n ( " Information " ) ) ;
2007-04-01 18:36:23 +00:00
infoDock - > setObjectName ( " infoDock " ) ;
infoDock - > setAllowedAreas ( Qt : : LeftDockWidgetArea | Qt : : RightDockWidgetArea ) ;
SidebarPage * infoWidget = new InfoSidebarPage ( infoDock ) ;
infoDock - > setWidget ( infoWidget ) ;
2007-05-06 21:50:24 +00:00
infoDock - > toggleViewAction ( ) - > setText ( i18n ( " Information " ) ) ;
2007-04-01 18:36:23 +00:00
actionCollection ( ) - > addAction ( " show_info_panel " , infoDock - > toggleViewAction ( ) ) ;
addDockWidget ( Qt : : RightDockWidgetArea , infoDock ) ;
2007-05-02 05:15:03 +00:00
connect ( this , SIGNAL ( urlChanged ( KUrl ) ) ,
infoWidget , SLOT ( setUrl ( KUrl ) ) ) ;
2007-05-03 05:52:54 +00:00
connect ( this , SIGNAL ( selectionChanged ( KFileItemList ) ) ,
infoWidget , SLOT ( setSelection ( KFileItemList ) ) ) ;
2007-05-17 14:51:54 +00:00
connect ( this , SIGNAL ( requestItemInfo ( KUrl ) ) ,
infoWidget , SLOT ( requestDelayedItemInfo ( KUrl ) ) ) ;
2007-04-01 18:36:23 +00:00
// setup "Tree View"
2007-04-14 16:50:51 +00:00
QDockWidget * treeViewDock = new QDockWidget ( i18n ( " Folders " ) ) ;
2007-04-01 18:36:23 +00:00
treeViewDock - > setObjectName ( " treeViewDock " ) ;
treeViewDock - > setAllowedAreas ( Qt : : LeftDockWidgetArea | Qt : : RightDockWidgetArea ) ;
TreeViewSidebarPage * treeWidget = new TreeViewSidebarPage ( treeViewDock ) ;
treeViewDock - > setWidget ( treeWidget ) ;
2007-05-06 21:50:24 +00:00
treeViewDock - > toggleViewAction ( ) - > setText ( i18n ( " Folders " ) ) ;
2007-04-01 18:36:23 +00:00
actionCollection ( ) - > addAction ( " show_folders_panel " , treeViewDock - > toggleViewAction ( ) ) ;
addDockWidget ( Qt : : LeftDockWidgetArea , treeViewDock ) ;
2007-05-02 05:15:03 +00:00
connect ( this , SIGNAL ( urlChanged ( KUrl ) ) ,
treeWidget , SLOT ( setUrl ( KUrl ) ) ) ;
connect ( treeWidget , SIGNAL ( changeUrl ( KUrl ) ) ,
this , SLOT ( changeUrl ( KUrl ) ) ) ;
connect ( treeWidget , SIGNAL ( changeSelection ( KFileItemList ) ) ,
this , SLOT ( changeSelection ( KFileItemList ) ) ) ;
connect ( treeWidget , SIGNAL ( urlsDropped ( KUrl : : List , KUrl ) ) ,
this , SLOT ( dropUrls ( KUrl : : List , KUrl ) ) ) ;
2007-04-01 18:36:23 +00:00
2007-05-06 21:50:24 +00:00
// setup "Terminal"
QDockWidget * terminalDock = new QDockWidget ( i18n ( " Terminal " ) ) ;
terminalDock - > setObjectName ( " terminalDock " ) ;
terminalDock - > setAllowedAreas ( Qt : : TopDockWidgetArea | Qt : : BottomDockWidgetArea ) ;
SidebarPage * terminalWidget = new TerminalSidebarPage ( terminalDock ) ;
terminalDock - > setWidget ( terminalWidget ) ;
terminalDock - > toggleViewAction ( ) - > setText ( i18n ( " Terminal " ) ) ;
actionCollection ( ) - > addAction ( " show_terminal_panel " , terminalDock - > toggleViewAction ( ) ) ;
addDockWidget ( Qt : : RightDockWidgetArea , terminalDock ) ;
connect ( this , SIGNAL ( urlChanged ( KUrl ) ) ,
terminalWidget , SLOT ( setUrl ( KUrl ) ) ) ;
2007-04-01 18:36:23 +00:00
const bool firstRun = DolphinSettings : : instance ( ) . generalSettings ( ) - > firstRun ( ) ;
if ( firstRun ) {
2007-04-22 21:27:40 +00:00
infoDock - > hide ( ) ;
2007-04-01 18:36:23 +00:00
treeViewDock - > hide ( ) ;
2007-05-06 21:50:24 +00:00
terminalDock - > hide ( ) ;
2007-04-01 18:36:23 +00:00
}
2007-04-01 22:28:03 +00:00
QDockWidget * placesDock = new QDockWidget ( i18n ( " Places " ) ) ;
placesDock - > setObjectName ( " placesDock " ) ;
placesDock - > setAllowedAreas ( Qt : : LeftDockWidgetArea | Qt : : RightDockWidgetArea ) ;
2007-04-02 08:51:57 +00:00
KFilePlacesView * listView = new KFilePlacesView ( placesDock ) ;
2007-04-01 22:28:03 +00:00
placesDock - > setWidget ( listView ) ;
2007-04-09 09:16:39 +00:00
listView - > setModel ( DolphinSettings : : instance ( ) . placesModel ( ) ) ;
2007-04-14 16:50:51 +00:00
placesDock - > toggleViewAction ( ) - > setText ( i18n ( " Show Places Panel " ) ) ;
actionCollection ( ) - > addAction ( " show_places_panel " , placesDock - > toggleViewAction ( ) ) ;
2007-04-01 22:28:03 +00:00
addDockWidget ( Qt : : LeftDockWidgetArea , placesDock ) ;
2007-04-02 08:51:57 +00:00
connect ( listView , SIGNAL ( urlChanged ( KUrl ) ) ,
this , SLOT ( changeUrl ( KUrl ) ) ) ;
connect ( this , SIGNAL ( urlChanged ( KUrl ) ) ,
listView , SLOT ( setUrl ( KUrl ) ) ) ;
2007-04-01 18:36:23 +00:00
}
void DolphinMainWindow : : updateHistory ( )
{
2007-06-07 21:10:48 +00:00
const KUrlNavigator * urlNavigator = m_activeViewContainer - > urlNavigator ( ) ;
2007-04-08 21:07:41 +00:00
const int index = urlNavigator - > historyIndex ( ) ;
2007-04-01 18:36:23 +00:00
QAction * backAction = actionCollection ( ) - > action ( " go_back " ) ;
if ( backAction ! = 0 ) {
2007-04-08 21:07:41 +00:00
backAction - > setEnabled ( index < urlNavigator - > historySize ( ) - 1 ) ;
2007-04-01 18:36:23 +00:00
}
QAction * forwardAction = actionCollection ( ) - > action ( " go_forward " ) ;
if ( forwardAction ! = 0 ) {
forwardAction - > setEnabled ( index > 0 ) ;
}
}
void DolphinMainWindow : : updateEditActions ( )
{
2007-06-07 21:10:48 +00:00
const KFileItemList list = m_activeViewContainer - > view ( ) - > selectedItems ( ) ;
2007-04-01 18:36:23 +00:00
if ( list . isEmpty ( ) ) {
stateChanged ( " has_no_selection " ) ;
2007-04-09 19:12:54 +00:00
} else {
2007-04-01 18:36:23 +00:00
stateChanged ( " has_selection " ) ;
QAction * renameAction = actionCollection ( ) - > action ( " rename " ) ;
if ( renameAction ! = 0 ) {
renameAction - > setEnabled ( list . count ( ) > = 1 ) ;
}
bool enableMoveToTrash = true ;
KFileItemList : : const_iterator it = list . begin ( ) ;
const KFileItemList : : const_iterator end = list . end ( ) ;
while ( it ! = end ) {
KFileItem * item = * it ;
const KUrl & url = item - > url ( ) ;
// only enable the 'Move to Trash' action for local files
if ( ! url . isLocalFile ( ) ) {
enableMoveToTrash = false ;
}
+ + it ;
}
QAction * moveToTrashAction = actionCollection ( ) - > action ( " move_to_trash " ) ;
moveToTrashAction - > setEnabled ( enableMoveToTrash ) ;
}
updatePasteAction ( ) ;
}
void DolphinMainWindow : : updateViewActions ( )
{
2007-06-07 21:10:48 +00:00
const DolphinView * view = m_activeViewContainer - > view ( ) ;
2007-04-01 18:36:23 +00:00
QAction * zoomInAction = actionCollection ( ) - > action ( KStandardAction : : stdName ( KStandardAction : : ZoomIn ) ) ;
if ( zoomInAction ! = 0 ) {
2007-06-07 21:10:48 +00:00
zoomInAction - > setEnabled ( view - > isZoomInPossible ( ) ) ;
2007-04-01 18:36:23 +00:00
}
QAction * zoomOutAction = actionCollection ( ) - > action ( KStandardAction : : stdName ( KStandardAction : : ZoomOut ) ) ;
if ( zoomOutAction ! = 0 ) {
2007-06-07 21:10:48 +00:00
zoomOutAction - > setEnabled ( view - > isZoomOutPossible ( ) ) ;
2007-04-01 18:36:23 +00:00
}
QAction * action = 0 ;
2007-06-07 21:10:48 +00:00
switch ( view - > mode ( ) ) {
2007-04-09 19:12:54 +00:00
case DolphinView : : IconsView :
action = actionCollection ( ) - > action ( " icons " ) ;
break ;
case DolphinView : : DetailsView :
action = actionCollection ( ) - > action ( " details " ) ;
break ;
case DolphinView : : ColumnView :
action = actionCollection ( ) - > action ( " columns " ) ;
break ;
default :
break ;
2007-04-01 18:36:23 +00:00
}
if ( action ! = 0 ) {
KToggleAction * toggleAction = static_cast < KToggleAction * > ( action ) ;
toggleAction - > setChecked ( true ) ;
}
2007-06-07 21:10:48 +00:00
slotSortingChanged ( view - > sorting ( ) ) ;
slotSortOrderChanged ( view - > sortOrder ( ) ) ;
2007-04-10 11:22:56 +00:00
slotCategorizedSortingChanged ( ) ;
2007-06-07 21:10:48 +00:00
slotAdditionalInfoChanged ( view - > additionalInfo ( ) ) ;
2007-04-01 18:36:23 +00:00
KToggleAction * showFilterBarAction =
static_cast < KToggleAction * > ( actionCollection ( ) - > action ( " show_filter_bar " ) ) ;
2007-06-07 21:10:48 +00:00
showFilterBarAction - > setChecked ( m_activeViewContainer - > isFilterBarVisible ( ) ) ;
2007-04-01 18:36:23 +00:00
KToggleAction * showPreviewAction =
static_cast < KToggleAction * > ( actionCollection ( ) - > action ( " show_preview " ) ) ;
2007-06-07 21:10:48 +00:00
showPreviewAction - > setChecked ( view - > showPreview ( ) ) ;
2007-04-01 18:36:23 +00:00
KToggleAction * showHiddenFilesAction =
static_cast < KToggleAction * > ( actionCollection ( ) - > action ( " show_hidden_files " ) ) ;
2007-06-07 21:10:48 +00:00
showHiddenFilesAction - > setChecked ( view - > showHiddenFiles ( ) ) ;
2007-04-01 18:36:23 +00:00
2007-06-12 21:45:22 +00:00
updateSplitAction ( m_viewContainer [ SecondaryView ] ! = 0 ) ;
2007-04-01 18:36:23 +00:00
KToggleAction * editableLocactionAction =
static_cast < KToggleAction * > ( actionCollection ( ) - > action ( " editable_location " ) ) ;
2007-06-07 21:10:48 +00:00
const KUrlNavigator * urlNavigator = m_activeViewContainer - > urlNavigator ( ) ;
editableLocactionAction - > setChecked ( urlNavigator - > isUrlEditable ( ) ) ;
2007-04-01 18:36:23 +00:00
}
void DolphinMainWindow : : updateGoActions ( )
{
QAction * goUpAction = actionCollection ( ) - > action ( KStandardAction : : stdName ( KStandardAction : : Up ) ) ;
2007-06-07 21:10:48 +00:00
const KUrl & currentUrl = m_activeViewContainer - > url ( ) ;
2007-04-01 18:36:23 +00:00
goUpAction - > setEnabled ( currentUrl . upUrl ( ) ! = currentUrl ) ;
}
void DolphinMainWindow : : copyUrls ( const KUrl : : List & source , const KUrl & dest )
{
KonqOperations : : copy ( this , KonqOperations : : COPY , source , dest ) ;
m_undoCommandTypes . append ( KonqUndoManager : : COPY ) ;
}
void DolphinMainWindow : : moveUrls ( const KUrl : : List & source , const KUrl & dest )
{
KonqOperations : : copy ( this , KonqOperations : : MOVE , source , dest ) ;
m_undoCommandTypes . append ( KonqUndoManager : : MOVE ) ;
}
void DolphinMainWindow : : linkUrls ( const KUrl : : List & source , const KUrl & dest )
{
KonqOperations : : copy ( this , KonqOperations : : LINK , source , dest ) ;
m_undoCommandTypes . append ( KonqUndoManager : : LINK ) ;
}
void DolphinMainWindow : : clearStatusBar ( )
{
2007-06-07 21:10:48 +00:00
m_activeViewContainer - > statusBar ( ) - > clear ( ) ;
2007-04-01 18:36:23 +00:00
}
void DolphinMainWindow : : connectViewSignals ( int viewIndex )
{
2007-06-07 21:10:48 +00:00
DolphinViewContainer * container = m_viewContainer [ viewIndex ] ;
connect ( container , SIGNAL ( showFilterBarChanged ( bool ) ) ,
this , SLOT ( updateFilterBarAction ( bool ) ) ) ;
DolphinView * view = container - > view ( ) ;
2007-04-01 18:36:23 +00:00
connect ( view , SIGNAL ( modeChanged ( ) ) ,
this , SLOT ( slotViewModeChanged ( ) ) ) ;
connect ( view , SIGNAL ( showPreviewChanged ( ) ) ,
this , SLOT ( slotShowPreviewChanged ( ) ) ) ;
connect ( view , SIGNAL ( showHiddenFilesChanged ( ) ) ,
this , SLOT ( slotShowHiddenFilesChanged ( ) ) ) ;
2007-04-10 11:22:56 +00:00
connect ( view , SIGNAL ( categorizedSortingChanged ( ) ) ,
this , SLOT ( slotCategorizedSortingChanged ( ) ) ) ;
2007-04-01 18:36:23 +00:00
connect ( view , SIGNAL ( sortingChanged ( DolphinView : : Sorting ) ) ,
this , SLOT ( slotSortingChanged ( DolphinView : : Sorting ) ) ) ;
connect ( view , SIGNAL ( sortOrderChanged ( Qt : : SortOrder ) ) ,
this , SLOT ( slotSortOrderChanged ( Qt : : SortOrder ) ) ) ;
connect ( view , SIGNAL ( additionalInfoChanged ( KFileItemDelegate : : AdditionalInformation ) ) ,
this , SLOT ( slotAdditionalInfoChanged ( KFileItemDelegate : : AdditionalInformation ) ) ) ;
connect ( view , SIGNAL ( selectionChanged ( KFileItemList ) ) ,
this , SLOT ( slotSelectionChanged ( KFileItemList ) ) ) ;
2007-05-17 14:51:54 +00:00
connect ( view , SIGNAL ( requestItemInfo ( KUrl ) ) ,
this , SLOT ( slotRequestItemInfo ( KUrl ) ) ) ;
2007-06-07 21:10:48 +00:00
connect ( view , SIGNAL ( activated ( ) ) ,
this , SLOT ( toggleActiveView ( ) ) ) ;
2007-04-01 18:36:23 +00:00
2007-06-07 21:10:48 +00:00
const KUrlNavigator * navigator = container - > urlNavigator ( ) ;
2007-04-01 18:36:23 +00:00
connect ( navigator , SIGNAL ( urlChanged ( const KUrl & ) ) ,
this , SLOT ( changeUrl ( const KUrl & ) ) ) ;
connect ( navigator , SIGNAL ( historyChanged ( ) ) ,
this , SLOT ( slotHistoryChanged ( ) ) ) ;
}
2007-04-12 17:37:53 +00:00
2007-06-03 14:07:45 +00:00
void DolphinMainWindow : : updateSplitAction ( bool isSplit )
{
2007-06-03 15:50:52 +00:00
QAction * splitAction = actionCollection ( ) - > action ( " split_view " ) ;
2007-06-03 14:07:45 +00:00
if ( isSplit ) {
splitAction - > setText ( i18n ( " Join " ) ) ;
splitAction - > setIcon ( KIcon ( " fileview-join " ) ) ;
} else {
splitAction - > setText ( i18n ( " Split " ) ) ;
splitAction - > setIcon ( KIcon ( " fileview-split " ) ) ;
}
}
2007-04-01 18:36:23 +00:00
DolphinMainWindow : : UndoUiInterface : : UndoUiInterface ( DolphinMainWindow * mainWin ) :
2007-04-12 17:37:53 +00:00
KonqUndoManager : : UiInterface ( mainWin ) ,
m_mainWin ( mainWin )
2007-04-01 18:36:23 +00:00
{
Q_ASSERT ( m_mainWin ! = 0 ) ;
}
DolphinMainWindow : : UndoUiInterface : : ~ UndoUiInterface ( )
2007-04-12 17:37:53 +00:00
{
}
2007-04-01 18:36:23 +00:00
void DolphinMainWindow : : UndoUiInterface : : jobError ( KIO : : Job * job )
{
2007-06-07 21:10:48 +00:00
DolphinStatusBar * statusBar = m_mainWin - > activeViewContainer ( ) - > statusBar ( ) ;
2007-04-01 18:36:23 +00:00
statusBar - > setMessage ( job - > errorString ( ) , DolphinStatusBar : : Error ) ;
}
# include "dolphinmainwindow.moc"