1 /************************************************************************
2 **
3 ** Copyright (C) 2019 Kevin B. Hendricks, Stratford Ontario Canada
4 **
5 ** This file is part of Sigil.
6 **
7 ** Sigil is free software: you can redistribute it and/or modify
8 ** it under the terms of the GNU General Public License as published by
9 ** the Free Software Foundation, either version 3 of the License, or
10 ** (at your option) any later version.
11 **
12 ** Sigil is distributed in the hope that it will be useful,
13 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 ** GNU General Public License for more details.
16 **
17 ** You should have received a copy of the GNU General Public License
18 ** along with Sigil. If not, see <http://www.gnu.org/licenses/>.
19 **
20 *************************************************************************/
21
22 #include "Dialogs/RERenamer.h"
23 #include "Misc/SettingsStore.h"
24
25 static QString SETTINGS_GROUP = "re_renamer";
26
RERenamer(const QString & retext,const QString & replacetext,QWidget * parent)27 RERenamer::RERenamer(const QString &retext, const QString& replacetext, QWidget *parent)
28 :
29 QDialog(parent),
30 m_REText(QString()),
31 m_ReplaceText(QString())
32 {
33 ui.setupUi(this);
34 ui.rexLineEdit->setText(retext);
35 ui.repLineEdit->setText(replacetext);
36 connectSignalsSlots();
37 ReadSettings();
38 }
39
GetREText()40 QString RERenamer::GetREText()
41 {
42 return m_REText;
43 }
44
45
GetReplaceText()46 QString RERenamer::GetReplaceText()
47 {
48 return m_ReplaceText;
49 }
50
51
SetREText()52 void RERenamer::SetREText()
53 {
54 m_REText = ui.rexLineEdit->text();
55 }
56
SetReplaceText()57 void RERenamer::SetReplaceText()
58 {
59 m_ReplaceText = ui.repLineEdit->text();
60 }
61
ReadSettings()62 void RERenamer::ReadSettings()
63 {
64 SettingsStore settings;
65 settings.beginGroup(SETTINGS_GROUP);
66 // The size of the window and it's full screen status
67 QByteArray geometry = settings.value("geometry").toByteArray();
68
69 if (!geometry.isNull()) {
70 restoreGeometry(geometry);
71 }
72
73 settings.endGroup();
74 }
75
WriteSettings()76 void RERenamer::WriteSettings()
77 {
78 SetREText();
79 SetReplaceText();
80 SettingsStore settings;
81 settings.beginGroup(SETTINGS_GROUP);
82 // The size of the window and it's full screen status
83 settings.setValue("geometry", saveGeometry());
84 settings.endGroup();
85 }
86
connectSignalsSlots()87 void RERenamer::connectSignalsSlots()
88 {
89 connect(this, SIGNAL(accepted()), this, SLOT(WriteSettings()));
90 }
91