void CMailViewPlugins::Configure() { FarMenu mnu( MMailboxes ); FarIntArray Indices; for ( int i = 0; i < m_Libs.Count(); i ++ ) { FarString Name = CMailbox::getLongName( (HINSTANCE)m_Libs[ i ] ); if ( Name.IsEmpty() ) Name = CMailbox::getShortName( (HINSTANCE)m_Libs[ i ] ); if ( Name.IsEmpty() ) Name = FarFileName( m_Names[ i ] ).GetName(); mnu.AddItem( Name )->SetData( Indices.Add( i ) ); } FarMenu::PItem Item; while ( ( Item = mnu.Show() ) != NULL ) { int nIdx = Indices[ Item->GetData() ]; FarString Default = CMailbox::getFilesMasks( (HINSTANCE)m_Libs[ nIdx ] ); FarString Current = m_Masks[ nIdx ]; if ( Current.IsEmpty() ) Current = Default; if ( ConfigureFileMasksDlg( Item->GetText(), Default, Current ) ) { m_Masks.Insert( nIdx, Current ); m_Masks.Delete( nIdx + 1 ); } mnu.SelectItem( Item ); } }
void FTP::InsertToQueue(void) { static LPCSTR strings[] = { FMSG(MQISingle), FMSG(MQIFTP), FMSG(MQIAnother), NULL }; FP_Menu mnu(strings); int sel; LPCSTR err; FTPUrl tmp; do { sel = mnu.Execute(FMSG(MQAddTitle),FMENU_WRAPMODE,NULL,"FTPQueueAddItem"); if(sel == -1) return; err = NULL; switch(sel) { case 0: UrlInit(&tmp); if(EditUrlItem(&tmp)) { AddToQueque(&tmp); return; } break; case 1: err = InsertCurrentToQueue(); if(!err && GetLastError() != ERROR_CANCELLED) return; break; case 2: err = InsertAnotherToQueue(); if(!err && GetLastError() != ERROR_CANCELLED) return; break; } if(err) { static LPCSTR itms[] = { FMSG(MQErrAdding), NULL, FMSG(MOk) }; itms[1] = err; FMessage(FMSG_WARNING,NULL,itms,3,1); } } while(true); }
void CColorCfg::Configure() { FarMenu mnu( MColors ); mnu.AddItem( MCfg_clNormal )->SetData( iclNormal ); mnu.AddItem( MCfg_clBold )->SetData( iclBold ); mnu.AddItem( MCfg_clItalic )->SetData( iclItalic ); mnu.AddItem( MCfg_clUnderline )->SetData( iclUnderline ); mnu.AddItem( MCfg_clBoldItalic )->SetData( iclBoldItalic ); mnu.AddItem( MCfg_clBoldUnderline )->SetData( iclBoldUnderline ); mnu.AddItem( MCfg_clItalicUnderline )->SetData( iclItalicUnderline ); mnu.AddItem( MCfg_clBoldItalicUnderline )->SetData( iclBoldItalicUnderline ); mnu.AddItem( MCfg_clReverse )->SetData( iclReverse ); mnu.AddItem( MCfg_clReverseBold )->SetData( iclReverseBold ); mnu.AddItem( MCfg_clReverseItalic )->SetData( iclReverseItalic ); mnu.AddItem( MCfg_clReverseUnderline )->SetData( iclReverseUnderline ); mnu.AddItem( MCfg_clReverseBoldItalic )->SetData( iclReverseBoldItalic ); mnu.AddItem( MCfg_clReverseBoldUnderline )->SetData( iclReverseBoldUnderline ); mnu.AddItem( MCfg_clReverseItalicUnderline )->SetData( iclReverseItalicUnderline ); mnu.AddItem( MCfg_clReverseBoldItalicUnderline )->SetData( iclReverseBoldItalicUnderline ); mnu.AddSeparator(); mnu.AddItem( MCfg_clKludges )->SetDisabled(); mnu.AddItem( MCfg_clQuotesEven )->SetData( iclQuotesEven ); mnu.AddItem( MCfg_clQuotesOdd )->SetData( iclQuotesOdd ); mnu.AddItem( MCfg_clSignature )->SetData( iclSignature ); mnu.AddItem( MCfg_clOrigin )->SetData( iclOrigin ); mnu.AddItem( MCfg_clTearline )->SetData( iclTearline ); mnu.AddItem( MCfg_clTagline )->SetData( iclTagline ); mnu.AddItem( Mcfg_clHyperlink )->SetData( iclHyperlink ); mnu.AddSeparator( MCfg__Window ); mnu.AddItem( MCfg_clTitle )->SetData( iclBorderTitle ); mnu.AddItem( MCfg_clBorder )->SetData( iclBorder ); mnu.AddItem( MCfg_clHeaderLines )->SetData( iclHeaderLine ); mnu.AddItem( MCfg_clHeaderEdit )->SetData( iclHeaderEdit ); mnu.AddItem( MCfg_clHeaderEditSel )->SetData( iclHeaderEditSel ); mnu.AddItem( MCfg_clDateTime )->SetData( iclDateTime ); FarMenu::PItem Item; while ( ( Item = mnu.Show() ) != NULL ) { ShowConsoleCursor( TRUE ); int idx = Item->GetData(); CFarColorDialog dlg( m_Palette[ idx ] ); if ( dlg.Execute() ) m_Palette[ idx ] = dlg.GetColorValue(); mnu.SelectItem( Item ); } }
void CViewCfg::Configure() { FarMenu mnu( MViewer ); mnu.AddItem( MColors )->SetData( (DWORD)&m_Colors ); mnu.AddItem( MViewCfg_HyperView )->SetData( (DWORD)&m_HTMLFilter ); mnu.AddItem( MViewCfg_Templates )->SetData( (DWORD)&m_Templates ); FarMenu::PItem Item; while ((Item = mnu.Show()) != NULL) { if (Item->GetData()) ((CMailViewCfg*)Item->GetData())->Configure(); mnu.SelectItem(Item); } }
bool WebView::popupSpellMenu(QContextMenuEvent *event) { // return false if not handled if (!ReKonfig::automaticSpellChecking()) return false; QWebElement element(m_contextMenuHitResult.element()); if (element.isNull()) return false; int selStart = element.evaluateJavaScript("this.selectionStart").toInt(); int selEnd = element.evaluateJavaScript("this.selectionEnd").toInt(); if (selEnd != selStart) return false; // selection, handle normally // No selection - Spell Checking only // Get word QString text = element.evaluateJavaScript("this.value").toString(); QRegExp ws("\\b"); int s1 = text.lastIndexOf(ws, selStart); int s2 = text.indexOf(ws, selStart); QString word = text.mid(s1, s2 - s1).trimmed(); // sanity check if (word.isEmpty()) return false; kDebug() << s1 << ":" << s2 << ":" << word << ":"; Sonnet::Speller spellor; if (spellor.isCorrect(word)) return false; // no need to popup spell menu // find alternates QStringList words = spellor.suggest(word); // Construct popup menu QMenu mnu(this); // Add alternates if (words.isEmpty()) { QAction *a = mnu.addAction(i18n("No suggestions for %1", word)); a->setEnabled(false); } else { QStringListIterator it(words); while (it.hasNext()) { QString w = it.next(); QAction *aWord = mnu.addAction(w); aWord->setData(w); } } // Add dictionary options mnu.addSeparator(); QAction *aIgnore = mnu.addAction(i18n("Ignore")); QAction *aAddToDict = mnu.addAction(i18n("Add to Dictionary")); QAction *aSpellChoice = mnu.exec(event->globalPos()); if (aSpellChoice) { if (aSpellChoice == aAddToDict) spellor.addToPersonal(word); else if (aSpellChoice == aIgnore) { // Ignore :) } else { // Choose a replacement word QString w = aSpellChoice->data().toString(); if (!w.isEmpty()) { // replace word QString script(QL1S("this.value=this.value.substring(0,")); script += QString::number(s1); script += QL1S(") + \'"); script += w.replace('\'', "\\\'"); // Escape any Quote marks in replacement word script += QL1C('\'') + QL1S("+this.value.substring("); script += QString::number(s2); script += QL1C(')'); element.evaluateJavaScript(script); // reposition cursor element.evaluateJavaScript("this.selectionEnd=this.selectionStart=" + QString::number(selStart) + QL1C(';')); } } } return true; }