]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/views/dolphincolumnview.cpp
The &-shortcut from another action is not set until the action has been shown at...
[dolphin.git] / src / views / dolphincolumnview.cpp
index 309674122b362843581f3f182924eefb22dc1c4e..4b3a9f582da9fae9825591c3a52936025e77326f 100644 (file)
@@ -120,6 +120,7 @@ DolphinColumnView::DolphinColumnView(QWidget* parent,
     m_dirLister->setDelayedMimeTypes(true);
     const bool showHiddenFiles = m_container->m_dolphinViewController->view()->showHiddenFiles();
     m_dirLister->setShowingDotFiles(showHiddenFiles);
+    connect(m_dirLister, SIGNAL(completed()), this, SLOT(slotDirListerCompleted()));
 
     m_dolphinModel = new DolphinModel(this);
     m_dolphinModel->setDirLister(m_dirLister);
@@ -496,6 +497,34 @@ void DolphinColumnView::slotShowPreviewChanged()
     updateDecorationSize(view->showPreview());
 }
 
+void DolphinColumnView::slotDirListerCompleted()
+{
+    if (!m_childUrl.isEmpty()) {
+        return;
+    }
+
+    // Try to optimize the width of the column, so that no name gets clipped
+    const int requiredWidth = sizeHintForColumn(DolphinModel::Name);
+
+    const ColumnModeSettings* settings = DolphinSettings::instance().columnModeSettings();
+    if (requiredWidth > settings->columnWidth()) {
+        int frameAroundContents = 0;
+        if (style()->styleHint(QStyle::SH_ScrollView_FrameOnlyAroundContents)) {
+            // TODO: Using 2 PM_DefaultFrameWidths are not sufficient. Check Qt-code
+            // for other pixelmetrics that should be added...
+            frameAroundContents = style()->pixelMetric(QStyle::PM_DefaultFrameWidth) * 4;
+        }
+
+        const int scrollBarWidth = style()->pixelMetric(QStyle::PM_ScrollBarExtent, 0, verticalScrollBar());
+
+        setMaximumWidth(requiredWidth + frameAroundContents + scrollBarWidth);
+        m_container->layoutColumns();
+        if (m_active) {
+            m_container->assureVisibleActiveColumn();
+        }
+    }
+}
+
 void DolphinColumnView::activate()
 {
     setFocus(Qt::OtherFocusReason);