X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/9a4a17dd4d7f3d195ab4393e057e8eb90b0a3422..d27b30a66ae9038eadf81cc06dae1b002bef7625:/src/dolphinmainwindow.cpp diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp index af9bd0a01..08773fac1 100644 --- a/src/dolphinmainwindow.cpp +++ b/src/dolphinmainwindow.cpp @@ -58,6 +58,7 @@ #include #include #include +#include #include "urlnavigator.h" #include "viewpropertiesdialog.h" @@ -69,19 +70,19 @@ #include "undomanager.h" #include "progressindicator.h" #include "dolphinsettings.h" -#include "sidebar.h" -#include "sidebarsettings.h" +#include "bookmarkssidebarpage.h" +#include "infosidebarpage.h" #include "generalsettings.h" #include "dolphinapplication.h" DolphinMainWindow::DolphinMainWindow() : - KMainWindow(0, "Dolphin"), + KMainWindow(0), m_splitter(0), - m_sidebar(0), m_activeView(0), m_clipboardContainsCutData(false) { + setObjectName("Dolphin"); m_view[PrimaryIdx] = 0; m_view[SecondaryIdx] = 0; @@ -323,6 +324,11 @@ void DolphinMainWindow::slotUndo() UndoManager::instance().undo(this); } +void DolphinMainWindow::slotNewMainWindow() +{ + DolphinApplication::app()->createMainWindow()->show(); +} + void DolphinMainWindow::closeEvent(QCloseEvent* event) { // KDE4-TODO @@ -334,13 +340,6 @@ void DolphinMainWindow::closeEvent(QCloseEvent* event) GeneralSettings* generalSettings = settings.generalSettings(); generalSettings->setFirstRun(false); - SidebarSettings* sidebarSettings = settings.sidebarSettings(); - const bool isSidebarVisible = (m_sidebar != 0); - sidebarSettings->setVisible(isSidebarVisible); - if (isSidebarVisible) { - sidebarSettings->setWidth(m_sidebar->width()); - } - settings.save(); KMainWindow::closeEvent(event); @@ -460,7 +459,7 @@ void DolphinMainWindow::createFile() KSortableList::ConstIterator it = m_createFileTemplates.begin(); KSortableList::ConstIterator end = m_createFileTemplates.end(); - const QString senderName(sender()->name()); + const QString senderName(sender()->objectName()); bool found = false; CreateFileEntry entry; while (!found && (it != end)) { @@ -485,7 +484,7 @@ void DolphinMainWindow::createFile() QString sourcePath(entry.templatePath.left(pos + 1)); sourcePath += KDesktopFile(entry.templatePath, true).readPathEntry("Url"); - QString name(i18n(entry.name.ascii())); + QString name(i18n(entry.name.toAscii())); // Most entry names end with "..." (e. g. "HTML File..."), which is ok for // menus but no good choice for a new file name -> remove the dots... name.replace("...", QString::null); @@ -591,20 +590,7 @@ void DolphinMainWindow::deleteItems() void DolphinMainWindow::properties() { - const KFileItemList* sourceList = m_activeView->selectedItems(); - if (sourceList == 0) { - return; - } - - KFileItemList list; - KFileItemList::const_iterator it = sourceList->begin(); - const KFileItemList::const_iterator end = sourceList->end(); - KFileItem* item = 0; - while (it != end) { - list.append(item); - ++it; - } - + const KFileItemList list = m_activeView->selectedItems(); new KPropertiesDialog(list, this); } @@ -1102,36 +1088,6 @@ void DolphinMainWindow::addUndoOperation(KJob* job) } } -void DolphinMainWindow::toggleSidebar() -{ - if (m_sidebar == 0) { - openSidebar(); - } - else { - closeSidebar(); - } - - KToggleAction* sidebarAction = static_cast(actionCollection()->action("sidebar")); - sidebarAction->setChecked(m_sidebar != 0); -} - -void DolphinMainWindow::closeSidebar() -{ - if (m_sidebar == 0) { - // the sidebar has already been closed - return; - } - - // store width of sidebar and remember that the sidebar has been closed - SidebarSettings* settings = DolphinSettings::instance().sidebarSettings(); - settings->setVisible(false); - settings->setWidth(m_sidebar->width()); - - m_sidebar->deleteLater(); - m_sidebar = 0; -} - - void DolphinMainWindow::init() { // Check whether Dolphin runs the first time. If yes then @@ -1157,7 +1113,6 @@ void DolphinMainWindow::init() } setupActions(); - setupGUI(Keys|Save|Create|ToolBar); const KUrl& homeUrl = root.first().url(); setCaption(homeUrl.fileName()); @@ -1171,14 +1126,9 @@ void DolphinMainWindow::init() m_activeView = m_view[PrimaryIdx]; setCentralWidget(m_splitter); + setupDockWidgets(); - // open sidebar - SidebarSettings* sidebarSettings = settings.sidebarSettings(); - assert(sidebarSettings != 0); - if (sidebarSettings->visible()) { - openSidebar(); - } - + setupGUI(Keys|Save|Create|ToolBar); createGUI(); stateChanged("new_file"); @@ -1216,6 +1166,9 @@ void DolphinMainWindow::loadSettings() void DolphinMainWindow::setupActions() { // setup 'File' menu + KAction *action = new KAction(KIcon("window_new"), i18n( "New &Window" ), actionCollection(), "new_window" ); + connect(action, SIGNAL(triggered()), this, SLOT(slotNewMainWindow())); + KAction* createFolder = new KAction(i18n("Folder..."), actionCollection(), "create_folder"); createFolder->setIcon(KIcon("folder")); createFolder->setShortcut(Qt::Key_N); @@ -1343,10 +1296,6 @@ void DolphinMainWindow::setupActions() editLocation->setShortcut(Qt::Key_F6); connect(editLocation, SIGNAL(triggered()), this, SLOT(editLocation())); - KToggleAction* sidebar = new KToggleAction(i18n("Sidebar"), actionCollection(), "sidebar"); - sidebar->setShortcut(Qt::Key_F9); - connect(sidebar, SIGNAL(triggered()), this, SLOT(toggleSidebar())); - KAction* adjustViewProps = new KAction(i18n("Adjust View Properties..."), actionCollection(), "view_properties"); connect(adjustViewProps, SIGNAL(triggered()), this, SLOT(adjustViewProperties())); @@ -1500,8 +1449,8 @@ void DolphinMainWindow::updateHistory() void DolphinMainWindow::updateEditActions() { - const KFileItemList* list = m_activeView->selectedItems(); - if ((list == 0) || (*list).isEmpty()) { + const KFileItemList list = m_activeView->selectedItems(); + if (list.isEmpty()) { stateChanged("has_no_selection"); } else { @@ -1509,13 +1458,13 @@ void DolphinMainWindow::updateEditActions() KAction* renameAction = actionCollection()->action("rename"); if (renameAction != 0) { - renameAction->setEnabled(list->count() >= 1); + renameAction->setEnabled(list.count() >= 1); } bool enableMoveToTrash = true; - KFileItemList::const_iterator it = list->begin(); - const KFileItemList::const_iterator end = list->end(); + KFileItemList::const_iterator it = list.begin(); + const KFileItemList::const_iterator end = list.end(); while (it != end) { KFileItem* item = *it; const KUrl& url = item->url(); @@ -1577,9 +1526,6 @@ void DolphinMainWindow::updateViewActions() KToggleAction* splitAction = static_cast(actionCollection()->action("split_view")); splitAction->setChecked(m_view[SecondaryIdx] != 0); - - KToggleAction* sidebarAction = static_cast(actionCollection()->action("sidebar")); - sidebarAction->setChecked(m_sidebar != 0); } void DolphinMainWindow::updateGoActions() @@ -1644,24 +1590,19 @@ void DolphinMainWindow::clearStatusBar() m_activeView->statusBar()->clear(); } -void DolphinMainWindow::openSidebar() +void DolphinMainWindow::setupDockWidgets() { - if (m_sidebar != 0) { - // the sidebar is already open - return; - } - - m_sidebar = new Sidebar(this, m_splitter); - m_sidebar->show(); - - connect(m_sidebar, SIGNAL(urlChanged(const KUrl&)), - this, SLOT(slotUrlChangeRequest(const KUrl&))); - m_splitter->setCollapsible(m_sidebar, false); - m_splitter->setResizeMode(m_sidebar, QSplitter::KeepSize); - m_splitter->moveToFirst(m_sidebar); + QDockWidget *shortcutsDock = new QDockWidget(i18n("Shortcuts")); + shortcutsDock->setObjectName("shortcutsDock"); + shortcutsDock->setFeatures(QDockWidget::DockWidgetMovable|QDockWidget::DockWidgetFloatable); + shortcutsDock->setWidget(new BookmarksSidebarPage(this)); + addDockWidget(Qt::LeftDockWidgetArea, shortcutsDock); - SidebarSettings* settings = DolphinSettings::instance().sidebarSettings(); - settings->setVisible(true); + QDockWidget *infoDock = new QDockWidget(i18n("Information")); + infoDock->setObjectName("infoDock"); + infoDock->setFeatures(QDockWidget::DockWidgetMovable|QDockWidget::DockWidgetFloatable); + infoDock->setWidget(new InfoSidebarPage(this)); + addDockWidget(Qt::RightDockWidgetArea, infoDock); } #include "dolphinmainwindow.moc"