Commit 8de8ebb1 authored by Ahmad Samir's avatar Ahmad Samir Committed by Christoph Cullmann
Browse files

Snippets: save and restore the dialogs' sizes

parent ceb40a57
......@@ -16,13 +16,17 @@
#include <ktexteditor/document.h>
#include <ktexteditor/editor.h>
#include <KConfigGroup>
#include <KLocalizedString>
#include <KSharedConfig>
#include <KStandardGuiItem>
#include <KUser>
#include <QDialogButtonBox>
#include <QPushButton>
static const char s_configFile[] = "kate-snippetsrc";
EditRepository::EditRepository(SnippetRepository *repository, QWidget *parent)
: QDialog(parent)
, Ui::EditRepositoryBase()
......@@ -84,6 +88,13 @@ EditRepository::EditRepository(SnippetRepository *repository, QWidget *parent)
validate();
updateFileTypes();
repoNameEdit->setFocus();
KSharedConfigPtr config = KSharedConfig::openConfig(QLatin1String(s_configFile));
KConfigGroup group = config->group("General");
const QSize savedSize = group.readEntry("Size", QSize());
if (savedSize.isValid()) {
resize(savedSize);
}
}
void EditRepository::validate()
......@@ -113,6 +124,11 @@ void EditRepository::save()
m_repo->save();
setWindowTitle(i18n("Edit Snippet Repository %1", m_repo->text()));
KSharedConfigPtr config = KSharedConfig::openConfig(QLatin1String(s_configFile));
KConfigGroup group = config->group("General");
group.writeEntry("Size", size());
group.sync();
}
void EditRepository::updateFileTypes()
......
......@@ -16,10 +16,12 @@
#include "snippetrepository.h"
#include "snippetstore.h"
#include <KConfigGroup>
#include <KHelpClient>
#include <KLocalizedString>
#include <KMessageBox>
#include <KMessageWidget>
#include <KSharedConfig>
#include <QAction>
#include <QPushButton>
......@@ -30,6 +32,8 @@
#include <KTextEditor/Editor>
#include <KTextEditor/View>
static const char s_configFile[] = "kate-snippetsrc";
KTextEditor::View *createView(QWidget *tabWidget)
{
auto document = KTextEditor::Editor::instance()->createDocument(tabWidget);
......@@ -112,8 +116,12 @@ EditSnippet::EditSnippet(SnippetRepository *repository, Snippet *snippet, QWidge
m_ui->snippetNameEdit->setFocus();
setTabOrder(m_ui->snippetNameEdit, m_snippetView);
QSize initSize = sizeHint();
initSize.setHeight(initSize.height() + 200);
KSharedConfigPtr config = KSharedConfig::openConfig(QLatin1String(s_configFile));
KConfigGroup group = config->group("General");
const QSize savedSize = group.readEntry("Size", QSize());
if (savedSize.isValid()) {
resize(savedSize);
}
}
void EditSnippet::test()
......@@ -173,6 +181,11 @@ void EditSnippet::save()
m_repo->save();
setWindowTitle(i18n("Edit Snippet %1 in %2", m_snippet->text(), m_repo->text()));
KSharedConfigPtr config = KSharedConfig::openConfig(QLatin1String(s_configFile));
KConfigGroup group = config->group("General");
group.writeEntry("Size", size());
group.sync();
}
void EditSnippet::reject()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment