aboutsummaryrefslogtreecommitdiffstats
path: root/ui/qt
diff options
context:
space:
mode:
authorgerald <gerald@f5534014-38df-0310-8fa8-9805f1628bb7>2012-08-14 00:25:42 +0000
committergerald <gerald@f5534014-38df-0310-8fa8-9805f1628bb7>2012-08-14 00:25:42 +0000
commit67129d2ae070da7ccf11564e70392fde2132c026 (patch)
treecdd86348c5e380ed05248daa7734cbdb65147db5 /ui/qt
parent4854c7a9ee0fcebbb1a33e917707e4131cde3ffd (diff)
Minor cleanup: Get rid of unnecessary signal+slot customization and mark
functions protected. git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@44481 f5534014-38df-0310-8fa8-9805f1628bb7
Diffstat (limited to 'ui/qt')
-rw-r--r--ui/qt/main_window.cpp126
-rw-r--r--ui/qt/main_window.h4
-rw-r--r--ui/qt/main_window.ui59
-rw-r--r--ui/qt/sparkline_delegate.h1
4 files changed, 82 insertions, 108 deletions
diff --git a/ui/qt/main_window.cpp b/ui/qt/main_window.cpp
index 1d0175618a..d9a9cf82e6 100644
--- a/ui/qt/main_window.cpp
+++ b/ui/qt/main_window.cpp
@@ -106,7 +106,7 @@ MainWindow::MainWindow(QWidget *parent) :
mainWelcome = new MainWelcome(ui->mainStack);
ui->mainStack->addWidget(mainWelcome);
connect(mainWelcome, SIGNAL(recentFileActivated(QString&)),
- this, SLOT(openCaptureFile(QString&)));
+ this, SLOT(on_actionFileOpen_triggered(QString&)));
connect(wsApp, SIGNAL(captureFileReadStarted(const capture_file*)),
this, SLOT(captureFileReadStarted(const capture_file*)));
@@ -255,12 +255,64 @@ void MainWindow::captureFileClosed(const capture_file *cf) {
capFile = NULL;
}
-void MainWindow::closeCaptureFile() {
- cf_close(&cfile);
- ui->mainStack->setCurrentWidget(mainWelcome);
+// XXX - Copied from ui/gtk/menus.c
+
+/**
+ * Add the capture filename (with an absolute path) to the "Recent Files" menu.
+ *
+ * @param cf_name Absolute path to the file.
+ * @param first Prepend the filename if true, otherwise append it. Default is false (append).
+ */
+// XXX - We should probably create a RecentFile class.
+void MainWindow::updateRecentFiles() {
+ QAction *ra;
+ QMenu *recentMenu = ui->menuOpenRecentCaptureFile;
+ QString action_cf_name;
+
+ if (!recentMenu) {
+ return;
+ }
+
+ recentMenu->clear();
+
+ /* Iterate through the actions in menuOpenRecentCaptureFile,
+ * removing special items, a maybe duplicate entry and every item above count_max */
+ int shortcut = Qt::Key_0;
+ foreach (recent_item_status *ri, wsApp->recent_item_list()) {
+ // Add the new item
+ ra = new QAction(recentMenu);
+ ra->setData(ri->filename);
+ // XXX - Needs get_recent_item_status or equivalent
+ ra->setEnabled(ri->accessible);
+ recentMenu->insertAction(NULL, ra);
+ action_cf_name = ra->data().toString();
+ if (shortcut <= Qt::Key_9) {
+ ra->setShortcut(Qt::META | shortcut);
+ shortcut++;
+ }
+ ra->setText(action_cf_name);
+ connect(ra, SIGNAL(triggered()), this, SLOT(recentActionTriggered()));
+ }
+
+ if (recentMenu->actions().count() > 0) {
+ // Separator + "Clear"
+ // XXX - Do we really need this?
+ ra = new QAction(recentMenu);
+ ra->setSeparator(true);
+ recentMenu->insertAction(NULL, ra);
+
+ ra = new QAction(recentMenu);
+ ra->setText(tr("Clear Menu"));
+ recentMenu->insertAction(NULL, ra);
+ connect(ra, SIGNAL(triggered()), wsApp, SLOT(clearRecentItems()));
+ } else {
+ if (ui->actionDummyNoFilesFound) {
+ recentMenu->addAction(ui->actionDummyNoFilesFound);
+ }
+ }
}
-void MainWindow::openCaptureFile(QString &cfPath)
+void MainWindow::on_actionFileOpen_triggered(QString &cfPath)
{
QString fileName = "";
QString displayFilter = "";
@@ -336,68 +388,16 @@ void MainWindow::openCaptureFile(QString &cfPath)
ui->statusBar->showExpert();
}
+void MainWindow::on_actionFileClose_triggered() {
+ cf_close(&cfile);
+ ui->mainStack->setCurrentWidget(mainWelcome);
+}
+
void MainWindow::recentActionTriggered() {
QAction *ra = qobject_cast<QAction*>(sender());
if (ra) {
QString cfPath = ra->data().toString();
- openCaptureFile(cfPath);
- }
-}
-
-// XXX - Copied from ui/gtk/menus.c
-
-/**
- * Add the capture filename (with an absolute path) to the "Recent Files" menu.
- *
- * @param cf_name Absolute path to the file.
- * @param first Prepend the filename if true, otherwise append it. Default is false (append).
- */
-// XXX - We should probably create a RecentFile class.
-void MainWindow::updateRecentFiles() {
- QAction *ra;
- QMenu *recentMenu = ui->menuOpenRecentCaptureFile;
- QString action_cf_name;
-
- if (!recentMenu) {
- return;
- }
-
- recentMenu->clear();
-
- /* Iterate through the actions in menuOpenRecentCaptureFile,
- * removing special items, a maybe duplicate entry and every item above count_max */
- int shortcut = Qt::Key_0;
- foreach (recent_item_status *ri, wsApp->recent_item_list()) {
- // Add the new item
- ra = new QAction(recentMenu);
- ra->setData(ri->filename);
- // XXX - Needs get_recent_item_status or equivalent
- ra->setEnabled(ri->accessible);
- recentMenu->insertAction(NULL, ra);
- action_cf_name = ra->data().toString();
- if (shortcut <= Qt::Key_9) {
- ra->setShortcut(Qt::META | shortcut);
- shortcut++;
- }
- ra->setText(action_cf_name);
- connect(ra, SIGNAL(triggered()), this, SLOT(recentActionTriggered()));
- }
-
- if (recentMenu->actions().count() > 0) {
- // Separator + "Clear"
- // XXX - Do we really need this?
- ra = new QAction(recentMenu);
- ra->setSeparator(true);
- recentMenu->insertAction(NULL, ra);
-
- ra = new QAction(recentMenu);
- ra->setText(tr("Clear Menu"));
- recentMenu->insertAction(NULL, ra);
- connect(ra, SIGNAL(triggered()), wsApp, SLOT(clearRecentItems()));
- } else {
- if (ui->actionDummyNoFilesFound) {
- recentMenu->addAction(ui->actionDummyNoFilesFound);
- }
+ on_actionFileOpen_triggered(cfPath);
}
}
diff --git a/ui/qt/main_window.h b/ui/qt/main_window.h
index ee4baac069..2c95c47f7d 100644
--- a/ui/qt/main_window.h
+++ b/ui/qt/main_window.h
@@ -75,9 +75,9 @@ public slots:
void captureFileClosed(const capture_file *cf);
private slots:
- void closeCaptureFile();
void updateRecentFiles();
- void openCaptureFile(QString& cfPath = *new QString());
+ void on_actionFileOpen_triggered(QString& cfPath = *new QString());
+ void on_actionFileClose_triggered();
void recentActionTriggered();
void on_actionGoNextPacket_triggered();
void on_actionGoPreviousPacket_triggered();
diff --git a/ui/qt/main_window.ui b/ui/qt/main_window.ui
index e403ebfa6e..ca7535f9cf 100644
--- a/ui/qt/main_window.ui
+++ b/ui/qt/main_window.ui
@@ -60,11 +60,11 @@
</property>
<addaction name="actionDummyNoFilesFound"/>
</widget>
- <addaction name="actionOpenCaptureFile"/>
+ <addaction name="actionFileOpen"/>
<addaction name="menuOpenRecentCaptureFile"/>
<addaction name="separator"/>
- <addaction name="actionCloseCaptureFile"/>
- <addaction name="actionQuit"/>
+ <addaction name="actionFileClose"/>
+ <addaction name="actionFileQuit"/>
</widget>
<widget class="QMenu" name="menuEdit">
<property name="title">
@@ -170,18 +170,24 @@
<bool>true</bool>
</attribute>
</widget>
- <action name="actionOpenCaptureFile">
+ <action name="actionFileOpen">
<property name="text">
<string>Open</string>
</property>
+ <property name="toolTip">
+ <string>Open a capture file</string>
+ </property>
<property name="shortcut">
<string>Ctrl+O</string>
</property>
</action>
- <action name="actionQuit">
+ <action name="actionFileQuit">
<property name="text">
<string>Quit</string>
</property>
+ <property name="toolTip">
+ <string>Quit Wireshark</string>
+ </property>
<property name="shortcut">
<string>Ctrl+Q</string>
</property>
@@ -222,10 +228,13 @@
<string>Stop capturing packets</string>
</property>
</action>
- <action name="actionCloseCaptureFile">
+ <action name="actionFileClose">
<property name="text">
<string>Close</string>
</property>
+ <property name="toolTip">
+ <string>Close the current capture file</string>
+ </property>
<property name="shortcut">
<string>Ctrl+W</string>
</property>
@@ -400,7 +409,7 @@
</resources>
<connections>
<connection>
- <sender>actionQuit</sender>
+ <sender>actionFileQuit</sender>
<signal>triggered()</signal>
<receiver>MainWindow</receiver>
<slot>close()</slot>
@@ -415,41 +424,5 @@
</hint>
</hints>
</connection>
- <connection>
- <sender>actionOpenCaptureFile</sender>
- <signal>triggered()</signal>
- <receiver>MainWindow</receiver>
- <slot>openCaptureFile()</slot>
- <hints>
- <hint type="sourcelabel">
- <x>-1</x>
- <y>-1</y>
- </hint>
- <hint type="destinationlabel">
- <x>408</x>
- <y>258</y>
- </hint>
- </hints>
- </connection>
- <connection>
- <sender>actionCloseCaptureFile</sender>
- <signal>triggered()</signal>
- <receiver>MainWindow</receiver>
- <slot>closeCaptureFile()</slot>
- <hints>
- <hint type="sourcelabel">
- <x>-1</x>
- <y>-1</y>
- </hint>
- <hint type="destinationlabel">
- <x>479</x>
- <y>383</y>
- </hint>
- </hints>
- </connection>
</connections>
- <slots>
- <slot>openCaptureFile()</slot>
- <slot>closeCaptureFile()</slot>
- </slots>
</ui>
diff --git a/ui/qt/sparkline_delegate.h b/ui/qt/sparkline_delegate.h
index ce8e9fb6a6..02d038a895 100644
--- a/ui/qt/sparkline_delegate.h
+++ b/ui/qt/sparkline_delegate.h
@@ -31,6 +31,7 @@ class SparkLineDelegate : public QStyledItemDelegate
public:
SparkLineDelegate(QWidget *parent = 0) : QStyledItemDelegate(parent) {}
+protected:
void paint(QPainter *painter, const QStyleOptionViewItem &option,
const QModelIndex &index) const;
QSize sizeHint(const QStyleOptionViewItem &option,