* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
***************************************************************************/
#include "dolphinmainwindow.h"
DolphinMainWindow::DolphinMainWindow() :
- KMainWindow(0, "Dolphin"),
+ KMainWindow(0),
m_splitter(0),
m_activeView(0),
m_clipboardContainsCutData(false)
{
+ setObjectName("Dolphin");
m_view[PrimaryIdx] = 0;
m_view[SecondaryIdx] = 0;
url,
props.viewMode(),
props.isShowHiddenFilesEnabled());
+ connectViewSignals(i);
m_view[i]->show();
}
}
emit activeViewChanged();
}
-void DolphinMainWindow::slotHistoryChanged()
-{
- updateHistory();
-}
-
-void DolphinMainWindow::slotUrlChanged(const KUrl& url)
-{
- updateEditActions();
- updateGoActions();
- setCaption(url.fileName());
-}
-
-void DolphinMainWindow::slotUrlChangeRequest(const KUrl& url)
-{
- clearStatusBar();
- m_activeView->setUrl(url);
-}
-
void DolphinMainWindow::slotViewModeChanged()
{
updateViewActions();
showHiddenFilesAction->setChecked(m_activeView->isShowHiddenFilesEnabled());
}
-void DolphinMainWindow::slotShowFilterBarChanged()
-{
- KToggleAction* showFilterBarAction =
- static_cast<KToggleAction*>(actionCollection()->action("show_filter_bar"));
- showFilterBarAction->setChecked(m_activeView->isFilterBarVisible());
-}
-
void DolphinMainWindow::slotSortingChanged(DolphinView::Sorting sorting)
{
- KAction* action = 0;
+ QAction* action = 0;
switch (sorting) {
case DolphinView::SortByName:
action = actionCollection()->action("by_name");
selectedUrlsCount += m_view[SecondaryIdx]->selectedUrls().count();
}
- KAction* compareFilesAction = actionCollection()->action("compare_files");
+ QAction* compareFilesAction = actionCollection()->action("compare_files");
compareFilesAction->setEnabled(selectedUrlsCount == 2);
m_activeView->updateStatusBar();
emit selectionChanged();
}
-void DolphinMainWindow::slotRedo()
+void DolphinMainWindow::slotHistoryChanged()
+{
+ updateHistory();
+}
+
+void DolphinMainWindow::slotUrlChanged(const KUrl& url)
+{
+ updateEditActions();
+ updateGoActions();
+ setCaption(url.fileName());
+}
+
+void DolphinMainWindow::updateFilterBarAction(bool show)
+{
+ KToggleAction* showFilterBarAction =
+ static_cast<KToggleAction*>(actionCollection()->action("show_filter_bar"));
+ showFilterBarAction->setChecked(show);
+}
+
+void DolphinMainWindow::redo()
{
UndoManager::instance().redo(this);
}
-void DolphinMainWindow::slotUndo()
+void DolphinMainWindow::undo()
{
UndoManager::instance().undo(this);
}
-void DolphinMainWindow::slotNewMainWindow()
+void DolphinMainWindow::openNewMainWindow()
{
DolphinApplication::app()->createMainWindow()->show();
}
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::slotUndoAvailable(bool available)
{
- KAction* undoAction = actionCollection()->action(KStdAction::stdName(KStdAction::Undo));
+ QAction* undoAction = actionCollection()->action(KStdAction::stdName(KStdAction::Undo));
if (undoAction != 0) {
undoAction->setEnabled(available);
}
void DolphinMainWindow::slotUndoTextChanged(const QString& text)
{
- KAction* undoAction = actionCollection()->action(KStdAction::stdName(KStdAction::Undo));
+ QAction* undoAction = actionCollection()->action(KStdAction::stdName(KStdAction::Undo));
if (undoAction != 0) {
undoAction->setText(text);
}
void DolphinMainWindow::slotRedoAvailable(bool available)
{
- KAction* redoAction = actionCollection()->action(KStdAction::stdName(KStdAction::Redo));
+ QAction* redoAction = actionCollection()->action(KStdAction::stdName(KStdAction::Redo));
if (redoAction != 0) {
redoAction->setEnabled(available);
}
void DolphinMainWindow::slotRedoTextChanged(const QString& text)
{
- KAction* redoAction = actionCollection()->action(KStdAction::stdName(KStdAction::Redo));
+ QAction* redoAction = actionCollection()->action(KStdAction::stdName(KStdAction::Redo));
if (redoAction != 0) {
redoAction->setText(text);
}
void DolphinMainWindow::updatePasteAction()
{
- KAction* pasteAction = actionCollection()->action(KStdAction::stdName(KStdAction::Paste));
+ QAction* pasteAction = actionCollection()->action(KStdAction::stdName(KStdAction::Paste));
if (pasteAction == 0) {
return;
}
void DolphinMainWindow::toggleSplitView()
{
if (m_view[SecondaryIdx] == 0) {
+ const int newWidth = (m_view[PrimaryIdx]->width() - m_splitter->handleWidth()) / 2;
// create a secondary view
m_view[SecondaryIdx] = new DolphinView(this,
- m_splitter,
+ 0,
m_view[PrimaryIdx]->url(),
m_view[PrimaryIdx]->mode(),
m_view[PrimaryIdx]->isShowHiddenFilesEnabled());
+ connectViewSignals(SecondaryIdx);
+ m_splitter->addWidget(m_view[SecondaryIdx]);
+ m_splitter->setSizes(QList<int>() << newWidth << newWidth);
m_view[SecondaryIdx]->show();
}
else {
// From an implementation point of view it is more efficient to close
// the primary view and exchange the internal pointers afterwards.
m_view[PrimaryIdx]->close();
- m_view[PrimaryIdx]->deleteLater();
+ delete m_view[PrimaryIdx];
m_view[PrimaryIdx] = m_view[SecondaryIdx];
m_view[SecondaryIdx] = 0;
setActiveView(m_view[PrimaryIdx]);
homeUrl,
props.viewMode(),
props.isShowHiddenFilesEnabled());
+ connectViewSignals(PrimaryIdx);
+ m_view[PrimaryIdx]->show();
m_activeView = m_view[PrimaryIdx];
{
// setup 'File' menu
KAction *action = new KAction(KIcon("window_new"), i18n( "New &Window" ), actionCollection(), "new_window" );
- connect(action, SIGNAL(triggered()), this, SLOT(slotNewMainWindow()));
+ connect(action, SIGNAL(triggered()), this, SLOT(openNewMainWindow()));
KAction* createFolder = new KAction(i18n("Folder..."), actionCollection(), "create_folder");
createFolder->setIcon(KIcon("folder"));
// setup 'Edit' menu
UndoManager& undoManager = UndoManager::instance();
KStdAction::undo(this,
- SLOT(slotUndo()),
+ SLOT(undo()),
actionCollection());
connect(&undoManager, SIGNAL(undoAvailable(bool)),
this, SLOT(slotUndoAvailable(bool)));
this, SLOT(slotUndoTextChanged(const QString&)));
KStdAction::redo(this,
- SLOT(slotRedo()),
+ SLOT(redo()),
actionCollection());
connect(&undoManager, SIGNAL(redoAvailable(bool)),
this, SLOT(slotRedoAvailable(bool)));
KStdAction::preferences(this, SLOT(editSettings()), actionCollection());
}
+void DolphinMainWindow::setupDockWidgets()
+{
+ QDockWidget *shortcutsDock = new QDockWidget(i18n("Shortcuts"));
+
+ shortcutsDock->setObjectName("shortcutsDock");
+ shortcutsDock->setWidget(new BookmarksSidebarPage(this));
+
+ shortcutsDock->toggleViewAction()->setObjectName("show_shortcuts_pane");
+ shortcutsDock->toggleViewAction()->setText(i18n("Show Shortcuts Panel"));
+ actionCollection()->insert(shortcutsDock->toggleViewAction());
+
+ addDockWidget(Qt::LeftDockWidgetArea, shortcutsDock);
+
+ QDockWidget *infoDock = new QDockWidget(i18n("Information"));
+
+ infoDock->setObjectName("infoDock");
+ infoDock->setWidget(new InfoSidebarPage(this));
+
+ infoDock->toggleViewAction()->setObjectName("show_info_pane");
+ infoDock->toggleViewAction()->setText(i18n("Show Information Panel"));
+ actionCollection()->insert(infoDock->toggleViewAction());
+
+ addDockWidget(Qt::RightDockWidgetArea, infoDock);
+}
+
void DolphinMainWindow::setupCreateNewMenuActions()
{
// Parts of the following code have been taken
int index = 0;
const Q3ValueList<UrlNavigator::HistoryElem> list = m_activeView->urlHistory(index);
- KAction* backAction = actionCollection()->action("go_back");
+ QAction* backAction = actionCollection()->action("go_back");
if (backAction != 0) {
backAction->setEnabled(index < static_cast<int>(list.count()) - 1);
}
- KAction* forwardAction = actionCollection()->action("go_forward");
+ QAction* forwardAction = actionCollection()->action("go_forward");
if (forwardAction != 0) {
forwardAction->setEnabled(index > 0);
}
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 {
stateChanged("has_selection");
- KAction* renameAction = actionCollection()->action("rename");
+ QAction* 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();
++it;
}
- KAction* moveToTrashAction = actionCollection()->action("move_to_trash");
+ QAction* moveToTrashAction = actionCollection()->action("move_to_trash");
moveToTrashAction->setEnabled(enableMoveToTrash);
}
updatePasteAction();
void DolphinMainWindow::updateViewActions()
{
- KAction* zoomInAction = actionCollection()->action(KStdAction::stdName(KStdAction::ZoomIn));
+ QAction* zoomInAction = actionCollection()->action(KStdAction::stdName(KStdAction::ZoomIn));
if (zoomInAction != 0) {
zoomInAction->setEnabled(m_activeView->isZoomInPossible());
}
- KAction* zoomOutAction = actionCollection()->action(KStdAction::stdName(KStdAction::ZoomOut));
+ QAction* zoomOutAction = actionCollection()->action(KStdAction::stdName(KStdAction::ZoomOut));
if (zoomOutAction != 0) {
zoomOutAction->setEnabled(m_activeView->isZoomOutPossible());
}
- KAction* action = 0;
+ QAction* action = 0;
switch (m_activeView->mode()) {
case DolphinView::IconsView:
action = actionCollection()->action("icons");
void DolphinMainWindow::updateGoActions()
{
- KAction* goUpAction = actionCollection()->action(KStdAction::stdName(KStdAction::Up));
+ QAction* goUpAction = actionCollection()->action(KStdAction::stdName(KStdAction::Up));
const KUrl& currentUrl = m_activeView->url();
goUpAction->setEnabled(currentUrl.upUrl() != currentUrl);
}
m_activeView->statusBar()->clear();
}
-void DolphinMainWindow::setupDockWidgets()
-{
- QDockWidget *shortcutsDock = new QDockWidget(i18n("Shortcuts"));
- shortcutsDock->setObjectName("shortcutsDock");
- shortcutsDock->setFeatures(QDockWidget::DockWidgetMovable|QDockWidget::DockWidgetFloatable);
- shortcutsDock->setWidget(new BookmarksSidebarPage(this));
- addDockWidget(Qt::LeftDockWidgetArea, shortcutsDock);
+void DolphinMainWindow::connectViewSignals(int viewIndex)
+{
+ DolphinView* view = m_view[viewIndex];
+ connect(view, SIGNAL(modeChanged()),
+ this, SLOT(slotViewModeChanged()));
+ connect(view, SIGNAL(showHiddenFilesChanged()),
+ this, SLOT(slotShowHiddenFilesChanged()));
+ connect(view, SIGNAL(sortingChanged(DolphinView::Sorting)),
+ this, SLOT(slotSortingChanged(DolphinView::Sorting)));
+ connect(view, SIGNAL(sortOrderChanged(Qt::SortOrder)),
+ this, SLOT(slotSortOrderChanged(Qt::SortOrder)));
+ connect(view, SIGNAL(selectionChanged()),
+ this, SLOT(slotSelectionChanged()));
+ connect(view, SIGNAL(showFilterBarChanged(bool)),
+ this, SLOT(updateFilterBarAction(bool)));
+
+ const UrlNavigator* navigator = view->urlNavigator();
+ connect(navigator, SIGNAL(urlChanged(const KUrl&)),
+ this, SLOT(slotUrlChanged(const KUrl&)));
+ connect(navigator, SIGNAL(historyChanged()),
+ this, SLOT(slotHistoryChanged()));
- 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"