Skip to content

Commit 398061b

Browse files
committed
Make FindReplaceDialog resize-able
Closes #624
1 parent aa1536c commit 398061b

File tree

3 files changed

+46
-49
lines changed

3 files changed

+46
-49
lines changed

src/NotepadNext/dialogs/FindReplaceDialog.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,10 +147,7 @@ FindReplaceDialog::FindReplaceDialog(ISearchResultsHandler *searchResults, MainW
147147

148148
loadSettings();
149149

150-
connect(qApp, &QApplication::aboutToQuit, this, &FindReplaceDialog::saveSettings);
151-
152150
changeTab(tabBar->currentIndex());
153-
154151
}
155152

156153
FindReplaceDialog::~FindReplaceDialog()
@@ -194,6 +191,13 @@ void FindReplaceDialog::showEvent(QShowEvent *event)
194191
QDialog::showEvent(event);
195192
}
196193

194+
void FindReplaceDialog::closeEvent(QCloseEvent *event)
195+
{
196+
saveSettings();
197+
198+
QDialog::closeEvent(event);
199+
}
200+
197201
static void updateComboList(QComboBox *comboBox, const QString &text)
198202
{
199203
// Block the signals while it is manipulated
@@ -501,6 +505,8 @@ void FindReplaceDialog::loadSettings()
501505

502506
settings.beginGroup("FindReplaceDialog");
503507

508+
restoreGeometry(settings.value("geometry").toByteArray());
509+
504510
ui->comboFind->addItems(settings.value("RecentSearchList").toStringList());
505511
ui->comboReplace->addItems(settings.value("RecentReplaceList").toStringList());
506512

@@ -544,6 +550,8 @@ void FindReplaceDialog::saveSettings()
544550
settings.beginGroup("FindReplaceDialog");
545551
settings.remove(""); // clear out any previous keys
546552

553+
settings.setValue("geometry", saveGeometry());
554+
547555
QStringList recentSearches;
548556
for (int i = 0; i < ui->comboFind->count(); ++i) {
549557
recentSearches << ui->comboFind->itemText(i);

src/NotepadNext/dialogs/FindReplaceDialog.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ class FindReplaceDialog : public QDialog
6161
protected:
6262
bool event(QEvent *event) override;
6363
void showEvent(QShowEvent *event) override;
64+
void closeEvent(QCloseEvent *event) override;
6465

6566
signals:
6667
void windowActivated();

src/NotepadNext/dialogs/FindReplaceDialog.ui

Lines changed: 34 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,6 @@
1010
<height>325</height>
1111
</rect>
1212
</property>
13-
<property name="minimumSize">
14-
<size>
15-
<width>475</width>
16-
<height>325</height>
17-
</size>
18-
</property>
19-
<property name="maximumSize">
20-
<size>
21-
<width>16777215</width>
22-
<height>325</height>
23-
</size>
24-
</property>
2513
<property name="windowTitle">
2614
<string>Find</string>
2715
</property>
@@ -79,14 +67,11 @@
7967
</property>
8068
<layout class="QVBoxLayout" name="verticalLayout">
8169
<property name="spacing">
82-
<number>4</number>
70+
<number>0</number>
8371
</property>
8472
<property name="topMargin">
8573
<number>4</number>
8674
</property>
87-
<property name="bottomMargin">
88-
<number>4</number>
89-
</property>
9075
<item>
9176
<widget class="QRadioButton" name="radioNormalSearch">
9277
<property name="enabled">
@@ -343,7 +328,7 @@
343328
</layout>
344329
</item>
345330
<item row="2" column="0">
346-
<layout class="QVBoxLayout" name="verticalLayout_5" stretch="0,0,0,0,0,0">
331+
<layout class="QVBoxLayout" name="verticalLayout_5" stretch="0,0,0">
347332
<property name="leftMargin">
348333
<number>11</number>
349334
</property>
@@ -447,32 +432,39 @@
447432
</spacer>
448433
</item>
449434
<item>
450-
<widget class="QCheckBox" name="checkBoxBackwardsDirection">
451-
<property name="text">
452-
<string>Backward direction</string>
435+
<layout class="QVBoxLayout" name="verticalLayout_6">
436+
<property name="spacing">
437+
<number>0</number>
453438
</property>
454-
</widget>
455-
</item>
456-
<item>
457-
<widget class="QCheckBox" name="checkBoxMatchWholeWord">
458-
<property name="text">
459-
<string>Match &amp;whole word only</string>
460-
</property>
461-
</widget>
462-
</item>
463-
<item>
464-
<widget class="QCheckBox" name="checkBoxMatchCase">
465-
<property name="text">
466-
<string>Match &amp;case</string>
467-
</property>
468-
</widget>
469-
</item>
470-
<item>
471-
<widget class="QCheckBox" name="checkBoxWrapAround">
472-
<property name="text">
473-
<string>Wra&amp;p Around</string>
474-
</property>
475-
</widget>
439+
<item>
440+
<widget class="QCheckBox" name="checkBoxBackwardsDirection">
441+
<property name="text">
442+
<string>Backward direction</string>
443+
</property>
444+
</widget>
445+
</item>
446+
<item>
447+
<widget class="QCheckBox" name="checkBoxMatchWholeWord">
448+
<property name="text">
449+
<string>Match &amp;whole word only</string>
450+
</property>
451+
</widget>
452+
</item>
453+
<item>
454+
<widget class="QCheckBox" name="checkBoxMatchCase">
455+
<property name="text">
456+
<string>Match &amp;case</string>
457+
</property>
458+
</widget>
459+
</item>
460+
<item>
461+
<widget class="QCheckBox" name="checkBoxWrapAround">
462+
<property name="text">
463+
<string>Wra&amp;p Around</string>
464+
</property>
465+
</widget>
466+
</item>
467+
</layout>
476468
</item>
477469
</layout>
478470
</item>
@@ -483,10 +475,6 @@
483475
<tabstops>
484476
<tabstop>comboFind</tabstop>
485477
<tabstop>comboReplace</tabstop>
486-
<tabstop>checkBoxBackwardsDirection</tabstop>
487-
<tabstop>checkBoxMatchWholeWord</tabstop>
488-
<tabstop>checkBoxMatchCase</tabstop>
489-
<tabstop>checkBoxWrapAround</tabstop>
490478
<tabstop>radioNormalSearch</tabstop>
491479
<tabstop>radioExtendedSearch</tabstop>
492480
<tabstop>radioRegexSearch</tabstop>

0 commit comments

Comments
 (0)