// public
void kpMainWindow::pasteTextAt (const QString &text, const QPoint &point,
                                bool allowNewTextSelectionPointShift)
{
#if DEBUG_KP_MAIN_WINDOW && 1
    kdDebug () << "kpMainWindow::pasteTextAt(" << text
               << ",point=" << point
               << ",allowNewTextSelectionPointShift="
               << allowNewTextSelectionPointShift
               << ")" << endl;
#endif

    QApplication::setOverrideCursor (Qt::waitCursor);

    if (toolHasBegunShape ())
        tool ()->endShapeInternal ();


    if (m_document &&
        m_document->selection () &&
        m_document->selection ()->isText () &&
        m_document->selection ()->pointIsInTextArea (point))
    {
        kpSelection *sel = m_document->selection ();

        const int row = sel->textRowForPoint (point);
        const int col = sel->textColForPoint (point);

        m_viewManager->setTextCursorPosition (row, col);

        pasteText (text);
    }
    else
    {
        QPoint pointToUse = point;

        if (allowNewTextSelectionPointShift)
        {
            // TODO: In terms of doc pixels, would be inconsistent behaviour
            //       based on zoomLevel of view.
            // pointToUse -= QPoint (-view->selectionResizeHandleAtomicSize (),
            //                       -view->selectionResizeHandleAtomicSize ());
        }

        pasteText (text, true/*force new text selection*/, pointToUse);
    }

    QApplication::restoreOverrideCursor ();
}
/*---------------------------------------------------------------------*//**
	サブ メニュー ノード クリック通知
**//*---------------------------------------------------------------------*/
bool SourceEditWindow::onClickSubMenuNode(const ExecCtx* ec, MenuTreeNode* mtnodeCall, MenuTreeNode* mtnodeParent, void* objCreateParam, void* objShowParam)
{
	const VcString* nameNode = mtnodeCall->getName(); ASSERT(nameNode != 0L);
	if(nameNode->equals("Copy"))			// コピー
	{
		copyText();
		return true;
	}
	if(nameNode->equals("Paste"))			// ペースト
	{
		pasteText();
		return true;
	}
	if(nameNode->equals("ConvToJs"))		// JS に変換
	{
		VcString code;
		_txtbox->getText()->takeRawString(&code);
		Source::convToJsCode(&code);
		_txtbox->text()->setSingleString(&code);
		_txtbox->setText(_txtbox->text(), true);
		return true;
	}
	if(nameNode->equals("ConvToSs"))		// SS に変換
	{
		VcString code;
		_txtbox->getText()->takeRawString(&code);
		Source::convToSsCode(&code);
		_txtbox->text()->setSingleString(&code);
		_txtbox->setText(_txtbox->text(), true);
		return true;
	}
	return false;
}
/*---------------------------------------------------------------------*//**
	キーボード フレーム制御
**//*---------------------------------------------------------------------*/
bool SourceEditWindow::execKeyboard(ExecRes* res, const Keyboard* kbd)
{
	TxtBoxExecRes tbres;
	if(_txtbox->execKeyboardEvent(&tbres, kbd))
	{
		// コマンドの実行
		switch(tbres.getCommand())
		{
		case TxtBox::CMD_COPY:
			copyText();
			break;
		case TxtBox::CMD_PASTE:
			pasteText();
			break;
		}

		///廃止予定[2011/12/22 r-kishi]
		// ライブ実行時は2回改行で入力完了
		bool isSentReturnKey = kbd->isRepeatTrigger('\n');
		if(_actmode == ACTMODE_LIVE)
		{
			if(_isLastSentReturnKey && isSentReturnKey)
			{
				if(res != 0L)	{	res->setDone();	}
				_isDone = true;
				_isInputDone = true;	// 入力完了
			}
		}
		_isLastSentReturnKey = isSentReturnKey;
		return true;
	}
	return false;
}
Exemplo n.º 4
0
void aHistLineEdit::mousePressEvent ( QMouseEvent *e )
{
  if(e->button() == MidButton){
    emit pasteText();
  }
  else{
    QLineEdit::mousePressEvent(e);
  }
}
Exemplo n.º 5
0
void MainWindow::createActions()
{
    newAct = new QAction(tr("&New"), this);
//    newAct = QAction(QIcon(":/images/new.png"), tr("&New"), this);
    newAct->setShortcuts(QKeySequence::New);
    newAct->setStatusTip(tr("Create a new file"));
    connect(newAct, SIGNAL(triggered()), this, SLOT(newFile()));

    openAct = new QAction(tr("&Open"), this);
//    openAct = QAction(QIcon(":/images/open.png"), tr("&Open"), this);
    openAct->setShortcuts(QKeySequence::Open);
    openAct->setStatusTip(tr("Open an existing file"));
    connect(openAct, SIGNAL(triggered()), this, SLOT(open()));

    saveAct = new QAction(tr("&Save"), this);
//    saveAct = QAction(QIcon(":/images/save.png"), tr("&Save"), this);
    saveAct->setShortcuts(QKeySequence::Save);
    saveAct->setStatusTip(tr("Create a new file"));
    connect(saveAct, SIGNAL(triggered()), this, SLOT(save()));

    saveAsAct = new QAction(tr("&SaveAs"), this);
    saveAsAct->setShortcuts(QKeySequence::SaveAs);
    saveAsAct->setStatusTip(tr("Create a new file as"));
    connect(saveAsAct, SIGNAL(triggered()), this, SLOT(saveAs()));


    exitAct = new QAction(tr("&Exit"), this);
    exitAct->setShortcuts(QKeySequence::Quit);
    exitAct->setStatusTip(tr("Close the program"));
    connect(exitAct, SIGNAL(triggered()), this, SLOT(exitAll()));

    aboutAct = new QAction(tr("&About"), this);
    aboutAct->setStatusTip(tr("Show the About box"));
    connect(aboutAct, SIGNAL(triggered()), this, SLOT(about()));


    selectAllAct = new QAction(tr("&SelectAll"), this);
    selectAllAct->setShortcuts(QKeySequence::SelectAll);
    selectAllAct->setStatusTip(tr("Select and All"));
    connect(selectAllAct, SIGNAL(triggered()), this, SLOT(selectAll()));

    copyAllAct = new QAction(tr("&CopyAll"), this);
    copyAllAct->setStatusTip(tr("Select and Copy All"));
    connect(copyAllAct, SIGNAL(triggered()), this, SLOT(copyAll()));

    copyTextAct = new QAction(tr("&Copy"), this);
    copyTextAct->setShortcuts(QKeySequence::Copy);
    copyTextAct->setStatusTip(tr("Copy the text"));
    connect(copyTextAct, SIGNAL(triggered()), this, SLOT(copyText()));

    pasteTextAct = new QAction(tr("&Paste"), this);
    pasteTextAct->setShortcuts(QKeySequence::Paste);
    pasteTextAct->setStatusTip(tr("Select All"));
    connect(pasteTextAct, SIGNAL(triggered()), this, SLOT(pasteText()));

}
Exemplo n.º 6
0
void WebWidget::pasteNote(QAction *action)
{
	if (action && action->data().isValid())
	{
		BookmarksItem *note = NotesManager::getModel()->bookmarkFromIndex(action->data().toModelIndex());

		if (note)
		{
			pasteText(note->data(BookmarksModel::DescriptionRole).toString());
		}
	}
}
Exemplo n.º 7
0
Window::Window(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::Window)
{
    clipboard = QApplication::clipboard();
    ui->setupUi(this);
    abtdlg = new AboutDialog(this);
    connect(ui->bCopy, SIGNAL(clicked()), this, SLOT(copyText()));
    connect(ui->bPaste, SIGNAL(clicked()), this, SLOT(pasteText()));
    connect(ui->bEncode, SIGNAL(clicked()), this, SLOT(encodeText()));
    connect(ui->bDecode, SIGNAL(clicked()), this, SLOT(decodeText()));
    connect(ui->bmd5, SIGNAL(clicked()), this, SLOT(getmd5()));
    connect(ui->bAbout, SIGNAL(clicked()), abtdlg, SLOT(show()));
    connect(ui->bExit, SIGNAL(clicked()), qApp, SLOT(quit()));
}
void GuiTextEditCtrl::onPaste()
{           
   //first, make sure there's something in the clipboard to copy...
   const UTF8 *clipboard = Platform::getClipboard();
   if(dStrlen(clipboard) <= 0)
      return;

   //save the current state
   saveUndoState();

   //delete anything hilited
   if (mBlockEnd > 0)
   {
      mTextBuffer.cut(mBlockStart, mBlockEnd - mBlockStart);
      mCursorPos = mBlockStart;
      mBlockStart = 0;
      mBlockEnd = 0;
   }

   // We'll be converting to UTF16, and maybe trimming the string,
   // so let's use a StringBuffer, for convinience.
   StringBuffer pasteText(clipboard);

   // Space left after we remove the highlighted text
   S32 stringLen = mTextBuffer.length();

   // Trim down to fit in a buffer of size mMaxStrLen
   S32 pasteLen = pasteText.length();

   if(stringLen + pasteLen > mMaxStrLen)
   {
      pasteLen = mMaxStrLen - stringLen;

      pasteText.cut(pasteLen, pasteText.length() - pasteLen);
   }

   if (mCursorPos == stringLen)
   {
      mTextBuffer.append(pasteText);
   }
   else
   {
      mTextBuffer.insert(mCursorPos, pasteText);
   }

   mCursorPos += pasteLen;
}
/**
 *	Processes key events, handling advanced editing commands. Advance editing
 *	commands are ignored if the advancedEditing flag is set to false. Bellow
 *	are the supported commands:
 *
 *	CTRL + <-		Go to beginning of word
 *	CTRL + ->		Go to end of word
 *	CTRL + A		Go to beginning of line (same as HOME)
 *	CTRL + E		Go to end word (same as END)
 *	CTRL + D		Delete character to the right (same as DELETE)
 *	CTRL + H		Delete character to the left (same as BACKSPACE)
 *	CTRL + K		Delete line to right of cursor (copies to clipboard)
 *	CTRL + U		Delete line to left of cursor (copies to clipboard)
 *	CTRL + [R|DEL]	Delete word to right of cursor (copies to clipboard)
 *	CTRL + [W|BS]	Delete word to left of cursor (copies to clipboard)
 *	CTRL + [Y|INS]	Paste clipboard contents
 */
bool LineEditor::processAdvanceEditKeys( KeyEvent event )
{
	if (!this->advancedEditing_) 
	{
		return false;
	}

	bool isHandled = false;
	if (event.isCtrlDown()) 
	{
		isHandled = true;
		switch (event.key())
		{
		case KeyEvent::KEY_LEFTARROW:
		case KeyEvent::KEY_JOY2:	// dpad left
			cx_ = curWordStart( cx_ );
			break;

		case KeyEvent::KEY_RIGHTARROW:
		case KeyEvent::KEY_JOY3:	// dpad right
			cx_ = curWordEnd( cx_ );
			break;

		case KeyEvent::KEY_A:
			cx_ = 0;
			break;

		case KeyEvent::KEY_E:
			cx_ = editString_.length();
			break;

		case KeyEvent::KEY_D:
			if ( cx_ < (int)editString_.length( ) )
			{
				deleteChar( cx_ );
			}
			break;

		case KeyEvent::KEY_H:
			if ( cx_ > 0 )
			{
				cx_--;
				deleteChar( cx_ );
			}
			break;

		case KeyEvent::KEY_K:
			clipBoard_ = cutText( cx_, editString_.length() );
			break;

		case KeyEvent::KEY_U:
			clipBoard_ = cutText( 0, cx_ );
			cx_ = 0;
			break;

		case KeyEvent::KEY_W:
		case KeyEvent::KEY_BACKSPACE:
		{
			int wordStart = curWordStart( cx_ );
			clipBoard_ = cutText( wordStart, cx_ );
			cx_ = wordStart;
			break;
		}

		case KeyEvent::KEY_R:
		case KeyEvent::KEY_DELETE:
		{
			clipBoard_ = cutText( cx_, curWordEnd( cx_ ) );
			break;
		}

		case KeyEvent::KEY_Y:
		case KeyEvent::KEY_INSERT:
			cx_ = pasteText( cx_, clipBoard_ );
			break;

		default:
			isHandled = false;
			break;
		}
	}	
	return isHandled;
}
Exemplo n.º 10
0
//creates an address object on the create tab
void MultisigDialog::on_addAddressButton_clicked()
{
    //max addresses 15
    if(ui->addressList->count() > 14){
        ui->addMultisigStatus->setStyleSheet("QLabel { color: red; }");
        ui->addMultisigStatus->setText(tr("Maximum possible addresses reached. (16)"));
        return;
    }

    QSizePolicy sizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
    sizePolicy.setHorizontalStretch(0);
    sizePolicy.setVerticalStretch(0);
    QFrame* addressFrame = new QFrame();
    sizePolicy.setHeightForWidth(addressFrame->sizePolicy().hasHeightForWidth());
    addressFrame->setSizePolicy(sizePolicy);
    addressFrame->setFrameShape(QFrame::StyledPanel);
    addressFrame->setFrameShadow(QFrame::Raised);
    addressFrame->setObjectName(QStringLiteral("addressFrame"));

    QVBoxLayout* frameLayout = new QVBoxLayout(addressFrame);
    frameLayout->setSpacing(1);
    frameLayout->setObjectName(QStringLiteral("frameLayout"));
    frameLayout->setContentsMargins(6, 6, 6, 6);

    QHBoxLayout* addressLayout = new QHBoxLayout();
    addressLayout->setSpacing(0);
    addressLayout->setObjectName(QStringLiteral("addressLayout"));

    QLabel* addressLabel = new QLabel(addressFrame);
    addressLabel->setObjectName(QStringLiteral("addressLabel"));
    addressLabel->setText(QApplication::translate("MultisigDialog", strprintf("Address / Key %i:", ui->addressList->count()+1).c_str() , 0));
    addressLayout->addWidget(addressLabel);

    QValidatedLineEdit* address = new QValidatedLineEdit(addressFrame);
    address->setObjectName(QStringLiteral("address"));
    addressLayout->addWidget(address);

    QPushButton* addressBookButton = new QPushButton(addressFrame);
    addressBookButton->setObjectName(QStringLiteral("addressBookButton"));
    QIcon icon3;
    icon3.addFile(QStringLiteral(":/icons/address-book"), QSize(), QIcon::Normal, QIcon::Off);
    addressBookButton->setIcon(icon3);
    addressBookButton->setAutoDefault(false);
    connect(addressBookButton, SIGNAL(clicked()), this, SLOT(addressBookButtonReceiving()));

    addressLayout->addWidget(addressBookButton);

    QPushButton* addressPasteButton = new QPushButton(addressFrame);
    addressPasteButton->setObjectName(QStringLiteral("addressPasteButton"));
    QIcon icon4;
    icon4.addFile(QStringLiteral(":/icons/editpaste"), QSize(), QIcon::Normal, QIcon::Off);
    addressPasteButton->setIcon(icon4);
    addressPasteButton->setAutoDefault(false);
    connect(addressPasteButton, SIGNAL(clicked()), this, SLOT(pasteText()));

    addressLayout->addWidget(addressPasteButton);

    QPushButton* addressDeleteButton = new QPushButton(addressFrame);
    addressDeleteButton->setObjectName(QStringLiteral("addressDeleteButton"));
    QIcon icon5;
    icon5.addFile(QStringLiteral(":/icons/remove"), QSize(), QIcon::Normal, QIcon::Off);
    addressDeleteButton->setIcon(icon5);
    addressDeleteButton->setAutoDefault(false);
    connect(addressDeleteButton, SIGNAL(clicked()), this, SLOT(deleteFrame()));

    addressLayout->addWidget(addressDeleteButton);
    frameLayout->addLayout(addressLayout);

    ui->addressList->addWidget(addressFrame);
}
Exemplo n.º 11
0
// public slot
void kpMainWindow::slotPaste ()
{
#if DEBUG_KP_MAIN_WINDOW && 1
    kdDebug () << "kpMainWindow::slotPaste() CALLED" << endl;
#endif

    // sync: restoreOverrideCursor() in all exit paths
    QApplication::setOverrideCursor (Qt::waitCursor);

    if (toolHasBegunShape ())
        tool ()->endShapeInternal ();


    if (!::HasSomethingToPasteWithDialogIfNot (this))
    {
        QApplication::restoreOverrideCursor ();
        return;
    }


    //
    // Acquire the pixmap
    //

    QMimeSource *ms = QApplication::clipboard ()->data (QClipboard::Clipboard);
    if (!ms)
    {
        kdError () << "kpMainWindow::slotPaste() without mimeSource" << endl;
        QApplication::restoreOverrideCursor ();
        return;
    }

    kpSelection sel;
    QString text;
    if (kpSelectionDrag::decode (ms, sel/*ref*/, pasteWarnAboutLossInfo ()))
    {
        sel.setTransparency (selectionTransparency ());
        paste (sel);
    }
    else if (QTextDrag::decode (ms, text/*ref*/))
    {
        pasteText (text);
    }
    else
    {
        QApplication::restoreOverrideCursor ();

        kdDebug () << "kpMainWindow::slotPaste() could not decode selection" << endl;
        kdDebug () << "\tFormats supported:" << endl;
        for (int i = 0; ms->format (i); i++)
        {
            kdDebug () << "\t\t" << i << ":" << ms->format (i) << endl;
        }

        // TODO: fix Klipper
        KMessageBox::sorry (this,
            i18n ("<qt><p>KolourPaint cannot paste the contents of"
                  " the clipboard as the data unexpectedly disappeared.</p>"

                  "<p>This usually occurs if the application which was"
                  " responsible"
                  " for the clipboard contents has been closed.</p></qt>"),
            i18n ("Cannot Paste"));

        // TODO: PROPAGATE: interprocess
        if (KMainWindow::memberList)
        {
        #if DEBUG_KP_MAIN_WINDOW
            kdDebug () << "\thave memberList" << endl;
        #endif

            for (QPtrList <KMainWindow>::const_iterator it = KMainWindow::memberList->begin ();
                 it != KMainWindow::memberList->end ();
                 it++)
            {
                kpMainWindow *mw = dynamic_cast <kpMainWindow *> (*it);

                if (!mw)
                {
                    kdError () << "kpMainWindow::slotPaste() given fake kpMainWindow: " << (*it) << endl;
                    continue;
                }
            #if DEBUG_KP_MAIN_WINDOW
                kdDebug () << "\t\tmw=" << mw << endl;
            #endif

                mw->slotEnablePaste ();
            }
        }

        return;
    }

    QApplication::restoreOverrideCursor ();
}