#include <kurl.h>
#include <kurlcombobox.h>
+#include <QDBusMessage>
#include <QKeyEvent>
#include <QClipboard>
#include <QLineEdit>
#include <QSplitter>
#include <QDockWidget>
+#include <kdebug.h>
+
DolphinMainWindow::DolphinMainWindow(int id) :
KXmlGuiWindow(0),
m_newMenu(0),
setActiveViewContainer(activeViewContainer);
}
-void DolphinMainWindow::dropUrls(const KUrl::List& urls,
- const KUrl& destination)
+void DolphinMainWindow::dropUrls(const KFileItem& destItem,
+ const KUrl& destPath,
+ QDropEvent* event)
{
DolphinDropController dropController(this);
connect(&dropController, SIGNAL(doingOperation(KIO::FileUndoManager::CommandType)),
this, SLOT(slotDoingOperation(KIO::FileUndoManager::CommandType)));
- dropController.dropUrls(urls, destination);
+ dropController.dropUrls(destItem, destPath, event);
}
void DolphinMainWindow::pasteIntoFolder()
updateEditActions();
Q_ASSERT(m_viewTab[m_tabIndex].primaryView != 0);
- int selectedUrlsCount = m_viewTab[m_tabIndex].primaryView->view()->selectedUrls().count();
+ int selectedUrlsCount = m_viewTab[m_tabIndex].primaryView->view()->selectedItemsCount();
if (m_viewTab[m_tabIndex].secondaryView != 0) {
- selectedUrlsCount += m_viewTab[m_tabIndex].secondaryView->view()->selectedUrls().count();
+ selectedUrlsCount += m_viewTab[m_tabIndex].secondaryView->view()->selectedItemsCount();
}
QAction* compareFilesAction = actionCollection()->action("compare_files");
compareFilesAction->setEnabled(false);
}
+ const bool activeViewHasSelection = (activeViewContainer()->view()->selectedItemsCount() > 0);
+ actionCollection()->action("quick_view")->setEnabled(activeViewHasSelection);
+
m_activeViewContainer->updateStatusBar();
emit selectionChanged(selection);
viewTab.primaryView->view()->reload();
m_viewTab.append(viewTab);
+
+ actionCollection()->action("close_tab")->setEnabled(true);
}
void DolphinMainWindow::toggleActiveView()
KRun::runCommand(command, "Kompare", "kompare", this);
}
+void DolphinMainWindow::quickView()
+{
+ const KUrl::List urls = activeViewContainer()->view()->selectedUrls();
+ Q_ASSERT(urls.count() > 0);
+
+ QDBusMessage msg = QDBusMessage::createMethodCall("org.kde.plasma", "/Previewer", "", "openFile");
+ foreach (const KUrl& url, urls) {
+ msg.setArguments(QList<QVariant>() << url.prettyUrl());
+ QDBusConnection::sessionBus().send(msg);
+ }
+}
+
void DolphinMainWindow::toggleShowMenuBar()
{
const bool visible = menuBar()->isVisible();
if (index == m_tabIndex) {
// The tab that should be closed is the active tab. Activate the
// previous tab before closing the tab.
- setActiveTab((index > 0) ? index - 1 : 1);
+ m_tabBar->setCurrentIndex((index > 0) ? index - 1 : 1);
}
// delete tab
// closing the last tab is not possible
if (m_viewTab.count() == 1) {
m_tabBar->removeTab(0);
+ actionCollection()->action("close_tab")->setEnabled(false);
} else {
m_tabBar->blockSignals(false);
}
}
}
+void DolphinMainWindow::slotTestCanDecode(const QDragMoveEvent* event, bool& canDecode)
+{
+ canDecode = KUrl::List::canDecode(event->mimeData());
+}
+
void DolphinMainWindow::init()
{
DolphinSettings& settings = DolphinSettings::instance();
this, SLOT(openTabContextMenu(int, const QPoint&)));
connect(m_tabBar, SIGNAL(newTabRequest()),
this, SLOT(openNewTab()));
+ connect(m_tabBar, SIGNAL(testCanDecode(const QDragMoveEvent*, bool&)),
+ this, SLOT(slotTestCanDecode(const QDragMoveEvent*, bool&)));
m_tabBar->blockSignals(true); // signals get unblocked after at least 2 tabs are open
QWidget* centralWidget = new QWidget(this);
m_centralWidgetLayout->addWidget(m_tabBar);
m_centralWidgetLayout->addWidget(m_viewTab[m_tabIndex].splitter);
-
setCentralWidget(centralWidget);
setupDockWidgets();
setupGUI(Keys | Save | Create | ToolBar);
- createGUI();
stateChanged("new_file");
- setAutoSaveSettings();
QClipboard* clipboard = QApplication::clipboard();
connect(clipboard, SIGNAL(dataChanged()),
}
updateViewActions();
+ QAction* showFilterBarAction = actionCollection()->action("show_filter_bar");
+ showFilterBarAction->setChecked(generalSettings->filterBar());
+
if (firstRun) {
// assure a proper default size if Dolphin runs the first time
resize(750, 500);
}
+ m_showMenuBar->setChecked(!menuBar()->isHidden()); // workaround for bug #171080
emit urlChanged(homeUrl);
}
QAction* closeTab = new QAction(KIcon("tab-close"), i18nc("@action:inmenu File", "Close Tab"), this);
closeTab->setShortcut(Qt::CTRL | Qt::Key_W);
+ closeTab->setEnabled(false);
connect(closeTab, SIGNAL(triggered()), this, SLOT(closeTab()));
actionCollection()->addAction("close_tab", closeTab);
compareFiles->setEnabled(false);
connect(compareFiles, SIGNAL(triggered()), this, SLOT(compareFiles()));
+ KAction* quickView = actionCollection()->addAction("quick_view");
+ quickView->setText(i18nc("@action:inmenu Tools", "Quick View"));
+ quickView->setIcon(KIcon("view-preview"));
+ quickView->setShortcut(Qt::CTRL + Qt::Key_Return);
+ quickView->setEnabled(false);
+ connect(quickView, SIGNAL(triggered()), this, SLOT(quickView()));
+
// setup 'Settings' menu
m_showMenuBar = KStandardAction::showMenubar(this, SLOT(toggleShowMenuBar()), actionCollection());
KStandardAction::preferences(this, SLOT(editSettings()), actionCollection());
this, SLOT(handlePlacesClick(KUrl, Qt::MouseButtons)));
connect(treeWidget, SIGNAL(changeSelection(KFileItemList)),
this, SLOT(changeSelection(KFileItemList)));
- connect(treeWidget, SIGNAL(urlsDropped(KUrl::List, KUrl)),
- this, SLOT(dropUrls(KUrl::List, KUrl)));
+ // TODO: connecting to urlsDropped() fails!
+ connect(treeWidget, SIGNAL(urlsDropped(KFileItem&, KUrl&, QDropEvent*)),
+ this, SLOT(dropUrls(KFileItem&, KUrl&, QDropEvent*)));
// setup "Terminal"
#ifndef Q_OS_WIN