summaryrefslogtreecommitdiffstats
path: root/ui/qt/profile_dialog.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'ui/qt/profile_dialog.cpp')
-rw-r--r--ui/qt/profile_dialog.cpp82
1 files changed, 45 insertions, 37 deletions
diff --git a/ui/qt/profile_dialog.cpp b/ui/qt/profile_dialog.cpp
index 5b53a2cf..9de24054 100644
--- a/ui/qt/profile_dialog.cpp
+++ b/ui/qt/profile_dialog.cpp
@@ -8,11 +8,8 @@
*/
#include "config.h"
-#include <glib.h>
#include "wsutil/filesystem.h"
-#include "wsutil/utf8_entities.h"
-#include "epan/prefs.h"
#include <ui/qt/utils/qt_ui_utils.h>
@@ -27,6 +24,7 @@
#include "main_application.h"
#include <ui/qt/utils/color_utils.h>
#include <ui/qt/simple_dialog.h>
+#include <ui/qt/widgets/wireshark_file_dialog.h>
#include <QBrush>
#include <QDir>
@@ -37,7 +35,6 @@
#include <QUrl>
#include <QComboBox>
#include <QLineEdit>
-#include <QFileDialog>
#include <QStandardPaths>
#include <QKeyEvent>
#include <QMenu>
@@ -74,9 +71,16 @@ ProfileDialog::ProfileDialog(QWidget *parent) :
pd_ui_->hintLabel->setAttribute(Qt::WA_MacSmallSize, true);
#endif
+ QString as_tooltip = pd_ui_->autoSwitchLimitLabel->toolTip();
+ pd_ui_->autoSwitchSpinBox->setToolTip(as_tooltip);
+ if (!is_packet_configuration_namespace()) {
+ pd_ui_->autoSwitchLimitLabel->setText(tr("Auto switch event limit"));
+ }
+ pd_ui_->autoSwitchSpinBox->setValue(recent.gui_profile_switch_check_count);
+
import_button_ = pd_ui_->buttonBox->addButton(tr("Import", "noun"), QDialogButtonBox::ActionRole);
-#ifdef HAVE_MINIZIP
+#if defined(HAVE_MINIZIP) || defined(HAVE_MINIZIPNG)
export_button_ = pd_ui_->buttonBox->addButton(tr("Export", "noun"), QDialogButtonBox::ActionRole);
QMenu * importMenu = new QMenu(import_button_);
@@ -112,13 +116,23 @@ ProfileDialog::ProfileDialog(QWidget *parent) :
currentItemChanged();
+ connect(pd_ui_->newToolButton, &StockIconToolButton::clicked, this, &ProfileDialog::newToolButtonClicked);
+ connect(pd_ui_->deleteToolButton, &StockIconToolButton::clicked, this, &ProfileDialog::deleteToolButtonClicked);
+ connect(pd_ui_->copyToolButton, &StockIconToolButton::clicked, this, &ProfileDialog::copyToolButtonClicked);
+ connect(pd_ui_->buttonBox, &QDialogButtonBox::accepted, this, &ProfileDialog::buttonBoxAccepted);
+ connect(pd_ui_->buttonBox, &QDialogButtonBox::rejected, this, &ProfileDialog::buttonBoxRejected);
+ connect(pd_ui_->buttonBox, &QDialogButtonBox::helpRequested, this, &ProfileDialog::buttonBoxHelpRequested);
+
+ pd_ui_->profileTreeView->resizeColumnToContents(ProfileModel::COL_NAME);
+ pd_ui_->profileTreeView->resizeColumnToContents(ProfileModel::COL_TYPE);
+
pd_ui_->profileTreeView->setFocus();
}
ProfileDialog::~ProfileDialog()
{
delete pd_ui_;
- empty_profile_list (TRUE);
+ empty_profile_list (true);
}
void ProfileDialog::keyPressEvent(QKeyEvent *evt)
@@ -149,11 +163,11 @@ int ProfileDialog::execAction(ProfileDialog::ProfileAction profile_action)
ret = exec();
break;
case NewProfile:
- on_newToolButton_clicked();
+ newToolButtonClicked();
ret = exec();
break;
case ImportZipProfile:
-#ifdef HAVE_MINIZIP
+#if defined(HAVE_MINIZIP) || defined(HAVE_MINIZIPNG)
importFromZip();
#endif
break;
@@ -161,12 +175,12 @@ int ProfileDialog::execAction(ProfileDialog::ProfileAction profile_action)
importFromDirectory();
break;
case ExportSingleProfile:
-#ifdef HAVE_MINIZIP
+#if defined(HAVE_MINIZIP) || defined(HAVE_MINIZIPNG)
exportProfiles();
#endif
break;
case ExportAllProfiles:
-#ifdef HAVE_MINIZIP
+#if defined(HAVE_MINIZIP) || defined(HAVE_MINIZIPNG)
exportProfiles(true);
#endif
break;
@@ -249,7 +263,7 @@ void ProfileDialog::updateWidgets()
import_button_->setToolTip(msg);
import_button_->setEnabled(enable_import);
-#ifdef HAVE_MINIZIP
+#if defined(HAVE_MINIZIP) || defined(HAVE_MINIZIPNG)
bool contains_user = false;
bool enable_export = false;
@@ -294,7 +308,7 @@ void ProfileDialog::updateWidgets()
msg = tr("%Ln Selected Personal Profile(s)...", "", user_profiles);
pd_ui_->hintLabel->setText(msg);
-#ifdef HAVE_MINIZIP
+#if defined(HAVE_MINIZIP) || defined(HAVE_MINIZIPNG)
export_selected_entry_->setText(msg);
#endif
}
@@ -314,7 +328,7 @@ void ProfileDialog::updateWidgets()
}
pd_ui_->copyToolButton->setEnabled(true);
-#ifdef HAVE_MINIZIP
+#if defined(HAVE_MINIZIP) || defined(HAVE_MINIZIPNG)
export_selected_entry_->setText(msg);
#endif
}
@@ -365,9 +379,6 @@ void ProfileDialog::updateWidgets()
pd_ui_->hintLabel->setUrl(hintUrl);
- /* ensure the name column is resized to it's content */
- pd_ui_->profileTreeView->resizeColumnToContents(ProfileModel::COL_NAME);
-
pd_ui_->deleteToolButton->setEnabled(enable_del);
ok_button_->setEnabled(enable_ok);
}
@@ -377,7 +388,7 @@ void ProfileDialog::currentItemChanged(const QModelIndex &, const QModelIndex &)
updateWidgets();
}
-void ProfileDialog::on_newToolButton_clicked()
+void ProfileDialog::newToolButtonClicked()
{
pd_ui_->lineProfileFilter->setText("");
pd_ui_->cmbProfileTypes->setCurrentIndex(ProfileSortModel::AllProfiles);
@@ -395,7 +406,7 @@ void ProfileDialog::on_newToolButton_clicked()
updateWidgets();
}
-void ProfileDialog::on_deleteToolButton_clicked()
+void ProfileDialog::deleteToolButtonClicked()
{
QModelIndexList profiles = selectedProfiles();
if (profiles.count() <= 0)
@@ -417,7 +428,7 @@ void ProfileDialog::on_deleteToolButton_clicked()
updateWidgets();
}
-void ProfileDialog::on_copyToolButton_clicked()
+void ProfileDialog::copyToolButtonClicked()
{
QModelIndexList profiles = selectedProfiles();
if (profiles.count() > 1)
@@ -444,11 +455,13 @@ void ProfileDialog::on_copyToolButton_clicked()
updateWidgets();
}
-void ProfileDialog::on_buttonBox_accepted()
+void ProfileDialog::buttonBoxAccepted()
{
bool write_recent = true;
bool item_data_removed = false;
+ recent.gui_profile_switch_check_count = pd_ui_->autoSwitchSpinBox->value();
+
QModelIndex index = sort_model_->mapToSource(pd_ui_->profileTreeView->currentIndex());
pd_ui_->buttonBox->setFocus();
@@ -483,7 +496,7 @@ void ProfileDialog::on_buttonBox_accepted()
write_profile_recent();
}
- gchar * err_msg = Q_NULLPTR;
+ char * err_msg = Q_NULLPTR;
if ((err_msg = apply_profile_changes()) != Q_NULLPTR) {
QMessageBox::critical(this, tr("Profile Error"),
err_msg,
@@ -512,22 +525,22 @@ void ProfileDialog::on_buttonBox_accepted()
if (profileName.length() > 0 && model_->findByName(profileName) >= 0) {
// The new profile exists, change.
- mainApp->setConfigurationProfile (profileName.toUtf8().constData(), FALSE);
+ mainApp->setConfigurationProfile (profileName.toUtf8().constData(), false);
} else if (!model_->activeProfile().isValid()) {
// The new profile does not exist, and the previous profile has
// been deleted. Change to the default profile.
- mainApp->setConfigurationProfile (Q_NULLPTR, FALSE);
+ mainApp->setConfigurationProfile (Q_NULLPTR, false);
}
}
-void ProfileDialog::on_buttonBox_rejected()
+void ProfileDialog::buttonBoxRejected()
{
QString msg;
if (! model_->clearImported(&msg))
QMessageBox::critical(this, tr("Error"), msg);
}
-void ProfileDialog::on_buttonBox_helpRequested()
+void ProfileDialog::buttonBoxHelpRequested()
{
mainApp->helpTopicAction(HELP_CONFIG_PROFILES_DIALOG);
}
@@ -558,14 +571,12 @@ void ProfileDialog::filterChanged(const QString &text)
else if (qobject_cast<QLineEdit *>(sender()))
sort_model_->setFilterString(text);
- pd_ui_->profileTreeView->resizeColumnToContents(ProfileModel::COL_NAME);
-
QModelIndex active = sort_model_->mapFromSource(model_->activeProfile());
if (active.isValid())
pd_ui_->profileTreeView->setCurrentIndex(active);
}
-#ifdef HAVE_MINIZIP
+#if defined(HAVE_MINIZIP) || defined(HAVE_MINIZIPNG)
void ProfileDialog::exportProfiles(bool exportAllPersonalProfiles)
{
QAction * action = qobject_cast<QAction *>(sender());
@@ -604,7 +615,7 @@ void ProfileDialog::exportProfiles(bool exportAllPersonalProfiles)
return;
}
- QString zipFile = QFileDialog::getSaveFileName(this, tr("Select zip file for export"), openDialogInitialDir(), tr("Zip File (*.zip)"));
+ QString zipFile = WiresharkFileDialog::getSaveFileName(this, tr("Select zip file for export"), openDialogInitialDir(), tr("Zip File (*.zip)"));
if (zipFile.length() > 0)
{
@@ -627,7 +638,7 @@ void ProfileDialog::exportProfiles(bool exportAllPersonalProfiles)
{
QString msg = tr("An error has occurred while exporting profiles");
if (err.length() > 0)
- msg.append(QString("\n\n%1: %3").arg(tr("Error")).arg(err));
+ msg.append(QString("\n\n%1: %2").arg(tr("Error"), err));
QMessageBox::critical(this, tr("Exporting profiles"), msg);
}
}
@@ -635,7 +646,7 @@ void ProfileDialog::exportProfiles(bool exportAllPersonalProfiles)
void ProfileDialog::importFromZip()
{
- QString zipFile = QFileDialog::getOpenFileName(this, tr("Select zip file for import"), openDialogInitialDir(), tr("Zip File (*.zip)"));
+ QString zipFile = WiresharkFileDialog::getOpenFileName(this, tr("Select zip file for import"), openDialogInitialDir(), tr("Zip File (*.zip)"));
QFileInfo fi(zipFile);
if (! fi.exists())
@@ -651,7 +662,7 @@ void ProfileDialog::importFromZip()
void ProfileDialog::importFromDirectory()
{
- QString importDir = QFileDialog::getExistingDirectory(this, tr("Select directory for import"), openDialogInitialDir());
+ QString importDir = WiresharkFileDialog::getExistingDirectory(this, tr("Select directory for import"), openDialogInitialDir());
QFileInfo fi(importDir);
if (! fi.isDir())
@@ -726,11 +737,8 @@ void ProfileDialog::resetTreeView()
selectionChanged();
- if (sort_model_->columnCount() <= 1)
+ if (sort_model_->columnCount() <= 1) {
pd_ui_->profileTreeView->header()->hide();
- else
- {
- pd_ui_->profileTreeView->header()->setStretchLastSection(false);
- pd_ui_->profileTreeView->header()->setSectionResizeMode(ProfileModel::COL_NAME, QHeaderView::Stretch);
}
}
+