summaryrefslogtreecommitdiff
path: root/ui
diff options
context:
space:
mode:
Diffstat (limited to 'ui')
-rw-r--r--ui/gtk/gui_utils.c9
-rw-r--r--ui/qt/main.cpp10
-rw-r--r--ui/qt/main_window.cpp102
-rw-r--r--ui/qt/main_window.h3
-rw-r--r--ui/qt/main_window_slots.cpp1
-rw-r--r--ui/qt/qt_ui_utils.h2
-rw-r--r--ui/qt/wireshark_application.cpp14
-rw-r--r--ui/qt/wireshark_application.h1
-rw-r--r--ui/ui_util.h2
9 files changed, 101 insertions, 43 deletions
diff --git a/ui/gtk/gui_utils.c b/ui/gtk/gui_utils.c
index c08ba8a9a4..8fc19d0e76 100644
--- a/ui/gtk/gui_utils.c
+++ b/ui/gtk/gui_utils.c
@@ -548,13 +548,6 @@ main_window_update(void)
gtk_main_iteration();
}
-/* exit the main window */
-void
-main_window_exit(void)
-{
- exit(0);
-}
-
#ifdef HAVE_LIBPCAP
/* quit a nested main window */
@@ -572,8 +565,6 @@ main_window_quit(void)
gtk_main_quit();
}
-
-
typedef struct pipe_input_tag {
gint source;
gpointer user_data;
diff --git a/ui/qt/main.cpp b/ui/qt/main.cpp
index 9cc27d5d1f..9ddc8e1fd3 100644
--- a/ui/qt/main.cpp
+++ b/ui/qt/main.cpp
@@ -169,25 +169,19 @@ void main_window_update(void)
WiresharkApplication::processEvents();
}
-/* exit the main window */
-void main_window_exit(void)
-{
- exit(0);
-}
-
#ifdef HAVE_LIBPCAP
/* quit a nested main window */
void main_window_nested_quit(void)
{
// if (gtk_main_level() > 0)
- WiresharkApplication::quit();
+ wsApp->quit();
}
/* quit the main window */
void main_window_quit(void)
{
- WiresharkApplication::quit();
+ wsApp->quit();
}
#endif /* HAVE_LIBPCAP */
diff --git a/ui/qt/main_window.cpp b/ui/qt/main_window.cpp
index da4f817e2e..2838a88f06 100644
--- a/ui/qt/main_window.cpp
+++ b/ui/qt/main_window.cpp
@@ -43,6 +43,7 @@
#include "ui/alert_box.h"
#include "ui/capture_globals.h"
#include "ui/main_statusbar.h"
+#include "ui/recent.h"
#include "ui/util.h"
#include "wireshark_application.h"
@@ -54,13 +55,15 @@
#include "qt_ui_utils.h"
-#include <QTreeWidget>
-#include <QTabWidget>
#include <QAction>
-#include <QToolButton>
+#include <QDesktopWidget>
#include <QKeyEvent>
-#include <QMetaObject>
#include <QMessageBox>
+#include <QMetaObject>
+#include <QPropertyAnimation>
+#include <QTabWidget>
+#include <QToolButton>
+#include <QTreeWidget>
#ifdef QT_MACEXTRAS_LIB
#include <QtMacExtras/QMacNativeToolBar>
@@ -389,8 +392,10 @@ void MainWindow::keyPressEvent(QKeyEvent *event) {
}
void MainWindow::closeEvent(QCloseEvent *event) {
- /* If we're in the middle of stopping a capture, don't do anything;
- the user can try deleting the window after the capture stops. */
+ saveWindowGeometry();
+
+ /* If we're in the middle of stopping a capture, don't do anything;
+ the user can try deleting the window after the capture stops. */
if (capture_stopping_) {
event->ignore();
return;
@@ -399,17 +404,88 @@ void MainWindow::closeEvent(QCloseEvent *event) {
// Make sure we kill any open dumpcap processes.
delete main_welcome_;
- if(testCaptureFileClose(true)) {
- /* QCoreApplication::quit() won't exit properly
- * because when during initialization phase we are not in the event loop */
+ if(!wsApp->isInitialized()) {
+ // If we're still initializing, QCoreApplication::quit() won't
+ // exit properly because we are not in the event loop. This
+ // means that the application won't clean up after itself. We
+ // might want to call wsApp->processEvents() during startup
+ // instead so that we can do a normal exit here.
exit(0);
}
- else
- {
- event->ignore();
- return;
+}
+
+const int min_sensible_dimension = 200;
+const int geom_animation_duration = 150;
+void MainWindow::loadWindowGeometry()
+{
+ QWidget shadow_main(wsApp->desktop());
+ shadow_main.setVisible(false);
+
+ // Start off with the Widget defaults
+ shadow_main.restoreGeometry(saveGeometry());
+
+ // Apply any saved settings
+
+ // Note that we're saving and restoring the outer window frame
+ // position and the inner client area size.
+ if (prefs.gui_geometry_save_position) {
+ shadow_main.move(recent.gui_geometry_main_x, recent.gui_geometry_main_y);
+ }
+
+ // XXX Preferences haven't been loaded at this point. For now we
+ // assume default (true) values for everything.
+
+ if (// prefs.gui_geometry_save_size &&
+ recent.gui_geometry_main_width > min_sensible_dimension &&
+ recent.gui_geometry_main_width > min_sensible_dimension) {
+ shadow_main.resize(recent.gui_geometry_main_width, recent.gui_geometry_main_height);
+ }
+
+ // Let Qt move and resize our window if needed (e.g. if it's offscreen)
+ QByteArray geom = shadow_main.saveGeometry();
+
+ if (strlen (get_conn_cfilter()) > 0) {
+ QPropertyAnimation *pos_anim = new QPropertyAnimation(this, "pos");
+ QPropertyAnimation *size_anim = new QPropertyAnimation(this, "size");
+
+ shadow_main.restoreGeometry(geom);
+
+ pos_anim->setDuration(geom_animation_duration);
+ pos_anim->setStartValue(pos());
+ pos_anim->setEndValue(shadow_main.pos());
+ size_anim->setDuration(geom_animation_duration);
+ size_anim->setStartValue(size());
+ size_anim->setEndValue(shadow_main.size());
+
+ pos_anim->start(QAbstractAnimation::DeleteWhenStopped);
+ size_anim->start(QAbstractAnimation::DeleteWhenStopped);
+ } else {
+ restoreGeometry(geom);
}
+#ifndef Q_OS_MAC
+ if (prefs.gui_geometry_save_maximized && recent.gui_geometry_main_maximized) {
+ setWindowState(Qt::WindowMaximized);
+ }
+#endif
+}
+
+void MainWindow::saveWindowGeometry()
+{
+ if (prefs.gui_geometry_save_position) {
+ recent.gui_geometry_main_x = pos().x();
+ recent.gui_geometry_main_y = pos().y();
+ }
+
+ if (prefs.gui_geometry_save_size) {
+ recent.gui_geometry_main_width = size().width();
+ recent.gui_geometry_main_height = size().height();
+ }
+
+ if (prefs.gui_geometry_save_maximized) {
+ // On OS X this is false when it shouldn't be
+ recent.gui_geometry_main_maximized = isMaximized();
+ }
}
QWidget* MainWindow::getLayoutWidget(layout_pane_content_e type) {
diff --git a/ui/qt/main_window.h b/ui/qt/main_window.h
index 1d67527931..f01851d6cc 100644
--- a/ui/qt/main_window.h
+++ b/ui/qt/main_window.h
@@ -129,7 +129,10 @@ private:
QSocketNotifier *pipe_notifier_;
#endif
+ void loadWindowGeometry();
+ void saveWindowGeometry();
QWidget* getLayoutWidget(layout_pane_content_e type);
+
void mergeCaptureFile();
void importCaptureFile();
void saveCaptureFile(capture_file *cf, bool stay_closed);
diff --git a/ui/qt/main_window_slots.cpp b/ui/qt/main_window_slots.cpp
index dd69526b23..a095c95355 100644
--- a/ui/qt/main_window_slots.cpp
+++ b/ui/qt/main_window_slots.cpp
@@ -1116,6 +1116,7 @@ void MainWindow::setFeaturesEnabled(bool enabled)
if(enabled)
{
main_ui_->statusBar->clearMessage();
+ loadWindowGeometry();
}
else
{
diff --git a/ui/qt/qt_ui_utils.h b/ui/qt/qt_ui_utils.h
index 2d049cfd95..d307a61fdd 100644
--- a/ui/qt/qt_ui_utils.h
+++ b/ui/qt/qt_ui_utils.h
@@ -68,8 +68,6 @@ struct remote_host_t {
gboolean nocap_local;
};
-extern gboolean main_do_quit(void);
-
#ifdef __cplusplus
}
#endif /* __cplusplus */
diff --git a/ui/qt/wireshark_application.cpp b/ui/qt/wireshark_application.cpp
index cc8990a377..c6bc651453 100644
--- a/ui/qt/wireshark_application.cpp
+++ b/ui/qt/wireshark_application.cpp
@@ -154,14 +154,6 @@ extern "C" void menu_recent_file_write_all(FILE *rf) {
}
}
-
-
-extern gboolean main_do_quit(void) {
- WiresharkApplication::quit();
- return FALSE;
-}
-
-//
void WiresharkApplication::refreshRecentFiles(void) {
recent_item_status *ri;
RecentFileStatus *rf_status;
@@ -539,6 +531,10 @@ void WiresharkApplication::clearRecentItems() {
void WiresharkApplication::cleanup()
{
software_update_cleanup();
+ /* write user's recent file to disk
+ * It is no problem to write this file, even if we do not quit */
+ write_profile_recent();
+ write_recent();
}
void WiresharkApplication::itemStatusFinished(const QString &filename, qint64 size, bool accessible) {
@@ -592,7 +588,7 @@ WiresharkApplication::WiresharkApplication(int &argc, char **argv) :
connect(recent_timer_, SIGNAL(timeout()), this, SLOT(refreshRecentFiles()));
recent_timer_->start(2000);
- connect(this, SIGNAL(aboutToQuit()), this, SLOT(cleanup()));
+ connect(qApp, SIGNAL(aboutToQuit()), this, SLOT(cleanup()));
}
void WiresharkApplication::registerUpdate(register_action_e action, const char *message)
diff --git a/ui/qt/wireshark_application.h b/ui/qt/wireshark_application.h
index ac4cac8d3e..1e2cb3de9c 100644
--- a/ui/qt/wireshark_application.h
+++ b/ui/qt/wireshark_application.h
@@ -85,6 +85,7 @@ public:
void setMonospaceFont(const char *font_string);
int monospaceTextSize(const char *str, bool bold = false);
void setConfigurationProfile(const gchar *profile_name);
+ bool isInitialized() { return initialized_; }
private:
void prefsToCaptureOpts();
diff --git a/ui/ui_util.h b/ui/ui_util.h
index d5449bdd92..3fcc2ff33b 100644
--- a/ui/ui_util.h
+++ b/ui/ui_util.h
@@ -49,8 +49,6 @@ typedef struct window_geometry_s {
/* update the main window */
extern void main_window_update(void);
-/* exit the main window */
-extern void main_window_exit(void);
/* quit a nested main window */
extern void main_window_nested_quit(void);
/* quit the main window */