X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/5840fcede7178c80d137f589110d09ee20a99483..abf17941f7:/src/dolphinmainwindow.cpp diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp index e4fcc6a97..a25c61038 100644 --- a/src/dolphinmainwindow.cpp +++ b/src/dolphinmainwindow.cpp @@ -36,6 +36,7 @@ #include "generalsettings.h" #include "viewpropertiesdialog.h" #include "viewproperties.h" +#include "mainwindowadaptor.h" #include #include @@ -48,6 +49,7 @@ #include #include #include +#include #include #include #include @@ -69,16 +71,20 @@ #include #include -DolphinMainWindow::DolphinMainWindow() : +DolphinMainWindow::DolphinMainWindow(int id) : KMainWindow(0), m_newMenu(0), m_splitter(0), - m_activeView(0) + m_activeView(0), + m_id(id) { setObjectName("Dolphin"); m_view[PrimaryIdx] = 0; m_view[SecondaryIdx] = 0; + new MainWindowAdaptor(this); + QDBusConnection::sessionBus().registerObject(QString("/dolphin/MainWindow%1").arg(m_id), this); + KonqUndoManager::incRef(); KonqUndoManager* undoManager = KonqUndoManager::self(); @@ -160,7 +166,7 @@ void DolphinMainWindow::dropUrls(const KUrl::List& urls, i18n("&Link Here") + "\t" + seq); popup.addSeparator(); - QAction* cancelAction = popup.addAction(KIcon("stop"), i18n("Cancel")); + popup.addAction(KIcon("stop"), i18n("Cancel")); QAction* activatedAction = popup.exec(QCursor::pos()); if (activatedAction == moveAction) { @@ -172,7 +178,7 @@ void DolphinMainWindow::dropUrls(const KUrl::List& urls, else if (activatedAction == linkAction) { action = Qt::LinkAction; } - else if (activatedAction == cancelAction) { + else { return; } } @@ -230,6 +236,13 @@ void DolphinMainWindow::refreshViews() emit activeViewChanged(); } +void DolphinMainWindow::changeUrl(const QString& url) +{ + if (activeView() != 0) { + activeView()->setUrl(KUrl(url)); + } +} + void DolphinMainWindow::slotViewModeChanged() { updateViewActions(); @@ -255,6 +268,15 @@ void DolphinMainWindow::slotSortingChanged(DolphinView::Sorting sorting) 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; default: break; } @@ -324,7 +346,7 @@ void DolphinMainWindow::closeEvent(QCloseEvent* event) // TODO: I assume there will be a generic way in KDE 4 to store the docks // of the main window. In the meantime they are stored manually: - QString filename = KStandardDirs::locateLocal("data", KGlobal::instance()->instanceName()); + QString filename = KStandardDirs::locateLocal("data", KGlobal::mainComponent().componentName()); filename.append("/panels_layout"); QFile file(filename); if (file.open(QIODevice::WriteOnly)) { @@ -488,6 +510,12 @@ void DolphinMainWindow::slotUndoTextChanged(const QString& text) } } +void DolphinMainWindow::undo() +{ + clearStatusBar(); + KonqUndoManager::self()->undo(); +} + void DolphinMainWindow::cut() { QMimeData* mimeData = new QMimeData(); @@ -628,6 +656,21 @@ void DolphinMainWindow::sortByDate() m_activeView->setSorting(DolphinView::SortByDate); } +void DolphinMainWindow::sortByPermissions() +{ + m_activeView->setSorting(DolphinView::SortByPermissions); +} + +void DolphinMainWindow::sortByOwner() +{ + m_activeView->setSorting(DolphinView::SortByOwner); +} + +void DolphinMainWindow::sortByGroup() +{ + m_activeView->setSorting(DolphinView::SortByGroup); +} + void DolphinMainWindow::toggleSortOrder() { const Qt::SortOrder order = (m_activeView->sortOrder() == Qt::Ascending) ? @@ -671,6 +714,7 @@ void DolphinMainWindow::toggleSplitView() setActiveView(m_view[PrimaryIdx]); } } + emit activeViewChanged(); } void DolphinMainWindow::reloadView() @@ -735,8 +779,6 @@ void DolphinMainWindow::toggleEditLocation() void DolphinMainWindow::editLocation() { - KToggleAction* action = static_cast(actionCollection()->action("editable_location")); - action->setChecked(true); m_activeView->setUrlEditable(true); } @@ -853,6 +895,9 @@ void DolphinMainWindow::init() // 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); @@ -924,8 +969,7 @@ void DolphinMainWindow::loadSettings() // TODO: I assume there will be a generic way in KDE 4 to restore the docks // of the main window. In the meantime they are restored manually (see also // DolphinMainWindow::closeEvent() for more details): - QString filename = KStandardDirs::locateLocal("data", KGlobal::instance()->instanceName()); - filename.append("/panels_layout"); + QString filename = KStandardDirs::locateLocal("data", KGlobal::mainComponent().componentName()); filename.append("/panels_layout"); QFile file(filename); if (file.open(QIODevice::ReadOnly)) { QByteArray data = file.readAll(); @@ -967,14 +1011,14 @@ void DolphinMainWindow::setupActions() connect(deleteAction, SIGNAL(triggered()), this, SLOT(deleteItems())); QAction* properties = actionCollection()->addAction("properties"); - properties->setText(i18n("Propert&ies")); - properties->setShortcut(Qt::Key_Alt | Qt::Key_Return); + 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(KonqUndoManager::self(), + KStandardAction::undo(this, SLOT(undo()), actionCollection()); @@ -1029,10 +1073,25 @@ void DolphinMainWindow::setupActions() sortByDate->setText(i18n("By Date")); connect(sortByDate, SIGNAL(triggered()), this, SLOT(sortByDate())); + KToggleAction* sortByPermissions = actionCollection()->add("by_permissions"); + sortByPermissions->setText(i18n("By Permissions")); + connect(sortByPermissions, SIGNAL(triggered()), this, SLOT(sortByPermissions())); + + KToggleAction* sortByOwner = actionCollection()->add("by_owner"); + sortByOwner->setText(i18n("By Owner")); + connect(sortByOwner, SIGNAL(triggered()), this, SLOT(sortByOwner())); + + KToggleAction* sortByGroup = actionCollection()->add("by_group"); + sortByGroup->setText(i18n("By Group")); + connect(sortByGroup, SIGNAL(triggered()), this, SLOT(sortByGroup())); + QActionGroup* sortGroup = new QActionGroup(this); sortGroup->addAction(sortByName); sortGroup->addAction(sortBySize); sortGroup->addAction(sortByDate); + sortGroup->addAction(sortByPermissions); + sortGroup->addAction(sortByOwner); + sortGroup->addAction(sortByGroup); KToggleAction* sortDescending = actionCollection()->add("descending"); sortDescending->setText(i18n("Descending")); @@ -1044,7 +1103,7 @@ void DolphinMainWindow::setupActions() KToggleAction* showHiddenFiles = actionCollection()->add("show_hidden_files"); showHiddenFiles->setText(i18n("Show Hidden Files")); - //showHiddenFiles->setShortcut(Qt::ALT | Qt::Key_ KDE4-TODO: what Qt-Key represents '.'? + showHiddenFiles->setShortcut(Qt::ALT | Qt::Key_Period); connect(showHiddenFiles, SIGNAL(triggered()), this, SLOT(toggleShowHiddenFiles())); KToggleAction* split = actionCollection()->add("split_view"); @@ -1064,12 +1123,15 @@ void DolphinMainWindow::setupActions() stop->setIcon(KIcon("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("editable_location"); showFullLocation->setText(i18n("Show Full Location")); showFullLocation->setShortcut(Qt::CTRL | Qt::Key_L); connect(showFullLocation, SIGNAL(triggered()), this, SLOT(toggleEditLocation())); - KToggleAction* editLocation = actionCollection()->add("edit_location"); + QAction* editLocation = actionCollection()->addAction("edit_location"); editLocation->setText(i18n("Edit Location")); editLocation->setShortcut(Qt::Key_F6); connect(editLocation, SIGNAL(triggered()), this, SLOT(editLocation())); @@ -1227,6 +1289,10 @@ void DolphinMainWindow::updateViewActions() KToggleAction* splitAction = static_cast(actionCollection()->action("split_view")); splitAction->setChecked(m_view[SecondaryIdx] != 0); + + KToggleAction* editableLocactionAction = + static_cast(actionCollection()->action("editable_location")); + editableLocactionAction->setChecked(m_activeView->isUrlEditable()); } void DolphinMainWindow::updateGoActions()