void TrayControlWindow::create_tray_actions() { m_act_launch = new QAction(QIcon(":/hub/Launch-07.png") ,tr("Launch"), this); m_act_settings = new QAction(QIcon(":/hub/Settings-07.png"), tr("Settings"), this); connect(m_act_settings, SIGNAL(triggered()), this, SLOT(show_settings_dialog())); m_act_vbox = new QAction(QIcon(":/hub/VM-07.png"), tr("Virtual machines"), this); connect(m_act_vbox, SIGNAL(triggered()), this, SLOT(show_vbox())); m_act_hub = new QAction(QIcon(":/hub/Environmetns-07.png"), tr("Environments"), this); m_act_quit = new QAction(QIcon(":/hub/Exit-07"), tr("Quit"), this); connect(m_act_quit, SIGNAL(triggered()), this, SLOT(application_quit())); m_act_info = new QAction(QIcon(":/hub/Balance-07.png"), CHubController::Instance().balance(), this); m_act_about = new QAction(QIcon(":/hub/about.png"), tr("About"), this); connect(m_act_about, SIGNAL(triggered()), this, SLOT(show_about())); m_act_generate_ssh = new QAction("Generate SSH key", this); connect(m_act_generate_ssh, SIGNAL(triggered()), this, SLOT(ssh_key_generate_triggered())); }
static LRESULT CALLBACK WindowProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { static SERVICE_TABLE_ENTRY service_table[] = { {server_name, (LPSERVICE_MAIN_FUNCTION) ServiceMain}, {NULL, NULL} }; int service_installed; char buf[200], *service_argv[] = {__argv[0], NULL}; POINT pt; HMENU hMenu; static UINT s_uTaskbarRestart; // for taskbar creation switch (msg) { case WM_CREATE: if (__argv[1] != NULL && !strcmp(__argv[1], service_magic_argument)) { start_mongoose(1, service_argv); StartServiceCtrlDispatcher(service_table); exit(EXIT_SUCCESS); } else { start_mongoose(__argc, __argv); s_uTaskbarRestart = RegisterWindowMessage(TEXT("TaskbarCreated")); } break; case WM_COMMAND: switch (LOWORD(wParam)) { case ID_QUIT: mg_stop(ctx); Shell_NotifyIcon(NIM_DELETE, &TrayIcon); PostQuitMessage(0); return 0; case ID_SETTINGS: show_settings_dialog(); break; case ID_INSTALL_SERVICE: case ID_REMOVE_SERVICE: manage_service(LOWORD(wParam)); break; case ID_CONNECT: printf("[%s]\n", get_url_to_first_open_port(ctx)); ShellExecute(NULL, "open", get_url_to_first_open_port(ctx), NULL, NULL, SW_SHOW); break; } break; case WM_USER: switch (lParam) { case WM_RBUTTONUP: case WM_LBUTTONUP: case WM_LBUTTONDBLCLK: hMenu = CreatePopupMenu(); AppendMenu(hMenu, MF_STRING | MF_GRAYED, ID_SEPARATOR, server_name); AppendMenu(hMenu, MF_SEPARATOR, ID_SEPARATOR, ""); service_installed = manage_service(0); snprintf(buf, sizeof(buf), "NT service: %s installed", service_installed ? "" : "not"); AppendMenu(hMenu, MF_STRING | MF_GRAYED, ID_SEPARATOR, buf); AppendMenu(hMenu, MF_STRING | (service_installed ? MF_GRAYED : 0), ID_INSTALL_SERVICE, "Install service"); AppendMenu(hMenu, MF_STRING | (!service_installed ? MF_GRAYED : 0), ID_REMOVE_SERVICE, "Deinstall service"); AppendMenu(hMenu, MF_SEPARATOR, ID_SEPARATOR, ""); AppendMenu(hMenu, MF_STRING, ID_CONNECT, "Start browser"); AppendMenu(hMenu, MF_STRING, ID_SETTINGS, "Edit Settings"); AppendMenu(hMenu, MF_SEPARATOR, ID_SEPARATOR, ""); AppendMenu(hMenu, MF_STRING, ID_QUIT, "Exit"); GetCursorPos(&pt); SetForegroundWindow(hWnd); TrackPopupMenu(hMenu, 0, pt.x, pt.y, 0, hWnd, NULL); PostMessage(hWnd, WM_NULL, 0, 0); DestroyMenu(hMenu); break; } break; case WM_CLOSE: mg_stop(ctx); Shell_NotifyIcon(NIM_DELETE, &TrayIcon); PostQuitMessage(0); return 0; // We've just sent our own quit message, with proper hwnd. default: if (msg==s_uTaskbarRestart) Shell_NotifyIcon(NIM_ADD, &TrayIcon); } return DefWindowProc(hWnd, msg, wParam, lParam); }