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_running = true;
|
||||||
m_finished = false;
|
m_finished = false;
|
||||||
static const QLatin1String kPreferenceDialogSize("Core/PreferenceDialogSize");
|
static const QLatin1String kPreferenceDialogSize("Core/PreferenceDialogSize");
|
||||||
if (ICore::settings()->contains(kPreferenceDialogSize))
|
const QSize initialSize(kInitialWidth, kInitialHeight);
|
||||||
resize(ICore::settings()->value(kPreferenceDialogSize).toSize());
|
resize(ICore::settings()->value(kPreferenceDialogSize, initialSize).toSize());
|
||||||
else
|
|
||||||
resize(kInitialWidth, kInitialHeight);
|
|
||||||
exec();
|
exec();
|
||||||
m_running = false;
|
m_running = false;
|
||||||
m_instance = nullptr;
|
m_instance = nullptr;
|
||||||
ICore::settings()->setValueWithDefault(kPreferenceDialogSize,
|
ICore::settings()->setValueWithDefault(kPreferenceDialogSize,
|
||||||
size(),
|
size(),
|
||||||
QSize(kInitialWidth, kInitialHeight));
|
initialSize);
|
||||||
// make sure that the current "single" instance is deleted
|
// make sure that the current "single" instance is deleted
|
||||||
// we can't delete right away, since we still access the m_applied member
|
// we can't delete right away, since we still access the m_applied member
|
||||||
deleteLater();
|
deleteLater();
|
||||||
|
@@ -9,6 +9,8 @@
|
|||||||
#include <utils/layoutbuilder.h>
|
#include <utils/layoutbuilder.h>
|
||||||
#include <utils/utilstr.h>
|
#include <utils/utilstr.h>
|
||||||
|
|
||||||
|
#include <coreplugin/icore.h>
|
||||||
|
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
|
|
||||||
@@ -18,12 +20,18 @@
|
|||||||
#include <QStandardItemModel>
|
#include <QStandardItemModel>
|
||||||
#include <QSortFilterProxyModel>
|
#include <QSortFilterProxyModel>
|
||||||
|
|
||||||
|
const int kInitialWidth = 400;
|
||||||
|
const int kInitialHeight = 220;
|
||||||
|
const char kPreferenceDialogSize[] = "Core/TopicChooserSize";
|
||||||
|
|
||||||
TopicChooser::TopicChooser(QWidget *parent, const QString &keyword,
|
TopicChooser::TopicChooser(QWidget *parent, const QString &keyword,
|
||||||
const QMultiMap<QString, QUrl> &links)
|
const QMultiMap<QString, QUrl> &links)
|
||||||
: QDialog(parent)
|
: QDialog(parent)
|
||||||
, m_filterModel(new QSortFilterProxyModel(this))
|
, 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"));
|
setWindowTitle(::Help::Tr::tr("Choose Topic"));
|
||||||
|
|
||||||
QStandardItemModel *model = new QStandardItemModel(this);
|
QStandardItemModel *model = new QStandardItemModel(this);
|
||||||
@@ -70,6 +78,13 @@ TopicChooser::TopicChooser(QWidget *parent, const QString &keyword,
|
|||||||
this, &TopicChooser::setFilter);
|
this, &TopicChooser::setFilter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TopicChooser::~TopicChooser()
|
||||||
|
{
|
||||||
|
Core::ICore::settings()->setValueWithDefault(kPreferenceDialogSize,
|
||||||
|
size(),
|
||||||
|
QSize(kInitialWidth, kInitialHeight));
|
||||||
|
}
|
||||||
|
|
||||||
QUrl TopicChooser::link() const
|
QUrl TopicChooser::link() const
|
||||||
{
|
{
|
||||||
if (m_activedIndex.isValid())
|
if (m_activedIndex.isValid())
|
||||||
|
@@ -24,6 +24,7 @@ class TopicChooser : public QDialog
|
|||||||
public:
|
public:
|
||||||
TopicChooser(QWidget *parent, const QString &keyword,
|
TopicChooser(QWidget *parent, const QString &keyword,
|
||||||
const QMultiMap<QString, QUrl> &links);
|
const QMultiMap<QString, QUrl> &links);
|
||||||
|
~TopicChooser() override;
|
||||||
|
|
||||||
QUrl link() const;
|
QUrl link() const;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user