Esempio n. 1
0
void QLineEdit::mouseReleaseEvent( QMouseEvent * e )
{
    if ( d->inDoubleClick ) {
	d->inDoubleClick = FALSE;
	return;
    }

#if defined(_WS_X11_)
    if ( hasMarkedText() && echoMode() == Normal )
	copyText();
#else
    if ( style() == MotifStyle && hasMarkedText() && echoMode() == Normal )
	copyText();
#endif
    if ( dragScrolling )
	dragScrolling = FALSE;
    if ( e->button() != LeftButton )
	return;

    int margin = frame() ? 4 : 2;
    if ( !QRect( margin, margin,
		 width() - 2*margin,
		 height() - 2*margin ).contains( e->pos() ) )
	return;

    int mousePos = offset + xPosToCursorPos( &tbuf[(int)offset],
					     fontMetrics(),
					     e->pos().x() - margin,
					     width() - margin - margin );
    int m1 = markDrag;
    newMark( mousePos, FALSE );
    repaintArea( m1, mousePos );
}
Esempio n. 2
0
CMD *parseRedirect(token **lstHead, CMD *cmd)
{
	int type = (*lstHead)->type;
	*lstHead = (*lstHead)->next;
	if(*lstHead == NULL || (*lstHead)->type != SIMPLE)
	{
		//error!
		fprintf(stderr,"%s\n","No in/out contents for redirection");
		return errorCMD(cmd);
	}

	if(type == RED_IN || type == RED_HERE)
	{
		//redirection in
		cmd->fromType = type;
		cmd->fromFile = copyText((*lstHead)->text);
	}
	else
	{
		//redirection out
		cmd->toType = type;
		cmd->toFile = copyText((*lstHead)->text);
	}
	*lstHead = (*lstHead)->next;
	return cmd;
}
/*---------------------------------------------------------------------*//**
	サブ メニュー ノード クリック通知
**//*---------------------------------------------------------------------*/
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;
}
Esempio n. 4
0
void MathDisplay::buildActions()
{
	setContextMenuPolicy(Qt::ActionsContextMenu);

	act_copyText = new QAction(tr("Copy text"), this);
	connect(act_copyText, SIGNAL(triggered()), this, SLOT(copyText()));
	this->addAction(act_copyText);

	act_copyLatex = new QAction(tr("Copy LaTeX code"), this);
	connect(act_copyLatex, SIGNAL(triggered()), this, SLOT(copyLatex()));
	this->addAction(act_copyLatex);

	act_copyMml = new QAction(tr("Copy MathML code"), this);
	connect(act_copyMml, SIGNAL(triggered()), this, SLOT(copyMml()));
	this->addAction(act_copyMml);

	act_copyImage = new QAction(tr("Copy image"), this);
	connect(act_copyImage, SIGNAL(triggered()), this, SLOT(copyImage()));
	act_copyImage->setEnabled(false);
	this->addAction(act_copyImage);

	act_saveImage = new QAction(tr("Save image"), this);
	connect(act_saveImage, SIGNAL(triggered()), this, SLOT(saveImage()));
	act_saveImage->setEnabled(false);
	this->addAction(act_saveImage);
}
/*---------------------------------------------------------------------*//**
	キーボード フレーム制御
**//*---------------------------------------------------------------------*/
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;
}
Esempio n. 6
0
void QLineEdit::markWord( int pos )
{
    int i = pos - 1;
    while ( i >= 0 && isprint(tbuf.at(i)) && !isspace(tbuf.at(i)) )
	i--;
    i++;
    markAnchor = i;

    int lim = tbuf.length();
    i = pos;
    while ( i < lim && isprint(tbuf.at(i)) && !isspace(tbuf.at(i)) )
	i++;
    markDrag = i;

    int maxVis	  = lastCharVisible();
    int markBegin = minMark();
    int markEnd	  = maxMark();
    if ( markBegin < offset || markBegin > maxVis ) {
	if ( markEnd >= offset && markEnd <= maxVis ) {
	    cursorPos = markEnd;
	} else {
	    offset    = markBegin;
	    cursorPos = markBegin;
	}
    } else {
	cursorPos = markBegin;
    }
    if ( style() == MotifStyle && echoMode() == Normal )
	copyText();
    d->pmDirty = TRUE;
}
Esempio n. 7
0
CMD *parseSimple(token **lstHead)
{
	CMD *cmd = mallocCMD();
	while((*lstHead) && ((*lstHead)->type == SIMPLE || IS_RED((*lstHead)->type)))
	{
		cmd->type = SIMPLE;
		if((*lstHead)->type == SIMPLE)
		{
			//not a redirection
			cmd->argv[cmd->argc] = copyText((*lstHead)->text);
			cmd->argc++;
			cmd->argv = realloc(cmd->argv,(cmd->argc+1)*sizeof(char*));
			cmd->argv[cmd->argc] = NULL;
			*lstHead = (*lstHead)->next;
		}
		else
		{
			//redirection found
			cmd = parseRedirect(lstHead,cmd);
			if(cmd->type == ERROR)
			{
				//if error occurred in parseRedirect
				return cmd;
			}
		}			
	}

	if(cmd && cmd->type == NONE)
	{
		//case where no SIMPLE was found
		freeCMD(cmd);
		return NULL;
	}
	return cmd;
}
Esempio n. 8
0
HTMLView::HTMLView( QWidget *parentWidget, const char *widgetname, const bool DNDEnabled, const bool JScriptEnabled )
        : KHTMLPart( parentWidget, widgetname )
{
    m_instances++;
    setJavaEnabled( false );
    setPluginsEnabled( false );

    setDNDEnabled( DNDEnabled );
    setJScriptEnabled( JScriptEnabled );

    KActionCollection* ac = actionCollection();
    ac->setAutoConnectShortcuts( true );
    m_copy = KStdAction::copy( this, SLOT( copyText() ), ac, "htmlview_copy" );
    m_selectAll = KStdAction::selectAll( this, SLOT( selectAll() ), ac, "htmlview_select_all" );
    {
        KPopupMenu m;
        m_copy->plug( &m );
        m_selectAll->plug( &m );

        m_copy->unplug( &m );
        m_selectAll->unplug( &m );
    }

    connect( this, SIGNAL( selectionChanged() ), SLOT( enableCopyAction() ) );
    enableCopyAction();
}
Esempio n. 9
0
/*!
  Handles selection copying.
*/
void QLineEdit::leaveEvent( QEvent * )
{
#if defined(_WS_X11_)
    if ( style() == WindowsStyle ) {
	// X11 users are very accustomed to "auto-copy"
	copyText();
    }
#endif
}
Esempio n. 10
0
void QLineEdit::newMark( int pos, bool copy )
{
    if ( markDrag != pos || cursorPos != pos )
	d->pmDirty = TRUE;
    markDrag  = pos;
    cursorPos = pos;
    if ( copy && style() == MotifStyle && echoMode() == Normal )
	copyText(); // ### ????????????
}
Esempio n. 11
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()));

}
Esempio n. 12
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()));
}
Esempio n. 13
0
void QLineEdit::focusOutEvent( QFocusEvent * )
{
    if ( style() == WindowsStyle ) {
#if defined(_WS_X11_)
	// X11 users are very accustomed to "auto-copy"
	copyText();
#endif
	if ( focusWidget() != this ||
	   qApp->focusWidget() == 0 ||
	   qApp->focusWidget()->topLevelWidget() != topLevelWidget() )
	    deselect();
    }
    d->dragTimer.stop();
    if ( cursorOn )
	blinkSlot();
}
Esempio n. 14
0
PORTAL *dispPortalAdd(
    PORTAL_JUSTIFY just,      // How to justify the text
    int ulRow,                // upper left row where portal starts
    int ulCol,                // upper left column where portal starts
    int width,                // width of portal in columns
    int height,               // height of portal in rows
    PORTAL_TYPE type,         // TEXT or GRAPHIC
    const void *data,         // text string or bitmap data. not 0 terminated
    FONT *font,               // null for graphic data
    size_t length,            // length of data
    int scroll,               // boolean 1/0 = scroll/no scroll
    int scrollDelay)          // delay in ms between column shifts
{
    PORTAL *tmp = getPortal();

    if(tmp == 0)
    {
        setError (EDISP_RANGE, "Out of portals in portalAdd()");
        return 0;
    }

    tmp->just = just;
    tmp->type = type;
    tmp->upperLeftRow = ulRow;
    tmp->upperLeftCol = ulCol;
    tmp->width = width;
    tmp->height = height;
    tmp->scroll = scroll;
    tmp->scrollDelay = scrollDelay;
    tmp->content.text.font = font;

    if (type == PORTAL_TEXT)
        copyText (tmp, data, length);
    else if (type == PORTAL_GRAPHIC)
        copyGraphic (tmp, data, length);
    else
    {
        setError (EDISP_INVAL, "Invalid parameter passed to portalAdd()");
        portals[tmp->id] = 0;
        return 0;
    }

    return tmp;
}
Esempio n. 15
0
int dispSetPortalText (PORTAL *p, const char *t)
{
    if ((p == 0) || (t == 0))
    {
        setError (EDISP_INVAL, "Null pointer passed to dispSetPortalText()");
        return -1;
    }

    p->content.text.size = strlen (t);
    if (p->content.text.size > sizeof p->content.text.data)
        p->content.text.size = sizeof p->content.text.data;

    memset (p->content.text.data, 0, sizeof p->content.text.data);
    for (int i = 0; i < p->content.text.size; ++i)
    {
        copyText (p, t, p->content.text.size);
        //p->content.text.data[i] = t[i];
        //putchar (p->content.text.data[i]);
    }
    putchar ('\n');

    return 0;
}
Esempio n. 16
0
KJotsMain::KJotsMain(const char* name)
  : KTopLevelWidget( name )
{
  //create widgets
  f_main = new QFrame( this, "Frame_0" );
  f_main->move(0, 28);
  f_main->setMinimumSize( 500, 180 );
  f_main->setFrameStyle( 0 );

  f_text = new QFrame( f_main, "Frame_1" );
  f_text->setGeometry( 8, 72, 452, 45 );
  f_text->setFrameStyle( 50 );
  
  f_labels = new QFrame( f_main, "Frame_2" );
  f_labels->setMinimumSize( 436, 24 );
  f_labels->setFrameStyle( 0 );
  
  menubar = new KMenuBar( this, "MenuBar_1" );
  // KMenubar is not a FRAME!!! (sven)
  //menubar->setFrameStyle( 34 );
  //menubar->setLineWidth( 2 );

  s_bar = new QScrollBar( f_main, "ScrollBar_1" );
  s_bar->setMinimumSize( 452, 16 );
  s_bar->setOrientation( QScrollBar::Horizontal );
  
  me_text = new MyMultiEdit( f_text, "me_text" );
  me_text->setMinimumSize( 436, 30 );
  me_text->insertLine( "" );

  l_folder = new QLabel( f_labels, "Label_4" );
  l_folder->setMinimumSize( 68, 20 );
  l_folder->setFrameStyle( QFrame::WinPanel | QFrame::Sunken );
  l_folder->setText( "" );
  
  le_subject = new QLineEdit( f_labels, "le_subject" );
  le_subject->setMinimumSize( 56, 20 );
  le_subject->setText( "" );
  le_subject->setFocusPolicy(QWidget::ClickFocus);
  
  bg_top = new MyButtonGroup( f_main, "ButtonGroup_2" );
  bg_top->setMinimumSize( 452, 32 );
  bg_top->setFrameStyle( 49 ); 
  bg_top->setTitle( "" );
  bg_top->setAlignment( 1 );
  bg_top->lower();
  
  this->setMinimumSize(500, 211);
  
  KConfig *config = KApplication::getKApplication()->getConfig();

  config->setGroup("kjots");
  entrylist.setAutoDelete(TRUE);
  button_list.setAutoDelete(TRUE);
  folderOpen = FALSE;
  entrylist.append(new TextEntry);
  confdiag = NULL;
  subj_list = new SubjList;
  connect( this, SIGNAL(folderChanged(QList<TextEntry> *)), subj_list,
	   SLOT(rebuildList( QList<TextEntry> *)) );
  connect( this, SIGNAL(entryMoved(int)), subj_list, SLOT( select(int)) );
  connect( subj_list, SIGNAL(entryMoved(int)), this, SLOT( barMoved(int)) );
  connect( le_subject, SIGNAL(textChanged(const char *)), subj_list, 
	   SLOT(entryChanged(const char*)) );
  me_text->setEnabled(FALSE);
  le_subject->setEnabled(FALSE);
  current = 0;
  connect( s_bar, SIGNAL(valueChanged(int)), this, SLOT(barMoved(int)) );
 
  top2bottom = new QGridLayout( f_main, 4, 1, 4 );
  top2bottom->addWidget( f_text, 0, 0, AlignCenter );
  top2bottom->setRowStretch( 0, 1 );
  top2bottom->addWidget( s_bar, 1, 0, AlignCenter );
  top2bottom->addWidget( bg_top, 2, 0, AlignCenter );
  top2bottom->addWidget( f_labels, 3, 0, AlignCenter );
  top2bottom->activate();

  labels_layout = new QGridLayout( f_labels, 1, 2, 0 );
  labels_layout->addWidget( l_folder, 0, 0, AlignVCenter | AlignLeft );
  labels_layout->addWidget( le_subject, 0, 1, AlignVCenter | AlignLeft );
  labels_layout->setColStretch( 1, 1 );
  labels_layout->activate();

  QFont font_label(l_folder->fontInfo().family());
  font_label.setBold(TRUE);
  l_folder->setFont(font_label);

  f_text_layout = new QGridLayout( f_text, 2, 1, 4 );
  f_text_layout->addWidget( me_text, 0, 0, AlignCenter );
  f_text_layout->setRowStretch( 0, 1 );
  f_text_layout->activate();

  s_bar->setRange(0,0);
  s_bar->setValue(0);
  s_bar->setSteps(1,1);

  bg_top->setExclusive(TRUE);
  me_text->setFocusPolicy(QWidget::StrongFocus);

  // read hotlist
  config->readListEntry( "Hotlist", hotlist );
  while( hotlist.count() > HOT_LIST_SIZE )
    hotlist.removeLast();
  // read list of folders
  config->readListEntry( "Folders", folder_list );

  QString temp;
  folders = new QPopupMenu;
  int i = 0;
  QPushButton *temp_button;
  for( temp = folder_list.first(); !temp.isEmpty(); temp = folder_list.next(), i++ )
    { 
      folders->insertItem(temp, i); 
      if( hotlist.contains(temp) )
	{
	  temp_button = new QPushButton(temp, bg_top);
	  temp_button->setFocusPolicy(QWidget::ClickFocus);
	  temp_button->setToggleButton(TRUE);
	  temp_button->setFixedSize(BUTTON_WIDTH,24);
	  bg_top->insert(temp_button, i);
	  button_list.append(temp_button);
	}
    }
  unique_id = i+1;
  connect( folders, SIGNAL(activated(int)), this, SLOT(openFolder(int)) );
  connect( bg_top, SIGNAL(clicked(int)), this, SLOT(openFolder(int)) );

  updateConfiguration();

  // creat keyboard shortcuts
  // CTRL+Key_J := previous page
  // CTRL+Key_K := next page
  // CTRL+Key_L := show subject list
  // CTRL+Key_A := add new page
  // CTRL+Key_M := move focus

  keys = new KAccel( this ); 


  keys->insertStdItem( KAccel::New, klocale->translate("New Book") ); 


  keys->connectItem( KAccel::New, this, SLOT(createFolder()) );
  keys->connectItem( KAccel::Save , this, SLOT(saveFolder()) );
  keys->connectItem( KAccel::Quit, qApp, SLOT(quit()) );
  keys->connectItem( KAccel::Cut , me_text, SLOT(cut()) );
  keys->connectItem( KAccel::Copy , me_text, SLOT(copyText()) );
  keys->connectItem( KAccel::Paste , me_text, SLOT(paste()) );

  keys->insertItem(i18n("PreviousPage"),    "PreviousPage",    CTRL+Key_J);
  keys->insertItem(i18n("NextPage"),        "NextPage",        CTRL+Key_K);
  keys->insertItem(i18n("ShowSubjectList"), "ShowSubjectList", CTRL+Key_L);
  keys->insertItem(i18n("AddNewPage"),      "AddNewPage",      CTRL+Key_A);
  keys->insertItem(i18n("MoveFocus"),       "MoveFocus",       CTRL+Key_M);
  keys->insertItem(i18n("CopySelection"),   "CopySelection",   CTRL+Key_Y);
  keys->connectItem( "PreviousPage", this, SLOT(prevEntry()) );
  keys->connectItem( "NextPage", this, SLOT(nextEntry()) );
  keys->connectItem( "ShowSubjectList", this, SLOT(toggleSubjList()) );
  keys->connectItem( "AddNewPage", this, SLOT(newEntry()) );
  keys->connectItem( "MoveFocus", this, SLOT(moveFocus()) );
  keys->connectItem( "CopySelection", this, SLOT(copySelection()) );
  keys->readSettings();

  // create menu
  int id;
  QPopupMenu *file = new QPopupMenu;
  id = file->insertItem(klocale->translate("&New Book"), this, SLOT(createFolder()));
  keys->changeMenuAccel(file, id, KAccel::New); 

  file->insertSeparator();
  id = file->insertItem(klocale->translate("Save current book"), this, SLOT(saveFolder()) );
  keys->changeMenuAccel(file, id, KAccel::Save); 
  id = file->insertItem(klocale->translate("Save book to ascii file"), this, SLOT(writeBook()) );
  id = file->insertItem(klocale->translate("Save page to ascii file"), this, SLOT(writePage()) );
  file->insertSeparator();
  id = file->insertItem(klocale->translate("Delete current book"), this, SLOT(deleteFolder()) );
  file->insertSeparator();
  id = file->insertItem(klocale->translate("&Quit"), qApp, SLOT( quit() ));
  keys->changeMenuAccel(file, id, KAccel::Quit); 

  QPopupMenu *edit_menu = new QPopupMenu;

  id = edit_menu->insertItem(klocale->translate("C&ut"),me_text, SLOT(cut()));
  keys->changeMenuAccel(edit_menu, id, KAccel::Cut); 
  id = edit_menu->insertItem(klocale->translate("&Copy") , me_text, SLOT(copyText()) );
  keys->changeMenuAccel(edit_menu, id, KAccel::Copy); 
  id = edit_menu->insertItem(klocale->translate("&Paste"), me_text, SLOT(paste()));
  keys->changeMenuAccel(edit_menu, id, KAccel::Paste); 
  edit_menu->insertSeparator();
  id = edit_menu->insertItem(klocale->translate("&New Page"), this, SLOT(newEntry()) );
  keys->changeMenuAccel(edit_menu, id, "AddNewPage"); 
  id = edit_menu->insertItem(klocale->translate("&Delete Page"), this, SLOT(deleteEntry()) );

  QPopupMenu *options = new QPopupMenu;
  options->insertItem(klocale->translate("&Config"), this, SLOT(configure()) );
  options->insertItem(klocale->translate("Configure &Keys"), this, SLOT(configureKeys()) );

  QPopupMenu *hotlist = new QPopupMenu;
  hotlist->insertItem(klocale->translate("Add current book to hotlist"), 
		      this, SLOT(addToHotlist()) );
  hotlist->insertItem(klocale->translate("Remove current book from hotlist"),
		      this, SLOT(removeFromHotlist()) );

  menubar->insertItem( klocale->translate("&File"), file );
  menubar->insertItem( klocale->translate("&Edit"), edit_menu );
  menubar->insertItem( klocale->translate("Hot&list"), hotlist );
  menubar->insertItem( klocale->translate("&Options"), options );
  menubar->insertItem( klocale->translate("&Books"), folders );
  menubar->insertSeparator();
  QString about = "KJots 0.3.1\n\r(C) ";
  about += (QString) klocale->translate("by") +
    " Christoph Neerfeld\n\[email protected]";
  menubar->insertItem( klocale->translate("&Help"),
		       KApplication::getKApplication()->getHelpMenu(TRUE, about ) );


  config->setGroup("kjots");
  // create toolbar
  toolbar = new KToolBar(this);
  QPixmap temp_pix;
  temp_pix = global_pix_loader->loadIcon("filenew.xpm");
  toolbar->insertButton(temp_pix, 0, SIGNAL(clicked()), this,
		      SLOT(newEntry()), TRUE, i18n("New"));
  temp_pix = global_pix_loader->loadIcon("filedel.xpm");
  toolbar->insertButton(temp_pix, 1, SIGNAL(clicked()), this,
		      SLOT(deleteEntry()), TRUE, i18n("Delete"));
  temp_pix = global_pix_loader->loadIcon("back.xpm");
  toolbar->insertButton(temp_pix, 2, SIGNAL(clicked()), this,
		      SLOT(prevEntry()), TRUE, i18n("Previous"));
  temp_pix = global_pix_loader->loadIcon("forward.xpm");
  toolbar->insertButton(temp_pix, 3, SIGNAL(clicked()), this,
		      SLOT(nextEntry()), TRUE, i18n("Next"));
  toolbar->insertSeparator();
  temp_pix = global_pix_loader->loadIcon("openbook.xpm");
  toolbar->insertButton(temp_pix, 4, SIGNAL(clicked()), this,
		      SLOT(toggleSubjList()), TRUE, i18n("Subject List"));
  toolbar->insertSeparator();
  temp_pix = global_pix_loader->loadIcon("exit.xpm");
  toolbar->setBarPos( (KToolBar::BarPosition) config->readNumEntry("ToolBarPos") );
  addToolBar(toolbar);
  setView(f_main, FALSE);
  setMenu(menubar);
  enableToolBar(KToolBar::Show);

  QString last_folder = config->readEntry("LastOpenFolder");
  int nr;
  if( (nr = folder_list.find(last_folder)) >= 0 )
    openFolder(nr);
  int width, height;
  width = config->readNumEntry("Width");
  height = config->readNumEntry("Height");
  if( width < minimumSize().width() )
    width = minimumSize().width();
  if( height < minimumSize().height() )
    height = minimumSize().height();
  resize(width, height);
}
Esempio n. 17
0
void QLineEdit::keyPressEvent( QKeyEvent *e )
{
    if ( e->key() == Key_Enter || e->key() == Key_Return ) {
	QValidator * v = validator();
	if ( !v || v->validate( tbuf, cursorPos ) == QValidator::Acceptable ) {
	    emit returnPressed();
	} else if ( v ) {
	    v->fixup( tbuf );
	    if ( v->validate( tbuf, cursorPos ) == QValidator::Acceptable )
		emit returnPressed();
	}
	// ### 2.0 must fix this
	e->ignore();
	return;
    }
    if ( e->ascii() >= 32 &&
	 e->key() != Key_Delete &&
	 e->key() != Key_Backspace ) {
	QString t( 2 );
	t[0] = e->ascii();
	t[1] = '\0';
	insert( t );
	return;
    }
    int unknown = 0;
    if ( e->state() & ControlButton ) {
	switch ( e->key() ) {
	case Key_A:
	case Key_Left:
	    home( e->state() & ShiftButton );
	    break;
	case Key_B:
	    cursorLeft( e->state() & ShiftButton );
	    break;
	case Key_C:
	    if ( hasMarkedText() && echoMode() == Normal )
		copyText();
	    break;
	case Key_D:
	    del();
	    break;
	case Key_E:
	case Key_Right:
	    end( e->state() & ShiftButton );
	    break;
	case Key_F:
	    cursorRight( e->state() & ShiftButton );
	    break;
	case Key_H:
	    backspace();
	    break;
	case Key_K:
	    if ( cursorPos < (int)tbuf.length() ) {
		QString t( tbuf );
		t.detach(); // ### 2.0
		t.truncate( cursorPos );
		validateAndSet( t, cursorPos, cursorPos, cursorPos );
	    }
	    break;
	case Key_V:
	    insert( QApplication::clipboard()->text() );
	case Key_X:
	    if ( hasMarkedText() && echoMode() == Normal ) {
		copyText();
		del();
	    }
	    break;
	default:
	    unknown++;
	}
    } else {
	switch ( e->key() ) {
	case Key_Left:
	    cursorLeft( e->state() & ShiftButton );
	    break;
	case Key_Right:
	    cursorRight( e->state() & ShiftButton );
	    break;
	case Key_Backspace:
	    backspace();
	    break;
	case Key_Home:
	    home( e->state() & ShiftButton );
	    break;
	case Key_End:
	    end( e->state() & ShiftButton );
	    break;
	case Key_Delete:
	    del();
	    break;
	default:
	    unknown++;
	}
    }

    if ( unknown ) {				// unknown key
	e->ignore();
	return;
    }
}