From 4132fbf81a250dbfddc92f7edc57c744f2b5b450 Mon Sep 17 00:00:00 2001 From: Andrew Bibb Date: Sat, 12 Mar 2022 13:29:50 -0500 Subject: [PATCH] revised open, save, and delete dialogs in VPN provisioning editor --- apps/cmstapp/code/vpn_prov_ed/vpn_ed.cpp | 63 +++++++++++------------- apps/resource.h | 2 +- text/changelog.txt | 1 + 3 files changed, 32 insertions(+), 34 deletions(-) diff --git a/apps/cmstapp/code/vpn_prov_ed/vpn_ed.cpp b/apps/cmstapp/code/vpn_prov_ed/vpn_ed.cpp index fe7a47f2..ef9a1831 100644 --- a/apps/cmstapp/code/vpn_prov_ed/vpn_ed.cpp +++ b/apps/cmstapp/code/vpn_prov_ed/vpn_ed.cpp @@ -653,10 +653,13 @@ void VPN_Editor::requestFileList(QAbstractButton* button) void VPN_Editor::processFileList(const QStringList& sl_conf) { // variables - bool ok; QString filename = ""; QList vlist; QDBusInterface* iface_pfl = new QDBusInterface("org.cmst.roothelper", "/", "org.cmst.roothelper", QDBusConnection::systemBus(), this); + QInputDialog* qid = new QInputDialog(this); + qid->setOption(QInputDialog::UseListViewForComboBoxItems); + qid->setWindowModality(Qt::WindowModality::ApplicationModal); + qid->setInputMode(QInputDialog::TextInput); // If we are trying to open and read the file if (i_sel & CMST::ProvEd_File_Read) { @@ -670,23 +673,16 @@ void VPN_Editor::processFileList(const QStringList& sl_conf) QMessageBox::Ok); break; case 1: - QMessageBox::information(this, - tr("%1 - Information").arg(TranslateStrings::cmtr("cmst")), - tr("
Reading configuration file: %1").arg(sl_conf.at(0)), - QMessageBox::Ok, - QMessageBox::Ok); filename = sl_conf.at(0); break; default: - QString item = QInputDialog::getItem(this, - tr("%1 - Select File").arg(TranslateStrings::cmtr("cmst")), - tr("Select a file to load."), - sl_conf, - 0, // current item 0 - false, // non-editable - &ok); - if (ok) filename = item; - break; + qid->setWindowTitle(tr("%1 - Select File").arg(TranslateStrings::cmtr("cmst")) ); + qid->setLabelText(tr("Select a file to load.") ); + qid->setComboBoxItems(sl_conf); + qid->exec(); + if (qid->result() == QDialog::Accepted) + filename = qid->textValue(); + break; } // switch // if we have a filename try to open the file @@ -710,16 +706,15 @@ void VPN_Editor::processFileList(const QStringList& sl_conf) QMessageBox::Ok); break; default: - QString item = QInputDialog::getItem(this, - tr("%1 - Select File").arg(TranslateStrings::cmtr("cmst")), - tr("Select a file to be deleted."), - sl_conf, - 0, // current item 0 - false, // non-editable - &ok); - if (ok) filename = item; + qid->setWindowTitle(tr("%1 - Select File").arg(TranslateStrings::cmtr("cmst")) ); + qid->setLabelText(tr("Select a file to be deleted.") ); + qid->setComboBoxItems(sl_conf); + qid->exec(); + if (qid->result() == QDialog::Accepted) + filename = qid->textValue(); break; } // switch + // if we have a filename try to delete the file if (! filename.isEmpty() ) { vlist.clear(); @@ -731,17 +726,17 @@ void VPN_Editor::processFileList(const QStringList& sl_conf) // If we are trying to save the file else if (i_sel & CMST::ProvEd_File_Write) { - QString item = QInputDialog::getItem(this, - tr("%1 - Select File").arg(TranslateStrings::cmtr("cmst")), - tr("Enter a new file name or select
an existing file to overwrite."), - sl_conf, - 0, // current item 0 - true, // editable - &ok); - if (ok) { - filename = item.simplified(); // multiple whitespace to one space + qid->setWindowTitle(tr("%1 - Select File").arg(TranslateStrings::cmtr("cmst")) ); + qid->setLabelText(tr("Enter a new file name or select
an existing file to overwrite.") ); + qid->setComboBoxEditable(true); + qid->setComboBoxItems(sl_conf); + qid->exec(); + if (qid->result() == QDialog::Accepted) { + filename = qid->textValue(); + filename = filename.simplified(); // multiple whitespace to one space filename = filename.replace(' ', '_'); // replace spaces with underscores - } // if ok + } // if accepted + // if we have a filename try to save the file if (! filename.isEmpty() ) { vlist.clear(); @@ -755,6 +750,8 @@ void VPN_Editor::processFileList(const QStringList& sl_conf) // cleanup i_sel = CMST::ProvEd_No_Selection; iface_pfl->deleteLater(); + delete qid; + return; } diff --git a/apps/resource.h b/apps/resource.h index 71dfef15..4c63e211 100755 --- a/apps/resource.h +++ b/apps/resource.h @@ -42,7 +42,7 @@ DEALINGS IN THE SOFTWARE. ///////////////////////////////// Program Values /////////////////////// // // Program Info (may be visible, but don't mark for tranalation) -#define VERSION "2022.03.12-1" +#define VERSION "2022.03.12-2" #define RELEASE_DATE "05 January 2022" #define COPYRIGHT_DATE "2013-2022" diff --git a/text/changelog.txt b/text/changelog.txt index 3a4b19a0..a8fbfdb8 100644 --- a/text/changelog.txt +++ b/text/changelog.txt @@ -2,6 +2,7 @@
Change Log
In Progress
    +
  • Revised open, save, delete dialog boxes in VPN Provisioning editor.
  • Revised open, save, delete dialog boxes in Provisioning editor.
  • Added networks validator and use in networks fields in VPN Provisioning editor.
  • Added cidr validators and use in server address fields in VPN Provisioning editor.