void MainUI::tabChanged(){ //update the buttons/menus based on the current widget PlainTextEditor *cur = currentEditor(); if(cur==0){ return; } //should never happen though bool changes = cur->hasChange(); ui->actionSave_File->setEnabled(changes); this->setWindowTitle( ui->tabWidget->tabText( ui->tabWidget->currentIndex() ) ); if(!ui->line_find->hasFocus() && !ui->line_replace->hasFocus()){ ui->tabWidget->currentWidget()->setFocus(); } }
void MainUI::tabClosed(int tab){ PlainTextEditor *edit = static_cast<PlainTextEditor*>(ui->tabWidget->widget(tab)); if(edit==0){ return; } //should never happen if(edit->hasChange()){ //Verify if the user wants to lose any unsaved changes } ui->tabWidget->removeTab(tab); edit->deleteLater(); }
void MainUI::updateTab(QString file){ PlainTextEditor *cur = 0; int index = -1; for(int i=0; i<ui->tabWidget->count(); i++){ PlainTextEditor *tmp = static_cast<PlainTextEditor*>(ui->tabWidget->widget(i)); if(tmp->currentFile()==file){ cur = tmp; index = i; break; } } if(cur==0){ return; } //should never happen bool changes = cur->hasChange(); //qDebug() << "Update Tab:" << file << cur << changes; ui->tabWidget->setTabText(index,(changes ? "*" : "") + file.section("/",-1)); ui->actionSave_File->setEnabled(changes); this->setWindowTitle( ui->tabWidget->tabText( ui->tabWidget->currentIndex() ) ); }