┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/panels/places/placespanel.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/panels/places/placespanel.cpp')
-rw-r--r--src/panels/places/placespanel.cpp58
1 files changed, 54 insertions, 4 deletions
diff --git a/src/panels/places/placespanel.cpp b/src/panels/places/placespanel.cpp
index a81b99770..61c15a7a1 100644
--- a/src/panels/places/placespanel.cpp
+++ b/src/panels/places/placespanel.cpp
@@ -23,6 +23,8 @@
#include "placespanel.h"
+#include "dolphin_generalsettings.h"
+
#include <KDebug>
#include <KDirNotify>
#include <KIcon>
@@ -78,6 +80,14 @@ bool PlacesPanel::urlChanged()
return true;
}
+void PlacesPanel::readSettings()
+{
+ if (m_controller) {
+ const int delay = GeneralSettings::autoExpandFolders() ? 750 : -1;
+ m_controller->setAutoActivationDelay(delay);
+ }
+}
+
void PlacesPanel::showEvent(QShowEvent* event)
{
if (event->spontaneous()) {
@@ -94,13 +104,16 @@ void PlacesPanel::showEvent(QShowEvent* event)
connect(m_model, SIGNAL(errorMessage(QString)),
this, SIGNAL(errorMessage(QString)));
- PlacesView* view = new PlacesView();
- view->setWidgetCreator(new KItemListWidgetCreator<PlacesItemListWidget>());
- view->setGroupHeaderCreator(new KItemListGroupHeaderCreator<PlacesItemListGroupHeader>());
+ m_view = new PlacesView();
+ m_view->setWidgetCreator(new KItemListWidgetCreator<PlacesItemListWidget>());
+ m_view->setGroupHeaderCreator(new KItemListGroupHeaderCreator<PlacesItemListGroupHeader>());
- m_controller = new KItemListController(m_model, view, this);
+ m_controller = new KItemListController(m_model, m_view, this);
m_controller->setSelectionBehavior(KItemListController::SingleSelection);
m_controller->setSingleClickActivation(true);
+
+ readSettings();
+
connect(m_controller, SIGNAL(itemActivated(int)), this, SLOT(slotItemActivated(int)));
connect(m_controller, SIGNAL(itemMiddleClicked(int)), this, SLOT(slotItemMiddleClicked(int)));
connect(m_controller, SIGNAL(itemContextMenuRequested(int,QPointF)), this, SLOT(slotItemContextMenuRequested(int,QPointF)));
@@ -204,6 +217,41 @@ void PlacesPanel::slotItemContextMenuRequested(int index, const QPointF& pos)
}
menu.addSeparator();
+ KMenu* iconSizeSubMenu = new KMenu(i18nc("@item:inmenu", "Icon Size"), &menu);
+
+ struct IconSizeInfo
+ {
+ int size;
+ const char* context;
+ const char* text;
+ };
+
+ const int iconSizeCount = 4;
+ static const IconSizeInfo iconSizes[iconSizeCount] = {
+ {KIconLoader::SizeSmall, I18N_NOOP2_NOSTRIP("Small icon size", "Small (%1x%2)")},
+ {KIconLoader::SizeSmallMedium, I18N_NOOP2_NOSTRIP("Medium icon size", "Medium (%1x%2)")},
+ {KIconLoader::SizeMedium, I18N_NOOP2_NOSTRIP("Large icon size", "Large (%1x%2)")},
+ {KIconLoader::SizeLarge, I18N_NOOP2_NOSTRIP("Huge icon size", "Huge (%1x%2)")}
+ };
+
+ QMap<QAction*, int> iconSizeActionMap;
+ QActionGroup* iconSizeGroup = new QActionGroup(iconSizeSubMenu);
+
+ for (int i = 0; i < iconSizeCount; ++i) {
+ const int size = iconSizes[i].size;
+ const QString text = i18nc(iconSizes[i].context, iconSizes[i].text,
+ size, size);
+
+ QAction* action = iconSizeSubMenu->addAction(text);
+ iconSizeActionMap.insert(action, size);
+ action->setActionGroup(iconSizeGroup);
+ action->setCheckable(true);
+ action->setChecked(m_view->iconSize() == size);
+ }
+
+ menu.addMenu(iconSizeSubMenu);
+
+ menu.addSeparator();
foreach (QAction* action, customContextMenuActions()) {
menu.addAction(action);
}
@@ -229,6 +277,8 @@ void PlacesPanel::slotItemContextMenuRequested(int index, const QPointF& pos)
m_model->requestTeardown(index);
} else if (action == ejectAction) {
m_model->requestEject(index);
+ } else if (iconSizeActionMap.contains(action)) {
+ m_view->setIconSize(iconSizeActionMap.value(action));
}
}