android: Fix XML form filter.
[qpwmc.git] / pwmdSaveDialog.cpp
blobf8d4607b287e76f15e6eade2ad18ab05827ee83f
1 /*
2 Copyright (C) 2010-2023 Ben Kibbey <bjk@luxsci.net>
4 This file is part of qpwmc.
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with this library; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
19 USA
21 #include <QSettings>
22 #include "pwmdSaveDialog.h"
24 PwmdSaveDialog::PwmdSaveDialog (Pwmd *handle, bool newFile, QWidget *p) :
25 QDialog (p)
27 ui.setupUi (this);
28 QSettings cfg ("qpwmc");
29 restoreGeometry (cfg.value ("saveDialogGeometry").toByteArray ());
30 setWindowFlags (Qt::WindowTitleHint);
31 ui.saveWidget->setParent (this);
32 ui.saveWidget->setHandle (handle, newFile);
34 QPushButton *pb = ui.buttonBox->button (QDialogButtonBox::Reset);
35 pb->disconnect (this);
36 pb->setHidden (false);
37 connect (pb, SIGNAL (clicked ()), ui.saveWidget, SLOT (slotResetRecipients ()));
38 disconnect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
40 pb = ui.buttonBox->button (QDialogButtonBox::Save);
41 connect (pb, SIGNAL (clicked ()), this, SLOT (slotAccepted ()));
42 pb->setEnabled (false);
43 connect (ui.saveWidget, SIGNAL (saveReady (bool)), this,
44 SLOT (slotSaveReady (bool)));
47 PwmdSaveDialog::~PwmdSaveDialog ()
49 QSettings cfg ("qpwmc");
51 cfg.setValue ("saveDialogGeometry", saveGeometry ());
54 void
55 PwmdSaveDialog::slotSaveReady (bool b)
57 QPushButton *pb = ui.buttonBox->button (QDialogButtonBox::Save);
58 pb->setEnabled (b);
61 void
62 PwmdSaveDialog::slotAccepted ()
64 if (ui.saveWidget->isSearching ())
65 return;
67 gpg_error_t rc = ui.saveWidget->save ();
69 if (!rc)
70 QDialog::accept ();
73 PwmdSaveWidget *
74 PwmdSaveDialog::widget()
76 return ui.saveWidget;