diff options
Diffstat (limited to '')
-rwxr-xr-x | src/ui/dialog/QuitDialog.cpp (renamed from src/ui/QuitDialog.cpp) | 70 |
1 files changed, 37 insertions, 33 deletions
diff --git a/src/ui/QuitDialog.cpp b/src/ui/dialog/QuitDialog.cpp index a5ed7c3f..da0be488 100755 --- a/src/ui/QuitDialog.cpp +++ b/src/ui/dialog/QuitDialog.cpp @@ -1,4 +1,6 @@ /** + * Copyright (C) 2021 Saturneric + * * This file is part of GpgFrontend. * * GpgFrontend is free software: you can redistribute it and/or modify @@ -6,23 +8,25 @@ * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Foobar is distributed in the hope that it will be useful, + * GpgFrontend 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 Foobar. If not, see <https://www.gnu.org/licenses/>. + * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>. + * + * The initial version of the source code is inherited from + * the gpg4usb project, which is under GPL-3.0-or-later. * - * The initial version of the source code is inherited from gpg4usb-team. - * Their source code version also complies with GNU General Public License. + * All the source code of GpgFrontend was modified and released by + * Saturneric<[email protected]> starting on May 12, 2021. * - * The source code version of this software was modified and released - * by Saturneric<[email protected]> starting on May 12, 2021. + * SPDX-License-Identifier: GPL-3.0-or-later * */ -#include "ui/QuitDialog.h" +#include "QuitDialog.h" #include <boost/format.hpp> @@ -32,42 +36,42 @@ QuitDialog::QuitDialog(QWidget* parent, const QHash<int, QString>& unsavedDocs) : QDialog(parent) { setWindowTitle(_("Unsaved Files")); setModal(true); - discarded = false; + discarded_ = false; /* * Table of unsaved documents */ QHashIterator<int, QString> i(unsavedDocs); int row = 0; - mFileList = new QTableWidget(this); - mFileList->horizontalHeader()->hide(); - mFileList->setColumnCount(3); - mFileList->setColumnWidth(0, 20); - mFileList->setColumnHidden(2, true); - mFileList->verticalHeader()->hide(); - mFileList->setShowGrid(false); - mFileList->setEditTriggers(QAbstractItemView::NoEditTriggers); - mFileList->setFocusPolicy(Qt::NoFocus); - mFileList->horizontalHeader()->setStretchLastSection(true); + m_fileList_ = new QTableWidget(this); + m_fileList_->horizontalHeader()->hide(); + m_fileList_->setColumnCount(3); + m_fileList_->setColumnWidth(0, 20); + m_fileList_->setColumnHidden(2, true); + m_fileList_->verticalHeader()->hide(); + m_fileList_->setShowGrid(false); + m_fileList_->setEditTriggers(QAbstractItemView::NoEditTriggers); + m_fileList_->setFocusPolicy(Qt::NoFocus); + m_fileList_->horizontalHeader()->setStretchLastSection(true); // fill the table i.toFront(); // jump to the end of list to fill the table backwards while (i.hasNext()) { i.next(); - mFileList->setRowCount(mFileList->rowCount() + 1); + m_fileList_->setRowCount(m_fileList_->rowCount() + 1); // checkbox in front of filename auto* tmp0 = new QTableWidgetItem(); tmp0->setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled); tmp0->setCheckState(Qt::Checked); - mFileList->setItem(row, 0, tmp0); + m_fileList_->setItem(row, 0, tmp0); // filename auto* tmp1 = new QTableWidgetItem(i.value()); - mFileList->setItem(row, 1, tmp1); + m_fileList_->setItem(row, 1, tmp1); // tab-index in hidden column auto* tmp2 = new QTableWidgetItem(QString::number(i.key())); - mFileList->setItem(row, 2, tmp2); + m_fileList_->setItem(row, 2, tmp2); ++row; } /* @@ -104,10 +108,10 @@ QuitDialog::QuitDialog(QWidget* parent, const QHash<int, QString>& unsavedDocs) auto* buttonBox = new QDialogButtonBox(QDialogButtonBox::Discard | QDialogButtonBox::Save | QDialogButtonBox::Cancel); - connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept())); - connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject())); + connect(buttonBox, &QDialogButtonBox::accepted, this, &QuitDialog::accept); + connect(buttonBox, &QDialogButtonBox::rejected, this, &QuitDialog::reject); QPushButton* btnNoKey = buttonBox->button(QDialogButtonBox::Discard); - connect(btnNoKey, SIGNAL(clicked()), SLOT(slotMyDiscard())); + connect(btnNoKey, &QPushButton::clicked, this,&QuitDialog::slot_my_discard); /* * Set the layout @@ -115,24 +119,24 @@ QuitDialog::QuitDialog(QWidget* parent, const QHash<int, QString>& unsavedDocs) auto* vbox = new QVBoxLayout(); vbox->addWidget(warnBox); vbox->addWidget(checkLabel); - vbox->addWidget(mFileList); + vbox->addWidget(m_fileList_); vbox->addWidget(note_label); vbox->addWidget(buttonBox); this->setLayout(vbox); } -void QuitDialog::slotMyDiscard() { - discarded = true; +void QuitDialog::slot_my_discard() { + discarded_ = true; reject(); } -bool QuitDialog::isDiscarded() const { return discarded; } +bool QuitDialog::IsDiscarded() const { return discarded_; } -QList<int> QuitDialog::getTabIdsToSave() { +QList<int> QuitDialog::GetTabIdsToSave() { QList<int> tabIdsToSave; - for (int i = 0; i < mFileList->rowCount(); i++) { - if (mFileList->item(i, 0)->checkState() == Qt::Checked) { - tabIdsToSave << mFileList->item(i, 2)->text().toInt(); + for (int i = 0; i < m_fileList_->rowCount(); i++) { + if (m_fileList_->item(i, 0)->checkState() == Qt::Checked) { + tabIdsToSave << m_fileList_->item(i, 2)->text().toInt(); } } return tabIdsToSave; |