#include <kfiledialog.h>
#include <kconfig.h>
#include <kurl.h>
-#include <kstdaccel.h>
#include <kaction.h>
-#include <kstdaction.h>
+#include <kstandardaction.h>
#include <kmenu.h>
-#include <kio/renamedlg.h>
+#include <kio/renamedialog.h>
#include <kinputdialog.h>
#include <kshell.h>
#include <kdesktopfile.h>
}
void DolphinMainWindow::dropUrls(const KUrl::List& urls,
- const KUrl& destination)
+ const KUrl& destination)
{
- int selectedIndex = -1;
+ m_dropDestination = destination;
+ m_droppedUrls = urls;
/* KDE4-TODO
const ButtonState keyboardState = KApplication::keyboardMouseState();
// no shortcut is used, hence open a popup menu
KMenu popup(this);
- popup.insertItem(SmallIcon("goto"), i18n("&Move Here") + "\t" /* KDE4-TODO: + KKey::modFlagLabel(KKey::SHIFT)*/, 0);
- popup.insertItem(SmallIcon("editcopy"), i18n( "&Copy Here" ) /* KDE4-TODO + "\t" + KKey::modFlagLabel(KKey::CTRL)*/, 1);
- popup.insertItem(i18n("&Link Here") /* KDE4-TODO + "\t" + KKey::modFlagLabel((KKey::ModFlag)(KKey::CTRL|KKey::SHIFT)) */, 2);
- popup.insertSeparator();
- popup.insertItem(SmallIcon("stop"), i18n("Cancel"), 3);
- popup.setAccel(i18n("Escape"), 3);
+ QAction* moveAction = popup.addAction(SmallIcon("goto"), i18n("&Move Here"));
+ connect(moveAction, SIGNAL(triggered()), this, SLOT(moveDroppedItems()));
- /* KDE4-TODO: selectedIndex = popup.exec(QCursor::pos()); */
- popup.exec(QCursor::pos());
- selectedIndex = 0; // KD4-TODO: use QAction instead of switch below
- // See libkonq/konq_operations.cc: KonqOperations::doDropFileCopy() (and doDrop, the main method)
- }
-
- if (selectedIndex < 0) {
- return;
- }
+ QAction* copyAction = popup.addAction(SmallIcon("editcopy"), i18n( "&Copy Here" ));
+ connect(copyAction, SIGNAL(triggered()), this, SLOT(copyDroppedItems()));
- switch (selectedIndex) {
- case 0: {
- // 'Move Here' has been selected
- updateViewProperties(urls);
- moveUrls(urls, destination);
- break;
- }
-
- case 1: {
- // 'Copy Here' has been selected
- updateViewProperties(urls);
- copyUrls(urls, destination);
- break;
- }
+ QAction* linkAction = popup.addAction(i18n("&Link Here"));
+ connect(linkAction, SIGNAL(triggered()), this, SLOT(linkDroppedItems()));
- case 2: {
- // 'Link Here' has been selected
- KIO::Job* job = KIO::link(urls, destination);
- addPendingUndoJob(job, DolphinCommand::Link, urls, destination);
- break;
- }
+ QAction* cancelAction = popup.addAction(SmallIcon("stop"), i18n("Cancel"));
+ popup.insertSeparator(cancelAction);
- default:
- // 'Cancel' has been selected
- break;
+ popup.exec(QCursor::pos());
}
+
+ m_droppedUrls.clear();
}
void DolphinMainWindow::refreshViews()
DolphinApplication::app()->createMainWindow()->show();
}
+void DolphinMainWindow::moveDroppedItems()
+{
+ moveUrls(m_droppedUrls, m_dropDestination);
+}
+
+void DolphinMainWindow::copyDroppedItems()
+{
+ copyUrls(m_droppedUrls, m_dropDestination);
+}
+
+void DolphinMainWindow::linkDroppedItems()
+{
+ KIO::Job* job = KIO::link(m_droppedUrls, m_dropDestination);
+ addPendingUndoJob(job, DolphinCommand::Link, m_droppedUrls, m_dropDestination);
+}
+
void DolphinMainWindow::closeEvent(QCloseEvent* event)
{
// KDE4-TODO
if (baseUrl.isLocalFile() && QFileInfo(baseUrl.path(KUrl::AddTrailingSlash) + name).exists()) {
- name = KIO::RenameDlg::suggestName(baseUrl, i18n("New Folder"));
+ name = KIO::RenameDialog::suggestName(baseUrl, i18n("New Folder"));
}
bool ok = false;
const bool fileExists = viewUrl.isLocalFile() &&
QFileInfo(viewUrl.path(KUrl::AddTrailingSlash) + KIO::encodeFileName(name)).exists();
if (fileExists) {
- name = KIO::RenameDlg::suggestName(viewUrl, name);
+ name = KIO::RenameDialog::suggestName(viewUrl, name);
}
// let the user change the suggested file name
void DolphinMainWindow::slotUndoAvailable(bool available)
{
- QAction* undoAction = actionCollection()->action(KStdAction::stdName(KStdAction::Undo));
+ QAction* undoAction = actionCollection()->action(KStandardAction::stdName(KStandardAction::Undo));
if (undoAction != 0) {
undoAction->setEnabled(available);
}
void DolphinMainWindow::slotUndoTextChanged(const QString& text)
{
- QAction* undoAction = actionCollection()->action(KStdAction::stdName(KStdAction::Undo));
+ QAction* undoAction = actionCollection()->action(KStandardAction::stdName(KStandardAction::Undo));
if (undoAction != 0) {
undoAction->setText(text);
}
void DolphinMainWindow::slotRedoAvailable(bool available)
{
- QAction* redoAction = actionCollection()->action(KStdAction::stdName(KStdAction::Redo));
+ QAction* redoAction = actionCollection()->action(KStandardAction::stdName(KStandardAction::Redo));
if (redoAction != 0) {
redoAction->setEnabled(available);
}
void DolphinMainWindow::slotRedoTextChanged(const QString& text)
{
- QAction* redoAction = actionCollection()->action(KStdAction::stdName(KStdAction::Redo));
+ QAction* redoAction = actionCollection()->action(KStandardAction::stdName(KStandardAction::Redo));
if (redoAction != 0) {
redoAction->setText(text);
}
void DolphinMainWindow::updatePasteAction()
{
- QAction* pasteAction = actionCollection()->action(KStdAction::stdName(KStdAction::Paste));
+ QAction* pasteAction = actionCollection()->action(KStandardAction::stdName(KStandardAction::Paste));
if (pasteAction == 0) {
return;
}
void DolphinMainWindow::togglePreview()
{
+ clearStatusBar();
+
+ const KToggleAction* showPreviewAction =
+ static_cast<KToggleAction*>(actionCollection()->action("show_preview"));
+ const bool show = showPreviewAction->isChecked();
+ m_activeView->setShowPreview(show);
}
void DolphinMainWindow::toggleShowHiddenFiles()
properties->setShortcut(Qt::Key_Alt | Qt::Key_Return);
connect(properties, SIGNAL(triggered()), this, SLOT(properties()));
- KStdAction::quit(this, SLOT(quit()), actionCollection());
+ KStandardAction::quit(this, SLOT(quit()), actionCollection());
// setup 'Edit' menu
UndoManager& undoManager = UndoManager::instance();
- KStdAction::undo(this,
+ KStandardAction::undo(this,
SLOT(undo()),
actionCollection());
connect(&undoManager, SIGNAL(undoAvailable(bool)),
connect(&undoManager, SIGNAL(undoTextChanged(const QString&)),
this, SLOT(slotUndoTextChanged(const QString&)));
- KStdAction::redo(this,
+ KStandardAction::redo(this,
SLOT(redo()),
actionCollection());
connect(&undoManager, SIGNAL(redoAvailable(bool)),
connect(&undoManager, SIGNAL(redoTextChanged(const QString&)),
this, SLOT(slotRedoTextChanged(const QString&)));
- KStdAction::cut(this, SLOT(cut()), actionCollection());
- KStdAction::copy(this, SLOT(copy()), actionCollection());
- KStdAction::paste(this, SLOT(paste()), actionCollection());
+ KStandardAction::cut(this, SLOT(cut()), actionCollection());
+ KStandardAction::copy(this, SLOT(copy()), actionCollection());
+ KStandardAction::paste(this, SLOT(paste()), actionCollection());
KAction* selectAll = new KAction(i18n("Select All"), actionCollection(), "select_all");
selectAll->setShortcut(Qt::CTRL + Qt::Key_A);
connect(invertSelection, SIGNAL(triggered()), this, SLOT(invertSelection()));
// setup 'View' menu
- KStdAction::zoomIn(this,
+ KStandardAction::zoomIn(this,
SLOT(zoomIn()),
actionCollection());
- KStdAction::zoomOut(this,
+ KStandardAction::zoomOut(this,
SLOT(zoomOut()),
actionCollection());
connect(adjustViewProps, SIGNAL(triggered()), this, SLOT(adjustViewProperties()));
// setup 'Go' menu
- KStdAction::back(this, SLOT(goBack()), actionCollection());
- KStdAction::forward(this, SLOT(goForward()), actionCollection());
- KStdAction::up(this, SLOT(goUp()), actionCollection());
- KStdAction::home(this, SLOT(goHome()), actionCollection());
+ 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
KAction* openTerminal = new KAction(i18n("Open Terminal"), actionCollection(), "open_terminal");
connect(compareFiles, SIGNAL(triggered()), this, SLOT(compareFiles()));
// setup 'Settings' menu
- KStdAction::preferences(this, SLOT(editSettings()), actionCollection());
+ KStandardAction::preferences(this, SLOT(editSettings()), actionCollection());
}
void DolphinMainWindow::setupDockWidgets()
{
- QDockWidget *shortcutsDock = new QDockWidget(i18n("Shortcuts"));
-
- shortcutsDock->setObjectName("shortcutsDock");
+ QDockWidget* shortcutsDock = new QDockWidget(i18n("Shortcuts"));
+ shortcutsDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
shortcutsDock->setWidget(new BookmarksSidebarPage(this));
- shortcutsDock->toggleViewAction()->setObjectName("show_shortcuts_pane");
+ shortcutsDock->toggleViewAction()->setObjectName("show_shortcuts_panel");
shortcutsDock->toggleViewAction()->setText(i18n("Show Shortcuts Panel"));
actionCollection()->insert(shortcutsDock->toggleViewAction());
addDockWidget(Qt::LeftDockWidgetArea, shortcutsDock);
- QDockWidget *infoDock = new QDockWidget(i18n("Information"));
-
- infoDock->setObjectName("infoDock");
+ QDockWidget* infoDock = new QDockWidget(i18n("Information"));
+ infoDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
infoDock->setWidget(new InfoSidebarPage(this));
- infoDock->toggleViewAction()->setObjectName("show_info_pane");
+ infoDock->toggleViewAction()->setObjectName("show_info_panel");
infoDock->toggleViewAction()->setText(i18n("Show Information Panel"));
actionCollection()->insert(infoDock->toggleViewAction());
void DolphinMainWindow::updateViewActions()
{
- QAction* zoomInAction = actionCollection()->action(KStdAction::stdName(KStdAction::ZoomIn));
+ QAction* zoomInAction = actionCollection()->action(KStandardAction::stdName(KStandardAction::ZoomIn));
if (zoomInAction != 0) {
zoomInAction->setEnabled(m_activeView->isZoomInPossible());
}
- QAction* zoomOutAction = actionCollection()->action(KStdAction::stdName(KStdAction::ZoomOut));
+ QAction* zoomOutAction = actionCollection()->action(KStandardAction::stdName(KStandardAction::ZoomOut));
if (zoomOutAction != 0) {
zoomOutAction->setEnabled(m_activeView->isZoomOutPossible());
}
void DolphinMainWindow::updateGoActions()
{
- QAction* goUpAction = actionCollection()->action(KStdAction::stdName(KStdAction::Up));
+ QAction* goUpAction = actionCollection()->action(KStandardAction::stdName(KStandardAction::Up));
const KUrl& currentUrl = m_activeView->url();
goUpAction->setEnabled(currentUrl.upUrl() != currentUrl);
}
-void DolphinMainWindow::updateViewProperties(const KUrl::List& urls)
-{
- if (urls.isEmpty()) {
- return;
- }
-
- // Updating the view properties might take up to several seconds
- // when dragging several thousand Urls. Writing a KIO slave for this
- // use case is not worth the effort, but at least the main widget
- // must be disabled and a progress should be shown.
- ProgressIndicator progressIndicator(this,
- i18n("Updating view properties..."),
- QString::null,
- urls.count());
-
- KUrl::List::ConstIterator end = urls.end();
- for(KUrl::List::ConstIterator it = urls.begin(); it != end; ++it) {
- progressIndicator.execOperation();
-
- ViewProperties props(*it);
- props.save();
- }
-}
-
void DolphinMainWindow::copyUrls(const KUrl::List& source, const KUrl& dest)
{
KIO::Job* job = KIO::copy(source, dest);