Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Utilities
Kate
Commits
8de8ebb1
Commit
8de8ebb1
authored
Oct 07, 2021
by
Ahmad Samir
Committed by
Christoph Cullmann
Oct 09, 2021
Browse files
Snippets: save and restore the dialogs' sizes
parent
ceb40a57
Changes
2
Hide whitespace changes
Inline
Side-by-side
addons/snippets/editrepository.cpp
View file @
8de8ebb1
...
...
@@ -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
()
...
...
addons/snippets/editsnippet.cpp
View file @
8de8ebb1
...
...
@@ -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
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment