#include "panels/information/informationpanel.h"
#include "search/dolphinsearchbox.h"
#include "search/dolphinsearchinformation.h"
-#include "settings/dolphinsettings.h"
#include "settings/dolphinsettingsdialog.h"
#include "statusbar/dolphinstatusbar.h"
#include "views/dolphinviewactionhandler.h"
#endif
#include "dolphin_generalsettings.h"
-#include "dolphin_iconsmodesettings.h"
#include "dolphin_searchsettings.h"
#include <KAcceleratorManager>
#include <KUrlComboBox>
#include <KToolInvocation>
+#include "views/dolphinplacesmodel.h"
+
#include <QDesktopWidget>
#include <QDBusMessage>
#include <QKeyEvent>
#include <QToolButton>
#include <QSplitter>
+namespace {
+ // Used for GeneralSettings::version() to determine whether
+ // an updated version of Dolphin is running.
+ const int CurrentDolphinVersion = 200;
+};
+
/*
* Menu shown when pressing the configure-button in the toolbar.
*/
m_lastHandleUrlStatJob(0),
m_searchDockIsTemporaryVisible(false)
{
+ DolphinPlacesModel::setModel(new KFilePlacesModel(this));
+ connect(DolphinPlacesModel::instance(), SIGNAL(errorMessage(QString)),
+ this, SLOT(showErrorMessage(QString)));
+
// Workaround for a X11-issue in combination with KModifierInfo
// (see DolphinContextMenu::initializeModifierKeyInfo() for
// more information):
setObjectName("Dolphin#");
m_viewTab.append(ViewTab());
+ ViewTab& viewTab = m_viewTab[m_tabIndex];
+ viewTab.wasActive = true; // The first opened tab is automatically active
KIO::FileUndoManager* undoManager = KIO::FileUndoManager::self();
undoManager->setUiInterface(new UndoUiInterface());
connect(undoManager, SIGNAL(undoAvailable(bool)),
this, SLOT(slotUndoAvailable(bool)));
- connect(undoManager, SIGNAL(undoTextChanged(const QString&)),
- this, SLOT(slotUndoTextChanged(const QString&)));
+ connect(undoManager, SIGNAL(undoTextChanged(QString)),
+ this, SLOT(slotUndoTextChanged(QString)));
connect(undoManager, SIGNAL(jobRecordingStarted(CommandType)),
this, SLOT(clearStatusBar()));
connect(undoManager, SIGNAL(jobRecordingFinished(CommandType)),
this, SLOT(showCommand(CommandType)));
- connect(DolphinSettings::instance().placesModel(), SIGNAL(errorMessage(const QString&)),
- this, SLOT(showErrorMessage(const QString&)));
- connect(&DragAndDropHelper::instance(), SIGNAL(errorMessage(const QString&)),
- this, SLOT(showErrorMessage(const QString&)));
-
- const DolphinSettings& settings = DolphinSettings::instance();
- GeneralSettings* generalSettings = settings.generalSettings();
- const bool firstRun = generalSettings->firstRun();
+ GeneralSettings* generalSettings = GeneralSettings::self();
+ const bool firstRun = (generalSettings->version() < 200);
if (firstRun) {
generalSettings->setViewPropsTimestamp(QDateTime::currentDateTime());
}
setAcceptDrops(true);
- m_viewTab[m_tabIndex].splitter = new QSplitter(this);
- m_viewTab[m_tabIndex].splitter->setChildrenCollapsible(false);
+ viewTab.splitter = new QSplitter(this);
+ viewTab.splitter->setChildrenCollapsible(false);
setupActions();
connect(m_actionHandler, SIGNAL(actionBeingHandled()), SLOT(clearStatusBar()));
connect(m_actionHandler, SIGNAL(createDirectory()), SLOT(createDirectory()));
- m_viewTab[m_tabIndex].primaryView = createViewContainer(homeUrl, m_viewTab[m_tabIndex].splitter);
+ viewTab.primaryView = createViewContainer(homeUrl, viewTab.splitter);
- m_activeViewContainer = m_viewTab[m_tabIndex].primaryView;
+ m_activeViewContainer = viewTab.primaryView;
connectViewSignals(m_activeViewContainer);
DolphinView* view = m_activeViewContainer->view();
m_activeViewContainer->show();
m_actionHandler->setCurrentView(view);
m_remoteEncoding = new DolphinRemoteEncoding(this, m_actionHandler);
- connect(this, SIGNAL(urlChanged(const KUrl&)),
+ connect(this, SIGNAL(urlChanged(KUrl)),
m_remoteEncoding, SLOT(slotAboutToOpenUrl()));
m_tabBar = new KTabBar(this);
this, SLOT(setActiveTab(int)));
connect(m_tabBar, SIGNAL(tabCloseRequested(int)),
this, SLOT(closeTab(int)));
- connect(m_tabBar, SIGNAL(contextMenu(int, const QPoint&)),
- this, SLOT(openTabContextMenu(int, const QPoint&)));
+ connect(m_tabBar, SIGNAL(contextMenu(int,QPoint)),
+ this, SLOT(openTabContextMenu(int,QPoint)));
connect(m_tabBar, SIGNAL(newTabRequest()),
this, SLOT(openNewTab()));
- connect(m_tabBar, SIGNAL(testCanDecode(const QDragMoveEvent*, bool&)),
- this, SLOT(slotTestCanDecode(const QDragMoveEvent*, bool&)));
+ connect(m_tabBar, SIGNAL(testCanDecode(const QDragMoveEvent*,bool&)),
+ this, SLOT(slotTestCanDecode(const QDragMoveEvent*,bool&)));
connect(m_tabBar, SIGNAL(mouseMiddleClick(int)),
this, SLOT(closeTab(int)));
- connect(m_tabBar, SIGNAL(tabMoved(int, int)),
- this, SLOT(slotTabMoved(int, int)));
- connect(m_tabBar, SIGNAL(receivedDropEvent(int, QDropEvent*)),
- this, SLOT(tabDropEvent(int, QDropEvent*)));
+ connect(m_tabBar, SIGNAL(tabMoved(int,int)),
+ this, SLOT(slotTabMoved(int,int)));
+ connect(m_tabBar, SIGNAL(receivedDropEvent(int,QDropEvent*)),
+ this, SLOT(tabDropEvent(int,QDropEvent*)));
m_tabBar->blockSignals(true); // signals get unblocked after at least 2 tabs are open
m_centralWidgetLayout->setSpacing(0);
m_centralWidgetLayout->setMargin(0);
m_centralWidgetLayout->addWidget(m_tabBar);
- m_centralWidgetLayout->addWidget(m_viewTab[m_tabIndex].splitter, 1);
+ m_centralWidgetLayout->addWidget(viewTab.splitter, 1);
setCentralWidget(centralWidget);
setupDockWidgets();
const int oldOpenTabsCount = m_viewTab.count();
- const GeneralSettings* generalSettings = DolphinSettings::instance().generalSettings();
- const bool hasSplitView = generalSettings->splitView();
+ const bool hasSplitView = GeneralSettings::splitView();
// Open each directory inside a new tab. If the "split view" option has been enabled,
// always show two directories within one tab.
const int tabCount = m_viewTab.count();
for (int i = 0; i < tabCount; ++i) {
m_viewTab[i].primaryView->view()->markUrlsAsSelected(files);
+ m_viewTab[i].primaryView->view()->markUrlAsCurrent(files.at(0));
if (m_viewTab[i].secondaryView) {
m_viewTab[i].secondaryView->view()->markUrlsAsSelected(files);
+ m_viewTab[i].secondaryView->view()->markUrlAsCurrent(files.at(0));
}
}
}
const int index = urlNavigator->historyIndex();
QAction* backAction = actionCollection()->action("go_back");
- backAction->setToolTip(i18nc("@info", "Go back"));
if (backAction) {
+ backAction->setToolTip(i18nc("@info", "Go back"));
backAction->setEnabled(index < urlNavigator->historySize() - 1);
}
QAction* forwardAction = actionCollection()->action("go_forward");
- forwardAction->setToolTip(i18nc("@info", "Go forward"));
if (forwardAction) {
+ forwardAction->setToolTip(i18nc("@info", "Go forward"));
forwardAction->setEnabled(index > 0);
}
}
actionCollection()->action("close_tab")->setEnabled(true);
- // provide a split view, if the startup settings are set this way
- const GeneralSettings* generalSettings = DolphinSettings::instance().generalSettings();
- if (generalSettings->splitView()) {
- const int tabIndex = m_viewTab.count() - 1;
- createSecondaryView(tabIndex);
- m_viewTab[tabIndex].secondaryView->setActive(true);
- m_viewTab[tabIndex].isPrimaryViewActive = false;
+ // Provide a split view, if the startup settings are set this way
+ if (GeneralSettings::splitView()) {
+ const int newTabIndex = m_viewTab.count() - 1;
+ createSecondaryView(newTabIndex);
+ m_viewTab[newTabIndex].secondaryView->setActive(true);
+ m_viewTab[newTabIndex].isPrimaryViewActive = false;
}
if (focusWidget) {
void DolphinMainWindow::activateNextTab()
{
- if ((m_viewTab.count() == 1) || (m_tabBar->count() < 2)) {
- return;
+ if (m_viewTab.count() >= 2) {
+ const int tabIndex = (m_tabBar->currentIndex() + 1) % m_tabBar->count();
+ m_tabBar->setCurrentIndex(tabIndex);
}
-
- const int tabIndex = (m_tabBar->currentIndex() + 1) % m_tabBar->count();
- m_tabBar->setCurrentIndex(tabIndex);
}
void DolphinMainWindow::activatePrevTab()
{
- if ((m_viewTab.count() == 1) || (m_tabBar->count() < 2)) {
- return;
- }
-
- int tabIndex = m_tabBar->currentIndex() - 1;
- if (tabIndex == -1) {
- tabIndex = m_tabBar->count() - 1;
+ if (m_viewTab.count() >= 2) {
+ int tabIndex = m_tabBar->currentIndex() - 1;
+ if (tabIndex == -1) {
+ tabIndex = m_tabBar->count() - 1;
+ }
+ m_tabBar->setCurrentIndex(tabIndex);
}
- m_tabBar->setCurrentIndex(tabIndex);
}
void DolphinMainWindow::openInNewTab()
void DolphinMainWindow::closeEvent(QCloseEvent* event)
{
- DolphinSettings& settings = DolphinSettings::instance();
- GeneralSettings* generalSettings = settings.generalSettings();
-
// Find out if Dolphin is closed directly by the user or
// by the session manager because the session is closed
bool closedByUser = true;
closedByUser = false;
}
- if ((m_viewTab.count() > 1) && generalSettings->confirmClosingMultipleTabs() && closedByUser) {
+ if (m_viewTab.count() > 1 && GeneralSettings::confirmClosingMultipleTabs() && closedByUser) {
// Ask the user if he really wants to quit and close all tabs.
// Open a confirmation dialog with 3 buttons:
// KDialog::Yes -> Quit
KMessageBox::Notify);
if (doNotAskAgainCheckboxResult) {
- generalSettings->setConfirmClosingMultipleTabs(false);
+ GeneralSettings::setConfirmClosingMultipleTabs(false);
}
switch (result) {
}
}
- generalSettings->setFirstRun(false);
-
- settings.save();
+ GeneralSettings::setVersion(CurrentDolphinVersion);
+ GeneralSettings::self()->writeConfig();
if (m_searchDockIsTemporaryVisible) {
QDockWidget* searchDock = findChild<QDockWidget*>("searchDock");
void DolphinMainWindow::updateNewMenu()
{
- m_newFileMenu->setViewShowsHiddenFiles(activeViewContainer()->view()->showHiddenFiles());
+ m_newFileMenu->setViewShowsHiddenFiles(activeViewContainer()->view()->hiddenFilesShown());
m_newFileMenu->checkUpToDate();
m_newFileMenu->setPopupFiles(activeViewContainer()->url());
}
void DolphinMainWindow::createDirectory()
{
- m_newFileMenu->setViewShowsHiddenFiles(activeViewContainer()->view()->showHiddenFiles());
+ m_newFileMenu->setViewShowsHiddenFiles(activeViewContainer()->view()->hiddenFilesShown());
m_newFileMenu->setPopupFiles(activeViewContainer()->url());
m_newFileMenu->createDirectory();
}
void DolphinMainWindow::slotSearchLocationChanged()
{
+#ifdef HAVE_NEPOMUK
QDockWidget* searchDock = findChild<QDockWidget*>("searchDock");
if (!searchDock) {
return;
SearchPanel* searchPanel = qobject_cast<SearchPanel*>(searchDock->widget());
if (searchPanel) {
- searchPanel->setSearchMode(SearchSettings::location() == QLatin1String("FromHere")
- ? SearchPanel::FromCurrentDir
- : SearchPanel::Everywhere);
+ searchPanel->setSearchLocation(SearchSettings::location() == QLatin1String("FromHere")
+ ? SearchPanel::FromCurrentDir
+ : SearchPanel::Everywhere);
}
+#endif
}
void DolphinMainWindow::updatePasteAction()
void DolphinMainWindow::togglePanelLockState()
{
- GeneralSettings* generalSettings = DolphinSettings::instance().generalSettings();
-
- const bool newLockState = !generalSettings->lockPanels();
+ const bool newLockState = !GeneralSettings::lockPanels();
foreach (QObject* child, children()) {
DolphinDockWidget* dock = qobject_cast<DolphinDockWidget*>(child);
if (dock) {
}
}
- generalSettings->setLockPanels(newLockState);
+ GeneralSettings::setLockPanels(newLockState);
}
void DolphinMainWindow::slotPlacesPanelVisibilityChanged(bool visible)
}
}
+void DolphinMainWindow::goHome(Qt::MouseButtons buttons)
+{
+ // The default case (left button pressed) is handled in goHome().
+ if (buttons == Qt::MidButton) {
+ openNewTab(GeneralSettings::self()->homeUrl());
+ }
+}
+
void DolphinMainWindow::compareFiles()
{
// The method is only invoked if exactly 2 files have
}
viewTab.splitter->show();
+ if (!viewTab.wasActive) {
+ viewTab.wasActive = true;
+
+ // If the tab has not been activated yet the size of the KItemListView is
+ // undefined and results in an unwanted animation. To prevent this a
+ // reloading of the directory gets triggered.
+ viewTab.primaryView->view()->reload();
+ if (viewTab.secondaryView) {
+ viewTab.secondaryView->view()->reload();
+ }
+ }
+
setActiveViewContainer(viewTab.isPrimaryViewActive ? viewTab.primaryView :
viewTab.secondaryView);
}
const KUrl::List urls = KUrl::List::fromMimeData(event->mimeData());
if (!urls.isEmpty() && tab != -1) {
const ViewTab& viewTab = m_viewTab[tab];
- const KUrl destPath = viewTab.isPrimaryViewActive ? viewTab.primaryView->url() : viewTab.secondaryView->url();
- DragAndDropHelper::instance().dropUrls(KFileItem(), destPath, event, m_tabBar);
+ const DolphinView* view = viewTab.isPrimaryViewActive ? viewTab.primaryView->view()
+ : viewTab.secondaryView->view();
+ DragAndDropHelper::dropUrls(view->rootItem(), event);
}
}
}
SearchPanel* searchPanel = qobject_cast<SearchPanel*>(searchDock->widget());
- if (searchPanel) {
- // Per default any search-operation triggered by the Search Panel is done
- // "Everywhere".
- SearchPanel::SearchMode searchMode = SearchPanel::Everywhere;
-
- if (enabled && (SearchSettings::location() == QLatin1String("FromHere"))) {
- // Only if the search-mode is enabled it is visible for the user whether
- // a searching is done "Everywhere" or "From Here" (= current directory).
- searchMode = SearchPanel::FromCurrentDir;
+ if (!searchPanel) {
+ return;
+ }
+
+ if (enabled) {
+ SearchPanel::SearchLocation searchLocation = SearchPanel::Everywhere;
+ const KUrl url = m_activeViewContainer->url();
+ const bool isSearchUrl = (url.protocol() == QLatin1String("nepomuksearch"));
+ if ((SearchSettings::location() == QLatin1String("FromHere") && !isSearchUrl)) {
+ searchLocation = SearchPanel::FromCurrentDir;
}
- searchPanel->setSearchMode(searchMode);
+ searchPanel->setSearchLocation(searchLocation);
+ } else {
+ searchPanel->setSearchLocation(SearchPanel::Everywhere);
}
#else
Q_UNUSED(enabled);
#endif
}
-void DolphinMainWindow::openContextMenu(const KFileItem& item,
+void DolphinMainWindow::openContextMenu(const QPoint& pos,
+ const KFileItem& item,
const KUrl& url,
const QList<QAction*>& customActions)
{
- QPointer<DolphinContextMenu> contextMenu = new DolphinContextMenu(this, item, url);
- contextMenu->setCustomActions(customActions);
- const DolphinContextMenu::Command command = contextMenu->open();
+ QWeakPointer<DolphinContextMenu> contextMenu = new DolphinContextMenu(this, pos, item, url);
+ contextMenu.data()->setCustomActions(customActions);
+ const DolphinContextMenu::Command command = contextMenu.data()->open();
switch (command) {
case DolphinContextMenu::OpenParentFolderInNewWindow: {
break;
}
- delete contextMenu;
+ delete contextMenu.data();
}
void DolphinMainWindow::updateToolBarMenu()
// by connecting to the aboutToHide() signal from the parent-menu.
menu->clear();
- const GeneralSettings* generalSettings = DolphinSettings::instance().generalSettings();
-
KActionCollection* ac = actionCollection();
// Add "Edit" actions
}
// Add "View" actions
- if (!generalSettings->showZoomSlider()) {
+ if (!GeneralSettings::showZoomSlider()) {
addActionToMenu(ac->action(KStandardAction::name(KStandardAction::ZoomIn)), menu);
addActionToMenu(ac->action(KStandardAction::name(KStandardAction::ZoomOut)), menu);
menu->addSeparator();
connect(menu, SIGNAL(aboutToHide()), helpMenu, SLOT(deleteLater()));
helpMenu->addAction(ac->action(KStandardAction::name(KStandardAction::HelpContents)));
helpMenu->addAction(ac->action(KStandardAction::name(KStandardAction::WhatsThis)));
+ helpMenu->addSeparator();
+ helpMenu->addAction(ac->action(KStandardAction::name(KStandardAction::ReportBug)));
+ helpMenu->addSeparator();
+ helpMenu->addAction(ac->action(KStandardAction::name(KStandardAction::SwitchApplicationLanguage)));
+ helpMenu->addSeparator();
helpMenu->addAction(ac->action(KStandardAction::name(KStandardAction::AboutApp)));
helpMenu->addAction(ac->action(KStandardAction::name(KStandardAction::AboutKDE)));
menu->addMenu(helpMenu);
// setup 'Go' menu
KAction* backAction = KStandardAction::back(this, SLOT(goBack()), actionCollection());
- connect(backAction, SIGNAL(triggered(Qt::MouseButtons, Qt::KeyboardModifiers)), this, SLOT(goBack(Qt::MouseButtons)));
+ connect(backAction, SIGNAL(triggered(Qt::MouseButtons,Qt::KeyboardModifiers)), this, SLOT(goBack(Qt::MouseButtons)));
KShortcut backShortcut = backAction->shortcut();
backShortcut.setAlternate(Qt::Key_Backspace);
backAction->setShortcut(backShortcut);
m_recentTabsMenu = new KActionMenu(i18n("Recently Closed Tabs"), this);
m_recentTabsMenu->setIcon(KIcon("edit-undo"));
actionCollection()->addAction("closed_tabs", m_recentTabsMenu);
- connect(m_recentTabsMenu->menu(), SIGNAL(triggered(QAction *)),
- this, SLOT(restoreClosedTab(QAction *)));
+ connect(m_recentTabsMenu->menu(), SIGNAL(triggered(QAction*)),
+ this, SLOT(restoreClosedTab(QAction*)));
QAction* action = new QAction(i18n("Empty Recently Closed Tabs"), m_recentTabsMenu);
action->setIcon(KIcon("edit-clear-list"));
m_recentTabsMenu->setEnabled(false);
KAction* forwardAction = KStandardAction::forward(this, SLOT(goForward()), actionCollection());
- connect(forwardAction, SIGNAL(triggered(Qt::MouseButtons, Qt::KeyboardModifiers)), this, SLOT(goForward(Qt::MouseButtons)));
+ connect(forwardAction, SIGNAL(triggered(Qt::MouseButtons,Qt::KeyboardModifiers)), this, SLOT(goForward(Qt::MouseButtons)));
KAction* upAction = KStandardAction::up(this, SLOT(goUp()), actionCollection());
- connect(upAction, SIGNAL(triggered(Qt::MouseButtons, Qt::KeyboardModifiers)), this, SLOT(goUp(Qt::MouseButtons)));
+ connect(upAction, SIGNAL(triggered(Qt::MouseButtons,Qt::KeyboardModifiers)), this, SLOT(goUp(Qt::MouseButtons)));
- KStandardAction::home(this, SLOT(goHome()), actionCollection());
+ KAction* homeAction = KStandardAction::home(this, SLOT(goHome()), actionCollection());
+ connect(homeAction, SIGNAL(triggered(Qt::MouseButtons,Qt::KeyboardModifiers)), this, SLOT(goHome(Qt::MouseButtons)));
// setup 'Tools' menu
KAction* showFilterBar = actionCollection()->addAction("show_filter_bar");
connect(openTerminal, SIGNAL(triggered()), this, SLOT(openTerminal()));
// setup 'Settings' menu
- KStandardAction::showMenubar(this, SLOT(toggleShowMenuBar()), actionCollection());
+ KToggleAction* showMenuBar = KStandardAction::showMenubar(0, 0, actionCollection());
+ connect(showMenuBar, SIGNAL(triggered(bool)), // Fixes #286822
+ this, SLOT(toggleShowMenuBar()), Qt::QueuedConnection);
KStandardAction::preferences(this, SLOT(editSettings()), actionCollection());
// not in menu actions
void DolphinMainWindow::setupDockWidgets()
{
- const bool lock = DolphinSettings::instance().generalSettings()->lockPanels();
+ const bool lock = GeneralSettings::lockPanels();
KDualAction* lockLayoutAction = actionCollection()->add<KDualAction>("lock_panels");
lockLayoutAction->setActiveText(i18nc("@action:inmenu Panels", "Unlock Panels"));
infoDock->setWidget(infoPanel);
QAction* infoAction = infoDock->toggleViewAction();
- infoAction->setIcon(KIcon("dialog-information"));
- infoAction->setShortcut(Qt::Key_F11);
- addActionCloneToCollection(infoAction, "show_information_panel");
+ createPanelAction(KIcon("dialog-information"), Qt::Key_F11, infoAction, "show_information_panel");
addDockWidget(Qt::RightDockWidgetArea, infoDock);
connect(this, SIGNAL(urlChanged(KUrl)),
foldersDock->setWidget(foldersPanel);
QAction* foldersAction = foldersDock->toggleViewAction();
- foldersAction->setShortcut(Qt::Key_F7);
- foldersAction->setIcon(KIcon("folder"));
- addActionCloneToCollection(foldersAction, "show_folders_panel");
+ createPanelAction(KIcon("folder"), Qt::Key_F7, foldersAction, "show_folders_panel");
addDockWidget(Qt::LeftDockWidgetArea, foldersDock);
connect(this, SIGNAL(urlChanged(KUrl)),
foldersPanel, SLOT(setUrl(KUrl)));
- connect(foldersPanel, SIGNAL(changeUrl(KUrl, Qt::MouseButtons)),
- this, SLOT(handlePlacesClick(KUrl, Qt::MouseButtons)));
+ connect(foldersPanel, SIGNAL(changeUrl(KUrl,Qt::MouseButtons)),
+ this, SLOT(handlePlacesClick(KUrl,Qt::MouseButtons)));
// Setup "Terminal"
#ifndef Q_OS_WIN
terminalDock->setWidget(terminalPanel);
connect(terminalPanel, SIGNAL(hideTerminalPanel()), terminalDock, SLOT(hide()));
+ connect(terminalDock, SIGNAL(visibilityChanged(bool)),
+ terminalPanel, SLOT(dockVisibilityChanged()));
QAction* terminalAction = terminalDock->toggleViewAction();
- terminalAction->setShortcut(Qt::Key_F4);
- terminalAction->setIcon(KIcon("utilities-terminal"));
- addActionCloneToCollection(terminalAction, "show_terminal_panel");
+ createPanelAction(KIcon("utilities-terminal"), Qt::Key_F4, terminalAction, "show_terminal_panel");
addDockWidget(Qt::BottomDockWidgetArea, terminalDock);
connect(this, SIGNAL(urlChanged(KUrl)),
searchDock->setWidget(searchPanel);
QAction* searchAction = searchDock->toggleViewAction();
- searchAction->setShortcut(Qt::Key_F12);
- searchAction->setIcon(KIcon("system-search"));
- addActionCloneToCollection(searchAction, "show_search_panel");
+ createPanelAction(KIcon("system-search"), Qt::Key_F12, searchAction, "show_search_panel");
addDockWidget(Qt::RightDockWidgetArea, searchDock);
connect(this, SIGNAL(urlChanged(KUrl)),
searchPanel, SLOT(setUrl(KUrl)));
#endif
- const bool firstRun = DolphinSettings::instance().generalSettings()->firstRun();
- if (firstRun) {
+ if (GeneralSettings::version() < 200) {
infoDock->hide();
foldersDock->hide();
#ifndef Q_OS_WIN
placesActions.append(separator);
placesActions.append(lockLayoutAction);
placesPanel->addActions(placesActions);
- placesPanel->setModel(DolphinSettings::instance().placesModel());
+ placesPanel->setModel(DolphinPlacesModel::instance());
placesPanel->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
placesDock->setWidget(placesPanel);
QAction* placesAction = placesDock->toggleViewAction();
- placesAction->setShortcut(Qt::Key_F9);
- placesAction->setIcon(KIcon("bookmarks"));
- addActionCloneToCollection(placesAction, "show_places_panel");
+ createPanelAction(KIcon("bookmarks"), Qt::Key_F9, placesAction, "show_places_panel");
addDockWidget(Qt::LeftDockWidgetArea, placesDock);
- connect(placesPanel, SIGNAL(urlChanged(KUrl, Qt::MouseButtons)),
- this, SLOT(handlePlacesClick(KUrl, Qt::MouseButtons)));
+ connect(placesPanel, SIGNAL(urlChanged(KUrl,Qt::MouseButtons)),
+ this, SLOT(handlePlacesClick(KUrl,Qt::MouseButtons)));
connect(this, SIGNAL(urlChanged(KUrl)),
placesPanel, SLOT(setUrl(KUrl)));
connect(placesDock, SIGNAL(visibilityChanged(bool)),
KActionMenu* panelsMenu = new KActionMenu(i18nc("@action:inmenu View", "Panels"), this);
actionCollection()->addAction("panels", panelsMenu);
panelsMenu->setDelayed(false);
- panelsMenu->addAction(placesAction);
- panelsMenu->addAction(infoAction);
- panelsMenu->addAction(foldersAction);
+ const KActionCollection* ac = actionCollection();
+ panelsMenu->addAction(ac->action("show_places_panel"));
+ panelsMenu->addAction(ac->action("show_information_panel"));
+ panelsMenu->addAction(ac->action("show_folders_panel"));
#ifndef Q_OS_WIN
- panelsMenu->addAction(terminalAction);
+ panelsMenu->addAction(ac->action("show_terminal_panel"));
#endif
#ifdef HAVE_NEPOMUK
- panelsMenu->addAction(searchAction);
+ panelsMenu->addAction(ac->action("show_search_panel"));
#endif
panelsMenu->addSeparator();
panelsMenu->addAction(lockLayoutAction);
setActiveViewContainer(activeViewContainer);
- const GeneralSettings* generalSettings = DolphinSettings::instance().generalSettings();
- if (generalSettings->modifiedStartupSettings()) {
+ if (GeneralSettings::modifiedStartupSettings()) {
// The startup settings have been changed by the user (see bug #254947).
// Synchronize the split-view setting with the active view:
- const bool splitView = generalSettings->splitView();
+ const bool splitView = GeneralSettings::splitView();
const ViewTab& activeTab = m_viewTab[m_tabIndex];
const bool toggle = ( splitView && !activeTab.secondaryView)
|| (!splitView && activeTab.secondaryView);
this, SLOT(slotRequestItemInfo(KFileItem)));
connect(view, SIGNAL(activated()),
this, SLOT(toggleActiveView()));
- connect(view, SIGNAL(tabRequested(const KUrl&)),
- this, SLOT(openNewTab(const KUrl&)));
- connect(view, SIGNAL(requestContextMenu(KFileItem, const KUrl&, const QList<QAction*>&)),
- this, SLOT(openContextMenu(KFileItem, const KUrl&, const QList<QAction*>&)));
+ connect(view, SIGNAL(tabRequested(KUrl)),
+ this, SLOT(openNewTab(KUrl)));
+ connect(view, SIGNAL(requestContextMenu(QPoint,KFileItem,KUrl,QList<QAction*>)),
+ this, SLOT(openContextMenu(QPoint,KFileItem,KUrl,QList<QAction*>)));
connect(view, SIGNAL(startedPathLoading(KUrl)),
this, SLOT(enableStopAction()));
connect(view, SIGNAL(finishedPathLoading(KUrl)),
this, SLOT(disableStopAction()));
const KUrlNavigator* navigator = container->urlNavigator();
- connect(navigator, SIGNAL(urlChanged(const KUrl&)),
- this, SLOT(changeUrl(const KUrl&)));
+ connect(navigator, SIGNAL(urlChanged(KUrl)),
+ this, SLOT(changeUrl(KUrl)));
connect(navigator, SIGNAL(historyChanged()),
this, SLOT(updateHistory()));
connect(navigator, SIGNAL(editableStateChanged(bool)),
this, SLOT(slotEditableStateChanged(bool)));
- connect(navigator, SIGNAL(tabRequested(const KUrl&)),
+ connect(navigator, SIGNAL(tabRequested(KUrl)),
this, SLOT(openNewTab(KUrl)));
}
void DolphinMainWindow::createSecondaryView(int tabIndex)
{
- QSplitter* splitter = m_viewTab[tabIndex].splitter;
- const int newWidth = (m_viewTab[tabIndex].primaryView->width() - splitter->handleWidth()) / 2;
+ ViewTab& viewTab = m_viewTab[tabIndex];
+
+ QSplitter* splitter = viewTab.splitter;
+ const int newWidth = (viewTab.primaryView->width() - splitter->handleWidth()) / 2;
- const DolphinView* view = m_viewTab[tabIndex].primaryView->view();
- m_viewTab[tabIndex].secondaryView = createViewContainer(view->rootUrl(), 0);
- splitter->addWidget(m_viewTab[tabIndex].secondaryView);
+ const DolphinView* view = viewTab.primaryView->view();
+ viewTab.secondaryView = createViewContainer(view->url(), 0);
+ splitter->addWidget(viewTab.secondaryView);
splitter->setSizes(QList<int>() << newWidth << newWidth);
- connectViewSignals(m_viewTab[tabIndex].secondaryView);
- m_viewTab[tabIndex].secondaryView->setActive(false);
- m_viewTab[tabIndex].secondaryView->show();
+
+ connectViewSignals(viewTab.secondaryView);
+ viewTab.secondaryView->setActive(false);
+ viewTab.secondaryView->resize(newWidth, viewTab.primaryView->height());
+ viewTab.secondaryView->show();
}
QString DolphinMainWindow::tabProperty(const QString& property, int tabIndex) const
return fm.elidedText(text, Qt::ElideMiddle, fm.maxWidth() * 10);
}
-void DolphinMainWindow::addActionCloneToCollection(QAction* action, const QString& actionName)
+void DolphinMainWindow::createPanelAction(const KIcon& icon,
+ const QKeySequence& shortcut,
+ QAction* dockAction,
+ const QString& actionName)
{
- KAction* actionClone = actionCollection()->addAction(actionName);
- actionClone->setText(action->text());
- actionClone->setIcon(action->icon());
- connect(actionClone, SIGNAL(triggered()), action, SLOT(trigger()));
+ KAction* panelAction = actionCollection()->addAction(actionName);
+ panelAction->setCheckable(true);
+ panelAction->setChecked(dockAction->isChecked());
+ panelAction->setText(dockAction->text());
+ panelAction->setIcon(icon);
+ panelAction->setShortcut(shortcut);
+
+ connect(panelAction, SIGNAL(triggered()), dockAction, SLOT(trigger()));
+ connect(dockAction, SIGNAL(toggled(bool)), panelAction, SLOT(setChecked(bool)));
}
DolphinMainWindow::UndoUiInterface::UndoUiInterface() :
// Assure that the menu is not shown outside the screen boundaries and
// that it does not overlap with the parent button.
const QRect screen = QApplication::desktop()->screenGeometry(QCursor::pos());
- if (pos.x() < 0) {
- pos.rx() = 0;
- } else if (pos.x() + width() >= screen.width()) {
- pos.rx() = screen.width() - width();
+ if (pos.x() < screen.x()) {
+ pos.rx() = screen.x();
+ } else if (pos.x() + width() > screen.x() + screen.width()) {
+ pos.rx() = screen.x() + screen.width() - width();
}
- if (pos.y() < 0) {
- pos.ry() = 0;
- } else if (pos.y() + height() >= screen.height()) {
+ if (pos.y() < screen.y()) {
+ pos.ry() = screen.y();
+ } else if (pos.y() + height() > screen.y() + screen.height()) {
pos.ry() = button->mapToGlobal(QPoint(0, 0)).y() - height();
}