mirror of
https://invent.kde.org/system/dolphin
synced 2024-07-04 17:30:55 +00:00
Use KNewMenu instead of custom implementation of Dolphin. TODO: currently errors are indicated automatically in a message box KNewMenu. In Dolphin modal dialogs having only an "OK" button are not used -> it would be nice if Dolphin could handle the errors in a custom way.
svn path=/trunk/playground/utils/dolphin/; revision=627085
This commit is contained in:
parent
78d1167c38
commit
214ee5de3f
|
@ -36,6 +36,7 @@
|
|||
#include <kio/netaccess.h>
|
||||
#include <kmenu.h>
|
||||
#include <kmimetypetrader.h>
|
||||
#include <knewmenu.h>
|
||||
#include <klocale.h>
|
||||
#include <kpropertiesdialog.h>
|
||||
#include <krun.h>
|
||||
|
@ -69,31 +70,15 @@ DolphinContextMenu::~DolphinContextMenu()
|
|||
|
||||
void DolphinContextMenu::openViewportContextMenu()
|
||||
{
|
||||
// Parts of the following code have been taken
|
||||
// from the class KonqOperations located in
|
||||
// libqonq/konq_operations.h of Konqueror.
|
||||
// (Copyright (C) 2000 David Faure <faure@kde.org>)
|
||||
|
||||
assert(m_fileInfo == 0);
|
||||
|
||||
DolphinMainWindow* dolphin = m_dolphinView->mainWindow();
|
||||
KMenu* popup = new KMenu(m_dolphinView);
|
||||
|
||||
// setup 'Create New' menu
|
||||
KMenu* createNewMenu = new KMenu(i18n("Create New"));
|
||||
createNewMenu->setIcon(SmallIcon("filenew"));
|
||||
|
||||
QAction* createFolderAction = dolphin->actionCollection()->action("create_folder");
|
||||
if (createFolderAction != 0) {
|
||||
createNewMenu->addAction(createFolderAction);
|
||||
}
|
||||
|
||||
QLinkedListIterator<QAction*> fileGrouptIt(dolphin->fileGroupActions());
|
||||
while (fileGrouptIt.hasNext()) {
|
||||
createNewMenu->addAction(fileGrouptIt.next());
|
||||
}
|
||||
|
||||
popup->addMenu(createNewMenu);
|
||||
KNewMenu* newMenu = dolphin->newMenu();
|
||||
newMenu->slotCheckUpToDate();
|
||||
newMenu->setPopupFiles(m_dolphinView->url());
|
||||
popup->addMenu(newMenu->menu());
|
||||
popup->addSeparator();
|
||||
|
||||
QAction* pasteAction = dolphin->actionCollection()->action(KStandardAction::stdName(KStandardAction::Paste));
|
||||
|
@ -142,11 +127,6 @@ void DolphinContextMenu::openViewportContextMenu()
|
|||
|
||||
void DolphinContextMenu::openItemContextMenu()
|
||||
{
|
||||
// Parts of the following code have been taken
|
||||
// from the class KonqOperations located in
|
||||
// libkonq/konq_operations.h of Konqueror.
|
||||
// (Copyright (C) 2000 David Faure <faure@kde.org>)
|
||||
|
||||
assert(m_fileInfo != 0);
|
||||
|
||||
KMenu* popup = new KMenu(m_dolphinView);
|
||||
|
@ -246,6 +226,11 @@ void DolphinContextMenu::openItemContextMenu()
|
|||
QList<QAction*> DolphinContextMenu::insertOpenWithItems(KMenu* popup,
|
||||
QVector<KService::Ptr>& openWithVector)
|
||||
{
|
||||
// Parts of the following code have been taken
|
||||
// from the class KonqOperations located in
|
||||
// libqonq/konq_operations.h of Konqueror.
|
||||
// (Copyright (C) 2000 David Faure <faure@kde.org>)
|
||||
|
||||
// Prepare 'Open With' sub menu. Usually a sub menu is created, where all applications
|
||||
// are listed which are registered to open the item. As last entry "Other..." will be
|
||||
// attached which allows to select a custom application. If no applications are registered
|
||||
|
@ -314,6 +299,11 @@ QList<QAction*> DolphinContextMenu::insertOpenWithItems(KMenu* popup,
|
|||
QList<QAction*> DolphinContextMenu::insertActionItems(KMenu* popup,
|
||||
QVector<KDEDesktopMimeType::Service>& actionsVector)
|
||||
{
|
||||
// Parts of the following code have been taken
|
||||
// from the class KonqOperations located in
|
||||
// libqonq/konq_operations.h of Konqueror.
|
||||
// (Copyright (C) 2000 David Faure <faure@kde.org>)
|
||||
|
||||
KMenu* actionsMenu = new KMenu(i18n("Actions"));
|
||||
|
||||
QList<QAction*> serviceActions;
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -30,6 +30,7 @@
|
|||
|
||||
#include <QList>
|
||||
|
||||
class KNewMenu;
|
||||
class KPrinter;
|
||||
class KUrl;
|
||||
class QLineEdit;
|
||||
|
@ -83,19 +84,18 @@ public:
|
|||
void dropUrls(const KUrl::List& urls,
|
||||
const KUrl& destination);
|
||||
|
||||
/**
|
||||
* Returns the list of actions which are part of the file group
|
||||
* of the 'Create New...' sub menu. Usually the list contains actions
|
||||
* for creating folders, text files, HTML files etc.
|
||||
*/
|
||||
QLinkedList<QAction*> fileGroupActions() const { return m_fileGroupActions; }
|
||||
|
||||
/**
|
||||
* Refreshs the views of the main window by recreating them dependent from
|
||||
* the given Dolphin settings.
|
||||
*/
|
||||
void refreshViews();
|
||||
|
||||
/**
|
||||
* Returns the 'Create New...' sub menu which also can be shared
|
||||
* with other menus (e. g. a context menu).
|
||||
*/
|
||||
KNewMenu* newMenu() const { return m_newMenu; }
|
||||
|
||||
signals:
|
||||
/**
|
||||
* Is send if the active view has been changed in
|
||||
|
@ -127,11 +127,8 @@ protected:
|
|||
void readProperties(KConfig*);
|
||||
|
||||
private slots:
|
||||
/** Opens an input dialog for creating a new folder. */
|
||||
void createFolder();
|
||||
|
||||
/** Creates a file with the MIME type given by the sender. */
|
||||
void createFile();
|
||||
/** Updates the 'Create New...' sub menu. */
|
||||
void updateNewMenu();
|
||||
|
||||
/** Renames the selected item of the active view. */
|
||||
void rename();
|
||||
|
@ -353,7 +350,6 @@ private:
|
|||
void setupAccel();
|
||||
void setupActions();
|
||||
void setupDockWidgets();
|
||||
void setupCreateNewMenuActions();
|
||||
void updateHistory();
|
||||
void updateEditActions();
|
||||
void updateViewActions();
|
||||
|
@ -371,6 +367,7 @@ private:
|
|||
void connectViewSignals(int viewIndex);
|
||||
|
||||
private:
|
||||
KNewMenu* m_newMenu;
|
||||
QSplitter* m_splitter;
|
||||
DolphinView* m_activeView;
|
||||
|
||||
|
@ -400,9 +397,6 @@ private:
|
|||
QString icon;
|
||||
QString comment;
|
||||
};
|
||||
|
||||
QLinkedList<QAction*> m_fileGroupActions;
|
||||
KSortableList<CreateFileEntry,QString> m_createFileTemplates;
|
||||
};
|
||||
|
||||
#endif // _DOLPHIN_H_
|
||||
|
|
|
@ -2,13 +2,8 @@
|
|||
<kpartgui version="2" name="dolphin" >
|
||||
<MenuBar>
|
||||
<Menu name="file">
|
||||
<Action name="create_new" />
|
||||
<Action name="new_window" />
|
||||
<Menu name="create_new" >
|
||||
<text>Create New</text>
|
||||
<Action name="create_folder" />
|
||||
<Separator/>
|
||||
<ActionList name="create_file_group" />
|
||||
</Menu>
|
||||
<Separator/>
|
||||
<Action name="rename" />
|
||||
<Action name="move_to_trash" />
|
||||
|
|
|
@ -555,25 +555,9 @@ void DolphinView::reload()
|
|||
startDirLister(m_urlNavigator->url(), true);
|
||||
}
|
||||
|
||||
void DolphinView::slotUrlListDropped(QDropEvent* /* event */,
|
||||
const KUrl::List& urls,
|
||||
const KUrl& url)
|
||||
void DolphinView::declareViewActive()
|
||||
{
|
||||
KUrl destination(url);
|
||||
if (destination.isEmpty()) {
|
||||
destination = m_urlNavigator->url();
|
||||
}
|
||||
else {
|
||||
// Check whether the destination Url is a directory. If this is not the
|
||||
// case, use the navigator Url as destination (otherwise the destination,
|
||||
// which represents a file, would be replaced by a copy- or move-operation).
|
||||
KFileItem fileItem(KFileItem::Unknown, KFileItem::Unknown, destination);
|
||||
if (!fileItem.isDir()) {
|
||||
destination = m_urlNavigator->url();
|
||||
}
|
||||
}
|
||||
|
||||
mainWindow()->dropUrls(urls, destination);
|
||||
mainWindow()->setActiveView( this );
|
||||
}
|
||||
|
||||
void DolphinView::mouseReleaseEvent(QMouseEvent* event)
|
||||
|
@ -833,11 +817,6 @@ void DolphinView::showFilterBar(bool show)
|
|||
}
|
||||
}
|
||||
|
||||
void DolphinView::declareViewActive()
|
||||
{
|
||||
mainWindow()->setActiveView( this );
|
||||
}
|
||||
|
||||
void DolphinView::updateStatusBar()
|
||||
{
|
||||
// As the item count information is less important
|
||||
|
|
|
@ -324,22 +324,20 @@ public:
|
|||
*/
|
||||
DolphinMainWindow* mainWindow() const ;
|
||||
|
||||
public slots:
|
||||
/** Reloads the current directory. */
|
||||
void reload();
|
||||
void slotUrlListDropped(QDropEvent* event,
|
||||
const KUrl::List& urls,
|
||||
const KUrl& url);
|
||||
|
||||
/**
|
||||
* Popups the filter bar above the status bar if \a show is true.
|
||||
*/
|
||||
void showFilterBar(bool show);
|
||||
|
||||
/**
|
||||
* Declare this View as the activeview of the mainWindow()
|
||||
*/
|
||||
void declareViewActive();
|
||||
|
||||
public slots:
|
||||
/**
|
||||
* Popups the filter bar above the status bar if \a show is true.
|
||||
*/
|
||||
void showFilterBar(bool show);
|
||||
|
||||
/**
|
||||
* Updates the number of items (= number of files + number of
|
||||
* directories) in the statusbar. If files are selected, the number
|
||||
|
@ -473,7 +471,7 @@ private:
|
|||
DolphinIconsView* m_iconsView;
|
||||
DolphinDetailsView* m_detailsView;
|
||||
|
||||
FilterBar *m_filterBar;
|
||||
FilterBar* m_filterBar;
|
||||
DolphinStatusBar* m_statusBar;
|
||||
|
||||
KDirModel* m_dirModel;
|
||||
|
|
Loading…
Reference in New Issue
Block a user