Exemple #1
0
void MainWindow::editCopyHtml()
{
    QClipboard* clipboard = QApplication::clipboard();
    clipboard->setText(ui->htmlSourceTextEdit->toPlainText());
}
void ThunderPanel::slotCopySourceAddress()
{
    QClipboard *clipboard = QApplication::clipboard();
    clipboard->setText(getUserDataByOffset(OFFSET_SOURCE));
}
void RequestDetailsDlg::slotSendToBuffer()
{
    QClipboard *clipboard = QApplication::clipboard();
    clipboard->setText(m_request->toString().join("\n\n\n"));
}
Exemple #4
0
/*
 *  Copies a string to the clipboard
 */
void FileEngine::copyToClipboard(const QString &string)
{
    QClipboard *clipboard = QGuiApplication::clipboard();

    clipboard->setText(string);
}
void QHexEditPrivate::keyPressEvent(QKeyEvent *event)
{
    int charX = (_cursorX - _xPosHex) / _charWidth;
    int posX = (charX / 3) * 2 + (charX % 3);
    int posBa = (_cursorY / _charHeight) * BYTES_PER_LINE + posX / 2;


/*****************************************************************************/
/* Cursor movements */
/*****************************************************************************/

    if (event->matches(QKeySequence::MoveToNextChar))
    {
        setCursorPos(_cursorPosition + 1);
        resetSelection(_cursorPosition);
    }
    if (event->matches(QKeySequence::MoveToPreviousChar))
    {
        setCursorPos(_cursorPosition - 1);
        resetSelection(_cursorPosition);
    }
    if (event->matches(QKeySequence::MoveToEndOfLine))
    {
        setCursorPos(_cursorPosition | (2 * BYTES_PER_LINE -1));
        resetSelection(_cursorPosition);
    }
    if (event->matches(QKeySequence::MoveToStartOfLine))
    {
        setCursorPos(_cursorPosition - (_cursorPosition % (2 * BYTES_PER_LINE)));
        resetSelection(_cursorPosition);
    }
    if (event->matches(QKeySequence::MoveToPreviousLine))
    {
        setCursorPos(_cursorPosition - (2 * BYTES_PER_LINE));
        resetSelection(_cursorPosition);
    }
    if (event->matches(QKeySequence::MoveToNextLine))
    {
        setCursorPos(_cursorPosition + (2 * BYTES_PER_LINE));
        resetSelection(_cursorPosition);
    }

    if (event->matches(QKeySequence::MoveToNextPage))
    {
        setCursorPos(_cursorPosition + (((_scrollArea->viewport()->height() / _charHeight) - 1) * 2 * BYTES_PER_LINE));
        resetSelection(_cursorPosition);
    }
    if (event->matches(QKeySequence::MoveToPreviousPage))
    {
        setCursorPos(_cursorPosition - (((_scrollArea->viewport()->height() / _charHeight) - 1) * 2 * BYTES_PER_LINE));
        resetSelection(_cursorPosition);
    }
    if (event->matches(QKeySequence::MoveToEndOfDocument))
    {
        setCursorPos(_data.size() * 2);
        resetSelection(_cursorPosition);
    }
    if (event->matches(QKeySequence::MoveToStartOfDocument))
    {
        setCursorPos(0);
        resetSelection(_cursorPosition);
    }

/*****************************************************************************/
/* Select commands */
/*****************************************************************************/
    if (event->matches(QKeySequence::SelectAll))
    {
        resetSelection(0);
        setSelection(2*_data.length() + 1);
    }
    if (event->matches(QKeySequence::SelectNextChar))
    {
        int pos = _cursorPosition + 1;
        setCursorPos(pos);
        setSelection(pos);
    }
    if (event->matches(QKeySequence::SelectPreviousChar))
    {
        int pos = _cursorPosition - 1;
        setSelection(pos);
        setCursorPos(pos);
    }
    if (event->matches(QKeySequence::SelectEndOfLine))
    {
        int pos = _cursorPosition - (_cursorPosition % (2 * BYTES_PER_LINE)) + (2 * BYTES_PER_LINE);
        setCursorPos(pos);
        setSelection(pos);
    }
    if (event->matches(QKeySequence::SelectStartOfLine))
    {
        int pos = _cursorPosition - (_cursorPosition % (2 * BYTES_PER_LINE));
        setCursorPos(pos);
        setSelection(pos);
    }
    if (event->matches(QKeySequence::SelectPreviousLine))
    {
        int pos = _cursorPosition - (2 * BYTES_PER_LINE);
        setCursorPos(pos);
        setSelection(pos);
    }
    if (event->matches(QKeySequence::SelectNextLine))
    {
        int pos = _cursorPosition + (2 * BYTES_PER_LINE);
        setCursorPos(pos);
        setSelection(pos);
    }

    if (event->matches(QKeySequence::SelectNextPage))
    {
        int pos = _cursorPosition + (((_scrollArea->viewport()->height() / _charHeight) - 1) * 2 * BYTES_PER_LINE);
        setCursorPos(pos);
        setSelection(pos);
    }
    if (event->matches(QKeySequence::SelectPreviousPage))
    {
        int pos = _cursorPosition - (((_scrollArea->viewport()->height() / _charHeight) - 1) * 2 * BYTES_PER_LINE);
        setCursorPos(pos);
        setSelection(pos);
    }
    if (event->matches(QKeySequence::SelectEndOfDocument))
    {
        int pos = _data.size() * 2;
        setCursorPos(pos);
        setSelection(pos);
    }
    if (event->matches(QKeySequence::SelectStartOfDocument))
    {
        int pos = 0;
        setCursorPos(pos);
        setSelection(pos);
    }

/*****************************************************************************/
/* Edit Commands */
/*****************************************************************************/
if (!_readOnly)
{
    /* Hex input */
        int key = int(event->text()[0].toAscii());
        if ((key>='0' && key<='9') || (key>='a' && key <= 'f'))
        {
            if (getSelectionBegin() != getSelectionEnd())
            {
                posBa = getSelectionBegin();
                remove(posBa, getSelectionEnd() - posBa);
                setCursorPos(2*posBa);
                resetSelection(2*posBa);
            }

            // If insert mode, then insert a byte
            if (_overwriteMode == false)
                if ((charX % 3) == 0)
                {
                    insert(posBa, char(0));
                    adjust();
                }

            // Change content
            if (_data.size() > 0)
            {
                QByteArray hexValue = _data.mid(posBa, 1).toHex();
                if ((charX % 3) == 0)
                    hexValue[0] = key;
                else
                    hexValue[1] = key;
                replace(posBa, 1, QByteArray().fromHex(hexValue));

                setCursorPos(_cursorPosition + 1);
                resetSelection(_cursorPosition);
            }
        }

        /* Cut & Paste */
        if (event->matches(QKeySequence::Cut))
        {
            QString result = QString();
            for (int idx = getSelectionBegin(); idx < getSelectionEnd(); idx++)
            {
                result += _data.mid(idx, 1).toHex() + " ";
                if ((idx % 16) == 15)
                    result.append("\n");
            }
            remove(getSelectionBegin(), getSelectionEnd());
            QClipboard *clipboard = QApplication::clipboard();
            clipboard->setText(result);
            setCursorPos(getSelectionBegin());
            resetSelection(getSelectionBegin());
        }

        if (event->matches(QKeySequence::Paste))
        {
            QClipboard *clipboard = QApplication::clipboard();
            QByteArray ba = QByteArray().fromHex(clipboard->text().toLatin1());
            insert(_cursorPosition / 2, ba);
            setCursorPos((_cursorPosition + (2 * ba.length()) + 1) & 0xfffffffe);
            resetSelection(getSelectionBegin());
        }


        /* Delete char */
        if (event->matches(QKeySequence::Delete))
        {
            if (getSelectionBegin() != getSelectionEnd())
            {
                posBa = getSelectionBegin();
                remove(posBa, getSelectionEnd() - posBa);
                setCursorPos(2*posBa);
                resetSelection(2*posBa);
            }
            else
            {
                remove(posBa);
            }
        }

        /* Backspace */
        if ((event->key() == Qt::Key_Backspace) && (event->modifiers() == Qt::NoModifier))
            {
                if (getSelectionBegin() != getSelectionEnd())
                {
                    posBa = getSelectionBegin();
                    remove(posBa, getSelectionEnd() - posBa);
                    setCursorPos(2*posBa);
                    resetSelection(2*posBa);
                }
                else
                {
                    remove(posBa - 1);
                    setCursorPos(_cursorPosition - 2);
                }
            }
    }

    if (event->matches(QKeySequence::Copy))
    {
        QString result = QString();
        for (int idx = getSelectionBegin(); idx < getSelectionEnd(); idx++)
        {
            result += _data.mid(idx, 1).toHex() + " ";
            if ((idx % 16) == 15)
                result.append('\n');
        }
        QClipboard *clipboard = QApplication::clipboard();
        clipboard->setText(result);
    }

    // Switch between insert/overwrite mode
    if ((event->key() == Qt::Key_Insert) && (event->modifiers() == Qt::NoModifier))
    {
        setOverwriteMode(!_overwriteMode);
        setCursorPos(_cursorPosition);
    }

    _scrollArea->ensureVisible(_cursorX, _cursorY + _charHeight/2, 3, _charHeight/2 + 2);

    update();
}
/**
 * Stores value and state of selected cell in variable.
 */
void DatasetEditWidget::copyCell(){
    QClipboard* clipboard = QApplication::clipboard();
    QModelIndex index = ui->tableView->currentIndex();
    clipboard->setText(model->viewModel()->data(index, Qt::DisplayRole).toString());
	ui->tableView->update(index);
}
Exemple #7
0
void MainWindow::slot_pbutton_copy()
{
    QClipboard *cb = QApplication::clipboard();
    cb->setText(ui->lineEdit->text());
}
Exemple #8
0
void ContactInfoWindow::copyPhoneToClipboard()
{
    QClipboard *clipboard = QApplication::clipboard();
    clipboard->setText(contact->phone);
    QMaemo5InformationBox::information(this,"Phone number copied to clipboard");
}
Exemple #9
0
void winHistory::on_btnToClipboard_clicked(){
    QClipboard *cb = QApplication::clipboard();
    cb->setText( ui->txtUrl->text(),
             QClipboard::Clipboard );
}
void LocationChatWidgetItem::copyToClipboard() {
	QClipboard *clipboard = QApplication::clipboard();
	clipboard->setText(QString("Location: https://maps.google.com/?q=%1,%2 - %3").arg(latitude).arg(longitude).arg(description));
}
Exemple #11
0
void DocumentFile::copyFilenameToClipboard()
{
    QClipboard *clipboard = QApplication::clipboard();
    clipboard->setText(d->filename);
}
Exemple #12
0
void cSettings::SaveToClipboard()
{
	WriteLog("Save settings to clipboard");
	QClipboard *clipboard = QApplication::clipboard();
	clipboard->setText(settingsText);
}
void DownloadItemViewModel::copyUrl()
{
    QClipboard* clipboard = QApplication::clipboard();
    clipboard->setText(m_url);
}
Exemple #14
0
void MythUITextEdit::CopyTextToClipboard()
{
    QClipboard *clipboard = QApplication::clipboard();
    if (clipboard)
        clipboard->setText(m_Message);
}
void QtResourceViewPrivate::slotCopyResourcePath()
{
    const QString path = q_ptr->selectedResource();
    QClipboard *clipboard = QApplication::clipboard();
    clipboard->setText(path);
}
Exemple #16
0
void Bridge::CopyToClipboard(const QString & text)
{
    QClipboard* clipboard = QApplication::clipboard();
    clipboard->setText(text);
}
void ToolBarColorBox::copyColorToClipboard()
{
    QClipboard *clipboard = QApplication::clipboard();
    clipboard->setText(m_color.name());
}
void RazorAboutDLGPrivate::copyToCliboardTechInfo()
{
    TechnicalInfo info;
    QClipboard *clipboard = QApplication::clipboard();
    clipboard->setText(info.text());
}
Exemple #19
0
void Actions::setClipboardText(const QString &text)
{
    QClipboard *clipboard = QApplication::clipboard();
    clipboard->setText(text, QClipboard::Selection);
    clipboard->setText(text, QClipboard::Clipboard);
}
Exemple #20
0
void g_setProperty(const char* what, const char* arg) {

    QString argGet = QString::fromUtf8(arg);
    int arg1 = 0;
    int arg2 = 0;
    int arg3 = 0;
    QString argString = "";

    if ( g_checkStringProperty(true,what)) {
        argString = argGet;
        argString.replace("\\","\\\\");
    } else {
        QStringList arrayArg = argGet.split("|",QString::KeepEmptyParts);
        arg1 = arrayArg.at(0).toInt();
        arg2 = arrayArg.at(1).toInt();
        arg3 = arrayArg.at(2).toInt();
    }



    /*------------------------------------------------------------------*/
    if (strcmp(what, "cursor") == 0)
    {
        QStringList acceptedValue;
        acceptedValue << "arrow" << "upArrow" << "cross" << "wait" << "IBeam";
        acceptedValue << "sizeVer" << "sizeHor" << "sizeBDiag" << "sizeFDiag" << "sizeAll";
        acceptedValue << "blank" << "splitV" << "splitH" << "pointingHand" << "forbidden";
        acceptedValue << "whatsThis" << "busy" << "openHand" << "closedHand" << "dragCopy";
        acceptedValue << "dragMove" << "dragLink";
        // value of cursor also taken from index of the text, do not change the list

        if (acceptedValue.contains(argString)) {
            arg1 = acceptedValue.indexOf(argString);
            MainWindow::getInstance()->setCursor((Qt::CursorShape) arg1);
        } else {
            QString info = "Accepted value for ";
            info.append(what);
            info.append(" :");
            MainWindow::getInstance()->printToOutput(info.toStdString().c_str());
            for( int i=0; i<acceptedValue.size(); ++i ) {
                MainWindow::getInstance()->printToOutput( QString("- ").append(acceptedValue.at(i)).toStdString().c_str() );
            }
        }


        /*------------------------------------------------------------------*/
    } else if (strcmp(what, "windowPosition") == 0)
    {
        MainWindow::getInstance()->move(arg1,arg2);

        /*------------------------------------------------------------------*/
    } else if (strcmp(what, "windowSize") == 0)
    {
        MainWindow::getInstance()->resizeWindow(arg1,arg2);


        /*------------------------------------------------------------------*/
    } else if (strcmp(what, "minimumSize") == 0)
    {
        MainWindow::getInstance()->setMinimumSize(QSize(arg1,arg2));

        /*------------------------------------------------------------------*/
    } else if (strcmp(what, "maximumSize") == 0)
    {
        MainWindow::getInstance()->setMaximumSize(QSize(arg1,arg2));

        /*------------------------------------------------------------------*/
    } else if (strcmp(what, "windowColor") == 0)
    {
        if (arg1 > 255) {
            arg1 = 255;
        }
        else if(arg1 < 0) {
            arg1 = 255;
        }
        if (arg2 > 255) {
            arg2 = 255;
        }
        else if(arg2 < 0) {
            arg2 = 255;
        }
        if (arg3 > 255) {
            arg3 = 255;
        }
        else if(arg3 < 0) {
            arg3 = 255;
        }
        QPalette palette;
        QColor backgroundColor = QColor(arg1, arg2, arg3);
        palette.setColor(QPalette::Window, backgroundColor);
        MainWindow::getInstance()->setPalette(palette);

        /*------------------------------------------------------------------*/
    } else if (strcmp(what, "windowTitle") == 0)
    {
        MainWindow::getInstance()->setWindowTitle(argString);

        /*------------------------------------------------------------------*/
    } else if (strcmp(what, "windowModel") == 0)
    {
        QStringList acceptedValue;
        acceptedValue << "reset" << "stayOnTop" << "stayOnBottom" << "frameless" << "noTitleBar";
        acceptedValue << "noButton" << "onlyMinimize" << "onlyMaximize" << "onlyClose" << "noMinimize";
        acceptedValue << "noMaximize" << "noClose" << "helpButton";

        if (acceptedValue.contains(argString)) {
            Qt::WindowFlags flags = MainWindow::getInstance()->windowFlags();

            if (argString == "reset") {
                flags = Qt::Window;
            } else if (argString == "stayOnTop") {
                flags |= Qt::WindowStaysOnTopHint;
            } else if (argString == "stayOnBottom") {
                flags |= Qt::WindowStaysOnBottomHint;
            } else if (argString == "frameless") {
                flags |= Qt::FramelessWindowHint;
            } else if (argString == "noTitleBar") {
                flags = Qt::Window;
                flags |= Qt::CustomizeWindowHint;
            } else if (argString == "noButton") {
                flags = Qt::Window;
                flags |= Qt::WindowTitleHint;
            } else if (argString == "noClose") {
                flags = Qt::Window;
                flags |= Qt::WindowMinimizeButtonHint;
            } else if (argString == "onlyMaximize") {
                flags = Qt::Window;
                flags |= Qt::WindowMaximizeButtonHint;
            } else if (argString == "onlyClose") {
                flags = Qt::Window;
                flags |= Qt::WindowCloseButtonHint;
            } else if (argString == "noMinimize") {
                flags = Qt::Window;
                flags |= Qt::WindowMaximizeButtonHint;
                flags |= Qt::WindowCloseButtonHint;
            } else if (argString == "noMaximize") {
                flags = Qt::Window;
                flags |= Qt::WindowMinimizeButtonHint;
                flags |= Qt::WindowCloseButtonHint;
            } else if (argString == "noClose") {
                flags = Qt::Window;
                flags |= Qt::WindowMinimizeButtonHint;
                flags |= Qt::WindowMaximizeButtonHint;
            } else if (argString == "helpButton") {
                flags = Qt::Window;
                flags |= Qt::WindowContextHelpButtonHint;
                flags |= Qt::WindowCloseButtonHint;
            }

            MainWindow::getInstance()->setWindowFlags(flags);
            if (MainWindow::getInstance()->fullScreen()) {
                MainWindow::getInstance()->showFullScreen();
            } else {
                MainWindow::getInstance()->showNormal();
            }

        } else {

            QString info = "Accepted value for ";
            info.append(what);
            info.append(" :");
            MainWindow::getInstance()->printToOutput(info.toStdString().c_str());
            for( int i=0; i<acceptedValue.size(); ++i ) {
                MainWindow::getInstance()->printToOutput( QString("- ").append(acceptedValue.at(i)).toStdString().c_str() );
            }
        }

        /*------------------------------------------------------------------*/
    } else if (strcmp(what, "cursorPosition") == 0)
    {
        QCursor::setPos(arg1,arg2);


        /*------------------------------------------------------------------*/
    } else if (strcmp(what, "clipboard") == 0)
    {
        QClipboard *clipboard = QApplication::clipboard();
        clipboard->setText(argString);

        /*------------------------------------------------------------------*/
    } else if (strcmp(what, "mkDir") == 0)
    {
        QStringList argSplit = argString.split("|",QString::KeepEmptyParts);
        if(argSplit.size() == 1) {

            MainWindow::getInstance()->printToOutput("[[Usage Example]]");
            MainWindow::getInstance()->printToOutput("application:set(\"mkDir\",application:get(\"directory\",\"executable\")..\"|dirName\")");
        } else {
            QDir dirPath = QDir::temp();
            dirPath.setPath(argSplit.at(0));
            dirPath.mkdir(argSplit.at(1));
        }

        /*------------------------------------------------------------------*/
    } else if (strcmp(what, "documentDirectory") == 0)
    {
        setDocumentsDirectory(argString.toStdString().c_str());
        /*------------------------------------------------------------------*/
    } else if (strcmp(what, "temporaryDirectory") == 0)
    {
        setTemporaryDirectory(argString.toStdString().c_str());

    } else {

        // feel free to change this list
        QStringList acceptedWhat;
        acceptedWhat << "windowPosition(x,y)";
        acceptedWhat << "windowSize(w,h)";
        acceptedWhat << "minimumSize(w,h)";
        acceptedWhat << "maximumSize(w,h)";
        acceptedWhat << "windowColor(r,g,b)";
        acceptedWhat << "windowTitle(text)";
        acceptedWhat << "windowModel(type//help)";
        acceptedWhat << "cursor(type//help)";
        acceptedWhat << "cursorPosition(x,y)";
        acceptedWhat << "clipboard(text)";
        acceptedWhat << "mkdir(path|dirName//help)";
        acceptedWhat << "documentDirectory(path)";
        acceptedWhat << "temporaryDirectory(path)";

        MainWindow::getInstance()->printToOutput("Accepted value for Desktop's application:set()");
        for( int i=0; i<acceptedWhat.size(); ++i ) {
            MainWindow::getInstance()->printToOutput( QString("- ").append(acceptedWhat.at(i)).toStdString().c_str() );
        }
    }
}
Exemple #21
0
bool HototWebPage::handleUri(const QString& originmsg)
{
    QString msg = originmsg;
    if (msg.startsWith("hotot:")) {
        msg = msg.mid(6);
        QString type = msg.section("/", 0, 0);
        QString method = msg.section("/", 1, 1);
        if (type == "system") {
            if (method == "notify") {
                QString notify_type = QUrl::fromPercentEncoding(msg.section("/", 2, 2).toUtf8());
                QString title = QUrl::fromPercentEncoding(msg.section("/", 3, 3).toUtf8());
                QString summary = QUrl::fromPercentEncoding(msg.section("/", 4, 4).toUtf8());
                QString image = QUrl::fromPercentEncoding(msg.section("/", 5, 5).toUtf8());

                m_mainWindow->notification(notify_type, title, summary, image);
            } else if (method == "unread_alert") {
                QString number = QUrl::fromPercentEncoding(msg.section("/", 2, 2).toUtf8());
                m_mainWindow->unreadAlert(number);
            } else if (method == "load_settings") {
                QString settingString = QUrl::fromPercentEncoding(msg.section("/", 2, -1).toUtf8());
                currentFrame()->evaluateJavaScript("hotot_qt = " + settingString + ";");
                bool useHttpProxy = currentFrame()->evaluateJavaScript("hotot_qt.use_http_proxy").toBool();
                bool useHttpProxyAuth = currentFrame()->evaluateJavaScript("hotot_qt.use_http_proxy_auth").toBool();
                int httpProxyPort = currentFrame()->evaluateJavaScript("hotot_qt.http_proxy_port").toInt();
                QString httpProxyHost = currentFrame()->evaluateJavaScript("hotot_qt.http_proxy_host").toString();
                QString httpProxyAuthName = currentFrame()->evaluateJavaScript("hotot_qt.http_proxy_auth_name").toString();
                QString httpProxyAuthPassword = currentFrame()->evaluateJavaScript("hotot_qt.http_proxy_auth_password").toString();

                if (useHttpProxy) {
                    QNetworkProxy proxy(m_mainWindow->useSocks() ? QNetworkProxy::Socks5Proxy : QNetworkProxy::HttpProxy,
                                        httpProxyHost,
                                        httpProxyPort);

                    if (useHttpProxyAuth)
                    {
                        proxy.setUser(httpProxyAuthName);
                        proxy.setPassword(httpProxyAuthPassword);
                    }
                    QNetworkProxy::setApplicationProxy(proxy);
                    QNetworkAccessManager* nm = networkAccessManager();
                    nm->setParent(NULL);
                    nm->deleteLater();
                    setNetworkAccessManager(new QNetworkAccessManager(this));
                    networkAccessManager()->setProxy(QNetworkProxy::DefaultProxy);
                }
            } else if (method == "sign_in") {
                m_mainWindow->setSignIn(true);
            } else if (method == "sign_out") {
                m_mainWindow->setSignIn(false);
            }
        } else if (type == "action") {
            if (method == "search") {

            } else if (method == "choose_file") {
                QFileDialog dialog;
                dialog.setAcceptMode(QFileDialog::AcceptOpen);
                dialog.setFileMode(QFileDialog::ExistingFile);
                dialog.setNameFilter(tr("Images (*.png *.bmp *.jpg *.gif)"));
                int result = dialog.exec();
                if (result) {
                    QStringList fileNames = dialog.selectedFiles();
                    if (fileNames.size() > 0) {
                        QString callback = msg.section("/", 2, 2);
                        currentFrame()->evaluateJavaScript(QString("%1(\"%2\")").arg(callback, QUrl::fromLocalFile(fileNames[0]).toString().replace("file://", "")));
                    }
                }
            } else if (method == "save_avatar") {
            } else if (method == "log") {
                qDebug() << msg;
            } else if (method == "paste_clipboard_text") {
                triggerAction(QWebPage::Paste);
            } else if (method == "set_clipboard_text") {
                QClipboard *clipboard = QApplication::clipboard();
                if (clipboard)
                    clipboard->setText(msg.section("/", 2, -1));
            }
        } else if (type == "request") {
            QString json = QUrl::fromPercentEncoding(msg.section("/", 1, -1).toUtf8());
            currentFrame()->evaluateJavaScript(QString("hotot_qt_request_json = %1 ;").arg(json));
            QString request_uuid = currentFrame()->evaluateJavaScript(QString("hotot_qt_request_json.uuid")).toString();
            QString request_method = currentFrame()->evaluateJavaScript(QString("hotot_qt_request_json.method")).toString();
            QString request_url = currentFrame()->evaluateJavaScript(QString("hotot_qt_request_json.url")).toString();
            QMap<QString, QVariant> request_params = currentFrame()->evaluateJavaScript(QString("hotot_qt_request_json.params")).toMap();
            QMap<QString, QVariant> request_headers = currentFrame()->evaluateJavaScript(QString("hotot_qt_request_json.headers")).toMap();
            QList<QVariant> request_files = currentFrame()->evaluateJavaScript(QString("hotot_qt_request_json.files")).toList();

            HototRequest* request = new HototRequest(
                request_uuid,
                request_method,
                request_url,
                request_params,
                request_headers,
                request_files,
                userAgentForUrl(request_url),
                networkAccessManager());
            connect(request, SIGNAL(requestFinished(HototRequest*, QByteArray, QString, bool)), this, SLOT(requestFinished(HototRequest*, QByteArray, QString, bool)));
            if (!request->doRequest())
                delete request;
        }
Exemple #22
0
void QgsClipboard::setSystemClipboard()
{
  // Replace the system clipboard.
  QSettings settings;
  bool copyWKT = settings.value( "qgis/copyGeometryAsWKT", true ).toBool();

  QStringList textLines;
  QStringList textFields;

  // first do the field names
  if ( copyWKT )
  {
    textFields += "wkt_geom";
  }

  Q_FOREACH ( const QgsField& field, mFeatureFields )
  {
    textFields += field.name();
  }
  textLines += textFields.join( "\t" );
  textFields.clear();

  // then the field contents
  for ( QgsFeatureList::const_iterator it = mFeatureClipboard.constBegin(); it != mFeatureClipboard.constEnd(); ++it )
  {
    QgsAttributes attributes = it->attributes();

    // TODO: Set up Paste Transformations to specify the order in which fields are added.
    if ( copyWKT )
    {
      if ( it->constGeometry() )
        textFields += it->constGeometry()->exportToWkt();
      else
      {
        textFields += settings.value( "qgis/nullValue", "NULL" ).toString();
      }
    }

    // QgsDebugMsg("about to traverse fields.");
    for ( int idx = 0; idx < attributes.count(); ++idx )
    {
      // QgsDebugMsg(QString("inspecting field '%1'.").arg(it2->toString()));
      textFields += attributes.at( idx ).toString();
    }

    textLines += textFields.join( "\t" );
    textFields.clear();
  }

  QString textCopy = textLines.join( "\n" );

  QClipboard *cb = QApplication::clipboard();

  // Copy text into the clipboard

  // With qgis running under Linux, but with a Windows based X
  // server (Xwin32), ::Selection was necessary to get the data into
  // the Windows clipboard (which seems contrary to the Qt
  // docs). With a Linux X server, ::Clipboard was required.
  // The simple solution was to put the text into both clipboards.

#ifdef Q_OS_LINUX
  cb->setText( textCopy, QClipboard::Selection );
#endif
  cb->setText( textCopy, QClipboard::Clipboard );

  QgsDebugMsgLevel( QString( "replaced system clipboard with: %1." ).arg( textCopy ), 4 );
}
void DiagnosticsDialog::copyToClipboard()
{
    const QString fullLog = mUI.messages->toPlainText();
    QClipboard* clipboard = QApplication::clipboard();
    clipboard->setText(fullLog);
}
Exemple #24
0
void DSystemInfo::CopyPressed()
{
	QClipboard* clipboard = QApplication::clipboard();
	clipboard->setText(m_ui->txtSysInfo->toPlainText());
}
void ThunderPanel::slotCopyDownloadAddress()
{
    QClipboard *clipboard = QApplication::clipboard();
    clipboard->setText(getUserDataByOffset(OFFSET_DOWNLOAD));
}
void qtDLGMemoryView::MenuCallback(QAction* pAction)
{
	if(QString().compare(pAction->text(),"Send to HexView") == 0)
	{
		qtDLGHexView *newView = new qtDLGHexView(this,Qt::Window,tblMemoryView->item(m_selectedRow,0)->text().toULongLong(0,16),
			tblMemoryView->item(m_selectedRow,1)->text().toULongLong(0,16),
			tblMemoryView->item(m_selectedRow,2)->text().toULongLong(0,16));
		newView->show();
	}
	else if(QString().compare(pAction->text(),"Dump to File") == 0)
	{
		HANDLE hProc = clsDebugger::GetProcessHandleByPID(tblMemoryView->item(m_selectedRow,0)->text().toULongLong(0,16));

		clsMemDump memDump(hProc,
			(PTCHAR)tblMemoryView->item(m_selectedRow,3)->text().utf16(),
			tblMemoryView->item(m_selectedRow,1)->text().toULongLong(0,16),
			tblMemoryView->item(m_selectedRow,2)->text().toULongLong(0,16));
	}
	else if(QString().compare(pAction->text(),"Line") == 0)
	{
		QClipboard* clipboard = QApplication::clipboard();
		clipboard->setText(QString("%1:%2:%3:%4:%5")
			.arg(tblMemoryView->item(m_selectedRow,0)->text())
			.arg(tblMemoryView->item(m_selectedRow,1)->text())
			.arg(tblMemoryView->item(m_selectedRow,2)->text())
			.arg(tblMemoryView->item(m_selectedRow,3)->text())
			.arg(tblMemoryView->item(m_selectedRow,4)->text()));
	}
	else if(QString().compare(pAction->text(),"Base Address") == 0)
	{
		QClipboard* clipboard = QApplication::clipboard();
		clipboard->setText(tblMemoryView->item(m_selectedRow,1)->text());
	}
	else if(QString().compare(pAction->text(),"Size") == 0)
	{
		QClipboard* clipboard = QApplication::clipboard();
		clipboard->setText(tblMemoryView->item(m_selectedRow,2)->text());
	}
	else if(QString().compare(pAction->text(),"Module") == 0)
	{
		QClipboard* clipboard = QApplication::clipboard();
		clipboard->setText(tblMemoryView->item(m_selectedRow,3)->text());
	}
	else if(QString().compare(pAction->text(),"Type") == 0)
	{
		QClipboard* clipboard = QApplication::clipboard();
		clipboard->setText(tblMemoryView->item(m_selectedRow,4)->text());
	}
	else if(QString().compare(pAction->text(),"Access") == 0)
	{
		QClipboard* clipboard = QApplication::clipboard();
		clipboard->setText(tblMemoryView->item(m_selectedRow,5)->text());
	}
	else if(QString().compare(pAction->text(),"PAGE_EXECUTE") == 0)
		SetPageProctection(PAGE_EXECUTE);
	else if(QString().compare(pAction->text(),"PAGE_EXECUTE_READ") == 0)
		SetPageProctection(PAGE_EXECUTE_READ);
	else if(QString().compare(pAction->text(),"PAGE_EXECUTE_READWRITE") == 0)
		SetPageProctection(PAGE_EXECUTE_READWRITE);
	else if(QString().compare(pAction->text(),"PAGE_EXECUTE_WRITECOPY") == 0)
		SetPageProctection(PAGE_EXECUTE_WRITECOPY);
	else if(QString().compare(pAction->text(),"PAGE_NOACCESS") == 0)
		SetPageProctection(PAGE_NOACCESS);
	else if(QString().compare(pAction->text(),"PAGE_READONLY") == 0)
		SetPageProctection(PAGE_READONLY);
	else if(QString().compare(pAction->text(),"PAGE_WRITECOPY") == 0)
		SetPageProctection(PAGE_WRITECOPY);	
	else if(QString().compare(pAction->text(),"PAGE_READWRITE") == 0)
		SetPageProctection(PAGE_READWRITE);
}
Exemple #27
0
void MainWindow::fileUploaded(QUrl url)
{
    QClipboard *clipboard = QApplication::clipboard();
    tray.showMessage("Upload complete", "Upload complete");
    clipboard->setText(url.toString());
}
Exemple #28
0
 virtual ~ClipSaver() {
   if (!clipContents.isEmpty()) theClipboard->setText(clipContents, clipMode);
 }
Exemple #29
0
int VerbyPlugin::launchItem(QList<InputData>* inputData, CatItem* item)
{
    item = item; // Compiler Warning

    if (inputData->count() != 2)
    {
        // Tell Launchy to handle the command
        return MSG_CONTROL_LAUNCHITEM;
    }

    QString noun = inputData->first().getTopResult().fullPath;
    CatItem& verbItem = inputData->last().getTopResult();
    QString verb = verbItem.shortName;

    qDebug() << "Verby launchItem" << verb;
    if (verb == "Run")
    {
        runProgram(noun, "");
    }
    else if (verb == "Open containing folder")
    {
        QFileInfo info(noun);
        if (info.isSymLink())
        {
            info.setFile(info.symLinkTarget());
        }

#ifdef Q_WS_WIN
        runProgram("explorer.exe", "\"" + QDir::toNativeSeparators(info.absolutePath()) + "\"");
#endif
    }
    else if (verb == "Open shortcut folder")
    {
        QFileInfo info(noun);

#ifdef Q_WS_WIN
        runProgram("explorer.exe", "\"" + QDir::toNativeSeparators(info.absolutePath()) + "\"");
#endif
    }
    else if (verb == "Run as")
    {
#ifdef Q_WS_WIN
        SHELLEXECUTEINFO shellExecInfo;

        shellExecInfo.cbSize = sizeof(SHELLEXECUTEINFO);
        shellExecInfo.fMask = SEE_MASK_FLAG_NO_UI;
        shellExecInfo.hwnd = NULL;
        shellExecInfo.lpVerb = L"runas";
        shellExecInfo.lpFile = (LPCTSTR)noun.utf16();
        shellExecInfo.lpParameters = NULL;
        QDir dir(noun);
        QFileInfo info(noun);
        if (!info.isDir() && info.isFile())
            dir.cdUp();
        QString filePath = QDir::toNativeSeparators(dir.absolutePath());
        shellExecInfo.lpDirectory = (LPCTSTR)filePath.utf16();
        shellExecInfo.nShow = SW_NORMAL;
        shellExecInfo.hInstApp = NULL;

        ShellExecuteEx(&shellExecInfo);
#endif
    }
    else if (verb == "File properties")
    {
#ifdef Q_WS_WIN
        SHELLEXECUTEINFO shellExecInfo;

        shellExecInfo.cbSize = sizeof(SHELLEXECUTEINFO);
        shellExecInfo.fMask = SEE_MASK_FLAG_NO_UI | SEE_MASK_INVOKEIDLIST;
        shellExecInfo.hwnd = NULL;
        shellExecInfo.lpVerb = L"properties";
        QString filePath = QDir::toNativeSeparators(noun);
        shellExecInfo.lpFile = (LPCTSTR)filePath.utf16();
        shellExecInfo.lpIDList = NULL; 
        shellExecInfo.lpParameters = NULL;
        shellExecInfo.lpDirectory = NULL;
        shellExecInfo.nShow = SW_NORMAL;
        shellExecInfo.hInstApp = NULL;

        ShellExecuteEx(&shellExecInfo);
#endif
    }
    else if (verb == "Copy path to clipboard")
    {
        QFileInfo info(noun);
        if (info.isSymLink())
        {
            info.setFile(info.symLinkTarget());
        }
        QClipboard *clipboard = QApplication::clipboard();
        clipboard->setText(QDir::toNativeSeparators(info.canonicalFilePath()));
    }
    else
    {
        // Tell Launchy to handle the command
        return MSG_CONTROL_LAUNCHITEM;
    }

    updateUsage(verbItem);
    return true;
}
Exemple #30
0
bool TextObjectEditorHelper::keyPressEvent(QKeyEvent* event)
{
// FIXME: repair weird Shift+Left/Right - needs some cursor position
	if (event->key() == Qt::Key_Backspace)
	{
		QString text = object->getText();
		
		if (selection_end == 0)
			return false;
		if (selection_end != selection_start)
		{
			text.remove(selection_start, selection_end - selection_start);
			selection_end = selection_start;
		}
		else
		{
			text.remove(selection_start - 1, 1);
			--selection_end;
			--selection_start;
		}
		object->setText(text);
		emit(selectionChanged(true));
	}
	else if (event->key() == Qt::Key_Delete)
	{
		QString text = object->getText();
		
		if (selection_start == text.size())
			return false;
		if (selection_end != selection_start)
		{
			text.remove(selection_start, selection_end - selection_start);
			selection_end = selection_start;
		}
		else
			text.remove(selection_start, 1);
		object->setText(text);
		emit(selectionChanged(true));
	}
	else if (event->matches(QKeySequence::MoveToPreviousChar) || event->matches(QKeySequence::SelectPreviousChar))
	{
		if (selection_start == 0)
		{
			if (selection_end != 0)
			{
				selection_end = 0;
				emit(selectionChanged(false));
			}
			return true;
		}
		--selection_start;
		if (!event->matches(QKeySequence::SelectPreviousChar))
			selection_end = selection_start;
		emit(selectionChanged(false));
	}
	else if (event->matches(QKeySequence::MoveToNextChar) || event->matches(QKeySequence::SelectNextChar))
	{
		if (selection_end == object->getText().length())
		{
			if (selection_start != object->getText().length())
			{
				selection_start = object->getText().length();
				emit(selectionChanged(false));
			}
			return true;
		}
		++selection_end;
		if (!event->matches(QKeySequence::SelectNextChar))
			selection_start = selection_end;
		emit(selectionChanged(false));
	}
	else if (event->matches(QKeySequence::MoveToPreviousLine) || event->matches(QKeySequence::SelectPreviousLine))
	{
		int line_num = object->findLineForIndex(selection_start);
		TextObjectLineInfo* line_info = object->getLineInfo(line_num);
		if (line_info->start_index == 0)
			return true;
		
		double x = line_info->getX(selection_start);
		TextObjectLineInfo* prev_line_info = object->getLineInfo(line_num-1);
		double y = prev_line_info->line_y;
		x = qMax( prev_line_info->line_x, qMin(x, prev_line_info->line_x + prev_line_info->width));
		
		selection_start = object->calcTextPositionAt(QPointF(x,y), false);
		if (!event->matches(QKeySequence::SelectPreviousLine))
			selection_end = selection_start;
		emit(selectionChanged(false));
	}
	else if (event->matches(QKeySequence::MoveToNextLine) || event->matches(QKeySequence::SelectNextLine))
	{
		int line_num = object->findLineForIndex(selection_end);
		TextObjectLineInfo* line_info = object->getLineInfo(line_num);
		if (line_info->end_index >= object->getText().length())
			return true;
		
		double x = line_info->getX(selection_end);
		TextObjectLineInfo* next_line_info = object->getLineInfo(line_num+1);
		double y = next_line_info->line_y;
		x = qMax( next_line_info->line_x, qMin(x, next_line_info->line_x + next_line_info->width));
		
		selection_end = object->calcTextPositionAt(QPointF(x,y), false);
		if (!event->matches(QKeySequence::SelectNextLine))
			selection_start = selection_end;
		emit(selectionChanged(false));
	}
	else if (event->matches(QKeySequence::MoveToStartOfLine) || event->matches(QKeySequence::SelectStartOfLine) ||
		     event->matches(QKeySequence::MoveToStartOfDocument) || event->matches(QKeySequence::SelectStartOfDocument))
	{
		int destination = (event->matches(QKeySequence::MoveToStartOfDocument) || event->matches(QKeySequence::SelectStartOfDocument)) ?
		                      0 : (object->findLineInfoForIndex(selection_start).start_index);
		if (event->matches(QKeySequence::SelectStartOfLine) || event->matches(QKeySequence::SelectStartOfDocument))
		{
			if (selection_start == destination)
				return true;
			selection_start = destination;
		}
		else
		{
			if (selection_end == destination)
				return true;
			selection_start = destination;
			selection_end = destination;
		}
		emit(selectionChanged(false));
	}
	else if (event->matches(QKeySequence::MoveToEndOfLine) || event->matches(QKeySequence::SelectEndOfLine) ||
		     event->matches(QKeySequence::MoveToEndOfDocument) || event->matches(QKeySequence::SelectEndOfDocument))
	{
		int destination;
		if (event->matches(QKeySequence::MoveToEndOfDocument) || event->matches(QKeySequence::SelectEndOfDocument))
			destination = object->getText().length();
		else
			destination = object->findLineInfoForIndex(selection_start).end_index;
		
		if (event->matches(QKeySequence::SelectEndOfLine) || event->matches(QKeySequence::SelectEndOfDocument))
		{
			if (selection_end == destination)
				return true;
			selection_end = destination;
		}
		else
		{
			if (selection_start == destination)
				return true;
			selection_start = destination;
			selection_end = destination;
		}
		emit(selectionChanged(false));
	}
	else if (event->matches(QKeySequence::SelectAll))
	{
		if (selection_start == 0 && selection_end == object->getText().length())
			return true;
		selection_start = 0;
		selection_end = object->getText().length();
		emit(selectionChanged(false));
	}
	else if (event->matches(QKeySequence::Copy) || event->matches(QKeySequence::Cut))
	{
		if (selection_end - selection_start > 0)
		{
			QClipboard* clipboard = QApplication::clipboard();
			clipboard->setText(object->getText().mid(selection_start, selection_end - selection_start));
			
			if (event->matches(QKeySequence::Cut))
				insertText(QString{});
		}
	}
	else if (event->matches(QKeySequence::Paste))
	{
		QClipboard* clipboard = QApplication::clipboard();
		const QMimeData* mime_data = clipboard->mimeData();
		
		if (mime_data->hasText())
			insertText(clipboard->text());
	}
	else if (event->key() == Qt::Key_Tab)
		insertText(QString(QLatin1Char('\t')));
	else if (event->key() == Qt::Key_Return)
		insertText(QString(QLatin1Char('\n')));
	else if (!event->text().isEmpty() && event->text()[0].isPrint() )
		insertText(event->text());
	else
		return false;
	return true;
}