Skip to content

Commit

Permalink
Improve Footer Dialog with options for page numbers & checkbox for
Browse files Browse the repository at this point in the history
default text.
  • Loading branch information
openforeveryone committed May 10, 2024
1 parent 87a4fbf commit 4334fd0
Show file tree
Hide file tree
Showing 10 changed files with 380 additions and 18 deletions.
6 changes: 3 additions & 3 deletions appearance.ui
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
<rect>
<x>0</x>
<y>0</y>
<width>445</width>
<height>348</height>
<width>538</width>
<height>358</height>
</rect>
</property>
<property name="windowTitle">
<string>Fonts and Colours - Word Search Creator</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<layout class="QVBoxLayout" name="_2">
<item>
<layout class="QGridLayout">
<property name="leftMargin">
Expand Down
2 changes: 1 addition & 1 deletion appearancedialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#include <QFontDialog>
#include <QColorDialog>

#include "wordsearchdrawer.h"
#include "wordsearchdoc.h"

#include "appearancedialog.h"

Expand Down
197 changes: 197 additions & 0 deletions footer.ui
Original file line number Diff line number Diff line change
@@ -0,0 +1,197 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>footer</class>
<widget class="QDialog" name="footer">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>585</width>
<height>180</height>
</rect>
</property>
<property name="windowTitle">
<string>Footer - Word Search Creator</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="label_7">
<property name="text">
<string>Display Page Number:</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QRadioButton" name="noPageNumberRadioButton">
<property name="text">
<string>Never</string>
</property>
<attribute name="buttonGroup">
<string notr="true">buttonGroup</string>
</attribute>
</widget>
</item>
<item>
<widget class="QRadioButton" name="multiplePageNumberRadioButton">
<property name="text">
<string>When Multiple Pages</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
<attribute name="buttonGroup">
<string notr="true">buttonGroup</string>
</attribute>
</widget>
</item>
<item>
<widget class="QRadioButton" name="alwaysPageNumberRadioButton">
<property name="text">
<string>Always</string>
</property>
<attribute name="buttonGroup">
<string notr="true">buttonGroup</string>
</attribute>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Display Page Count:</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QRadioButton" name="noPageCountRadioButton">
<property name="text">
<string>Never</string>
</property>
<attribute name="buttonGroup">
<string notr="true">buttonGroup_2</string>
</attribute>
</widget>
</item>
<item>
<widget class="QRadioButton" name="pageCountRadioButton">
<property name="text">
<string>When Displaying Page Number</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
<attribute name="buttonGroup">
<string notr="true">buttonGroup_2</string>
</attribute>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QCheckBox" name="customFooterCheckBox">
<property name="text">
<string>Use Custom Footer</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLabel" name="footerLabel">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Footer Text:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="footerTextLineEdit">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>footer</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
<buttongroups>
<buttongroup name="buttonGroup_2"/>
<buttongroup name="buttonGroup"/>
</buttongroups>
</ui>
74 changes: 74 additions & 0 deletions footerdialog.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/***************************************************************************
* Copyright (C) 2006-2024 M Wellings *
* [email protected] *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License version 2 as *
* published by the Free Software Foundation *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/

#include <QDebug>

#include "wordsearchdoc.h"

#include "footerdialog.h"

footerdialog::footerdialog(QWidget *parent)
: QDialog(parent)
{
setupUi(this);
this->setWindowModality(Qt::WindowModal);
connect(buttonBox, SIGNAL(accepted()), this, SLOT(okPressed()));
}

void footerdialog::setDoc(WordSearchDoc *wsd)
{
this->wsd = wsd;
customFooterCheckBox->setChecked(!wsd->getFooter().isNull());
if (!wsd->getFooter().isNull())
footerTextLineEdit->setText(wsd->getFooter());
else
footerTextLineEdit->setText(WordSearchDoc::getDefaultFooter());
if (wsd->getShowPageNumber() == WordSearchDoc::showPageNumberType::PageNumberNever)
noPageNumberRadioButton->setChecked(true);
else if (wsd->getShowPageNumber() == WordSearchDoc::showPageNumberType::PageNumberAlways)
alwaysPageNumberRadioButton->setChecked(true);
noPageCountRadioButton->setChecked(!wsd->getShowPageCount());
}

void footerdialog::okPressed()
{
if (customFooterCheckBox->isChecked())
wsd->setFooter(footerTextLineEdit->text());
else
wsd->setFooter(QString());
if (noPageNumberRadioButton->isChecked())
wsd->setShowPageNumber(WordSearchDoc::showPageNumberType::PageNumberNever);
else if (multiplePageNumberRadioButton->isChecked())
wsd->setShowPageNumber(WordSearchDoc::showPageNumberType::PageNumberMultipage);
else
wsd->setShowPageNumber(WordSearchDoc::showPageNumberType::PageNumberAlways);
wsd->setShowPageCount(pageCountRadioButton->isChecked());
accept();
}

void footerdialog::on_customFooterCheckBox_toggled(bool checked)
{
qDebug() << "on_cudtomFooterCheckBox_toggled";
footerLabel->setEnabled(checked);
footerTextLineEdit->setEnabled(checked);
if (!checked)
footerTextLineEdit->setText(WordSearchDoc::getDefaultFooter());
else
footerTextLineEdit->setText("");
}
45 changes: 45 additions & 0 deletions footerdialog.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/***************************************************************************
* Copyright (C) 2006-2024 M Wellings *
* [email protected] *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License version 2 as *
* published by the Free Software Foundation *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/

#ifndef FOOTERDIALOG_H
#define FOOTERDIALOG_H

#include "ui_footer.h"

class WordSearchDoc;

class footerdialog : public QDialog, private Ui::footer
{
Q_OBJECT

public:
explicit footerdialog(QWidget *parent = nullptr);
void setDoc(WordSearchDoc *wsd);

private slots:
void okPressed();

void on_customFooterCheckBox_toggled(bool checked);

private:
WordSearchDoc *wsd;

};

#endif // FOOTERDIALOG_H
Loading

0 comments on commit 4334fd0

Please sign in to comment.