KDEpasswd2Dialog::KDEpasswd2Dialog(const char *oldpass, QCString user) : KPasswordDialog(NewPassword, false, 0) { m_Pass = oldpass; m_User = user; setCaption(i18n("Change Password")); if(m_User.isEmpty()) setPrompt(i18n("Please enter your new password:"******"Please enter the new password for user <b>%1</b>:").arg(m_User)); }
//Reset the console void pConsole::reset() { clear(); setTextInteractionFlags( Qt::TextSelectableByMouse | Qt::TextSelectableByKeyboard | Qt::LinksAccessibleByMouse | Qt::LinksAccessibleByKeyboard | Qt::TextEditable ); setUndoRedoEnabled( false ); setTabStopWidth( 30 ); QFont font = QFont( "Bitstream Vera Sans Mono", 11 ); font.setBold( true ); setFont( font ); QPalette pal = viewport()->palette(); pal.setColor( viewport()->backgroundRole(), QColor( Qt::black ) ); pal.setColor( viewport()->foregroundRole(), QColor( Qt::white ) ); viewport()->setPalette( pal ); mColors[ ctCommand ] = Qt::white; mColors[ ctError ] = Qt::red; mColors[ ctOutput ] = Qt::blue; mColors[ ctCompletion ] = Qt::green; mRecordedScript.clear(); mTypedCommand.clear(); setHistory( QStringList() ); setPromptVisible( true ); setPrompt( "@:/> " ); }
void GameMenu::skillClicked(int n) { if (skills.size() == 0 || skills[n] == NULL) { return; } if (skills[n]->cdNow() != skills[n]->cdMax()) { setPrompt("Waiting For CoolDown: " + skills[n]->objectName()); } else { emit skillUsed(n); } }
ManageFolderAlertsDialog::ManageFolderAlertsDialog( int folderId ) : ManageAlertsDialog( folderId ), m_folderId( folderId ) { FolderEntity folder = FolderEntity::find( folderId ); setPrompt( tr( "Edit alert settings for folder <b>%1</b>:" ).arg( folder.name() ) ); AlertsModel* model = new AlertsModel( this ); model->initializeFolder( folderId ); initializeList( model ); }
ManageGlobalAlertsDialog::ManageGlobalAlertsDialog( int typeId ) : ManageAlertsDialog( 0 ), m_typeId( typeId ) { TypeEntity type = TypeEntity::find( typeId ); setPrompt( tr( "Edit alert settings for type <b>%1</b>:" ).arg( type.name() ) ); AlertsModel* model = new AlertsModel( this ); model->initializeGlobalList( typeId ); initializeList( model ); }
bool JPWiFly::getPrompt() { bool res; if (!gotPrompt) { DPRINT(F("setPrompt\n\r")); res = setPrompt(); if (!res) DPRINT(F("setPrompt failed")); } else { DPRINT(F("getPrompt \"")); DPRINT(prompt); DPRINT("\"\n\r"); res = buffer.readTo(prompt.c_str()); } return res; }
void QConsoleWidget::endEvals() { /* 当此函栈反解的时候eval才结束 提前结束eval会出现逻辑错误 */ class EndEvalsLock__ { QConsoleWidget * __this_0_; public: EndEvalsLock__(QConsoleWidget * _t_): __this_0_(_t_){ __this_0_->isEvaling_ = true; } ~EndEvalsLock__() { __this_0_->isEvaling_ = false; } }; EndEvalsLock__ __lock__this__(this); bool need_update_charFormate__ = false; do{//: get all command information here auto doc_ = this->document(); doc_->clearUndoRedoStacks(); auto block_ = doc_->findBlock( this->promptEndPos_); /* 当clear and save 时调用 */ if (block_.isValid() == false) { need_update_charFormate__ = true; break; } { QTextCursor tc_( block_ ); auto bf_ = block_.blockFormat(); bf_.setTextIndent(0); tc_.setBlockFormat( bf_ ); this->setTextCursor(tc_); } } while (0); setPrompt( getPrompt() ); this->setUndoRedoEnabled(true); _pf<void, EnableActions>(this); if ( need_update_charFormate__ ) { this->updateCharFormat(); } }
MkSShellConsole::MkSShellConsole( QWidget* parent ) : pConsole( parent ) { setWindowTitle( "MkS Shell" ); setColor( ctCommand, Qt::white ); setColor( ctError, Qt::red ); setColor( ctOutput, Qt::green ); setColor( ctCompletion, Qt::gray ); clear(); setPrompt( "MkS:/> " ); addAvailableCommand( MkSShellInterpreter::instance( this ) ); }
RemoteSessionContext::RemoteSessionContext( SVN::Pool &pool, const char* configDirectory, const char* usernameStr, const char* passwordStr, Prompter::UniquePtr prompter, jobject jcfgcb, jobject jtunnelcb) : OperationContext(pool), m_raCallbacks(NULL) { setConfigDirectory(configDirectory); if (usernameStr != NULL) username(usernameStr); if (passwordStr != NULL) password(passwordStr); setPrompt(prompter); setConfigEventHandler(jcfgcb); setTunnelCallback(jtunnelcb); /* * Setup callbacks */ SVN_JNI_ERR(svn_ra_create_callbacks(&m_raCallbacks, m_pool->getPool()), ); m_raCallbacks->auth_baton = getAuthBaton(pool); m_raCallbacks->cancel_func = checkCancel; m_raCallbacks->get_client_string = clientName; m_raCallbacks->progress_baton = NULL; m_raCallbacks->progress_func = progress; /* * JNI RA layer does not work with WC so all WC callbacks are set to NULL */ m_raCallbacks->get_wc_prop = NULL; m_raCallbacks->invalidate_wc_props = NULL; m_raCallbacks->push_wc_prop = NULL; m_raCallbacks->set_wc_prop = NULL; /* * Don't set deprecated callback */ m_raCallbacks->open_tmp_file = NULL; if (m_jtunnelcb) { m_raCallbacks->check_tunnel_func = checkTunnel; m_raCallbacks->open_tunnel_func = openTunnel; m_raCallbacks->tunnel_baton = m_jtunnelcb; } }
//#i. cd <directory> - change current default directory to <directory> //#If the <directory> argument is not present, report the current //#directory. If the directory does not exist an appropriate error //#should be reported. This command should also change the PWD //#environment variable. int cd(char **args){ /*check for additional arguments, if none, print current directory*/ if(args[1] == NULL){ /*fork/exec statement--case 0 is the child process, default is the parent, -1 is an error*/ switch(childPID = fork()){ case -1: debug("Fork error"); break; case 0: execlp("pwd", "pwd", NULL); exit(-1); default: if(!noWait) waitpid(childPID, &status, WUNTRACED); } return childPID; //return success or failure } /*Execution should not reach this point unless other arguments were passed*/ /*check target directory*/ if(chdir(args[1]) == 0){ /*set PWD variable to new directory*/ setPrompt(); debug("Allocating space for newPWD"); debug("Current cwd:"); debug(cwd); /*allocate memory needed for newPWD, store full string, then push to environment variables*/ /*cwd should contain five fewer characters than required for the new PWD at this point*/ newPWD = (char *)malloc(sizeof(char) * (strlen(cwd) +5)); debug("Concatenating \'PWD=\' to newPWD"); strcat(newPWD, "PWD="); debug("Concatenating cwd to newPWD"); strcat(newPWD, cwd); putenv(newPWD); //oh god i think this is a memory leak...gotta fix that someday }else{ /*Executes if target directory does not exist or is not accessible*/ puts("That directory does not exist or cannot be accessed."); return -1; //return error } return 0; //return success }
MetadataDialog::MetadataDialog( AttributeType type, QWidget* parent ) : CommandDialog( parent ), m_type( type ) { AttributeHelper helper; setWindowTitle( tr( "Attribute Details" ) ); setPromptPixmap( IconLoader::pixmap( "status-info", 22 ) ); setPrompt( tr( "Specify details of <b>%1</b> attribute:" ).arg( helper.typeName( type ) ) ); QVBoxLayout* layout = new QVBoxLayout(); m_editor = MetadataEditorFactory::createMetadataEditor( type, this, this ); layout->addWidget( m_editor->widget() ); setContentLayout( layout, m_editor->isFixedHeight() ); }
int AmPromptCollection::configureModule(AmConfigReader& cfg, vector<pair<string, string> >& announcements, const char* mod_name) { int res = 0; for (vector<pair<string, string> >::iterator it= announcements.begin(); it != announcements.end(); it++) { string fname = cfg.getParameter(it->first, ""); if (fname.empty()){ WARN("using default file '%s' for '%s' prompt in '%s' module\n", it->second.c_str(), it->first.c_str(), mod_name); fname = it->second; } if (0 != setPrompt(it->first, fname, mod_name)) res = -1; } return res; }
static void preSpawn( void ) { info *cinfo; clockActive = EditFlags.ClockActive; EditFlags.ClockActive = false; #ifndef __WIN__ FiniColors(); if( !EditFlags.LineDisplay ) { ClearScreen(); } #endif /* * after a system command, all files could potentially have their * read/write attributes changed */ for( cinfo = InfoHead; cinfo != NULL; cinfo = cinfo->next ) { cinfo->CurrentFile->check_readonly = true; } setPrompt(); }
MembersDialog::MembersDialog( int projectId ) : InformationDialog( NULL, Qt::Window ), m_projectId( projectId ) { ProjectEntity project = ProjectEntity::find( projectId ); QAction* action; action = new QAction( IconLoader::icon( "user-new" ), tr( "&Add Members..." ), this ); action->setShortcut( QKeySequence::New ); connect( action, SIGNAL( triggered() ), this, SLOT( addMember() ) ); setAction( "addMember", action ); action = new QAction( IconLoader::icon( "edit-access" ), tr( "&Change Access..." ), this ); connect( action, SIGNAL( triggered() ), this, SLOT( changeAccess() ) ); setAction( "changeAccess", action ); action = new QAction( IconLoader::icon( "edit-delete" ), tr( "&Remove Members" ), this ); action->setShortcut( QKeySequence::Delete ); connect( action, SIGNAL( triggered() ), this, SLOT( removeMember() ) ); setAction( "removeMember", action ); setDefaultMenuAction( "menuMember", "changeAccess" ); loadXmlUiFile( ":/resources/membersdialog.xml" ); XmlUi::Builder* builder = new XmlUi::Builder( this ); builder->addClient( this ); setWindowTitle( tr( "Manage Permissions" ) ); setPromptPixmap( IconLoader::pixmap( "edit-access", 22 ) ); setPrompt( tr( "Edit permissions of project <b>%1</b>:" ).arg( project.name() ) ); QVBoxLayout* layout = new QVBoxLayout(); QGroupBox* globalGroup = new QGroupBox( tr( "Global Access" ), this ); layout->addWidget( globalGroup ); QHBoxLayout* globalLayout = new QHBoxLayout( globalGroup ); m_globalEdit = new QLineEdit( globalGroup ); m_globalEdit->setReadOnly( true ); globalLayout->addWidget( m_globalEdit ); QPushButton* globalButton = new QPushButton( tr( "Change..." ), globalGroup ); globalButton->setIcon( IconLoader::icon( "edit-modify" ) ); globalButton->setIconSize( QSize( 16, 16 ) ); globalLayout->addWidget( globalButton ); connect( globalButton, SIGNAL( clicked() ), this, SLOT( changeGlobalAccess() ) ); layout->addSpacing( 5 ); QVBoxLayout* membersLayout = new QVBoxLayout(); membersLayout->setSpacing( 4 ); layout->addLayout( membersLayout ); XmlUi::ToolStrip* strip = new XmlUi::ToolStrip( this ); builder->registerToolStrip( "stripMembers", strip ); membersLayout->addWidget( strip ); m_list = new QTreeView( this ); membersLayout->addWidget( m_list ); TreeViewHelper helper( m_list ); helper.initializeView( TreeViewHelper::MultiSelect ); m_list->sortByColumn( 0, Qt::AscendingOrder ); m_model = new MembersModel( projectId, this ); m_list->setModel( m_model ); helper.loadColumnWidths( "MembersDialogWidths", QList<int>() << 150 << 150 ); connect( m_list->selectionModel(), SIGNAL( selectionChanged( const QItemSelection&, const QItemSelection& ) ), this, SLOT( updateActions() ) ); connect( m_list, SIGNAL( doubleClicked( const QModelIndex& ) ), this, SLOT( doubleClicked( const QModelIndex& ) ) ); connect( m_list, SIGNAL( customContextMenuRequested( const QPoint& ) ), this, SLOT( listContextMenu( const QPoint& ) ) ); connect( m_model, SIGNAL( layoutChanged() ), this, SLOT( updateActions() ) ); connect( m_model, SIGNAL( modelReset() ), this, SLOT( updateActions() ) ); setContentLayout( layout, false ); resize( 350, 450 ); dataManager->addObserver( this ); updateGlobalAccess(); updateActions(); }
Smb4KPasswordDialog::Smb4KPasswordDialog(Smb4KBasicNetworkItem* networkItem, const QMap<QString,QString> &knownLogins, QWidget* parent) : KPasswordDialog(parent, KPasswordDialog::ShowUsernameLine) { m_item = networkItem; switch (m_item->type()) { case Host: { Smb4KHost *host = static_cast<Smb4KHost *>(m_item); if (host) { setUsername(host->login()); setPassword(host->password()); setPrompt(i18n("<qt>Please enter a username and a password for the host <b>%1</b>.</qt>", host->hostName())); } else { // Do nothing } break; } case Share: { Smb4KShare *share = static_cast<Smb4KShare *>(m_item); if (share) { // Enter authentication information into the dialog if (!knownLogins.isEmpty()) { setKnownLogins(knownLogins); } else { setUsername(share->login()); setPassword(share->password()); } if (!share->isHomesShare()) { setPrompt(i18n("<qt>Please enter a username and a password for the share <b>%1</b>.</qt>", share->unc())); } else { setPrompt(i18n("<qt>Please enter a username and a password for the share <b>%1</b>.</qt>", share->homeUNC())); } } else { // Do nothing } break; } default: { break; } } connect(this, SIGNAL(gotUsernameAndPassword(QString,QString,bool)), SLOT(slotGotUsernameAndPassword(QString,QString,bool))); }
void OVAFSearchContext::setLog(OVTextBuffer* composingText, OVLoaderService* loaderService) { if (!m_logging) return; setPrompt(composingText, loaderService); string locale = loaderService->locale(); vector<string> localizedSearchTypeNames; if (m_searchType == 0 ) { if (locale == "zh_TW" || locale == "zh-Hant") { #ifndef _MSC_VER loaderService->setPromptDescription(string("請輸入您想查詢單字,按 Enter 開始搜尋。\n按 Backspace 刪字,按 ESC 取消。")); #else loaderService->setPromptDescription(string("\xE8\xAB\x8B\xE8\xBC\xB8\xE5\x85\xA5\xE6\x82\xA8\xE6\x83\xB3\xE6\x9F\xA5\xE8\xA9\xA2\xE5\x96\xAE\xE5\xAD\x97\xEF\xBC\x8C\xE6\x8C\x89 Enter \xE9\x96\x8B\xE5\xA7\x8B\xE6\x90\x9C\xE5\xB0\x8B\xE3\x80\x82\n\xE6\x8C\x89 Backspace \xE5\x88\xAA\xE5\xAD\x97\xEF\xBC\x8C\xE6\x8C\x89 ESC \xE5\x8F\x96\xE6\xB6\x88\xE3\x80\x82")); #endif } else if (locale == "zh_CN" || locale == "zh-Hans") { #ifndef _MSC_VER loaderService->setPromptDescription(string("请输入您想查询单字,按 Enter 开始搜索。\n按 Backspace 删字,按 ESC 取消。")); #else loaderService->setPromptDescription(string("\xE8\xAF\xB7\xE8\xBE\x93\xE5\x85\xA5\xE6\x82\xA8\xE6\x83\xB3\xE6\x9F\xA5\xE8\xAF\xA2\xE5\x8D\x95\xE5\xAD\x97\xEF\xBC\x8C\xE6\x8C\x89 Enter \xE5\xBC\x80\xE5\xA7\x8B\xE6\x90\x9C\xE5\xAF\xBB\xE3\x80\x82\n\xE6\x8C\x89 Backspace \xE5\x88\xA0\xE5\xAD\x97\xEF\xBC\x8C\xE6\x8C\x89 ESC \xE5\x8F\x96\xE6\xB6\x88\xE3\x80\x82")); #endif } else { loaderService->setPromptDescription(string("Pleae type the English word that you want to look up.") + string("\nPress Enter to perform search, press ESC to cancel")); } } if (m_searchType == 1 ) { if (locale == "zh_TW" || locale == "zh-Hant") { #ifndef _MSC_VER loaderService->setPromptDescription(string("請輸入您想查詢單字,按 Enter 開始搜尋。\n按 Backspace 刪字,按 ESC 取消。")); #else loaderService->setPromptDescription(string("\xE8\xAB\x8B\xE8\xBC\xB8\xE5\x85\xA5\xE6\x82\xA8\xE6\x83\xB3\xE6\x9F\xA5\xE8\xA9\xA2\xE5\x96\xAE\xE5\xAD\x97\xEF\xBC\x8C\xE6\x8C\x89 Enter \xE9\x96\x8B\xE5\xA7\x8B\xE6\x90\x9C\xE5\xB0\x8B\xE3\x80\x82\n\xE6\x8C\x89 Backspace \xE5\x88\xAA\xE5\xAD\x97\xEF\xBC\x8C\xE6\x8C\x89 ESC \xE5\x8F\x96\xE6\xB6\x88\xE3\x80\x82")); #endif } else if (locale == "zh_CN" || locale == "zh-Hans") { #ifndef _MSC_VER loaderService->setPromptDescription(string("请输入您想查询单字,按 Enter 开始搜索。\n按 Backspace 删字,按 ESC 取消。")); #else loaderService->setPromptDescription(string("\xE8\xAF\xB7\xE8\xBE\x93\xE5\x85\xA5\xE6\x82\xA8\xE6\x83\xB3\xE6\x9F\xA5\xE8\xAF\xA2\xE5\x8D\x95\xE5\xAD\x97\xEF\xBC\x8C\xE6\x8C\x89 Enter \xE5\xBC\x80\xE5\xA7\x8B\xE6\x90\x9C\xE5\xAF\xBB\xE3\x80\x82\n\xE6\x8C\x89 Backspace \xE5\x88\xA0\xE5\xAD\x97\xEF\xBC\x8C\xE6\x8C\x89 ESC \xE5\x8F\x96\xE6\xB6\x88\xE3\x80\x82")); #endif } else { loaderService->setPromptDescription(string("Pleae type the Chinese word that you want to look up.") + string("\nPress Enter to perform search, press ESC to cancel")); } } else if (m_searchType == 2 || m_searchType == 4 || m_searchType == 5 || m_searchType == 6) { string frontPrompt, auctionPrompt, mapPrompt, endPrompt; if (locale == "zh_TW" || locale == "zh-Hant") { #ifndef _MSC_VER frontPrompt = "請輸入搜尋關鍵字"; auctionPrompt = "請輸入商品關鍵字"; mapPrompt = "請輸入地址或是地標"; endPrompt = ",按 Enter 開始搜尋。\n按 Backspace 刪字,按 ESC 取消。"; #else frontPrompt = "\xe8\xab\x8b\xe8\xbc\xb8\xe5\x85\xa5\xe6\x90\x9c\xe5\xb0\x8b\xe9\x97\x9c\xe9\x8d\xb5\xe5\xad\x97"; auctionPrompt = "\xe8\xab\x8b\xe8\xbc\xb8\xe5\x85\xa5\xe5\x95\x86\xe5\x93\x81\xe9\x97\x9c\xe9\x8d\xb5\xe5\xad\x97"; mapPrompt = "\xe8\xab\x8b\xe8\xbc\xb8\xe5\x85\xa5\xe5\x9c\xb0\xe5\x9d\x80\xe6\x88\x96\xe6\x98\xaf\xe5\x9c\xb0\xe6\xa8\x99"; endPrompt = "\xef\xbc\x8c\xe6\x8c\x89 Enter \xe9\x96\x8b\xe5\xa7\x8b\xe6\x90\x9c\xe5\xb0\x8b\xe3\x80\x82\n\xe6\x8c\x89 Backspace \xe5\x88\xaa\xe5\xad\x97\xef\xbc\x8c\xe6\x8c\x89 ESC \xe5\x8f\x96\xe6\xb6\x88\xe3\x80\x82"; #endif } else if (locale == "zh_CN" || locale == "zh-Hans") { #ifndef _MSC_VER frontPrompt = "请输入搜索关键字"; auctionPrompt = "请输入商品关键字"; mapPrompt = "请输入地址或是地标"; endPrompt = ",按 Enter 开始搜索。\n按 Backspace 删字,按 ESC 取消。"; #else frontPrompt = "\xe8\xaf\xb7\xe8\xbe\x93\xe5\x85\xa5\xe6\x90\x9c\xe7\xb4\xa2\xe5\x85\xb3\xe9\x94\xae\xe5\xad\x97"; auctionPrompt = "\xe8\xaf\xb7\xe8\xbe\x93\xe5\x85\xa5\xe5\x95\x86\xe5\x93\x81\xe5\x85\xb3\xe9\x94\xae\xe5\xad\x97"; mapPrompt = "\xe8\xaf\xb7\xe8\xbe\x93\xe5\x85\xa5\xe5\x9c\xb0\xe5\x9d\x80\xe6\x88\x96\xe6\x98\xaf\xe5\x9c\xb0\xe6\xa0\x87"; endPrompt = "\xef\xbc\x8c\xe6\x8c\x89 Enter \xe5\xbc\x80\xe5\xa7\x8b\xe6\x90\x9c\xe7\xb4\xa2\xe3\x80\x82\n\xe6\x8c\x89 Backspace \xe5\x88\xa0\xe5\xad\x97\xef\xbc\x8c\xe6\x8c\x89 ESC \xe5\x8f\x96\xe6\xb6\x88\xe3\x80\x82"; #endif } else { frontPrompt = "Pleae type the English word that you want to look up."; auctionPrompt = "Please enter the item you're looking for."; mapPrompt = "Please enter the address or the name of the site."; endPrompt = "\nPress Enter to perform search, press ESC to cancel"; } switch(m_searchType) { case 5: frontPrompt = auctionPrompt; break; case 6: frontPrompt = mapPrompt; break; } loaderService->setPromptDescription(frontPrompt + endPrompt); } else if (m_searchType == 3 ) { if (locale == "zh_TW" || locale == "zh-Hant") { #ifndef _MSC_VER loaderService->setPromptDescription(string("請輸入股票名稱或是代號,按 Enter 後開啟瀏覽器搜尋。\n按 Backspace 刪字,按 ESC 取消。")); #else loaderService->setPromptDescription(string("\xE8\xAB\x8B\xE8\xBC\xB8\xE5\x85\xA5\xE8\x82\xA1\xE7\xA5\xA8\xE5\x90\x8D\xE7\xA8\xB1\xE6\x88\x96\xE6\x98\xAF\xE4\xBB\xA3\xE8\x99\x9F\xEF\xBC\x8C\xE6\x8C\x89 Enter \xE5\xBE\x8C\xE9\x96\x8B\xE5\x95\x9F\xE7\x80\x8F\xE8\xA6\xBD\xE5\x99\xA8\xE6\x90\x9C\xE5\xB0\x8B\xE3\x80\x82\n\xE6\x8C\x89 Backspace \xE5\x88\xAA\xE5\xAD\x97\xEF\xBC\x8C\xE6\x8C\x89 ESC \xE5\x8F\x96\xE6\xB6\x88\xE3\x80\x82")); #endif } else if (locale == "zh_CN" || locale == "zh-Hans") { #ifndef _MSC_VER loaderService->setPromptDescription(string("请输入股票名称或是代号,按 Enter 后开启浏览器搜索。\n按 Backspace 删字,按 ESC 取消。")); #else loaderService->setPromptDescription(string("\xE8\xAF\xB7\xE8\xBE\x93\xE5\x85\xA5\xE8\x82\xA1\xE7\xA5\xA8\xE5\x90\x8D\xE7\xA7\xB0\xE6\x88\x96\xE6\x98\xAF\xE4\xBB\xA3\xE5\x8F\xB7\xEF\xBC\x8C\xE6\x8C\x89 Enter \xE5\x90\x8E\xE5\xBC\x80\xE5\x90\xAF\xE6\xB5\x8F\xE8\xA7\x88\xE5\x99\xA8\xE6\x90\x9C\xE5\xAF\xBB\xE3\x80\x82\n\xE6\x8C\x89 Backspace \xE5\x88\xA0\xE5\xAD\x97\xEF\xBC\x8C\xE6\x8C\x89 ESC \xE5\x8F\x96\xE6\xB6\x88\xE3\x80\x82\x22")); #endif } else { loaderService->setPromptDescription(string("Please type the symbol or Chinese name of a stock.") + string("\nPress Enter to launch browser, press ESC to cancel")); } } }
KDEpasswd1Dialog::KDEpasswd1Dialog() : KPasswordDialog(Password, false, 0) { setCaption(i18n("Change Password")); setPrompt(i18n("Please enter your current password:")); }
QConsoleWidget::QConsoleWidget(QWidget * p) :TP(p) { thisp = new QConsoleWidgetPrivate(this, this); /* 背景透明 */ this->setFrameStyle(QFrame::NoFrame); TP::setStyleSheet( "background-color:rgba(0,0,0,0);" "border-color:#00000000;" ); /*设置默认字体*/ { QTextCursor _cursor = this->textCursor(); thisp->textCharFormat = _cursor.charFormat() ; QFont font_ = thisp->textCharFormat.font(); font_.setPixelSize(20); thisp->textCharFormat.setFont(font_); thisp->textCharFormat.setForeground( QColor(0,0,0,255) ); _cursor.setCharFormat( thisp->textCharFormat ); this->setTextCursor( _cursor ); } this->setMinimumHeight(32); /* 禁用redo undo */ this->setUndoRedoEnabled(false); /*检查鼠标行为个数*/ static_assert( INDEX_SIZE == sizeof(mouseActions) / sizeof(void *), ""); /*初始化鼠标行为*/ _pf<void, InitActions>(this); /*初始化鼠标菜单*/ _pf<void, InitMenus>(this); /*设置默认提示符*/ setPrompt(">>>"); thisp->raise(); /* */ {//信号槽连接,更新按钮位置 auto vsb = this->verticalScrollBar(); typedef void(QScrollBar::* TT)(int); vsb->connect(vsb,TT(&QScrollBar::valueChanged), [this](int) { _pf<void, UpdatePromptWidgetPositon>(this); } ); } {//信号槽连接,更新format //void blockCountChanged(int newBlockCount) auto doc_ = this->document(); typedef void(QTextDocument::*DT)(int); doc_->connect(doc_,DT(&QTextDocument::blockCountChanged), [this](int) { if (isEvaling_) { return; } this->updateCharFormat();// }); } _pf<void, MoveToEnd>(this); /* 提取竖直滚动条hidevent 提取竖直滚动条showEvent */ { this->verticalScrollBar()->installEventFilter(this); } /* 清屏并重置字体设置 */ this->beginEvals(); this->saveAndClear(); this->endEvals(); /* 开启redo undo */ this->setUndoRedoEnabled(true); }
/*BEGIN main driver function*/ int main(int argc, char **argv){ /*BEGIN variable declarations*/ char buf[MAX_BUFFER]; //line buffer char *args[MAX_ARGS]; //pointers to arg strings char **arg; //working pointer thru args int noPrompt = 0; /*END variable declarations*/ /*Register the signal handler function*/ if (signal(SIGINT, sigHandler) == SIG_ERR) printf("\nSomething went wrong; can't catch SIGINT\n"); /*Set the prompt. Also puts a value in cwd that is used in several other operations*/ setPrompt(); //set the literal path for the readme file readme = (char*)malloc(sizeof(char) * (strlen(cwd) + 8)); strcat(readme, cwd); strcat(readme, "/readme"); /*Set the SHELL environment variable*/ shell= (char *)malloc(sizeof(char) * (strlen(cwd)+strlen(argv[0])+8)); strcat(shell, "SHELL="); strcat(shell, cwd); strcat(shell, "/"); strcat(shell, argv[0]); putenv(shell); /*Set the initial call to the shell. Used in setting PARENT environment variable for child processes*/ initCall = (char *)malloc(sizeof(char) * (strlen(cwd) + strlen(argv[0]) + 2)); strcat(initCall, cwd); strcat(initCall, "/"); strcat(initCall, argv[0]); /*check for arguments to program, assume first argument after program name is batchfile, ignore all others(for now)*/ if(argc > 1){ /*Check for existance of file*/ if(access(argv[1], F_OK)==-1){ puts("Bad filename or path"); }else /*Check for read/execute access to file(commands being executed = execute access should be honored)*/ if((access(argv[1], R_OK)==0)&&(access(argv[1], X_OK)==0)){ freopen(argv[1], "r", stdin); noPrompt = 1; }else puts("Cannot open that file, you may not have access permissions to it."); } /*BEGIN infinite loop*///Looped input reading code based on strtokeg.c while(!feof(stdin)) { /*display current PID if debug is set*/ if(DEBUG) printf("Process: %d \n", (int)getpid()); /*get user input unless batchfile used*/ if(!noPrompt) fputs(prompt, stdout); if(fgets(buf, MAX_BUFFER, stdin)) //read a line { noWait = 0; //reset background flag in case it was used in last command /*tokenize input into args array*/ arg = args; *arg++ = strtok(buf, DELIMITERS); //tokenize first argument while((*arg++ = strtok(NULL, DELIMITERS))); //last entry will be null and loop will exit //alias implementation needs an alias list and a way to push aliased commands to args[] if(args[0]) { debug("First Arg:"); debug(args[0]); if(!strcmp(args[0],"clr")){ if(clr(args) == -1) debug("Clear error"); }else{ //else1 if(!strcmp(args[0], "cd")){ if(cd(args) == -1) debug("Cd error"); }else{ //else2 if(!strcmp(args[0], "dir")){ if(dir(args) == -1) debug("Dir error"); }else{ //else3 if(!strcmp(args[0], "environ")){ if(envrn(args) == -1) debug("Env error"); }else{ //else4 if(!strcmp(args[0], "echo")){ if(echo(args) == -1) debug("Echo error"); }else{ //else5 if(!strcmp(args[0], "help")){ if(help(args) == -1) debug("Help error"); }else{ //else6 if(!strcmp(args[0], "pause")){ if(pauseShell(args) == -1) debug("Pause error"); }else{ //else7 if(!strcmp(args[0], "quit")){ if(quit(args) == -1) debug("Quit error"); }else{ //else8 if(!strcmp(args[0], "alias")){ fputs("Sorry, alias has not yet been implemented\n", stdout); debug("alias not implemented yet"); }else{ //else9 if(externalCall(args)== -1) debug("Externalcall error"); }//else9 }//else8 }//else7 }//else6 }//else5 }//else4 }//else3 }//else2 }//else1 }//if(args[0]) }//if(fgets(buf, MAX_BUFFER, stdin)) } /*END infinite loop*/ return -1; //this point should not be reachable }
KdeSudo::KdeSudo(QWidget *parent, const char *name,const QString& icon, const QString& generic, bool withIgnoreButton) : KPasswordDialog(KPasswordDialog::Password, false, (withIgnoreButton ? User1: false), icon, parent, name) { KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); QString defaultComment = i18n("<b>%1</b> needs administrative privileges. Please enter your password for verification."); p=NULL; bError=false; m_pCookie = new KCookie; // Set vars bool newDcop = args->isSet("newdcop"); bool realtime = args->isSet("r"); bool priority = args->isSet("p"); bool showCommand = (!args->isSet("d")); bool changeUID = true; bool noExec = false; keepPwd = (!args->isSet("n")); emptyPwd = args->isSet("s"); QString runas = args->getOption("u"); QString cmd; if (!args->isSet("c") && !args->count() && (!args->isSet("s"))) { KMessageBox::information(NULL, i18n("No command arguments supplied!\nUsage: kdesudo [-u <runas>] <command>\nKdeSudo will now exit...")); noExec = true; } p = new KProcess; p->clearArguments(); // Parsins args /* Get the comment out of cli args */ QByteArray commentBytes = args->getOption("comment"); QTextCodec* tCodecConv = QTextCodec::codecForLocale(); QString comment = tCodecConv->toUnicode(commentBytes, commentBytes.size()); if (args->isSet("f")) { // If file is writeable, do not change uid QString filename = QFile::decodeName(args->getOption("f")); QString file = filename; if (!file.isEmpty()) { if (file.at(0) != '/') { KStandardDirs dirs; dirs.addKDEDefaults(); file = dirs.findResource("config", file); if (file.isEmpty()) { kdError(1206) << "Config file not found: " << file << "\n"; exit(1); } } QFileInfo fi(file); if (!fi.exists()) { kdError(1206) << "File does not exist: " << file << "\n"; exit(1); } if (fi.isWritable()) { changeUID = false; } } } if (withIgnoreButton) { setButtonText(User1, i18n("&Ignore")); } // Apologies for the C code, taken from kdelibs/kdesu/kdesu_stub.c // KControl and other places need to use the user's existing DCOP server // For that we set DCOPSERVER. Create a file in /tmp and use iceauth to add magic cookies // from the existing server and set ICEAUTHORITY to point to the file if (!newDcop) { dcopServer = m_pCookie->dcopServer(); QCString dcopAuth = m_pCookie->dcopAuth(); QCString iceAuth = m_pCookie->iceAuth(); FILE *fout; char iceauthority[200]; char *host, *auth; host = qstrdup(dcopServer); auth = qstrdup(iceAuth); int tempfile; int oldumask = umask(077); strcpy(iceauthority, "/tmp/iceauth.XXXXXXXXXX"); tempfile = mkstemp(iceauthority); umask(oldumask); if (tempfile == -1) { kdError() << "error in kdesudo mkstemp" << endl; exit(1); } else { // close(tempfile); //FIXME why does this make the connect() call later crash? } iceauthorityFile = iceauthority; //FIXME we should change owner of iceauthority file, but don't have permissions setenv("ICEAUTHORITY", iceauthorityFile, 1); fout = popen("iceauth >/dev/null 2>&1", "w"); if (!fout) { kdError() << "error in kdesudo running iceauth" << endl; exit(1); } fprintf(fout, "add ICE \"\" %s %s\n", host, auth); auth = qstrdup(dcopAuth); //auth = xstrsep(params[P_DCOP_AUTH].value); fprintf(fout, "add DCOP \"\" %s %s\n", host, auth); unsetenv("ICEAUTHORITY"); pclose(fout); } connect( p, SIGNAL(receivedStdout(KProcess*, char*, int)), this, SLOT(receivedOut(KProcess*, char*, int)) ); connect( p, SIGNAL(receivedStderr(KProcess*, char*, int)), this, SLOT(receivedOut(KProcess*, char*, int)) ); connect( p, SIGNAL(processExited (KProcess *)), this, SLOT(procExited(KProcess*))); QString xauthenv = QString(getenv("HOME")) + "/.Xauthority"; p->setEnvironment("XAUTHORITY", xauthenv); // Generate the xauth cookie and put it in a tempfile // set the environment variables to reflect that. // Default cookie-timeout is 60 sec. . // 'man xauth' for more info on xauth cookies. KTempFile temp = KTempFile("/tmp/kdesudo-","-xauth"); m_tmpname = temp.name(); FILE *f; char buf[1024]; QCString disp = m_pCookie->display(); // command: xauth -q -f m_tmpname generate $DISPLAy . trusted timeout 60 QString c = "/usr/bin/xauth -q -f " + m_tmpname + " generate " + QString::fromLocal8Bit(disp) + " . trusted timeout 60"; blockSigChild(); // pclose uses waitpid() if (!(f = popen(c, "r"))) { kdWarning() << k_lineinfo << "Cannot run: " << c << "\n"; unblockSigChild(); return; } // non root users need to be able to read the xauth file. // the xauth file is deleted when kdesudo exits. security? QFile tf(m_tmpname); if (!runas.isEmpty() && runas != "root" && tf.exists()) chmod(m_tmpname.ascii(),0644); QCStringList output; while (fgets(buf, 1024, f) > 0) output += buf; if (pclose(f) < 0) { kdError() << k_lineinfo << "Could not run xauth.\n"; unblockSigChild(); return; } unblockSigChild(); p->setEnvironment("DISPLAY", disp); p->setEnvironment("XAUTHORITY", m_tmpname); if (emptyPwd) *p << "sudo" << "-k"; else { if (changeUID) { *p << "sudo" << "-H" << "-S" << "-p" << "passprompt"; if (!runas.isEmpty()) *p << "-u" << runas; } if (!dcopServer.isEmpty()) *p << "DCOPSERVER=" + dcopServer; if (!iceauthorityFile.isEmpty()) *p << "ICEAUTHORITY=" + iceauthorityFile; if (realtime) { *p << "nice" << "-n" << "10"; addLine(i18n("Priority:"), i18n("realtime:") + QChar(' ') + QString("50/100")); } else if (priority) { QString n = args->getOption("p"); int intn = atoi(n); intn = (intn * 40 / 100) - (20 + 0.5); QString strn; strn.sprintf("%d",intn); *p << "nice" << "-n" << strn; addLine(i18n("Priority:"), n + QString("/100")); } *p << "--"; if (args->isSet("c")) { QString command = args->getOption("c"); QStringList commandSplit = QStringList::split(" ", command); for (int i = 0; i < commandSplit.count(); i++) { QString toto = validArg(commandSplit[i]); *p << toto; cmd += validArg(commandSplit[i]) + QChar(' '); } } else if (args->count()) { for (int i = 0; i < args->count(); i++) { if (i==0) { QStringList argsSplit = QStringList::split(" ", args->arg(i)); for (int i = 0; i < argsSplit.count(); i++) { *p << validArg(argsSplit[i]); cmd += validArg(argsSplit[i]) + QChar(' '); } } else { *p << validArg(args->arg(i)); cmd += validArg(args->arg(i)) + QChar(' '); } } } // strcmd needs to be defined if (showCommand && !cmd.isEmpty()) addLine(i18n("Command:"), cmd); } if (comment.isEmpty()) { if (!generic.isEmpty()) setPrompt(defaultComment.arg(generic)); else setPrompt(defaultComment.arg(cmd)); } else setPrompt(comment); if (noExec) exit(0); else p->start( KProcess::NotifyOnExit, KProcess::All ); }
ReportDialog::ReportDialog( SourceType source, ReportMode mode, QWidget* parent ) : CommandDialog( parent ), m_source( source ), m_mode( mode ), m_folderId( 0 ), m_typeId( 0 ), m_projectId( 0 ), m_history( IssueDetailsGenerator::NoHistory ), m_tableButton( NULL ), m_fullTableButton( NULL ), m_summaryButton( NULL ), m_fullReportButton( NULL ), m_page( NULL ), m_pdfPrinter( NULL ) { if ( source == FolderSource ) { m_tableButton = new QRadioButton( tr( "Table with visible columns only" ), this ); m_fullTableButton = new QRadioButton( tr( "Table with all system and user columns" ), this ); } if ( mode != ExportCsv ) { if ( source == FolderSource ) m_summaryButton = new QRadioButton( tr( "Summary report including issue details" ), this ); if ( source == IssueSource ) { m_summaryButton = new QRadioButton( tr( "Summary report without issue history" ), this ); m_fullReportButton = new QRadioButton( tr( "Full report including issue history" ), this ); } } QVBoxLayout* optionsLayout = NULL; if ( m_tableButton || m_fullTableButton || m_summaryButton || m_fullReportButton ) { optionsLayout = new QVBoxLayout(); if ( m_tableButton ) optionsLayout->addWidget( m_tableButton ); if ( m_fullTableButton ) optionsLayout->addWidget( m_fullTableButton ); if ( m_summaryButton ) optionsLayout->addWidget( m_summaryButton ); if ( m_fullReportButton ) optionsLayout->addWidget( m_fullReportButton ); } if ( optionsLayout || mode == Print ) { QHBoxLayout* layout = new QHBoxLayout(); if ( optionsLayout ) layout->addLayout( optionsLayout ); if ( mode == Print ) { QPushButton* previewButton = new QPushButton( tr( "&Print Preview..." ), this ); previewButton->setIcon( IconLoader::icon( "print-preview" ) ); previewButton->setIconSize( QSize( 16, 16 ) ); layout->addWidget( previewButton, 0, Qt::AlignBottom | Qt::AlignRight ); connect( previewButton, SIGNAL( clicked() ), this, SLOT( showPreview() ) ); } setContentLayout( layout, true ); } if ( m_tableButton ) m_tableButton->setChecked( true ); else if ( m_summaryButton ) m_summaryButton->setChecked( true ); QString sourceName; switch ( source ) { case FolderSource: sourceName = tr( "list of issues" ); break; case IssueSource: sourceName = tr( "issue details" ); break; case ProjectSource: sourceName = tr( "project summary" ); break; } switch ( mode ) { case Print: setWindowTitle( tr( "Print" ) ); setPromptPixmap( IconLoader::pixmap( "file-print", 22 ) ); setPrompt( tr( "Print %1:" ).arg( sourceName ) ); break; case ExportCsv: setWindowTitle( tr( "Export To CSV" ) ); setPromptPixmap( IconLoader::pixmap( "export-csv", 22 ) ); setPrompt( tr( "Export %1 to CSV file:" ).arg( sourceName ) ); break; case ExportHtml: setWindowTitle( tr( "Export To HTML" ) ); setPromptPixmap( IconLoader::pixmap( "export-html", 22 ) ); setPrompt( tr( "Export %1 to HTML file:" ).arg( sourceName ) ); break; case ExportPdf: setWindowTitle( tr( "Export To PDF" ) ); setPromptPixmap( IconLoader::pixmap( "export-pdf", 22 ) ); setPrompt( tr( "Export %1 to PDF file:" ).arg( sourceName ) ); break; } showInfo( tr( "Create the report." ) ); }
void CEngine::initEmulationMode() { setPrompt("-->"); stacker.put(1); stacker.swap(); }
int main(int argc, char **argv) { if(isArgumentForShowingVersion(argv)) showVersionAndExit(); char *buf; char *bufCopy; pid_t pid = getpid(); pid_t backgroundJob; int status = 0; char *prompt = getPrompt(); int bg; int jobNumber = 1; int counts; int jumpSet = 0; char *arguments[2048]; initialize(); printf("\n"); setPrompt(prompt); while ((buf = readline(prompt))) { if(strlen(buf) != 0) { bufCopy = buddy_malloc((strlen(buf)+1)*sizeof(char)); strcpy(bufCopy, buf); add_history(bufCopy); } else { printFinishedJobs(jobList); free(buf); continue; } free(buf); if(isCommandNotEmpty(bufCopy)) bg = isBackgroundCommand(bufCopy); getArgument(arguments, bufCopy, &counts); if(isExitCommand(bufCopy)){ buddy_free(bufCopy); freeList(jobList); if(arguments != NULL){ freeArguments(counts, arguments, NULL); } exit(0); } if(isCdCommand(bufCopy, arguments)){ changeDir(arguments); freeArguments(counts, arguments, bufCopy); } else if(isJobsCommand(bufCopy)) { printList(jobList); freeArguments(counts, arguments, bufCopy); } else if(isFgCommand(bufCopy, arguments)){ fg(arguments, jobList, counts, bufCopy); } else if(isBgCommand(bufCopy, arguments)){ bgS(arguments, jobList, counts, bufCopy); } else if (isCommandNotEmpty(bufCopy)) { if(bg == 1) { backgroundJob = fork(); if(backgroundJob == 0) { ignoreSignals(); runCommand(arguments, bufCopy); } else{ NodePtr n = createAndSetNode(&jobNumber, backgroundJob, bufCopy, bg); recordCommand(n, jobNumber, bg); freeArguments(counts, arguments, bufCopy); } } else { pid = fork(); if(pid == 0){ runCommand(arguments, bufCopy); } else { NodePtr n = createAndSetNode(&jobNumber, pid, bufCopy, bg); ignoreSignals(); if((waitpid(pid,&status,WUNTRACED))<0) err_sys("waitpid error"); freeArguments(counts, arguments, bufCopy); restoreSignalsAndDetermineStatus(status, jobList, n); } } } else { freeArguments(counts, arguments, bufCopy); } if(jumpSet == 0){ sigsetjmp(env, 1); jumpSet = 1; } continue; } if(buf == NULL) printf("\n"); exit(0); }