Skip to content

Commit

Permalink
revised open, save, and delete dialogs in VPN provisioning editor
Browse files Browse the repository at this point in the history
  • Loading branch information
andrew-bibb committed Mar 12, 2022
1 parent 0f06758 commit 4132fbf
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 34 deletions.
63 changes: 30 additions & 33 deletions apps/cmstapp/code/vpn_prov_ed/vpn_ed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -653,10 +653,13 @@ void VPN_Editor::requestFileList(QAbstractButton* button)
void VPN_Editor::processFileList(const QStringList& sl_conf)
{
// variables
bool ok;
QString filename = "";
QList<QVariant> 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) {
Expand All @@ -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("<center>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
Expand All @@ -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();
Expand All @@ -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<br>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<br>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();
Expand All @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion apps/resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions text/changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<b><center>Change Log</center></b>
<b> In Progress </b>
<ul>
<li>Revised open, save, delete dialog boxes in VPN Provisioning editor.<li>
<li>Revised open, save, delete dialog boxes in Provisioning editor.<li>
<li>Added networks validator and use in networks fields in VPN Provisioning editor.</li>
<li>Added cidr validators and use in server address fields in VPN Provisioning editor.</li>
Expand Down

0 comments on commit 4132fbf

Please sign in to comment.