X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/b2f5de974463f54023905e0979102d179eed0a00..32b51b7b92e16cfaf1121cbe80ca267fc8bb0718:/src/views/viewproperties.cpp diff --git a/src/views/viewproperties.cpp b/src/views/viewproperties.cpp index ff0c274be..bcea06253 100644 --- a/src/views/viewproperties.cpp +++ b/src/views/viewproperties.cpp @@ -27,6 +27,8 @@ #include #include #include +#include +#include #include #include @@ -53,7 +55,7 @@ ViewProperties::ViewProperties(const KUrl& url) : m_node(0) { GeneralSettings* settings = GeneralSettings::self(); - const bool useGlobalViewProps = settings->globalViewProps(); + const bool useGlobalViewProps = settings->globalViewProps() || url.isEmpty(); bool useDetailsViewWithPath = false; // We try and save it to the file .directory in the directory being viewed. @@ -69,8 +71,13 @@ ViewProperties::ViewProperties(const KUrl& url) : useDetailsViewWithPath = true; } else if (url.isLocalFile()) { m_filePath = url.toLocalFile(); - const QFileInfo info(m_filePath); - if (!info.isWritable() || !isPartOfHome(m_filePath)) { + const QFileInfo dirInfo(m_filePath); + const QFileInfo fileInfo(m_filePath + QDir::separator() + ViewPropertiesFileName); + // Check if the directory is writable and check if the ".directory" file exists and + // is read- and writable. + if (!dirInfo.isWritable() + || (fileInfo.exists() && !(fileInfo.isReadable() && fileInfo.isWritable())) + || !isPartOfHome(m_filePath)) { #ifdef Q_OS_WIN // m_filePath probably begins with C:/ - the colon is not a valid character for paths though m_filePath = QDir::separator() + m_filePath.remove(QLatin1Char(':')); @@ -95,13 +102,13 @@ ViewProperties::ViewProperties(const KUrl& url) : setVisibleRoles(QList() << "path"); } else { // The global view-properties act as default for directories without - // any view-property configuration - settings->setGlobalViewProps(true); - - ViewProperties defaultProps(url); + // any view-property configuration. Constructing a ViewProperties + // instance for an empty KUrl ensures that the global view-properties + // are loaded. + KUrl emptyUrl; + ViewProperties defaultProps(emptyUrl); setDirProperties(defaultProps); - settings->setGlobalViewProps(false); m_changedProps = false; } }