forked from qt-creator/qt-creator
Help: Store and restore size of TopicChooser
The default size seems too small to use Change-Id: Ia8284e1e8b97ee7c76dc4d1ce807fec017ff10dd Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -765,16 +765,14 @@ bool SettingsDialog::execDialog()
|
||||
m_running = true;
|
||||
m_finished = false;
|
||||
static const QLatin1String kPreferenceDialogSize("Core/PreferenceDialogSize");
|
||||
if (ICore::settings()->contains(kPreferenceDialogSize))
|
||||
resize(ICore::settings()->value(kPreferenceDialogSize).toSize());
|
||||
else
|
||||
resize(kInitialWidth, kInitialHeight);
|
||||
const QSize initialSize(kInitialWidth, kInitialHeight);
|
||||
resize(ICore::settings()->value(kPreferenceDialogSize, initialSize).toSize());
|
||||
exec();
|
||||
m_running = false;
|
||||
m_instance = nullptr;
|
||||
ICore::settings()->setValueWithDefault(kPreferenceDialogSize,
|
||||
size(),
|
||||
QSize(kInitialWidth, kInitialHeight));
|
||||
initialSize);
|
||||
// make sure that the current "single" instance is deleted
|
||||
// we can't delete right away, since we still access the m_applied member
|
||||
deleteLater();
|
||||
|
@@ -9,6 +9,8 @@
|
||||
#include <utils/layoutbuilder.h>
|
||||
#include <utils/utilstr.h>
|
||||
|
||||
#include <coreplugin/icore.h>
|
||||
|
||||
#include <QMap>
|
||||
#include <QUrl>
|
||||
|
||||
@@ -18,12 +20,18 @@
|
||||
#include <QStandardItemModel>
|
||||
#include <QSortFilterProxyModel>
|
||||
|
||||
const int kInitialWidth = 400;
|
||||
const int kInitialHeight = 220;
|
||||
const char kPreferenceDialogSize[] = "Core/TopicChooserSize";
|
||||
|
||||
TopicChooser::TopicChooser(QWidget *parent, const QString &keyword,
|
||||
const QMultiMap<QString, QUrl> &links)
|
||||
: QDialog(parent)
|
||||
, m_filterModel(new QSortFilterProxyModel(this))
|
||||
{
|
||||
resize(400, 220);
|
||||
const QSize initialSize(kInitialWidth, kInitialHeight);
|
||||
resize(Core::ICore::settings()->value(kPreferenceDialogSize, initialSize).toSize());
|
||||
|
||||
setWindowTitle(::Help::Tr::tr("Choose Topic"));
|
||||
|
||||
QStandardItemModel *model = new QStandardItemModel(this);
|
||||
@@ -70,6 +78,13 @@ TopicChooser::TopicChooser(QWidget *parent, const QString &keyword,
|
||||
this, &TopicChooser::setFilter);
|
||||
}
|
||||
|
||||
TopicChooser::~TopicChooser()
|
||||
{
|
||||
Core::ICore::settings()->setValueWithDefault(kPreferenceDialogSize,
|
||||
size(),
|
||||
QSize(kInitialWidth, kInitialHeight));
|
||||
}
|
||||
|
||||
QUrl TopicChooser::link() const
|
||||
{
|
||||
if (m_activedIndex.isValid())
|
||||
|
@@ -24,6 +24,7 @@ class TopicChooser : public QDialog
|
||||
public:
|
||||
TopicChooser(QWidget *parent, const QString &keyword,
|
||||
const QMultiMap<QString, QUrl> &links);
|
||||
~TopicChooser() override;
|
||||
|
||||
QUrl link() const;
|
||||
|
||||
|
Reference in New Issue
Block a user