void MainWindow::updateActions() { kDebug() << "updating actions.."; bool rekonqPage = currentTab()->page()->isOnRekonqPage(); QAction *historyBackAction = actionByName(KStandardAction::name(KStandardAction::Back)); if( rekonqPage && currentTab()->view()->history()->count() > 0 ) historyBackAction->setEnabled(true); else historyBackAction->setEnabled(currentTab()->view()->history()->canGoBack()); QAction *historyForwardAction = actionByName(KStandardAction::name(KStandardAction::Forward)); historyForwardAction->setEnabled(currentTab()->view()->history()->canGoForward()); }
bool QgsShortcutsManager::registerAction( QAction *action, const QString &defaultSequence ) { if ( mActions.contains( action ) ) return false; // already registered #ifdef QGISDEBUG // if using a debug build, warn on duplicate actions if ( actionByName( action->text() ) || shortcutByName( action->text() ) ) QgsLogger::warning( QStringLiteral( "Duplicate shortcut registered: %1" ).arg( action->text() ) ); #endif mActions.insert( action, defaultSequence ); connect( action, &QObject::destroyed, this, &QgsShortcutsManager::actionDestroyed ); QString actionText = action->text(); actionText.remove( '&' ); // remove the accelerator // load overridden value from settings QgsSettings settings; QString sequence = settings.value( mSettingsPath + actionText, defaultSequence ).toString(); action->setShortcut( sequence ); action->setToolTip( "<b>" + action->toolTip() + "</b>" ); updateActionToolTip( action, sequence ); return true; }
bool QgsShortcutsManager::setKeySequence( const QString &name, const QString &sequence ) { if ( QAction *action = actionByName( name ) ) return setKeySequence( action, sequence ); else if ( QShortcut *shortcut = shortcutByName( name ) ) return setKeySequence( shortcut, sequence ); else return false; }
bool QgsShortcutsManager::registerShortcut( QShortcut *shortcut, const QString &defaultSequence ) { #ifdef QGISDEBUG // if using a debug build, warn on duplicate actions if ( actionByName( shortcut->objectName() ) || shortcutByName( shortcut->objectName() ) ) QgsLogger::warning( QStringLiteral( "Duplicate shortcut registered: %1" ).arg( shortcut->objectName() ) ); #endif mShortcuts.insert( shortcut, defaultSequence ); connect( shortcut, &QObject::destroyed, this, &QgsShortcutsManager::shortcutDestroyed ); QString shortcutName = shortcut->objectName(); // load overridden value from settings QgsSettings settings; QString keySequence = settings.value( mSettingsPath + shortcutName, defaultSequence ).toString(); shortcut->setKey( keySequence ); return true; }
// This version of Create() is only needed till open gets frobbed to // provide data in the fstat format. // // Parses a row returned by P4 opened, of the form: // "//depot/dir/subdir/fname#9 - edit change 25 (text) by user@machine *locked*" // "//depot/x_win32/samples/rpc/README.TXT#1 - add default change (text)" // "//depot/x_win32/embedded - dash/README.TXT#1 - add default change (text)" BOOL CP4FileStats::Create(LPCTSTR openRow) { // Find the revision delimiter '#', and then scan subsequent fileRow // characters for the separator, " - ". We need to look for the // rev number first, because " - " may be embedded within the filename. CString line=openRow; int pound= line.Find(_T('#')); if(pound == -1) { ASSERT(0); return FALSE; } // doesnt look like a fileRow int separator= pound+1; int len= line.GetLength(); for( ; separator < len ; separator++) { if(line[separator]==_T(' ') && line[separator+1]==_T('-') && line[separator+2]==_T(' ')) break; } if(separator == len) { ASSERT(0); return FALSE; } // doesnt look like a fileRow m_DepotPath=line.Left(pound); // File revision - note that this is stored under haveRev, no matter which user has the // file. // note, too that rev can be 0, if the opened command returns a version #null // (so remove the assert that used to be here) // long rev=_ttol(openRow+pound+1); m_HaveRev=rev; CString info=line.Mid(separator+3); CString ModeText=info.Left(info.Find(_T(" "))); // File open action int openAction = actionByName(ModeText); // File change number info=info.Mid(ModeText.GetLength()+1); if(info.Find(_T("default"))==0) { m_OpenChangeNum=0; // default change } else { if(info.Find(_T("change"))==0) { m_OpenChangeNum=_ttoi(info.Mid(7)); } } // File type info=info.Mid(info.Find(_T("("))+1); CString TypeText=info.Left(info.Find(_T(")"))); m_HeadType = m_Type = TypeText; info=info.Mid( min( info.GetLength()-1, TypeText.GetLength() + 2)); int byStart, userLen; if( (byStart=info.Find(_T("by"))) == 0) { info=info.Mid(byStart+3); // Skip over "by " userLen=info.Find(_T(" ")); if(userLen == -1) m_OtherUsers=info; else m_OtherUsers=info.Left(userLen); if( Compare( m_OtherUsers, GET_P4REGPTR()->GetMyID()) ==0 ) { m_OtherUsers.Empty(); m_OtherOpens=0; m_MyOpenAction= (BYTE) openAction; m_HaveRev= rev; if(info.Find(_T("locked")) > 0) m_MyLock=TRUE; } else { // See if its on my client int at= m_OtherUsers.Find(_T('@')); if( at != -1 && ++at < m_OtherUsers.GetLength() ) { if( Compare( m_OtherUsers.Mid(at), GET_P4REGPTR()->GetP4Client()) ==0 ) m_OtherUserMyClient= TRUE; } else // Why didnt we find client name ASSERT(0); // Update locked and open action info m_OtherOpens=1; if(info.Find(_T("locked")) > 0) m_OtherLock=TRUE; m_OtherOpenAction= (BYTE) openAction; } } else { // didnt find "by", so its my open file m_OtherOpens=0; m_MyOpenAction= (BYTE) openAction; m_HaveRev= rev; if(info.Find(_T("locked")) > 0) m_MyLock=TRUE; } return TRUE; }
// Create from an fstat result set. BOOL CP4FileStats::Create(StrDict *client) { int i; StrPtr *str; Error err; // Get the depot name str= client->GetVar( "depotFile", &err); // name in depot ASSERT(str || err.Test()); if(err.Test()) goto badFile; m_DepotPath = CharToCString(str->Value()); // If the client path exists, note that file is in client view str= client->GetVar( "clientFile" ); if(str) { m_ClientPath = CharToCString(str->Value()); m_ClientPath.Replace(_T('/'), _T('\\')); } else { // need to determine if the client path doesn't exist or doesn't translate // we can't handle the no translation case. CString txt = FormatError(&err); if(txt.Find(_T("No Translation")) == 0) goto badFile; // there is no client path m_ClientPath=_T(""); } // Concatenate a list of all other users with the file open { char varName[] = "otherOpen "; char varNam2[] = "otherAction "; for(m_OtherOpens=m_OtherOpenAction=0; m_OtherOpens < 100; m_OtherOpens++) { _itoa(m_OtherOpens, varName+9, 10); if( (str=client->GetVar( varName )) == 0 ) break; else { if(m_OtherOpens==0) m_OtherUsers = CharToCString(str->Value()); else { m_OtherUsers+=_T("/"); m_OtherUsers+=CharToCString(str->Value()); } if (m_OtherOpenAction != F_DELETE) { _itoa(m_OtherOpens, varNam2+11, 10); if ( (str=client->GetVar( varNam2 )) != 0) { m_OtherOpenAction = actionByName(CharToCString(str->Value())); } } } } } if( (str= client->GetVar( "headRev" )) != NULL) m_HeadRev=atol(str->Value()); if( (str= client->GetVar( "haveRev" )) != NULL) m_HaveRev=atol(str->Value()); if( (str= client->GetVar( "change" )) != NULL) m_OpenChangeNum=atol(str->Value()); if( (str= client->GetVar( "headChange" )) != NULL) m_HeadChangeNum=atol(str->Value()); if( (str= client->GetVar( "headTime" )) != NULL) m_HeadTime=atol(str->Value()); if( (str= client->GetVar( "ourLock" )) != NULL) m_MyLock=TRUE; if( (str= client->GetVar( "otherLock" )) != NULL) m_OtherLock=TRUE; if( (str= client->GetVar( "type" )) != NULL) m_Type= CharToCString(str->Value()); if( (str= client->GetVar( "headType" )) != NULL) m_HeadType= CharToCString(str->Value()); if( (str= client->GetVar( "headAction" )) != NULL) { m_HeadAction = actionByName(CharToCString(str->Value())); } ASSERT(client->GetVar("headAction")==NULL || m_HeadAction); if( (str= client->GetVar( "action" )) != NULL) { m_MyOpenAction = actionByName(CharToCString(str->Value())); } ASSERT(client->GetVar("action")==NULL || m_MyOpenAction); if (!m_HaveRev && !m_HeadRev && (m_MyOpenAction == F_ADD || m_MyOpenAction == F_BRANCH)) m_HaveRev = 1; if( (str= client->GetVar( "unresolved" )) != NULL) m_Unresolved=TRUE; str= client->GetVar( "actionOwner" ); if(str) { m_ActionOwner = CharToCString(str->Value()); if (Compare( m_ActionOwner, GET_P4REGPTR()->GetP4User() ) !=0) { m_OtherUserMyClient = TRUE; m_OtherUsers = m_ActionOwner + _T('@') + GET_P4REGPTR()->GetP4Client(); } } str= client->GetVar( "digest" ); if(str) m_Digest = CharToCString(str->Value()); if( (str= client->GetVar( "fileSize" )) != NULL) m_FileSize=atol(str->Value()); // In release builds, these values may be zero for an unrecognized // file type or action, which maps to F_UNKNOWNFILETYPE or F_UNKNOWNACTION // ASSERT(client->GetVar("headType")== NULL || m_HeadType); // commented out as useless and irritating in debug version - leighb 99/11/30 ASSERT(client->GetVar("headAction")==NULL || m_HeadAction); ASSERT(client->GetVar("action")==NULL || m_MyOpenAction); return TRUE; badFile: // most likely a translation failure. Nothing to do but ignore this file. return FALSE; }
void MainWindow::initToolsMenu() { if (!m_toolsMenu) return; m_toolsMenu->menu()->clear(); m_toolsMenu->addAction(actionByName(KStandardAction::name(KStandardAction::Open))); m_toolsMenu->addAction(actionByName(KStandardAction::name(KStandardAction::SaveAs))); m_toolsMenu->addAction(actionByName(KStandardAction::name(KStandardAction::Print))); m_toolsMenu->addAction(actionByName(KStandardAction::name(KStandardAction::Find))); QAction *action = actionByName(KStandardAction::name(KStandardAction::Zoom)); action->setCheckable(true); connect (m_zoomBar, SIGNAL(visibilityChanged(bool)), action, SLOT(setChecked(bool))); m_toolsMenu->addAction(action); m_toolsMenu->addAction(actionByName(QL1S("encodings"))); m_toolsMenu->addSeparator(); m_toolsMenu->addAction(actionByName(QL1S("private_browsing"))); m_toolsMenu->addAction(actionByName(QL1S("clear_private_data"))); m_toolsMenu->addSeparator(); KActionMenu *webMenu = new KActionMenu(KIcon("applications-development-web"), i18n("Development"), this); webMenu->addAction(actionByName(QL1S("web_inspector"))); webMenu->addAction(actionByName(QL1S("page_source"))); webMenu->addAction(actionByName(QL1S("net_analyzer"))); m_toolsMenu->addAction(webMenu); m_toolsMenu->addSeparator(); action = m_bookmarksBar->toolBar()->toggleViewAction(); action->setText(i18n("Bookmarks Toolbar")); action->setIcon(KIcon("bookmarks-bar")); m_toolsMenu->addAction(action); m_toolsMenu->addAction(actionByName(QL1S("show_history_panel"))); m_toolsMenu->addAction(actionByName(QL1S("show_bookmarks_panel"))); m_toolsMenu->addAction(actionByName(KStandardAction::name(KStandardAction::FullScreen))); m_toolsMenu->addSeparator(); this->setHelpMenuEnabled(true); helpMenu()->setIcon(KIcon("help-browser")); m_toolsMenu->addAction(helpMenu()->menuAction()); m_toolsMenu->addAction(actionByName(KStandardAction::name(KStandardAction::Preferences))); }