From 0466db389125e255c27dabf1b9d21f0b814d5daa Mon Sep 17 00:00:00 2001 From: Simon Quigley Date: Mon, 5 Feb 2018 21:27:56 -0600 Subject: [PATCH] Remember the view mode. --- debian/changelog | 10 ++ debian/patches/remember-view-mode.patch | 119 ++++++++++++++++++++++++ debian/patches/series | 2 + 3 files changed, 131 insertions(+) create mode 100644 debian/patches/remember-view-mode.patch create mode 100644 debian/patches/series diff --git a/debian/changelog b/debian/changelog index 790d713..0d59cc2 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,13 @@ +lxqt-qtplugin (0.12.0-4ubuntu1) UNRELEASED; urgency=medium + + * Cherry-pick an upstream commit because the upstream release cycle is too + slow: + - Remember the view mode. + + remember-view-mode.patch + + Upstream commit dfa18ac. + + -- Simon Quigley Mon, 05 Feb 2018 21:23:14 -0600 + lxqt-qtplugin (0.12.0-4) unstable; urgency=medium * Bumped Standards to 4.1.2, no changes needed diff --git a/debian/patches/remember-view-mode.patch b/debian/patches/remember-view-mode.patch new file mode 100644 index 0000000..cc50f1c --- /dev/null +++ b/debian/patches/remember-view-mode.patch @@ -0,0 +1,119 @@ +Description: Remember the view mode + Since the LXQt file dialog has richer modes than the Qt file dialog does, it + is better to remember the user's choice on closing the dialog, as is the case + in KDE. +Author: Tsu Jan +Origin: backport +Bug: https://github.com/lxde/lxqt/issues/1358 +Applied-Upstream: commit:dfa18ac +Last-Update: 2018-02-05 +--- a/src/lxqtfiledialoghelper.cpp ++++ b/src/lxqtfiledialoghelper.cpp +@@ -12,6 +12,9 @@ + + static std::unique_ptr libfmQtContext_; + ++inline static const QString viewModeToString(Fm::FolderView::ViewMode value); ++inline static Fm::FolderView::ViewMode viewModeFromString(const QString& str); ++ + LXQtFileDialogHelper::LXQtFileDialogHelper() { + if(!libfmQtContext_) { + // initialize libfm-qt only once +@@ -53,6 +56,8 @@ bool LXQtFileDialogHelper::show(Qt::Wind + // https://github.com/KDE/plasma-integration/blob/master/src/platformtheme/kdeplatformfiledialoghelper.cpp + dlg_->windowHandle()->setTransientParent(parent); + ++ applyOptions(); ++ + loadSettings(); + // central positioning with respect to the parent window + if(parent && parent->isVisible()) { +@@ -60,8 +65,6 @@ bool LXQtFileDialogHelper::show(Qt::Wind + parent->y() + (parent->height() - dlg_->height()) / 2); + } + +- applyOptions(); +- + // NOTE: the timer here is required as a workaround borrowed from KDE. Without this, the dialog UI will be blocked. + // QFileDialog calls our platform plugin to show our own native file dialog instead of showing its widget. + // However, it still creates a hidden dialog internally, and then make it modal. +@@ -139,8 +142,6 @@ void LXQtFileDialogHelper::applyOptions( + } + + dlg_->setFilter(opt->filter()); +- dlg_->setViewMode(opt->viewMode() == QFileDialogOptions::Detail ? Fm::FolderView::DetailedListMode +- : Fm::FolderView::CompactMode); + dlg_->setFileMode(QFileDialog::FileMode(opt->fileMode())); + dlg_->setAcceptMode(QFileDialog::AcceptMode(opt->acceptMode())); // also sets a default label for accept button + // bool useDefaultNameFilters() const; +@@ -191,12 +192,56 @@ void LXQtFileDialogHelper::applyOptions( + // QStringList supportedSchemes() const; + } + ++static const QString viewModeToString(Fm::FolderView::ViewMode value) { ++ QString ret; ++ switch(value) { ++ case Fm::FolderView::DetailedListMode: ++ default: ++ ret = QLatin1String("Detailed"); ++ break; ++ case Fm::FolderView::CompactMode: ++ ret = QLatin1String("Compact"); ++ break; ++ case Fm::FolderView::IconMode: ++ ret = QLatin1String("Icon"); ++ break; ++ case Fm::FolderView::ThumbnailMode: ++ ret = QLatin1String("Thumbnail"); ++ break; ++ } ++ return ret; ++} ++ ++Fm::FolderView::ViewMode viewModeFromString(const QString& str) { ++ Fm::FolderView::ViewMode ret; ++ if(str == QLatin1String("Detailed")) { ++ ret = Fm::FolderView::DetailedListMode; ++ } ++ else if(str == QLatin1String("Compact")) { ++ ret = Fm::FolderView::CompactMode; ++ } ++ else if(str == QLatin1String("Icon")) { ++ ret = Fm::FolderView::IconMode; ++ } ++ else if(str == QLatin1String("Thumbnail")) { ++ ret = Fm::FolderView::ThumbnailMode; ++ } ++ else { ++ ret = Fm::FolderView::DetailedListMode; ++ } ++ return ret; ++} ++ + void LXQtFileDialogHelper::loadSettings() { + QSettings settings(QSettings::UserScope, "lxqt", "filedialog"); + settings.beginGroup ("Sizes"); + dlg_->resize(settings.value("WindowSize", QSize(700, 500)).toSize()); + dlg_->setSplitterPos(settings.value("SplitterPos", 200).toInt()); + settings.endGroup(); ++ ++ settings.beginGroup ("View"); ++ dlg_->setViewMode(viewModeFromString(settings.value("Mode", "Detailed").toString())); ++ settings.endGroup(); + } + + void LXQtFileDialogHelper::saveSettings() { +@@ -211,6 +256,13 @@ void LXQtFileDialogHelper::saveSettings( + settings.setValue("SplitterPos", splitterPos); + } + settings.endGroup(); ++ ++ settings.beginGroup ("View"); ++ QString mode = viewModeToString(dlg_->viewMode()); ++ if(settings.value("Mode") != mode) { ++ settings.setValue("Mode", mode); ++ } ++ settings.endGroup(); + } + + /* diff --git a/debian/patches/series b/debian/patches/series new file mode 100644 index 0000000..4b97cbc --- /dev/null +++ b/debian/patches/series @@ -0,0 +1,2 @@ +# Ubuntu-specific patches +remember-view-mode.patch