当前位置: 首页>>代码示例>>C++>>正文


C++ connect函数代码示例

本文整理汇总了C++中connect函数的典型用法代码示例。如果您正苦于以下问题:C++ connect函数的具体用法?C++ connect怎么用?C++ connect使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了connect函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: CWE134_Uncontrolled_Format_String__wchar_t_connect_socket_vfprintf_32_bad

void CWE134_Uncontrolled_Format_String__wchar_t_connect_socket_vfprintf_32_bad()
{
    wchar_t * data;
    wchar_t * *dataPtr1 = &data;
    wchar_t * *dataPtr2 = &data;
    wchar_t dataBuffer[100] = L"";
    data = dataBuffer;
    {
        wchar_t * data = *dataPtr1;
        {
#ifdef _WIN32
            WSADATA wsaData;
            int wsaDataInit = 0;
#endif
            int recvResult;
            struct sockaddr_in service;
            wchar_t *replace;
            SOCKET connectSocket = INVALID_SOCKET;
            size_t dataLen = wcslen(data);
            do
            {
#ifdef _WIN32
                if (WSAStartup(MAKEWORD(2,2), &wsaData) != NO_ERROR)
                {
                    break;
                }
                wsaDataInit = 1;
#endif
                /* POTENTIAL FLAW: Read data using a connect socket */
                connectSocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
                if (connectSocket == INVALID_SOCKET)
                {
                    break;
                }
                memset(&service, 0, sizeof(service));
                service.sin_family = AF_INET;
                service.sin_addr.s_addr = inet_addr(IP_ADDRESS);
                service.sin_port = htons(TCP_PORT);
                if (connect(connectSocket, (struct sockaddr*)&service, sizeof(service)) == SOCKET_ERROR)
                {
                    break;
                }
                /* Abort on error or the connection was closed, make sure to recv one
                 * less char than is in the recv_buf in order to append a terminator */
                /* Abort on error or the connection was closed */
                recvResult = recv(connectSocket, (char *)(data + dataLen), sizeof(wchar_t) * (100 - dataLen - 1), 0);
                if (recvResult == SOCKET_ERROR || recvResult == 0)
                {
                    break;
                }
                /* Append null terminator */
                data[dataLen + recvResult / sizeof(wchar_t)] = L'\0';
                /* Eliminate CRLF */
                replace = wcschr(data, L'\r');
                if (replace)
                {
                    *replace = L'\0';
                }
                replace = wcschr(data, L'\n');
                if (replace)
                {
                    *replace = L'\0';
                }
            }
            while (0);
            if (connectSocket != INVALID_SOCKET)
            {
                CLOSE_SOCKET(connectSocket);
            }
#ifdef _WIN32
            if (wsaDataInit)
            {
                WSACleanup();
            }
#endif
        }
        *dataPtr1 = data;
    }
    {
        wchar_t * data = *dataPtr2;
        badVaSink(data, data);
    }
}
开发者ID:maurer,项目名称:tiamat,代码行数:83,代码来源:CWE134_Uncontrolled_Format_String__wchar_t_connect_socket_vfprintf_32.c

示例2: QMainWindow


//.........这里部分代码省略.........
    style2 = action_group_style->addAction(tr("Dot Line Pen"));
    style3 = action_group_style->addAction(tr("Dash dot Line Pen"));
    style4 = action_group_style->addAction(tr("Dash Dot Dot Line Pen"));
    style5 = action_group_style->addAction(tr("Custom Dash Line Pen"));

    QActionGroup *action_group_form = new QActionGroup(this);
    form0 = action_group_form->addAction(tr("Line Form"));
    form1 = action_group_form->addAction(tr("Rectangle Form"));
    form2 = action_group_form->addAction(tr("Elipse Form"));

    // Adition of shortcuts for principal actions
    openAction->setShortcut( tr("Ctrl+O"));
    saveAction->setShortcut( tr("Ctrl+S"));
    quitAction->setShortcut( tr("Ctrl+Q"));
    paintAction->setShortcut( tr("Ctrl+P"));
    editAction->setShortcut( tr("Ctrl+E"));
    moveAction->setShortcut( tr("Ctrl+M"));

    // Adition of shortcuts for those other actions
    set_pen_color->setShortcut( tr("Ctrl+C"));
    set_pen_style->setShortcut( tr("Ctrl+Space"));
    set_pen_width_larger->setShortcut( tr("Ctrl++"));
    set_pen_width_shorter->setShortcut( tr("Ctrl+-"));
    set_figure_form->setShortcut( tr("Ctrl+F"));
    undo->setShortcut(tr ("Ctrl+Z"));

    // Adition of tool tips for principal actions
    openAction->setToolTip( tr("Open file"));
    saveAction->setToolTip( tr("Save file"));
    quitAction->setToolTip( tr("Quit file"));

    // Adition of status tips for principal actions
    openAction->setStatusTip( tr("Open file"));
    saveAction->setStatusTip( tr("Save file"));
    quitAction->setStatusTip( tr("Quit file"));

    // Adition of actions to menus
    openMenu->addAction(openAction);
    saveMenu->addAction(saveAction);
    quitMenu->addAction(quitAction);

    penMenu->addAction(set_pen_width_larger);
    penMenu->addAction(set_pen_width_shorter);
    penMenu->addAction(undo);

    colorMenu->addAction(set_pen_color);
    colorMenu->addActions(action_group_color->actions());

    styleMenu->addAction(set_pen_style);
    styleMenu->addActions(action_group_style->actions());

    formMenu->addAction(set_figure_form);
    formMenu->addActions(action_group_form->actions());

    // Adition of principal actions to toolbar
    toolbar->addAction(openAction);
    toolbar->addAction(saveAction);
    toolbar->addAction(quitAction);
    toolbar->addAction(paintAction);
    toolbar->addAction(editAction);
    toolbar->addAction(moveAction);

    // Set some parameters to the sliders
    slider_color->setTickPosition(QSlider::TicksBothSides);
    slider_color->setMinimum(0);
    slider_color->setMaximum(17);
    slider_color->setSingleStep(1);

    slider_style->setTickPosition(QSlider::TicksBothSides);
    slider_style->setMinimum(0);
    slider_style->setMaximum(5);
    slider_style->setSingleStep(1);

    // Link actions and signals to slots
    connect(openAction, SIGNAL(triggered( )), this, SLOT(openFile()));
    connect(saveAction, SIGNAL(triggered( )), this, SLOT(saveFile()));
    connect(quitAction, SIGNAL(triggered( )), this, SLOT(quitApp()));

    connect(paintAction, SIGNAL(triggered( )), mydrawzone, SLOT(set_draw_mode_paint()));
    connect(editAction, SIGNAL(triggered( )), mydrawzone, SLOT(set_draw_mode_edit()));
    connect(moveAction, SIGNAL(triggered( )), mydrawzone, SLOT(set_draw_mode_move()));
    connect(set_pen_width_larger, SIGNAL(triggered( )), mydrawzone, SLOT(set_pen_width_larger()));
    connect(set_pen_width_shorter, SIGNAL(triggered( )), mydrawzone, SLOT(set_pen_width_shorter()));
    connect(undo, SIGNAL(triggered( )), mydrawzone, SLOT(undo()));

    connect(set_pen_color, SIGNAL(triggered( )), mydrawzone, SLOT(set_pen_color()));
    connect(action_group_color, SIGNAL(triggered(QAction *)), this, SLOT(doIt(QAction *)));
    connect(this, SIGNAL(color_pen_changed(int)), mydrawzone, SLOT(set_pen_color(int)));

    connect(set_pen_style, SIGNAL(triggered( )), mydrawzone, SLOT(set_pen_style()));
    connect(action_group_style, SIGNAL(triggered(QAction *)), this, SLOT(doIt2(QAction *)));
    connect(this, SIGNAL(style_pen_changed(int)), mydrawzone, SLOT(set_pen_style(int)));

    connect(set_figure_form, SIGNAL(triggered( )), mydrawzone, SLOT(set_figure_form()));
    connect(action_group_form, SIGNAL(triggered(QAction *)), this, SLOT(doIt3(QAction *)));
    connect(this, SIGNAL(form_painter_changed(int)), mydrawzone, SLOT(set_figure_form(int)));

    connect(slider_color, SIGNAL(valueChanged(int)), this, SLOT(slide_color_pen_changed(int)));
    connect(slider_style, SIGNAL(valueChanged(int)), this, SLOT(slide_style_pen_changed(int)));
}
开发者ID:artursarlo,项目名称:igr201_tp2,代码行数:101,代码来源:mainwindow.cpp

示例3: response


//.........这里部分代码省略.........
    // Closing data connection
    _setResponse(cmd);
  }
  else if (cmd == 250) {
    // Requested file action okay, completed
    _setResponse(cmd);
  }
  else if (cmd == 257) {
    // Pathname
    _setResponse(cmd);
    if (ftpresponse != NULL) {
      uint16_t i;
      for (i = 0; i<strlen(ftpresponse); i++) {
        if (*(recvBuf+i) == '"') break;
      }
      if (i<strlen(ftpresponse)) {
        memmove(ftpresponse, ftpresponse+i+1, strlen(ftpresponse)-i);
        for (i=strlen(ftpresponse)-1; i>0; i--) {
          if (*(ftpresponse+i) == '"') *(ftpresponse+i) = '\0';
        }
      }
    }
  }
  else if ((cmd == 150) || (cmd == 125)) {
    // mark: Accepted data connection
    if ((ftpfile != NULL) && ftpDataSocket != NULL) {
      status |= FTP_SENDING;
      if ((send_type & SEND_STRING)) {
        ftp_log("[FTP dta] Sending string to %s (%d)\r\n", ftpfile, file_size);
      }
      else {
        ftp_log("[FTP dta] Sending file %s (%d)\r\n", ftpfile, file_size);
      }
    }
    else _setResponse(cmd);
  }
  else if (cmd == 227) {
    // entering passive mod
    char *tStr = strtok(recvBuf, "(,");
    uint8_t array_pasv[6];
    for ( int i = 0; i < 6; i++) {
      tStr = strtok(NULL, "(,");
      if (tStr != NULL) {
        array_pasv[i] = atoi(tStr);
      }
      else {
        array_pasv[i] = 0;
      }
    }
    uint32_t dataPort, dataServ;
    dataPort = (uint32_t)((array_pasv[4] << 8) + (array_pasv[5] & 255));
    dataServ = (uint32_t)((array_pasv[0] << 24) + (array_pasv[1] << 16) + (array_pasv[2] << 8) + (array_pasv[3] & 255));

    if ((dataServ != 0) && (dataPort != 0)) {
      // connect data socket
      if (_openDataSocket() >= 0) {
        ftpDataSocket->addr.s_ip = dataServ;
        ftpDataSocket->addr.s_port = dataPort;

        char ip[17]; memset(ip, 0x00, 17);
        inet_ntoa(ip, ftpDataSocket->addr.s_ip);
        ftp_log("[FTP dta] Opening data connection to: %s:%d\r\n", ip, ftpDataSocket->addr.s_port);

        struct sockaddr_t *paddr = &(ftpDataSocket->addr);
        int slen = sizeof(ftpDataSocket->addr);
      
        //_micoNotify will be called if connected
        int stat = connect(ftpDataSocket->socket, paddr, slen);
        if (stat < 0) {
          ftp_log("[FTP dta] Data connection error: %d\r\n", stat);
          ftpCmdSocket->clientFlag = NO_ACTION;
          ftpCmdSocket->clientLastFlag = NO_ACTION;
          data_done = 1;
          file_status = -9;
          closeDataSocket();
        }
        else {
          // Data socket connected, initialize action
          if (ftpCmdSocket->clientLastFlag == REQ_ACTION_LIST) {
            ftpCmdSocket->clientLastFlag = NO_ACTION;
            ftpCmdSocket->clientFlag = REQ_ACTION_DOLIST;
          }
          else if (ftpCmdSocket->clientLastFlag == REQ_ACTION_RECV) {
            ftpCmdSocket->clientLastFlag = NO_ACTION;
            ftpCmdSocket->clientFlag = REQ_ACTION_DORECV;
          }
          else if (ftpCmdSocket->clientLastFlag == REQ_ACTION_SEND) {
            ftpCmdSocket->clientLastFlag = NO_ACTION;
            ftpCmdSocket->clientFlag = REQ_ACTION_DOSEND;
          }
        }
      }
    }
    else {
      ftp_log("[FTP dta] Wrong pasv address:port received!\r\n");
      ftpCmdSocket->clientFlag = REQ_ACTION_DISCONNECT;
    }
  }
  else _setResponse(cmd);
}
开发者ID:maplefish,项目名称:MICO,代码行数:101,代码来源:ftp.c

示例4: tcp_connect

long tcp_connect(bmdnet_handler_ptr handler,char*host,long port)
{
	long status;
#ifndef _WIN32
	char aux[256];
	struct sockaddr_in serv_addr;
	struct hostent hostinfo_buf;
	struct hostent *hostinfo=&hostinfo_buf;
	long one = 1;
	int si_temp; /* to musi byc int - nie zmieniac !!!! */
#else
	struct addrinfo *result = NULL, hints;
	char * portstr=NULL;
#endif
	if (host == NULL || port == 0 || port > 65535)
	{
		return(-1);
	}

	handler->s = (long)socket(AF_INET, SOCK_STREAM,IPPROTO_TCP);
	if (handler->s <= 0)
		return -1;

#ifndef WIN32
	if (setsockopt(handler->s, SOL_SOCKET, SO_REUSEADDR, &one, sizeof(one)))
	{
		return ERR(ERR_net, "Cannot set SO_REUSEADDR flag on socket", "LK");
	}
	memset(&serv_addr, 0, sizeof(serv_addr));
	serv_addr.sin_family = AF_INET;
	serv_addr.sin_port = htons((short)port);

	if( gethostbyname_r(host, &hostinfo_buf, aux, sizeof(aux), &hostinfo, &si_temp) != 0 )
	{
		PRINT_ERROR("gethostbyname_r failed.\n");
		return(-1);
	}
	if (hostinfo==NULL) {
		PRINT_ERROR("Hostname not found.\n");
		return(-1);
	}
	serv_addr.sin_addr=*(struct in_addr *)hostinfo->h_addr;
	status = connect(handler->s, (const struct sockaddr *)&serv_addr,sizeof(serv_addr));
	if (status)
	{
		PRINT_ERROR("Cannot connect to host.\n");
		return(-1);
	}
#else
	ZeroMemory( &hints, sizeof(hints) );
	hints.ai_family = AF_UNSPEC;
	hints.ai_socktype = SOCK_STREAM;
	hints.ai_protocol = IPPROTO_TCP;
	portstr = calloc(6,sizeof(char));
	_itoa_s(port, portstr, 6,10);
	status = getaddrinfo(host, portstr, &hints, &result);
	if( status == WSAHOST_NOT_FOUND )
	{
		BMD_FOK(BMD_ERR_NET_RESOLV);
	}
	else
		if( status != 0 )
		{
			BMD_FOK(BMD_ERR_OP_FAILED);
		}
	if (result == NULL)
	{
		BMD_FOK(BMD_ERR_OP_FAILED);
	}
	status = connect(handler->s, result->ai_addr,(long)result->ai_addrlen);
	if (status)
	{
		PRINT_ERROR("Cannot connect to host.\n");
		return(-1);
	}
#endif

	return BMD_OK;
};
开发者ID:unizeto,项目名称:bmd,代码行数:79,代码来源:libbmdnet_connect.c

示例5: connect

void MainWindow::setupConnections()
{
    // Importing
    connect(importButton, SIGNAL(clicked()), this, SLOT(launchImageImport()));
    connect(filedata, SIGNAL(imagesImported()), aListWidget, SLOT(populate()));
    connect(filedata, SIGNAL(imagesImported()), bListWidget, SLOT(populate()));
    connect(filedata, SIGNAL(imagesImported()), vectorListWidget, SLOT(populate()));
    connect(filedata, SIGNAL(imagesImported()), this, SLOT(notifyFolderChange()));
    connect(filedata, SIGNAL(vectorListUpdated()), vectorListWidget, SLOT(update()));

    // Image selection
    connect(aListWidget, SIGNAL(fileClicked(int)), this, SLOT(pivAclicked(int)));
    connect(bListWidget, SIGNAL(fileClicked(int)), this, SLOT(pivBclicked(int)));
    connect(vectorListWidget, SIGNAL(fileClicked(int)), this, SLOT(vectorClicked(int)));
    connect(forwardButton, SIGNAL(clicked()), this, SLOT(forwardOne()));
    connect(backButton, SIGNAL(clicked()), this, SLOT(backwardOne()));

    // Image/vector viewing
    connect(zoomInButton, SIGNAL(clicked()), pivDisplay, SLOT(zoomIn()));
    connect(zoomOutButton, SIGNAL(clicked()), pivDisplay, SLOT(zoomOut()));
    connect(zoomFitButton, SIGNAL(clicked()), pivDisplay, SLOT(zoomFit()));
    // The following should be moved into settings
    connect(vectorToggle, SIGNAL(toggled(bool)), pivDisplay, SLOT(vectorsToggled(bool)));
    //
    connect(colourButtonFiltered, SIGNAL(clicked()), this, SLOT(chooseFilteredColour()));
    connect(colourButtonUnfiltered, SIGNAL(clicked()), this, SLOT(chooseUnfilteredColour()));
    connect(scaleSpin, SIGNAL(valueChanged(double)), settings, SLOT(setVectorScale(double)));
    connect(subSpin, SIGNAL(valueChanged(double)), settings, SLOT(setVectorSub(double)));
    connect(settings, SIGNAL(vectorSettingChanged()), pivDisplay, SLOT(vectorsChanged()));

    // Masking
    connect(maskButton, SIGNAL(clicked()), maskButton, SLOT(showMenu()));
    connect(filedata,SIGNAL(imagesImported()), maskDropDown, SLOT(imageLoaded()));
    connect(maskDropDown, SIGNAL(importMaskClicked()), filedata, SLOT(importMask()));
    connect(filedata, SIGNAL(maskLoaded()), maskDropDown, SLOT(maskLoaded()));
    connect(maskDropDown, SIGNAL(gridToggled(bool)), pivDisplay, SLOT(maskToggled(bool)));
    connect(maskDropDown, SIGNAL(clearMask(bool)), settings, SLOT(setIsMask(bool)));

    // Process tab
    connect(hSizeCombo, SIGNAL(activated(int)), settings, SLOT(setIntLengthX(int)));
    connect(vSizeCombo, SIGNAL(activated(int)), settings, SLOT(setIntLengthY(int)));
    connect(hSpaceSpin, SIGNAL(valueChanged(int)), settings, SLOT(setDeltaX(int)));
    connect(vSpaceSpin, SIGNAL(valueChanged(int)), settings, SLOT(setDeltaY(int)));

    // Filter tab
    connect(globalRangeCheck, SIGNAL(toggled(bool)), this, SLOT(filterChanged()));
    connect(minUedit, SIGNAL(textChanged(QString)), this, SLOT(setFilterValues()));
    connect(maxUedit, SIGNAL(textChanged(QString)), this, SLOT(setFilterValues()));
    connect(minVedit, SIGNAL(textChanged(QString)), this, SLOT(setFilterValues()));
    connect(maxVedit, SIGNAL(textChanged(QString)), this, SLOT(setFilterValues()));
    connect(globalStDevCheck, SIGNAL(toggled(bool)), this, SLOT(filterChanged()));
    connect(nStdDevSpin, SIGNAL(valueChanged(double)), this, SLOT(setFilterValues()));

    connect(localCheck, SIGNAL(toggled(bool)), this, SLOT(filterChanged()));
    connect(localMethodCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(setFilterValues()));
    connect(localNxNCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(setFilterValues()));
    connect(localUedit, SIGNAL(textChanged(QString)), this, SLOT(setFilterValues()));
    connect(localVedit, SIGNAL(textChanged(QString)), this, SLOT(setFilterValues()));

    connect(interpolateCheck, SIGNAL(toggled(bool)), this, SLOT(filterChanged()));
    connect(interpolateMethodCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(setFilterValues()));
    connect(interpolateNxNCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(setFilterValues()));

    connect(smoothCheck, SIGNAL(toggled(bool)), this, SLOT(filterChanged()));
    connect(smoothRadiusEdit, SIGNAL(textChanged(QString)), this, SLOT(setFilterValues()));
    connect(smoothNxNCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(setFilterValues()));

    // DoingPIV
    connect(outputFolderEdit, SIGNAL(textEdited(QString)), this, SLOT(setOutput()));
    connect(outputFolderButton, SIGNAL(clicked()), this, SLOT(chooseOutputFolder()));
    connect(outputFormatCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(setOutput()));
    connect(correlateButton, SIGNAL(clicked()), process, SLOT(processCurrentImagePair()));
    connect(process, SIGNAL(currentProcessed()), pivDisplay, SLOT(displayCurrent()));
    connect(process, SIGNAL(currentProcessed()), output, SLOT(outputCurrent()));
    connect(filterButton, SIGNAL(clicked()), analysis, SLOT(filterCurrent()));
    connect(analysis, SIGNAL(currentFiltered()), pivDisplay, SLOT(displayCurrent()));
    connect(analysis, SIGNAL(currentFiltered()), output, SLOT(outputCurrent()));
    connect(batchButton, SIGNAL(clicked()), process, SLOT(launchBatchWindow()));
    connect(process, SIGNAL(batchProcessed()), this, SLOT(batchDone()));
    connect(pivDisplay, SIGNAL(mouseMoved(QPointF)), this, SLOT(updatePositionLabel(QPointF)));

    // Data Quality
    connect(filterSNRCheck, SIGNAL(toggled(bool)), this, SLOT(qualityChanged()));
    connect(snrEdit, SIGNAL(textEdited(QString)), this, SLOT(qualityChanged()));
    connect(filterIntCheck, SIGNAL(toggled(bool)), this, SLOT(qualityChanged()));
    connect(intensityEdit, SIGNAL(textEdited(QString)), this, SLOT(qualityChanged()));
}
开发者ID:vijaymurthy,项目名称:openpiv-c--qt,代码行数:87,代码来源:mainwindow.cpp

示例6: make_tunnel

void make_tunnel(int rsock, const char *remote)
{
	char buf[4096], *outbuf = NULL, *inbuf = NULL;
	int sock = -1, outlen = 0, inlen = 0;
	struct sockaddr *sa = NULL;
	const char *source;

	if (map_list) {
		if (!(source = map_find(remote))) {
			debug("<%d> connection from unmapped address (%s), disconnecting\n", rsock, remote);
			goto cleanup;
		}

		debug("<%d> mapped to %s\n", rsock, source);
	} else
		source = source_host;

	if (ircpass) {
		int i, ret;

		for (i = 0; i < sizeof(buf) - 1; i++) {
			if ((ret = read(rsock, buf + i, 1)) < 1)
				goto cleanup;
			if (buf[i] == '\n')
				break;
		}

		buf[i] = 0;
		
		if (i > 0 && buf[i - 1] == '\r')
			buf[i - 1] = 0;

		if (i == 4095 || strncasecmp(buf, "PASS ", 5)) {
			char *tmp;

			debug("<%d> irc proxy auth failed - junk\n", rsock);

			tmp = "ERROR :Closing link: Make your client send password first\r\n";
			if (write(rsock, tmp, strlen(tmp)) != strlen(tmp)) {
				// Do nothing. We're failing anyway.
			}
				
			goto cleanup;
		}

		if (strcmp(buf + 5, ircpass)) {
			char *tmp;

			debug("<%d> irc proxy auth failed - password incorrect\n", rsock);
			tmp = ":6tunnel 464 * :Password incorrect\r\nERROR :Closing link: Password incorrect\r\n";
			if (write(rsock, tmp, strlen(tmp)) != strlen(tmp)) {
				// Do nothing. We're failing anyway.
			}
			
			goto cleanup;
		}
		
		debug("<%d> irc proxy auth succeded\n", rsock);
	}
  
	if (!(sa = resolve_host(remote_host, remote_hint))) {
		debug("<%d> unable to resolve %s\n", rsock, remote_host);
		goto cleanup;
	}

	if ((sock = socket(sa->sa_family, SOCK_STREAM, 0)) == -1) {
		debug("<%d> unable to create socket (%s)\n", rsock, strerror(errno));
		goto cleanup;
	}

	free(sa);
	sa = NULL;

	if (source) {
		if (!(sa = resolve_host(source, local_hint))) {
			debug("<%d> unable to resolve source host (%s)\n", rsock, source);
			goto cleanup;
		}

		if (bind(sock, sa, (local_hint == AF_INET) ? sizeof(struct sockaddr_in) : sizeof(struct sockaddr_in6))) {
			debug("<%d> unable to bind to source host (%s)\n", rsock, source);
			goto cleanup;
		}

		free(sa);
		sa = NULL;
	}

	sa = resolve_host(remote_host, remote_hint);

	((struct sockaddr_in*) sa)->sin_port = htons(remote_port);

	if (connect(sock, sa, (sa->sa_family == AF_INET) ? sizeof(struct sockaddr_in) : sizeof(struct sockaddr_in6))) {
		debug("<%d> connection refused (%s,%d)\n", rsock, remote_host, remote_port);
		goto cleanup;
	}

	free(sa);
	sa = NULL;

//.........这里部分代码省略.........
开发者ID:robszewczyk,项目名称:6tunnel,代码行数:101,代码来源:6tunnel.c

示例7: QWidget

ModulesDialog::ModulesDialog(QWidget *parent)
	: QWidget(parent, Qt::Window),
	lv_modules(0), l_moduleinfo(0)
{
	kdebugf();
	setWindowTitle(tr("Manage Modules"));
	setAttribute(Qt::WA_DeleteOnClose);

	// create main QLabel widgets (icon and app info)
	QWidget *left = new QWidget(this);
	QVBoxLayout *leftLayout = new QVBoxLayout(left);
	leftLayout->setMargin(10);
	leftLayout->setSpacing(10);

	QLabel *l_icon = new QLabel(left);

	leftLayout->addWidget(l_icon);
	leftLayout->addStretch();

	QWidget *center = new QWidget(this);
	QVBoxLayout *centerLayout = new QVBoxLayout(center);
	centerLayout->setMargin(10);
	centerLayout->setSpacing(10);

	QLabel *l_info = new QLabel(center);
	l_icon->setPixmap(IconsManager::instance()->loadPixmap("ManageModulesWindowIcon"));
	l_info->setText(tr("This dialog box allows you to manage installed modules. Modules are responsible "
			"for numerous vital features like playing sounds or message encryption.\n"
			"You can load (or unload) them by double-clicking on their names."));
	l_info->setWordWrap(true);
#ifndef	Q_OS_MAC
	l_info->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum));
#endif
	// end create main QLabel widgets (icon and app info)

	// our QListView
	lv_modules = new QTreeWidget(center);
	QStringList headers;
	headers << tr("Module name") << tr("Version") << tr("Module type") << tr("State");
	lv_modules->setHeaderLabels(headers);
	lv_modules->setSortingEnabled(true);
	lv_modules->setAllColumnsShowFocus(true);
	lv_modules->setIndentation(false);
	lv_modules->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum));

	
	// end our QListView

	//our QVGroupBox
	QGroupBox *vgb_info = new QGroupBox(center);
	QVBoxLayout *infoLayout = new QVBoxLayout(vgb_info);
	vgb_info->setTitle(tr("Info"));
	//end our QGroupBox

	l_moduleinfo = new QLabel(vgb_info);
	l_moduleinfo->setText(tr("<b>Module:</b><br/><b>Depends on:</b><br/><b>Conflicts with:</b><br/><b>Provides:</b><br/><b>Author:</b><br/><b>Version:</b><br/><b>Description:</b>"));
#ifndef	Q_OS_MAC
	l_moduleinfo->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum));
#endif
	l_moduleinfo->setWordWrap(true);

	infoLayout->addWidget(l_moduleinfo);

	// buttons
	QWidget *bottom = new QWidget(center);
	QHBoxLayout *bottomLayout = new QHBoxLayout(bottom);
	bottomLayout->setSpacing(5);

	hideBaseModules = new QCheckBox(tr("Hide base modules"), bottom);
	hideBaseModules->setChecked(config_file.readBoolEntry("General", "HideBaseModules"));
	connect(hideBaseModules, SIGNAL(clicked()), this, SLOT(refreshList()));
	QPushButton *pb_close = new QPushButton(IconsManager::instance()->loadIcon("CloseWindow"), tr("&Close"), bottom);

	bottomLayout->addWidget(hideBaseModules);
	bottomLayout->addStretch();
	bottomLayout->addWidget(pb_close);
#ifdef Q_OS_MAC
	bottom->setMaximumHeight(pb_close->height() + 5);
#endif
	// end buttons

	centerLayout->addWidget(l_info);
	centerLayout->addWidget(lv_modules);
	centerLayout->addWidget(vgb_info);
	centerLayout->addWidget(bottom);

	QHBoxLayout *layout = new QHBoxLayout(this);
	layout->addWidget(left);
	layout->addWidget(center);

	connect(pb_close, SIGNAL(clicked()), this, SLOT(close()));
	connect(lv_modules, SIGNAL(itemSelectionChanged()), this, SLOT(itemsChanging()));
	connect(lv_modules, SIGNAL(itemDoubleClicked(QTreeWidgetItem *, int)), this, SLOT(moduleAction(QTreeWidgetItem *)));

	loadWindowGeometry(this, "General", "ModulesDialogGeometry", 0, 50, 600, 620);
	refreshList();
	lv_modules->sortByColumn(0, Qt::AscendingOrder);
	kdebugf2();
}
开发者ID:ziemniak,项目名称:kadu,代码行数:99,代码来源:modules.cpp

示例8: QObject

/*!
  \class RWidgetResizer
  Create a new RReportWidget resize manager. A resize manager show 8 circle on
  widget that user can drag them to resize the widget
*/
QReportWidgetResizer::QReportWidgetResizer(QGraphicsScene *parent) :
    QObject(),
    parentScene(parent),
    //_parent( 0 ),
    m_scale(1)
{
    resizerTL = new QReportResizeHandle(0, 0, CIRCLER);
    resizerT  = new QReportResizeHandle(0, 0, CIRCLER);
    resizerTR = new QReportResizeHandle(0, 0, CIRCLER);
    resizerL  = new QReportResizeHandle(0, 0, CIRCLER);
    resizerR  = new QReportResizeHandle(0, 0, CIRCLER);
    resizerBL = new QReportResizeHandle(0, 0, CIRCLER);
    resizerB  = new QReportResizeHandle(0, 0, CIRCLER);
    resizerBR = new QReportResizeHandle(0, 0, CIRCLER);

    /*parent->addItem( resizerTL );
    parent->addItem( resizerT  );
    parent->addItem( resizerTR );
    parent->addItem( resizerL  );
    parent->addItem( resizerR  );
    parent->addItem( resizerBL );
    parent->addItem( resizerB  );
    parent->addItem( resizerBR );*/

    handles.append(resizerTL);
    handles.append(resizerT);
    handles.append(resizerTR);
    handles.append(resizerL);
    handles.append(resizerR);
    handles.append(resizerBL);
    handles.append(resizerB);
    handles.append(resizerBR);

    resizerTL->setPen(QPen(Qt::black));

    setVisible(false);

    resizerTL->setCursor(Qt::SizeFDiagCursor);
    resizerT->setCursor(Qt::SizeVerCursor);
    resizerTR->setCursor(Qt::SizeBDiagCursor);
    resizerL->setCursor(Qt::SizeHorCursor);
    resizerR->setCursor(Qt::SizeHorCursor);
    resizerBL->setCursor(Qt::SizeBDiagCursor);
    resizerB->setCursor(Qt::SizeVerCursor);
    resizerBR->setCursor(Qt::SizeFDiagCursor);

    resizerT->setResizeDirection(::Top);
    resizerL->setResizeDirection(::Left);
    resizerR->setResizeDirection(::Right);
    resizerB->setResizeDirection(::Bottom);

    resizerTR->setResizeDirection(::Top    | ::Right);
    resizerTL->setResizeDirection(::Top    | ::Left);
    resizerBR->setResizeDirection(::Bottom | ::Right);
    resizerBL->setResizeDirection(::Bottom | ::Left);

    for (int i = 0; i < handles.count(); i++) {
        /*QRadialGradient gradient( CIRCLER, CIRCLER, 270);
        gradient.setColorAt(0, QColor::fromRgb(128, 128, 255) );
        gradient.setColorAt(1, QColor::fromRgb(255, 255, 255) );
        handles.at( i )->setBrush( QBrush(gradient) );*/

        handles.at(i)->setBrush(QBrush(Qt::white));
        parent->addItem(handles.at(i));

        connect(handles.at(i), SIGNAL(moving(QPointF)),
                this,          SLOT(handleMoving(QPointF)));

        connect(handles.at(i), SIGNAL(moved()),
                this,          SIGNAL(resized()));

    }//for
}
开发者ID:HamedMasafi,项目名称:QtReport,代码行数:78,代码来源:qreportwidgetresizer.cpp

示例9: main

int main(int argc, char** argv)
{
	 int val=30;	
	 //playc.flagc1=1;
	//playc.flagc2=1;
	//playc.flagc3 =1;
	playc. flags1=0;
//	playc.flags2=0;
//	playc.flags3=0;
	playc.a_rchar[0]='$';
	playc.a_rchar[1]='O';
	playc.v_score=0;
	playc.v_rscore=0;
	playc.v_total=0;
	playc.v_life=3;
	playc.ack=1;
        int sockfd, n,len,portno;
        char buff[100];
	int buffi[5];
        struct sockaddr_in serv;
        struct hostent *server;
	/*if(argc < 3){
	printf(stderr,"using %s hostname port \n",argv[0]);
	exit(0);
	}*/
	
	//portno=atoi(argv[2]);
		if( (sockfd=socket(AF_INET,SOCK_STREAM,0)) < 0 )
        {
                printf("\nError! Socket not created...\n");
                exit(0);
        }
        //server=gethostbyname(argv[1]);
	if(server == NULL){
		fprintf(stderr,"ERROR, no such host\n");
		exit(0);
	}
	bzero(&serv,sizeof(serv));
        serv.sin_family=AF_INET;
        serv.sin_port=htons(60607);
        
        if(inet_pton(AF_INET,"127.0.0.1", &serv.sin_addr) < 0)
        {
        
	 printf("\nError in conversion of IP address from string to num\n");
                exit(0);
        }

        if( connect(sockfd,(struct sockaddr*)&serv, sizeof(serv)) <0)
        {
                printf("\nError! Conx not established...\n");
                exit(0);
        }

        printf("\n Connected.... \n");
	//sleep(5);
	//write(sockfd,&flag1,sizeof(flag1));
	//write(sockfd,&flagc1,sizeof(flagc1));
//	write(sockfd,&val,sizeof(val));
	//write(sockfd,&playc,sizeof(playc));
//	cout<<"\nSize of play"<<sizeof(playc);
	playc.flags1=1;
	write(sockfd,&playc.flags1,sizeof(playc.flags1));
	playc.f_Init();
	write(sockfd,&playc.v_opt,sizeof(playc.v_opt));
//	read(sockfd,&playc,sizeof(playc));
//	cout<<"\n"<<n;
//	playc.f_Number();
//	sleep(3);
//	playc.v_opt=1;
//	system("clear");
//	cout<<playc.v_opt;
	
//	write(sockfd,&playc.v_opt,sizeof(playc.v_opt));
	while(1)
	{
		if((len =read(sockfd,&playc.a_a,sizeof(playc.a_a))) > 0)
		{
	    //    cout<<"length is :"<<len;
	//sleep(2);
	//	cout<<"hererasdfsdf"<<len;
		playc.f_Display();
		playc.f_Print();
		playc.f_Msleep(250);
	//	sleep(10);
		if(playc.f_Kbhit())
		{
		//	 playc.flags1=2;
                  //      write(sockfd,&playc.flags1,sizeof(playc.flags1));
                    //   write(sockfd,&playc.a_a,sizeof(playc.a_a));

		   	//system("stty raw");

			playc.flags1=3;

		 	playc.v_ch=getchar();

			write(sockfd,&playc.flags1,sizeof(playc.flags1));
                	write(sockfd,&playc.v_ch,sizeof(playc.v_ch));

//.........这里部分代码省略.........
开发者ID:ashwath26,项目名称:Networking,代码行数:101,代码来源:test.c

示例10: QDialog

creatordialog::creatordialog(QString main_table,QWidget *parent) :
    QDialog(parent),
    ui(new Ui::creatordialog)
{
    ui->setupUi(this);
    level=0;

    path=dir.absolutePath();

    relation=false;
    count=false;
    ui->pushButton_add->setVisible(false);
    ui->pushButton_delete->setVisible(false);

    table_constructor=main_table;
    this->setWindowTitle("Kreator relacji");
    ui->stackedWidget->setCurrentIndex(0);

    QImage image(path + "/obrazy/sigma_LOGO_3D.png");
    ui->logo_label->setPixmap(QPixmap::fromImage(image.scaled(200,200,Qt::KeepAspectRatio,Qt::FastTransformation)));

    ui->pushButton->setIcon(QIcon(path + "/obrazy/arrow_right.png"));
    ui->pushButton->setIconSize(QSize(40, 40));

    ui->pushButton_delete->setIcon(QIcon(path + "/obrazy/delete_row.png"));
    ui->pushButton_delete->setIconSize(QSize(20, 20));

    ui->pushButton_add->setIcon(QIcon(path + "/obrazy/add_row.png"));
    ui->pushButton_add->setIconSize(QSize(20, 20));

    ui->checkBox_2->setVisible(true);
    relational_table="";
    relational_table_2="";

    table=main_table;

    if(main_table=="Daneosobowe") {
        ui->checkBox->setText("Maszyny");
        ui->checkBox_2->setVisible(false);
    }
    else if(main_table=="Czesci") {
        ui->checkBox->setText("Maszyny");
        ui->checkBox_2->setVisible(false);
    }
    else if(main_table=="Maszyny") {
        ui->checkBox->setText("Części");
        ui->checkBox_2->setText("Dane osobowe");
    }

    else if(main_table=="Maszyny_has_Daneosobowe") {
        relation=true;
        relational_table_2=main_table;
        on_pushButton_clicked();
    }
    else if(main_table=="Maszyny_has_Czesci") {
        relation=true;
        relational_table_2=main_table;
        on_pushButton_clicked();
    }

    if(relation) {
        ui->pushButton_add->setVisible(true);
        ui->pushButton_delete->setVisible(true);
    }

    connect(this, SIGNAL(rejected()), this, SLOT(closing_creator_dialog()));
}
开发者ID:RStravinsky,项目名称:Service,代码行数:67,代码来源:creatordialog.cpp

示例11: connect

void wgt_base::connect_to_signal_mapper(QPushButton *button, int i, QSignalMapper *signalMapper)
{
	signalMapper->setMapping(button, i);
	connect(button, SIGNAL(clicked()), signalMapper, SLOT(map()));
}
开发者ID:TomekGH,项目名称:mrrocpp,代码行数:5,代码来源:wgt_base.cpp

示例12: QObject

Server_ProtocolHandler::Server_ProtocolHandler(Server *_server, QObject *parent)
	: QObject(parent), server(_server), authState(PasswordWrong), acceptsUserListChanges(false), acceptsRoomListChanges(false), userInfo(0), lastCommandTime(QDateTime::currentDateTime())
{
	connect(server, SIGNAL(pingClockTimeout()), this, SLOT(pingClockTimeout()));
}
开发者ID:Enoctil,项目名称:cockatrice,代码行数:5,代码来源:server_protocolhandler.cpp

示例13: QLabel

void VNewFileDialog::setupUI(const QString &p_title,
                             const QString &p_info,
                             const QString &p_defaultName)
{
    QLabel *infoLabel = NULL;
    if (!p_info.isEmpty()) {
        infoLabel = new QLabel(p_info);
    }

    // Name.
    m_nameEdit = new VMetaWordLineEdit(p_defaultName);
    QValidator *validator = new QRegExpValidator(QRegExp(VUtils::c_fileNameRegExp),
                                                 m_nameEdit);
    m_nameEdit->setValidator(validator);
    int dotIndex = p_defaultName.lastIndexOf('.');
    m_nameEdit->setSelection(0, (dotIndex == -1) ? p_defaultName.size() : dotIndex);

    // Template.
    m_templateCB = VUtils::getComboBox();
    m_templateCB->setToolTip(tr("Choose a template (magic word supported)"));
    m_templateCB->setSizeAdjustPolicy(QComboBox::AdjustToContents);

    QPushButton *templateBtn = new QPushButton(VIconUtils::buttonIcon(":/resources/icons/manage_template.svg"),
                                               "");
    templateBtn->setToolTip(tr("Manage Templates"));
    templateBtn->setProperty("FlatBtn", true);
    connect(templateBtn, &QPushButton::clicked,
            this, [this]() {
                QUrl url = QUrl::fromLocalFile(g_config->getTemplateConfigFolder());
                QDesktopServices::openUrl(url);
            });

    QHBoxLayout *tempBtnLayout = new QHBoxLayout();
    tempBtnLayout->addWidget(m_templateCB);
    tempBtnLayout->addWidget(templateBtn);
    tempBtnLayout->addStretch();

    m_templateEdit = new QTextEdit();
    m_templateEdit->setReadOnly(true);

    QVBoxLayout *templateLayout = new QVBoxLayout();
    templateLayout->addLayout(tempBtnLayout);
    templateLayout->addWidget(m_templateEdit);

    m_templateEdit->hide();

    // InsertTitle.
    m_insertTitleCB = new QCheckBox(tr("Insert note name as title (for Markdown only)"));
    m_insertTitleCB->setToolTip(tr("Insert note name into the new note as a title"));
    m_insertTitleCB->setChecked(g_config->getInsertTitleFromNoteName());
    connect(m_insertTitleCB, &QCheckBox::stateChanged,
            this, [this](int p_state) {
                g_config->setInsertTitleFromNoteName(p_state == Qt::Checked);
            });

    QFormLayout *topLayout = new QFormLayout();
    topLayout->addRow(tr("Note &name:"), m_nameEdit);
    topLayout->addWidget(m_insertTitleCB);
    topLayout->addRow(tr("Template:"), templateLayout);

    m_nameEdit->setMinimumWidth(m_insertTitleCB->sizeHint().width());

    m_warnLabel = new QLabel();
    m_warnLabel->setWordWrap(true);
    m_warnLabel->hide();

    // Ok is the default button.
    m_btnBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
    connect(m_btnBox, &QDialogButtonBox::accepted,
            this, [this]() {
                s_lastTemplateFile = m_templateCB->currentData().toString();
                QDialog::accept();
            });
    connect(m_btnBox, &QDialogButtonBox::rejected, this, &QDialog::reject);

    QPushButton *okBtn = m_btnBox->button(QDialogButtonBox::Ok);
    okBtn->setProperty("SpecialBtn", true);
    m_templateCB->setMaximumWidth(okBtn->sizeHint().width() * 4);

    QVBoxLayout *mainLayout = new QVBoxLayout();
    if (infoLabel) {
        mainLayout->addWidget(infoLabel);
    }

    mainLayout->addLayout(topLayout);
    mainLayout->addWidget(m_warnLabel);
    mainLayout->addWidget(m_btnBox);
    mainLayout->setSizeConstraint(QLayout::SetFixedSize);
    setLayout(mainLayout);

    setWindowTitle(p_title);
}
开发者ID:getwindow,项目名称:vnote,代码行数:92,代码来源:vnewfiledialog.cpp

示例14: TQWidget

MntConfigWidget::MntConfigWidget(TQWidget *parent, const char *name, bool init)
  : TQWidget(parent, name)
{
  mInitializing = false;

  GUI = !init;
  if (GUI)
  {
    //tabList fillup waits until disklist.readDF() is done...
    mDiskList.readFSTAB();
    mDiskList.readDF();
    mInitializing = true;
    connect( &mDiskList,TQT_SIGNAL(readDFDone()),this,TQT_SLOT(readDFDone()));

    TQString text;
    TQVBoxLayout *topLayout = new TQVBoxLayout( this, 0, KDialog::spacingHint());

    mList = new CListView( this, "list", 8 );
    mList->setAllColumnsShowFocus( true );
    mList->addColumn( i18n("Icon") );
    mList->addColumn( i18n("Device") );
    mList->addColumn( i18n("Mount Point") );
    mList->addColumn( i18n("Mount Command") );
    mList->addColumn( i18n("Unmount Command") );
    mList->setFrameStyle( TQFrame::WinPanel + TQFrame::Sunken );
    connect( mList, TQT_SIGNAL(selectionChanged(TQListViewItem *)),
	     this, TQT_SLOT(clicked(TQListViewItem *)));

    topLayout->addWidget( mList );

    text = TQString("%1: %2  %3: %4").
      arg(mList->header()->label(DEVCOL)).
      arg(i18n("None")).
      arg(mList->header()->label(MNTPNTCOL)).
      arg(i18n("None"));
    mGroupBox = new TQGroupBox( text, this );
    TQ_CHECK_PTR(mGroupBox);
    topLayout->addWidget(mGroupBox);

    TQGridLayout *gl = new TQGridLayout(mGroupBox, 3, 4, KDialog::spacingHint());
    if( gl == 0 ) { return; }
    gl->addRowSpacing( 0, fontMetrics().lineSpacing() );

    mIconLineEdit = new TQLineEdit(mGroupBox);
    TQ_CHECK_PTR(mIconLineEdit);
    mIconLineEdit->setMinimumWidth( fontMetrics().maxWidth()*10 );
    connect( mIconLineEdit, TQT_SIGNAL(textChanged(const TQString&)),
	     this,TQT_SLOT(iconChanged(const TQString&)));
    connect( mIconLineEdit, TQT_SIGNAL(textChanged(const TQString&)),
	     this,TQT_SLOT(slotChanged()));
    gl->addWidget( mIconLineEdit, 2, 0 );

    mIconButton = new TDEIconButton(mGroupBox);
    mIconButton->setIconType(TDEIcon::Small, TDEIcon::Device);
    TQ_CHECK_PTR(mIconButton);
    mIconButton->setFixedWidth( mIconButton->sizeHint().height() );
    connect(mIconButton,TQT_SIGNAL(iconChanged(TQString)),this,TQT_SLOT(iconChangedButton(TQString)));
    gl->addWidget( mIconButton, 2, 1 );

    //Mount
    mMountButton = new TQPushButton( i18n("Get Mount Command"), mGroupBox );
    TQ_CHECK_PTR(mMountButton);
    connect(mMountButton,TQT_SIGNAL(clicked()),this,TQT_SLOT(selectMntFile()));
    gl->addWidget( mMountButton, 1, 2 );

    mMountLineEdit = new TQLineEdit(mGroupBox);
    TQ_CHECK_PTR(mMountLineEdit);
    mMountLineEdit->setMinimumWidth( fontMetrics().maxWidth()*10 );
    connect(mMountLineEdit,TQT_SIGNAL(textChanged(const TQString&)),
	    this,TQT_SLOT(mntCmdChanged(const TQString&)));
    connect( mMountLineEdit, TQT_SIGNAL(textChanged(const TQString&)),
	     this,TQT_SLOT(slotChanged()));
    gl->addWidget( mMountLineEdit, 1, 3 );

    //Umount
    mUmountButton = new TQPushButton(i18n("Get Unmount Command"), mGroupBox );
    TQ_CHECK_PTR( mUmountButton );
    connect(mUmountButton,TQT_SIGNAL(clicked()),this,TQT_SLOT(selectUmntFile()));
    gl->addWidget( mUmountButton, 2, 2 );

    mUmountLineEdit=new TQLineEdit(mGroupBox);
    TQ_CHECK_PTR(mUmountLineEdit);
    mUmountLineEdit->setMinimumWidth( fontMetrics().maxWidth()*10 );
    connect(mUmountLineEdit,TQT_SIGNAL(textChanged(const TQString&)),
	    this,TQT_SLOT(umntCmdChanged(const TQString&)));
    connect( mUmountLineEdit, TQT_SIGNAL(textChanged(const TQString&)),
	     this,TQT_SLOT(slotChanged()));
    gl->addWidget( mUmountLineEdit, 2, 3 );

  }

  loadSettings();
  if(init)
  {
    applySettings();
    mDiskLookup.resize(0);
  }

  mGroupBox->setEnabled( false );
}
开发者ID:Fat-Zer,项目名称:tdeutils,代码行数:100,代码来源:mntconfig.cpp

示例15: connect

void MainWindow::showContextMenu( QTableWidgetItem * item,bool itemClicked )
{
	QMenu m ;

	m.setFont( this->font() ) ;

	QString mt = m_ui->tableWidget->item( item->row(),1 )->text() ;
	QString type = m_ui->tableWidget->item( item->row(),2 )->text() ;

	if( mt == QString( "Nil" ) ){
		connect( m.addAction( tr( "mount" ) ),SIGNAL( triggered() ),this,SLOT( slotMount() ) ) ;
	}else{
		QString mp = QString( "/run/media/private/%1/" ).arg( utility::userName() ) ;
		QString mp_1 = QString( "/home/%1/" ).arg( utility::userName() ) ;
		if( mt.startsWith( mp ) || mt.startsWith( mp_1 ) ){
			connect( m.addAction( tr( "unmount" ) ),SIGNAL( triggered() ),this,SLOT( pbUmount() ) ) ;
			m.addSeparator() ;
			connect( m.addAction( tr( "properties" ) ),SIGNAL( triggered() ),this,SLOT( volumeProperties() ) ) ;
			m.addSeparator() ;
			m_sharedFolderPath = utility::sharedMountPointPath( mt ) ;
			if( m_sharedFolderPath.isEmpty() ){
				connect( m.addAction( tr( "open folder" ) ),SIGNAL( triggered() ),
					 this,SLOT( slotOpenFolder() ) ) ;
			}else{
				connect( m.addAction( tr( "open private folder" ) ),SIGNAL( triggered() ),
					 this,SLOT( slotOpenFolder() ) ) ;
				connect( m.addAction( tr( "open shared folder" ) ),SIGNAL( triggered() ),
					 this,SLOT( slotOpenSharedFolder() ) ) ;
			}
		}else{
			m_sharedFolderPath = utility::sharedMountPointPath( mt ) ;
			if( m_sharedFolderPath.isEmpty() ){
				if( utility::pathIsReadable( mt ) ){
					connect( m.addAction( tr( "properties" ) ),SIGNAL( triggered() ),this,SLOT( volumeProperties() ) ) ;
					m.addSeparator() ;
					connect( m.addAction( tr( "open folder" ) ),SIGNAL( triggered() ),
						 this,SLOT( slotOpenFolder() ) ) ;
				}else{
					connect( m.addAction( tr( "properties" ) ),SIGNAL( triggered() ),this,SLOT( volumeProperties() ) ) ;
				}
			}else{
				connect( m.addAction( tr( "properties" ) ),SIGNAL( triggered() ),this,SLOT( volumeProperties() ) ) ;
				m.addSeparator() ;
				connect( m.addAction( tr( "open shared folder" ) ),SIGNAL( triggered() ),
					 this,SLOT( slotOpenSharedFolder() ) ) ;
			}
		}
	}

	m.addSeparator() ;
	m.addAction( tr( "close menu" ) ) ;

	if( itemClicked ){
		m.exec( QCursor::pos() ) ;
	}else{
		QPoint p = this->pos() ;
		int x = p.x() + 100 + m_ui->tableWidget->columnWidth( 0 ) ;
		int y = p.y() + 50 + m_ui->tableWidget->rowHeight( 0 ) * item->row() ;
		p.setX( x ) ;
		p.setY( y ) ;
		m.exec( p ) ;
	}
}
开发者ID:ghostbunny,项目名称:zuluCrypt,代码行数:63,代码来源:mainwindow.cpp


注:本文中的connect函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。