#include <assert.h>\r
\r
#include "dolphinapplication.h"\r
+#include "dolphinnewmenu.h"\r
#include "dolphinsettings.h"\r
#include "dolphinsettingsdialog.h"\r
#include "dolphinstatusbar.h"\r
#include "generalsettings.h"\r
#include "viewpropertiesdialog.h"\r
#include "viewproperties.h"\r
+#include "mainwindowadaptor.h"\r
\r
#include <kaction.h>\r
#include <kactioncollection.h>\r
#include <kicon.h>\r
#include <kiconloader.h>\r
#include <kio/netaccess.h>\r
+#include <kio/deletejob.h>\r
#include <kio/renamedialog.h>\r
#include <kinputdialog.h>\r
#include <klocale.h>\r
#include <kmenu.h>\r
#include <kmessagebox.h>\r
-#include <knewmenu.h>\r
#include <konqmimedata.h>\r
#include <kpropertiesdialog.h>\r
#include <kprotocolinfo.h>\r
#include <QSplitter>\r
#include <QDockWidget>\r
\r
-DolphinMainWindow::DolphinMainWindow() :\r
+DolphinMainWindow::DolphinMainWindow(int id) :\r
KMainWindow(0),\r
m_newMenu(0),\r
m_splitter(0),\r
- m_activeView(0)\r
+ m_activeView(0),\r
+ m_id(id)\r
{\r
setObjectName("Dolphin");\r
m_view[PrimaryIdx] = 0;\r
m_view[SecondaryIdx] = 0;\r
\r
+ new MainWindowAdaptor(this);\r
+ QDBusConnection::sessionBus().registerObject(QString("/dolphin/MainWindow%1").arg(m_id), this);\r
+\r
KonqUndoManager::incRef();\r
\r
KonqUndoManager* undoManager = KonqUndoManager::self();\r
i18n("&Link Here") + "\t" + seq);\r
\r
popup.addSeparator();\r
- QAction* cancelAction = popup.addAction(KIcon("stop"), i18n("Cancel"));\r
+ popup.addAction(KIcon("stop"), i18n("Cancel"));\r
\r
QAction* activatedAction = popup.exec(QCursor::pos());\r
if (activatedAction == moveAction) {\r
else if (activatedAction == linkAction) {\r
action = Qt::LinkAction;\r
}\r
- else if (activatedAction == cancelAction) {\r
+ else {\r
return;\r
}\r
}\r
emit activeViewChanged();\r
}\r
\r
+void DolphinMainWindow::changeUrl(const QString& url)\r
+{\r
+ if (activeView() != 0) {\r
+ activeView()->setUrl(KUrl(url));\r
+ }\r
+}\r
+\r
void DolphinMainWindow::slotViewModeChanged()\r
{\r
updateViewActions();\r
case DolphinView::SortByDate:\r
action = actionCollection()->action("by_date");\r
break;\r
+ case DolphinView::SortByPermissions:\r
+ action = actionCollection()->action("by_permissions");\r
+ break;\r
+ case DolphinView::SortByOwner:\r
+ action = actionCollection()->action("by_owner");\r
+ break;\r
+ case DolphinView::SortByGroup:\r
+ action = actionCollection()->action("by_group");\r
+ break;\r
default:\r
break;\r
}\r
\r
// TODO: I assume there will be a generic way in KDE 4 to store the docks\r
// of the main window. In the meantime they are stored manually:\r
- QString filename = KStandardDirs::locateLocal("data", KGlobal::instance()->instanceName());\r
+ QString filename = KStandardDirs::locateLocal("data", KGlobal::mainComponent().componentName());\r
filename.append("/panels_layout");\r
QFile file(filename);\r
if (file.open(QIODevice::WriteOnly)) {\r
}\r
}\r
\r
+void DolphinMainWindow::undo()\r
+{\r
+ clearStatusBar();\r
+ KonqUndoManager::self()->undo();\r
+}\r
+\r
void DolphinMainWindow::cut()\r
{\r
QMimeData* mimeData = new QMimeData();\r
m_activeView->setSorting(DolphinView::SortByDate);\r
}\r
\r
+void DolphinMainWindow::sortByPermissions()\r
+{\r
+ m_activeView->setSorting(DolphinView::SortByPermissions);\r
+}\r
+\r
+void DolphinMainWindow::sortByOwner()\r
+{\r
+ m_activeView->setSorting(DolphinView::SortByOwner);\r
+}\r
+\r
+void DolphinMainWindow::sortByGroup()\r
+{\r
+ m_activeView->setSorting(DolphinView::SortByGroup);\r
+}\r
+\r
void DolphinMainWindow::toggleSortOrder()\r
{\r
const Qt::SortOrder order = (m_activeView->sortOrder() == Qt::Ascending) ?\r
setActiveView(m_view[PrimaryIdx]);\r
}\r
}\r
+ emit activeViewChanged();\r
}\r
\r
void DolphinMainWindow::reloadView()\r
\r
void DolphinMainWindow::editLocation()\r
{\r
- KToggleAction* action = static_cast<KToggleAction*>(actionCollection()->action("editable_location"));\r
- action->setChecked(true);\r
m_activeView->setUrlEditable(true);\r
}\r
\r
// a proper default window size is given at the end of DolphinMainWindow::init().\r
GeneralSettings* generalSettings = DolphinSettings::instance().generalSettings();\r
const bool firstRun = generalSettings->firstRun();\r
+ if (firstRun) {\r
+ generalSettings->setViewPropsTimestamp(QDateTime::currentDateTime());\r
+ }\r
\r
setAcceptDrops(true);\r
\r
// TODO: I assume there will be a generic way in KDE 4 to restore the docks\r
// of the main window. In the meantime they are restored manually (see also\r
// DolphinMainWindow::closeEvent() for more details):\r
- QString filename = KStandardDirs::locateLocal("data", KGlobal::instance()->instanceName());\r
- filename.append("/panels_layout");\r
+ QString filename = KStandardDirs::locateLocal("data", KGlobal::mainComponent().componentName()); filename.append("/panels_layout");\r
QFile file(filename);\r
if (file.open(QIODevice::ReadOnly)) {\r
QByteArray data = file.readAll();\r
void DolphinMainWindow::setupActions()\r
{\r
// setup 'File' menu\r
- m_newMenu = new KNewMenu(actionCollection(), this, "create_new");\r
+ m_newMenu = new DolphinNewMenu(this);\r
KMenu* menu = m_newMenu->menu();\r
menu->setTitle(i18n("Create New..."));\r
menu->setIcon(SmallIcon("filenew"));\r
connect(deleteAction, SIGNAL(triggered()), this, SLOT(deleteItems()));\r
\r
QAction* properties = actionCollection()->addAction("properties");\r
- properties->setText(i18n("Propert&ies"));\r
- properties->setShortcut(Qt::Key_Alt | Qt::Key_Return);\r
+ properties->setText(i18n("Properties"));\r
+ properties->setShortcut(Qt::ALT | Qt::Key_Return);\r
connect(properties, SIGNAL(triggered()), this, SLOT(properties()));\r
\r
KStandardAction::quit(this, SLOT(quit()), actionCollection());\r
\r
// setup 'Edit' menu\r
- KStandardAction::undo(KonqUndoManager::self(),\r
+ KStandardAction::undo(this,\r
SLOT(undo()),\r
actionCollection());\r
\r
sortByDate->setText(i18n("By Date"));\r
connect(sortByDate, SIGNAL(triggered()), this, SLOT(sortByDate()));\r
\r
+ KToggleAction* sortByPermissions = actionCollection()->add<KToggleAction>("by_permissions");\r
+ sortByPermissions->setText(i18n("By Permissions"));\r
+ connect(sortByPermissions, SIGNAL(triggered()), this, SLOT(sortByPermissions()));\r
+\r
+ KToggleAction* sortByOwner = actionCollection()->add<KToggleAction>("by_owner");\r
+ sortByOwner->setText(i18n("By Owner"));\r
+ connect(sortByOwner, SIGNAL(triggered()), this, SLOT(sortByOwner()));\r
+\r
+ KToggleAction* sortByGroup = actionCollection()->add<KToggleAction>("by_group");\r
+ sortByGroup->setText(i18n("By Group"));\r
+ connect(sortByGroup, SIGNAL(triggered()), this, SLOT(sortByGroup()));\r
+\r
QActionGroup* sortGroup = new QActionGroup(this);\r
sortGroup->addAction(sortByName);\r
sortGroup->addAction(sortBySize);\r
sortGroup->addAction(sortByDate);\r
+ sortGroup->addAction(sortByPermissions);\r
+ sortGroup->addAction(sortByOwner);\r
+ sortGroup->addAction(sortByGroup);\r
\r
KToggleAction* sortDescending = actionCollection()->add<KToggleAction>("descending");\r
sortDescending->setText(i18n("Descending"));\r
\r
KToggleAction* showHiddenFiles = actionCollection()->add<KToggleAction>("show_hidden_files");\r
showHiddenFiles->setText(i18n("Show Hidden Files"));\r
- //showHiddenFiles->setShortcut(Qt::ALT | Qt::Key_ KDE4-TODO: what Qt-Key represents '.'?\r
+ showHiddenFiles->setShortcut(Qt::ALT | Qt::Key_Period);\r
connect(showHiddenFiles, SIGNAL(triggered()), this, SLOT(toggleShowHiddenFiles()));\r
\r
KToggleAction* split = actionCollection()->add<KToggleAction>("split_view");\r
stop->setIcon(KIcon("stop"));\r
connect(stop, SIGNAL(triggered()), this, SLOT(stopLoading()));\r
\r
+ // TODO: the URL navigator must emit a signal if the editable state has been\r
+ // changed, so that the corresponding showFullLocation action is updated. Also\r
+ // the naming "Show full Location" is currently confusing...\r
KToggleAction* showFullLocation = actionCollection()->add<KToggleAction>("editable_location");\r
showFullLocation->setText(i18n("Show Full Location"));\r
showFullLocation->setShortcut(Qt::CTRL | Qt::Key_L);\r
connect(showFullLocation, SIGNAL(triggered()), this, SLOT(toggleEditLocation()));\r
\r
- KToggleAction* editLocation = actionCollection()->add<KToggleAction>("edit_location");\r
+ QAction* editLocation = actionCollection()->addAction("edit_location");\r
editLocation->setText(i18n("Edit Location"));\r
editLocation->setShortcut(Qt::Key_F6);\r
connect(editLocation, SIGNAL(triggered()), this, SLOT(editLocation()));\r
\r
KToggleAction* splitAction = static_cast<KToggleAction*>(actionCollection()->action("split_view"));\r
splitAction->setChecked(m_view[SecondaryIdx] != 0);\r
+\r
+ KToggleAction* editableLocactionAction =\r
+ static_cast<KToggleAction*>(actionCollection()->action("editable_location"));\r
+ editableLocactionAction->setChecked(m_activeView->isUrlEditable());\r
}\r
\r
void DolphinMainWindow::updateGoActions()\r