#include <Q3ValueList>
#include <QCloseEvent>
#include <QSplitter>
+#include <QDockWidget>
#include "urlnavigator.h"
#include "viewpropertiesdialog.h"
#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;
UndoManager::instance().undo(this);
}
+void DolphinMainWindow::slotNewMainWindow()
+{
+ DolphinApplication::app()->createMainWindow()->show();
+}
+
void DolphinMainWindow::closeEvent(QCloseEvent* event)
{
// KDE4-TODO
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);
KSortableList<CreateFileEntry, QString>::ConstIterator it = m_createFileTemplates.begin();
KSortableList<CreateFileEntry, QString>::ConstIterator end = m_createFileTemplates.end();
- const QString senderName(sender()->name());
+ const QString senderName(sender()->objectName());
bool found = false;
CreateFileEntry entry;
while (!found && (it != end)) {
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);
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);
}
}
}
-void DolphinMainWindow::toggleSidebar()
-{
- if (m_sidebar == 0) {
- openSidebar();
- }
- else {
- closeSidebar();
- }
-
- KToggleAction* sidebarAction = static_cast<KToggleAction*>(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
}
setupActions();
- setupGUI(Keys|Save|Create|ToolBar);
const KUrl& homeUrl = root.first().url();
setCaption(homeUrl.fileName());
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");
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);
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()));
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 {
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();
KToggleAction* splitAction = static_cast<KToggleAction*>(actionCollection()->action("split_view"));
splitAction->setChecked(m_view[SecondaryIdx] != 0);
-
- KToggleAction* sidebarAction = static_cast<KToggleAction*>(actionCollection()->action("sidebar"));
- sidebarAction->setChecked(m_sidebar != 0);
}
void DolphinMainWindow::updateGoActions()
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"