示例#1
0
void zoomWindow::contextMenu(QPoint)
{
	QMenu *menu = new QMenu(this);
	if (!this->link.isEmpty())
	{
		// Favoris
		if (m_favorites.contains(link, Qt::CaseInsensitive))
		{
			menu->addAction(QIcon(":/images/icons/remove.png"), tr("Retirer des favoris"), this, SLOT(unfavorite()));
			menu->addAction(QIcon(":/images/icons/save.png"), tr("Choisir comme image"), this, SLOT(setfavorite()));
		}
		else
		{ menu->addAction(QIcon(":/images/icons/add.png"), tr("Ajouter aux favoris"), this, SLOT(favorite())); }
		// Garder pour plus tard
		if (m_viewItLater.contains(link, Qt::CaseInsensitive))
		{ menu->addAction(QIcon(":/images/icons/remove.png"), tr("Ne pas garder pour plus tard"), this, SLOT(unviewitlater())); }
		else
		{ menu->addAction(QIcon(":/images/icons/add.png"), tr("Garder pour plus tard"), this, SLOT(viewitlater())); }
		// Ignorer
		if (m_ignore.contains(link, Qt::CaseInsensitive))
		{ menu->addAction(QIcon(":/images/icons/showed.png"), tr("Ne plus ignorer"), this, SLOT(unignore())); }
		else
		{ menu->addAction(QIcon(":/images/icons/hidden.png"), tr("Ignorer"), this, SLOT(ignore())); }
		menu->addSeparator();
		// Onglets
		menu->addAction(QIcon(":/images/icons/tab-plus.png"), tr("Ouvrir dans un nouvel onglet"), this, SLOT(openInNewTab()));
		menu->addAction(QIcon(":/images/icons/window.png"), tr("Ouvrir dans une nouvelle fenêtre"), this, SLOT(openInNewWindow()));
		menu->addAction(QIcon(":/images/icons/browser.png"), tr("Ouvrir dans le navigateur"), this, SLOT(openInBrowser()));
	}
	menu->exec(QCursor::pos());
}
示例#2
0
/**
 * Callback function for the main window
 */
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) {
	int wmId, wmEvent;
	HDC hDc;
	COLORREF myColor = RGB(150,150,200);
	switch (message) {
	case WM_COMMAND:
		wmId    = LOWORD(wParam); 
		wmEvent = HIWORD(wParam); 
		switch (wmId) {

		//protocol combobox
		case ID_CBPROTOCOLS:

			//on combobox selection change
			if(wmEvent == CBN_SELCHANGE) {
				LRESULT selection = SendMessage(GetDlgItem(hWnd, ID_CBFUNCTIONS), CB_GETCURSEL, 0, 0);
				LRESULT dutProtocol = SendMessage(GetDlgItem(hWnd, ID_CBPROTOCOLS), CB_GETCURSEL, 0, 0);
				if(selection < 0)
					break;
				//set protocol for the function
				if(dutProtocol == -1)
					vapix->getFunction(selection)->setProtocol(vapix->getFunction(selection)->setProtocol(dutProtocol));
				else
					vapix->getFunction(selection)->setProtocol(dutProtocol);
				//emulate ID_EDIT_PORT EN_CHANGE message to update ID_EDIT_TOSEND text
				SendMessage(hWnd, WM_COMMAND, MAKEWPARAM(ID_EDIT_PORT, EN_CHANGE), 0); 
			}
			break;

		//function combobox
		case ID_CBFUNCTIONS:

			//on combobox selection change
			if(wmEvent == CBN_SELCHANGE) {
				//clear the response edit box
				SetWindowText(GetDlgItem(hWnd, ID_EDIT_INFO), NULL);
				//reset dependent comboboxes
				SendMessage(GetDlgItem(hWnd, ID_CBPROTOCOLS), CB_RESETCONTENT, 0, 0);
				SendMessage(GetDlgItem(hWnd, ID_CBATTRIBUTE), CB_RESETCONTENT, 0, 0);
				SendMessage(GetDlgItem(hWnd, ID_CBVALUE), CB_RESETCONTENT, 0, 0);
				SendMessage(GetDlgItem(hWnd, ID_LBATTRIBUTES), LB_RESETCONTENT, 0, 0);
				//get selection index
				LRESULT selection = SendMessage(GetDlgItem(hWnd, ID_CBFUNCTIONS), CB_GETCURSEL, 0, 0);
				//set hostname/ip in the vapix object
				char* dutAddress = (char*)malloc(sizeof(char)*200);
				memset(dutAddress, '\0', 200);
				GetWindowText(GetDlgItem(hWnd, ID_EDIT_ADDRESS), dutAddress, 200);
				vapix->setHostname(dutAddress);
				//set port
				char* dutPort = (char*)malloc(sizeof(char)*6);
				memset(dutPort, '\0', 6);
				GetWindowText(GetDlgItem(hWnd, ID_EDIT_PORT), dutPort, 6);
				if(atoi(dutPort) > 0)
					vapix->setPort(selection, atoi(dutPort));
				else
					vapix->setPort(selection, atoi(vapix->getFunction(selection)->getProtocol()[1]));
				//remove attribute objects
				for(int i=0; i<VAPIX_FUNCTIONS_COUNT; i++) {
					vapix->getFunction(i)->removeAllAttributes();
				}
				//then get the function string and set it in the edit box
				SetWindowText(GetDlgItem(hWnd, ID_EDIT_TOSEND), vapix->getBrowserFunctionString(selection));
				//fill the protocols combobox
				int vpSize = 0;
				char*** validProtocols = vapix->getFunction(selection)->getValidProtocols(&vpSize);
				for(int i = 0; i<vpSize; i++) {
					SendMessage(GetDlgItem(hWnd, ID_CBPROTOCOLS), CB_ADDSTRING, 0, (LPARAM) validProtocols[i][0]);
				}
				//fill the attributes combobox with the vapix attributes for the selected function
				int vaSize = 0;
				VapixAttribute** vapixAttributes = vapix->getFunction(selection)->getValidAttributes(&vaSize);
				for(int i = 0; i<vaSize; i++) {
					SendMessage(GetDlgItem(hWnd, ID_CBATTRIBUTE), CB_ADDSTRING, 0, (LPARAM) vapixAttributes[i]->getName());
				}
				free(dutAddress);
				free(dutPort);
			}
			break;

		//attribute combobox
		case ID_CBATTRIBUTE:

			//on combobox selection change
			if(wmEvent == CBN_SELCHANGE) {
				//reset dependent comboboxes
				SendMessage(GetDlgItem(hWnd, ID_CBVALUE), CB_RESETCONTENT, 0, 0);
				//get selection index
				LRESULT selection = SendMessage(GetDlgItem(hWnd, ID_CBFUNCTIONS), CB_GETCURSEL, 0, 0);
				LRESULT selection2 = SendMessage(GetDlgItem(hWnd, ID_CBATTRIBUTE), CB_GETCURSEL, 0, 0);
				//fill the values combobox with the vapix values for the selected attribute in the selected function
				int vvSize = 0;
				char** vapixAttributeValues = vapix->getFunction(selection)->getValidAttribute(selection2)->getValidValues(&vvSize);
				for(int i = 0; i<vvSize; i++) {
					SendMessage(GetDlgItem(hWnd, ID_CBVALUE), CB_ADDSTRING, 0, (LPARAM) vapixAttributeValues[i]);
				}
				//update the "send" string
				SetWindowText(GetDlgItem(hWnd, ID_EDIT_TOSEND), vapix->getBrowserFunctionString(selection));
			}
			break;

		//add attribute button
		case ID_ATTRIBADD:
			addAttribute();
			break;
		//remove attribute button
		case ID_ATTRIBREMOVE:
			removeAttribute();
			break;
		case ID_EDIT_ADDRESS:
			if(wmEvent == EN_CHANGE) {
				char* dutAddress = (char*)malloc(sizeof(char)*200);
				memset(dutAddress, '\0', 200);
				GetWindowText(GetDlgItem(hWnd, ID_EDIT_ADDRESS), dutAddress, 200);
				vapix->setHostname(dutAddress);
				LRESULT selection = SendMessage(GetDlgItem(hWnd, ID_CBFUNCTIONS), CB_GETCURSEL, 0, 0);
				if(selection >= 0) {
					SetWindowText(GetDlgItem(hWnd, ID_EDIT_TOSEND), vapix->getBrowserFunctionString(selection));
				}
				free(dutAddress);
			}
			break;
		case ID_EDIT_PORT:
			if(wmEvent == EN_CHANGE) {
				LRESULT selection = SendMessage(GetDlgItem(hWnd, ID_CBFUNCTIONS), CB_GETCURSEL, 0, 0);
				if(selection < 0)
					break;
				char* dutPort = (char*)malloc(sizeof(char)*6);
				memset(dutPort, '\0', 6);
				GetWindowText(GetDlgItem(hWnd, ID_EDIT_PORT), dutPort, 6);
				//empty field means use protocol default port
				if(dutPort[0] == '\0')
					vapix->setPort(selection, atoi(vapix->getFunction(selection)->getProtocol()[1]));
				else
					vapix->setPort(selection, atoi(dutPort));
				SetWindowText(GetDlgItem(hWnd, ID_EDIT_TOSEND), vapix->getBrowserFunctionString(selection));
				free(dutPort);
			}
			break;
		case ID_SHOW_BUTTON:
			{
				//get selection index
				LRESULT selection = SendMessage(GetDlgItem(hWnd, ID_CBFUNCTIONS), CB_GETCURSEL, 0, 0);
				if(selection < 0) {
					MessageBox(hWnd, "A function must be selected before making a request!", "Info", MB_ICONEXCLAMATION);
					break;
				}

				//check if the function is returning text or binary
				int opener = vapix->getFunction(selection)->getOpener();
				switch(opener) {
				case 0:
					//open locally
					connectFunction(hWnd);
					break;
				case 1:
					//open in browser
					{
						char* temp = (char*)malloc(sizeof(char)*100);
						//get URI
						GetWindowText(GetDlgItem(hWnd, ID_EDIT_TOSEND), temp, 100);
						//open URI in the default browser
						openInBrowser(temp);
						free(temp);
					}
					break;
				case 2:
					//open in external video player (VLC)
					{
						//TODO: make it add user:password@ to URI
						char* temp = (char*)malloc(sizeof(char)*100);
						//get URI
						GetWindowText(GetDlgItem(hWnd, ID_EDIT_TOSEND), temp, 100);
						//open URI in VLC
						openInVLC(temp);
						free(temp);
					}
					break;
				default:
					{
						LRESULT selectedFunction = SendMessage(GetDlgItem(hWnd, ID_CBFUNCTIONS), CB_GETCURSEL, 0, 0);
						char* tmpStr = (char*)malloc(sizeof(char)*200);
						memset(tmpStr, '\0', 200);
						sprintf(tmpStr, "The selected function has an opener value (int VapixObject::VapixFunction::opener = %d)\nthat is not recognised by this version of Waapix(v%s).", vapix->getFunction(selectedFunction)->getOpener(), WAAPIX_VERSION);
						MessageBox(hWnd, tmpStr, "Error activating function", MB_ICONEXCLAMATION);
						free(tmpStr);
					}
				}
			}
			break;
		case ID_EXIT_BUTTON:
			DestroyWindow(hWnd);
			break;
		case IDM_ABOUT:
			showAboutBox(hWnd);
			break;
		case IDM_EXIT:
			DestroyWindow(hWnd);
			break;
		default:
			return DefWindowProc(hWnd, message, wmId, wmEvent);
		}
		break;
	case WM_DESTROY:
		WSACleanup();
		PostQuitMessage(0);
		break;
	case WM_CTLCOLORSTATIC:
		hDc = (HDC)(wParam); 
		SetBkMode(hDc, TRANSPARENT);
		return (INT_PTR)GetStockObject(NULL_BRUSH);
		break;
	case WM_SIZING:
		{
			RECT clientRect, *currentRect = (RECT*)lParam;
			BOOL processed = FALSE;
			GetClientRect(hWnd, &clientRect);
			if (currentRect->right - currentRect->left < MIN_WIDTH) {
				currentRect->right = currentRect->left + MIN_WIDTH;
				processed = TRUE;
			}
			if (currentRect->bottom - currentRect->top < MIN_HEIGHT) {
				currentRect->bottom = currentRect->top + MIN_HEIGHT;
				processed = TRUE;
			}
			if (processed) return TRUE;
		}
		break;
	case WM_SIZE:
		{
			RECT clientRect;
			GetClientRect(hWnd, &clientRect);
			SetWindowPos(GetDlgItem(hWnd, ID_EDIT_INFO), HWND_NOTOPMOST, 15, 272, clientRect.right-30, clientRect.bottom-272-15, SWP_NOZORDER);
		}
		break;
	default:
		return DefWindowProc(hWnd, message, wParam, lParam);
	}
	return 0;
}
示例#3
0
int FormFunc::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QWidget::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0:
            infoLUpdated((*reinterpret_cast< QString(*)>(_a[1])));
            break;
        case 1:
            searchB();
            break;
        case 2:
            nextB();
            break;
        case 3:
            prevB();
            break;
        case 4:
            clrB();
            break;
        case 5:
            playB();
            break;
        case 6:
            downloadB();
            break;
        case 7:
            setPage();
            break;
        case 8:
            abortB();
            break;
        case 9:
            timeOut();
            break;
        case 10:
            mnuTPopup();
            break;
        case 11:
            mnuQPopup();
            break;
        case 12:
            copyAddr();
            break;
        case 13:
            delQueueEntry();
            break;
        case 14:
            dwnPB();
            break;
        case 15:
            copyAddr2();
            break;
        case 16:
            chPage((*reinterpret_cast< bool(*)>(_a[1])));
            break;
        case 17:
            queueB();
            break;
        case 18:
            searchAddressAfterThr();
            break;
        case 19:
            openInBrowser();
            break;
        case 20:
            updateInfoL((*reinterpret_cast< QString(*)>(_a[1])));
            break;
        case 21:
            infoL((*reinterpret_cast< QString(*)>(_a[1])));
            break;
        default:
            ;
        }
        _id -= 22;
    }
    return _id;
}