regen pidl all: rm epan/dissectors/pidl/*-stamp; pushd epan/dissectors/pidl/ && make...
[wireshark-sm.git] / plugins / epan / pluginifdemo / ui / uiclasshandler.cpp
blob6550bf2fd92aec1115c289feb4df500b336400b5
1 /* uiclasshandler.cpp
3 * Author: Roland Knall <rknall@gmail.com>
5 * Wireshark - Network traffic analyzer
6 * By Gerald Combs <gerald@wireshark.org>
7 * Copyright 1998 Gerald Combs
9 * SPDX-License-Identifier: GPL-2.0-or-later
12 #include <config.h>
14 #include <glib.h>
16 #include <QObject>
17 #include <QApplication>
18 #include <QMutex>
20 #include <epan/plugin_if.h>
22 #if defined(_WIN32)
23 #define _WINSOCKAPI_
24 #endif
26 #include <ui/qt/main_window.h>
28 #include "uihandler.h"
29 #include "pluginifdemo_main.h"
30 #include "pluginifdemo_about.h"
32 QMutex * GuiHandler::singletonMutex = new QMutex();
34 GuiHandler::GuiHandler()
38 GuiHandler * GuiHandler::getInstance()
40 static GuiHandler * instance = 0;
42 QMutexLocker locker(singletonMutex);
44 if ( instance == 0 )
46 instance = new GuiHandler();
49 return instance;
52 void GuiHandler::showAboutDialog(ext_menubar_gui_type gui_type _U_, gpointer gui_data _U_)
54 PluginIFDemo_About * mainwindow = new PluginIFDemo_About();
55 executeDialog((QDialog*)mainwindow);
58 void GuiHandler::showMainDialog(ext_menubar_gui_type gui_type _U_, gpointer gui_data _U_)
60 PluginIFDemo_Main * mainwindow = new PluginIFDemo_Main();
61 mainwindow->setToolbar(_toolbar);
62 executeDialog((QDialog*)mainwindow);
65 void GuiHandler::executeDialog(QDialog * dialog)
67 bool hasGuiApp = (qobject_cast<QApplication*>(QCoreApplication::instance())!=0);
69 if ( ! hasGuiApp )
71 /* Necessity for creating the correct app context */
72 int argc = 1;
73 char * argv = (char *) "Test";
75 /* In Gtk there is no application context, must be created and displayed */
76 QApplication app(argc, &argv);
78 dialog->show();
80 app.exec();
82 else
84 /* With Wireshark Qt, an application context already exists, therefore just
85 * displaying the dialog using show to have it non-modal */
86 dialog->show();
90 void GuiHandler::doReset()
92 emit reset();
95 void GuiHandler::addLogMessage(QString message)
97 emit logChanged(message);
100 void GuiHandler::setToolbar(ext_toolbar_t * toolbar)
102 _toolbar = toolbar;
106 * Editor modelines
108 * Local Variables:
109 * c-basic-offset: 4
110 * tab-width: 8
111 * indent-tabs-mode: nil
112 * End:
114 * ex: set shiftwidth=4 tabstop=8 expandtab:
115 * :indentSize=4:tabSize=8:noTabs=true: