aboutsummaryrefslogtreecommitdiffstats
path: root/ui/qt
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2018-07-03 17:51:30 -0700
committerGuy Harris <guy@alum.mit.edu>2018-07-04 00:52:08 +0000
commita442fd512bcf46e03ed4b8b40d756a2f17215fe6 (patch)
treedde05a7d575bd201a5c82b56c02922aba97528e8 /ui/qt
parent9541945aa217a43d285e7b44b6c4516253f716a1 (diff)
Set the file path for a main window if it's not a temporary file.
That's needed to support the "proxy icon", so it can be dragged. Change-Id: I1ad209cd43a2a6df9c52d076f6513780b0ac51be Reviewed-on: https://code.wireshark.org/review/28587 Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'ui/qt')
-rw-r--r--ui/qt/capture_file.cpp60
-rw-r--r--ui/qt/capture_file.h20
-rw-r--r--ui/qt/main_window.cpp11
3 files changed, 63 insertions, 28 deletions
diff --git a/ui/qt/capture_file.cpp b/ui/qt/capture_file.cpp
index fc4ae6c907..de7d586876 100644
--- a/ui/qt/capture_file.cpp
+++ b/ui/qt/capture_file.cpp
@@ -86,7 +86,6 @@ QString CaptureFile::no_capture_file_ = QObject::tr("[no capture file]");
CaptureFile::CaptureFile(QObject *parent, capture_file *cap_file) :
QObject(parent),
cap_file_(cap_file),
- file_name_(no_capture_file_),
file_state_(QString())
{
#ifdef HAVE_LIBPCAP
@@ -115,23 +114,10 @@ int CaptureFile::currentRow()
return -1;
}
-const QString CaptureFile::fileTitle()
+const QString CaptureFile::filePath()
{
- if (isValid() && cap_file_->is_tempfile) {
- //
- // For a temporary file, put the source of the data
- // in the window title, not whatever random pile
- // of characters is the last component of the path
- // name.
- //
- return cf_get_tempfile_source(cap_file_) + file_state_;
- } else {
- return fileName() + file_state_;
- }
-}
+ QString path;
-const QString CaptureFile::fileName()
-{
if (isValid()) {
//
// Sadly, some UN*Xes don't necessarily use UTF-8
@@ -145,16 +131,49 @@ const QString CaptureFile::fileName()
NULL,
NULL);
if (utf8_filename) {
- QFileInfo cfi(QString::fromUtf8(utf8_filename));
- file_name_ = cfi.fileName();
+ path = QString::fromUtf8(utf8_filename);
g_free(utf8_filename);
} else {
// So what the heck else can we do here?
- file_name_ = tr("(File name can't be mapped to UTF-8)");
+ path = tr("(File name can't be mapped to UTF-8)");
}
+ } else {
+ path = QString();
+ }
+ return path;
+}
+
+const QString CaptureFile::fileName()
+{
+ QString name;
+
+ if (isValid()) {
+ QFileInfo cfi(filePath());
+ name = cfi.fileName();
+ } else {
+ name = QString();
}
- return file_name_;
+ return name;
+}
+
+const QString CaptureFile::fileTitle()
+{
+ if (isValid()) {
+ if (cap_file_->is_tempfile) {
+ //
+ // For a temporary file, put the source of the data
+ // in the window title, not whatever random pile
+ // of characters is the last component of the path
+ // name.
+ //
+ return cf_get_tempfile_source(cap_file_) + file_state_;
+ } else {
+ return fileName() + file_state_;
+ }
+ } else {
+ return no_capture_file_;
+ }
}
struct _packet_info *CaptureFile::packetInfo()
@@ -246,7 +265,6 @@ void CaptureFile::captureFileEvent(int event, gpointer data)
file_state_ = tr(" [closed]");
emit captureEvent(CaptureEvent(CaptureEvent::File, CaptureEvent::Closed));
cap_file_ = NULL;
- file_name_ = no_capture_file_;
file_state_ = QString();
break;
case(cf_cb_file_read_started):
diff --git a/ui/qt/capture_file.h b/ui/qt/capture_file.h
index f5f3ad948f..f91a3351d9 100644
--- a/ui/qt/capture_file.h
+++ b/ui/qt/capture_file.h
@@ -43,6 +43,19 @@ public:
*/
int currentRow();
+ /** Return the full pathname.
+ *
+ * @return The entire pathname.
+ */
+ const QString filePath();
+
+ /** Return the plain filename.
+ *
+ * @return The last component of the pathname; this includes the
+ * extension.
+ */
+ const QString fileName();
+
/** Return a string representing the file suitable for use in a
* window title.
*
@@ -64,12 +77,6 @@ public:
*/
const QString fileTitle();
- /** Return the plain filename.
- *
- * @return The basename of the capture file without an extension.
- */
- const QString fileName();
-
/** Return the current packet information.
*
* @return A pointer to the current packet_info struct or NULL.
@@ -130,7 +137,6 @@ private:
static QString no_capture_file_;
capture_file *cap_file_;
- QString file_name_;
QString file_state_;
};
diff --git a/ui/qt/main_window.cpp b/ui/qt/main_window.cpp
index 13f5bf56a4..29d5e084f4 100644
--- a/ui/qt/main_window.cpp
+++ b/ui/qt/main_window.cpp
@@ -2147,6 +2147,17 @@ void MainWindow::setTitlebarForCaptureFile()
{
if (capture_file_.capFile() && capture_file_.capFile()->filename) {
setWSWindowTitle(QString("[*]%1").arg(capture_file_.fileTitle()));
+ //
+ // XXX - on non-Mac platforms, put in the application
+ // name? Or do so only for temporary files?
+ //
+ if (!capture_file_.capFile()->is_tempfile) {
+ //
+ // Set the file path; that way, for macOS, it'll set the
+ // "proxy icon".
+ //
+ setWindowFilePath(capture_file_.filePath());
+ }
setWindowModified(cf_has_unsaved_data(capture_file_.capFile()));
} else {
/* We have no capture file. */