diff options
author | Gerald Combs <gerald@wireshark.org> | 2016-04-29 08:53:44 -0700 |
---|---|---|
committer | Gerald Combs <gerald@wireshark.org> | 2016-04-29 22:41:20 +0000 |
commit | 69714b7457dc02a80e7ca453b60d5f5432756158 (patch) | |
tree | 4ddc18ed7f94b15b1c8fa36d23b5f762a5528c2b /ui | |
parent | 5efb45231671baa2db2011d8f67f9d6e72bc455b (diff) | |
download | wireshark-69714b7457dc02a80e7ca453b60d5f5432756158.tar.gz |
Qt: Add recent items to the OS X dock menu.
Qt 5.2 added QMenu::setAsDockMenu. Use it to add recent items to the
Wireshark dock menu.
Add QWinJumpList code which does something similar. Comment it out
because it does it slowly and not-quite-correctly.
Change-Id: I801b1037b998516eacab695f982d7d6e889bafb6
Reviewed-on: https://code.wireshark.org/review/15166
Petri-Dish: Gerald Combs <gerald@wireshark.org>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Gerald Combs <gerald@wireshark.org>
Diffstat (limited to 'ui')
-rw-r--r-- | ui/qt/main_window.cpp | 13 | ||||
-rw-r--r-- | ui/qt/main_window.h | 6 | ||||
-rw-r--r-- | ui/qt/main_window_slots.cpp | 48 |
3 files changed, 60 insertions, 7 deletions
diff --git a/ui/qt/main_window.cpp b/ui/qt/main_window.cpp index 2e1d9b453d..bbeb59ddf5 100644 --- a/ui/qt/main_window.cpp +++ b/ui/qt/main_window.cpp @@ -278,15 +278,18 @@ MainWindow::MainWindow(QWidget *parent) : funnel_statistics_(NULL), freeze_focus_(NULL), capture_stopping_(false), - capture_filter_valid_(false), + capture_filter_valid_(false) #ifdef HAVE_LIBPCAP - capture_interfaces_dialog_(NULL), - info_data_(), + , capture_interfaces_dialog_(NULL) + , info_data_() #endif #ifdef _WIN32 - pipe_timer_(NULL) + , pipe_timer_(NULL) #else - pipe_notifier_(NULL) + , pipe_notifier_(NULL) +#endif +#if defined(Q_OS_MAC) && QT_VERSION >= QT_VERSION_CHECK(5, 2, 0) + , dock_menu_(NULL) #endif { if (!gbl_cur_main_window_) { diff --git a/ui/qt/main_window.h b/ui/qt/main_window.h index 72bf460479..f1f84f4c1e 100644 --- a/ui/qt/main_window.h +++ b/ui/qt/main_window.h @@ -129,7 +129,6 @@ private: }; Ui::MainWindow *main_ui_; - QMenu *open_recent_menu_; QSplitter master_split_; QSplitter extra_split_; QVector<unsigned> cur_layout_; @@ -175,6 +174,11 @@ private: QSocketNotifier *pipe_notifier_; #endif +#if defined(Q_OS_MAC) && QT_VERSION >= QT_VERSION_CHECK(5, 2, 0) + QMenu *dock_menu_; +#endif + + QWidget* getLayoutWidget(layout_pane_content_e type); void freeze(); diff --git a/ui/qt/main_window_slots.cpp b/ui/qt/main_window_slots.cpp index 278a8ff3f4..e892261bba 100644 --- a/ui/qt/main_window_slots.cpp +++ b/ui/qt/main_window_slots.cpp @@ -156,6 +156,14 @@ #include <QUrl> #include <QDebug> +// XXX You must uncomment QT_WINEXTRAS_LIB lines in CMakeList.txt and +// cmakeconfig.h.in. +// #if defined(QT_WINEXTRAS_LIB) && QT_VERSION >= QT_VERSION_CHECK(5, 2, 0) +// #include <QWinJumpList> +// #include <QWinJumpListCategory> +// #include <QWinJumpListItem> +// #endif + // // Public slots // @@ -1000,9 +1008,24 @@ void MainWindow::updateRecentFiles() { if (!recentMenu) { return; } - recentMenu->clear(); +// #if defined(QT_WINEXTRAS_LIB) && QT_VERSION >= QT_VERSION_CHECK(5, 2, 0) +// QWinJumpList recent_jl(this); +// QWinJumpListCategory *recent_jlc = recent_jl.recent(); +// if (recent_jlc) { +// recent_jlc->clear(); +// recent_jlc->setVisible(true); +// } +// #endif +#if defined(Q_OS_MAC) && QT_VERSION >= QT_VERSION_CHECK(5, 2, 0) + if (!dock_menu_) { + dock_menu_ = new QMenu(); + dock_menu_->setAsDockMenu(); + } + dock_menu_->clear(); +#endif + /* Iterate through the actions in menuOpenRecentCaptureFile, * removing special items, a maybe duplicate entry and every item above count_max */ int shortcut = Qt::Key_0; @@ -1020,6 +1043,29 @@ void MainWindow::updateRecentFiles() { } ra->setText(action_cf_name); connect(ra, SIGNAL(triggered()), this, SLOT(recentActionTriggered())); + +// This is slow, at least on my VM here. The added links also open Wireshark +// in a new window. It might make more sense to add a recent item when we +// open a capture file. +// #if defined(QT_WINEXTRAS_LIB) && QT_VERSION >= QT_VERSION_CHECK(5, 2, 0) +// if (recent_jlc) { +// QFileInfo fi(ri->filename); +// QWinJumpListItem *jli = recent_jlc->addLink( +// fi.fileName(), +// QApplication::applicationFilePath(), +// QStringList() << "-r" << ri->filename +// ); +// // XXX set icon +// jli->setWorkingDirectory(QDir::toNativeSeparators(QApplication::applicationDirPath())); +// } +// #endif +#if defined(Q_OS_MAC) && QT_VERSION >= QT_VERSION_CHECK(5, 2, 0) + QAction *rda = new QAction(dock_menu_); + QFileInfo fi(ri->filename); + rda->setText(fi.fileName()); + dock_menu_->insertAction(NULL, rda); + connect(rda, SIGNAL(triggered()), ra, SLOT(trigger())); +#endif } if (recentMenu->actions().count() > 0) { |