void MainUI::showLineNumbers(bool show){ settings->setValue("showLineNumbers",show); for(int i=0; i<ui->tabWidget->count(); i++){ PlainTextEditor *edit = static_cast<PlainTextEditor*>(ui->tabWidget->widget(i)); edit->showLineNumbers(show); } }
void MainUI::OpenFile(QString file){ QStringList files; if(file.isEmpty()){ //Prompt for a file to open files = QFileDialog::getOpenFileNames(this, tr("Open File(s)"), currentFileDir(), tr("Text Files (*)") ); if(files.isEmpty()){ return; } //cancelled }else{ files << file; } for(int i=0; i<files.length(); i++){ PlainTextEditor *edit = new PlainTextEditor(settings, this); connect(edit, SIGNAL(FileLoaded(QString)), this, SLOT(updateTab(QString)) ); connect(edit, SIGNAL(UnsavedChanges(QString)), this, SLOT(updateTab(QString)) ); ui->tabWidget->addTab(edit, files[i].section("/",-1)); edit->showLineNumbers(ui->actionLine_Numbers->isChecked()); edit->setLineWrapMode( ui->actionWrap_Lines->isChecked() ? QPlainTextEdit::WidgetWidth : QPlainTextEdit::NoWrap); edit->setFocusPolicy(Qt::ClickFocus); //no "tabbing" into this widget ui->tabWidget->setCurrentWidget(edit); edit->LoadFile(files[i]); edit->setFocus(); QApplication::processEvents(); //to catch the fileLoaded() signal } }