From 2113bdee5dc78d6b615768afabc3ecd7d14f4b83 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Mon, 1 Sep 2014 10:32:25 +0200 Subject: QFileDialog: save and restore all settings even if widgets not used MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Some applications may use native file dialogs and some may use the widget implementation, but QFileDialog always saves all settings to the same place each time it destroyed. So it is important to remember all settings read in restoreState and put them back in saveState. This bug was introduced by 37ca2224eca671200a2710f57f970d2993e62aa5 Task-number: QTBUG-36888 Change-Id: Ied1db83817480312e963a042784d7bdd16f0a2b1 Reviewed-by: Jan Arve Sæther --- src/widgets/dialogs/qfiledialog.cpp | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) (limited to 'src/widgets/dialogs/qfiledialog.cpp') diff --git a/src/widgets/dialogs/qfiledialog.cpp b/src/widgets/dialogs/qfiledialog.cpp index 9219757dbf..e53cdeac29 100644 --- a/src/widgets/dialogs/qfiledialog.cpp +++ b/src/widgets/dialogs/qfiledialog.cpp @@ -454,15 +454,15 @@ QByteArray QFileDialog::saveState() const stream << d->qFileDialogUi->splitter->saveState(); stream << d->qFileDialogUi->sidebar->urls(); } else { - stream << QByteArray(); - stream << QList(); + stream << d->splitterState; + stream << d->sidebarUrls; } stream << history(); stream << *lastVisitedDir(); if (d->usingWidgets()) stream << d->qFileDialogUi->treeView->header()->saveState(); else - stream << QByteArray(); + stream << d->headerData; stream << qint32(viewMode()); return data; } @@ -484,9 +484,6 @@ bool QFileDialog::restoreState(const QByteArray &state) QDataStream stream(&sd, QIODevice::ReadOnly); if (stream.atEnd()) return false; - QByteArray splitterState; - QByteArray headerData; - QList bookmarks; QStringList history; QString currentDirectory; qint32 marker; @@ -497,11 +494,11 @@ bool QFileDialog::restoreState(const QByteArray &state) if (marker != QFileDialogMagic || v != version) return false; - stream >> splitterState - >> bookmarks + stream >> d->splitterState + >> d->sidebarUrls >> history >> currentDirectory - >> headerData + >> d->headerData >> viewMode; setDirectory(lastVisitedDir()->isEmpty() ? currentDirectory : *lastVisitedDir()); @@ -510,7 +507,7 @@ bool QFileDialog::restoreState(const QByteArray &state) if (!d->usingWidgets()) return true; - if (!d->qFileDialogUi->splitter->restoreState(splitterState)) + if (!d->qFileDialogUi->splitter->restoreState(d->splitterState)) return false; QList list = d->qFileDialogUi->splitter->sizes(); if (list.count() >= 2 && list.at(0) == 0 && list.at(1) == 0) { @@ -519,12 +516,12 @@ bool QFileDialog::restoreState(const QByteArray &state) d->qFileDialogUi->splitter->setSizes(list); } - d->qFileDialogUi->sidebar->setUrls(bookmarks); + d->qFileDialogUi->sidebar->setUrls(d->sidebarUrls); while (history.count() > 5) history.pop_front(); setHistory(history); QHeaderView *headerView = d->qFileDialogUi->treeView->header(); - if (!headerView->restoreState(headerData)) + if (!headerView->restoreState(d->headerData)) return false; QList actions = headerView->actions(); -- cgit v1.2.3 From 974c2108352d1136835a615d3b56b827d6ef99dd Mon Sep 17 00:00:00 2001 From: Matti Paaso Date: Thu, 21 Aug 2014 16:51:22 +0300 Subject: Update license headers and add new license files - Renamed LICENSE.LGPL to LICENSE.LGPLv21 - Added LICENSE.LGPLv3 - Removed LICENSE.GPL Change-Id: Iec3406e3eb3f133be549092015cefe33d259a3f2 Reviewed-by: Iikka Eklund --- src/widgets/dialogs/qfiledialog.cpp | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) (limited to 'src/widgets/dialogs/qfiledialog.cpp') diff --git a/src/widgets/dialogs/qfiledialog.cpp b/src/widgets/dialogs/qfiledialog.cpp index 0ead8a6797..0ba3ea40e0 100644 --- a/src/widgets/dialogs/qfiledialog.cpp +++ b/src/widgets/dialogs/qfiledialog.cpp @@ -5,36 +5,28 @@ ** ** This file is part of the QtWidgets module of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL$ +** $QT_BEGIN_LICENSE:LGPL21$ ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information ** use the contact form at http://qt.digia.com/contact-us. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception +** rights. These rights are described in the Digia Qt LGPL Exception ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** ** $QT_END_LICENSE$ ** ****************************************************************************/ -- cgit v1.2.3