diff --git a/NEWS.md b/NEWS.md index 331d6042..4d66fe04 100644 --- a/NEWS.md +++ b/NEWS.md @@ -14,6 +14,7 @@ Red Panda C++ Version 2.8 - fix: Restore main window and cpu info window will set wrong font in the cpu info. - enhancement: Let encoding options in the statusbar more explicit. - fix: Crash when find occurrences in a project that has missing files. + - enhancement: Print current selection can be used in the print dialog. Red Panda C++ Version 2.7 diff --git a/RedPandaIDE/editor.cpp b/RedPandaIDE/editor.cpp index d1415895..f31ee1f9 100644 --- a/RedPandaIDE/editor.cpp +++ b/RedPandaIDE/editor.cpp @@ -2954,16 +2954,19 @@ void Editor::print() QPrintDialog dialog(&printer, this); dialog.setWindowTitle(tr("Print Document")); -// if (editor->selAvail()) -// dialog.addEnabledOption(QAbstractPrintDialog::PrintSelection); + dialog.setOption(QAbstractPrintDialog::PrintCurrentPage,false); + dialog.setOption(QAbstractPrintDialog::PrintPageRange,false); + if (selAvail()) + dialog.setOption(QAbstractPrintDialog::PrintSelection); if (dialog.exec() != QDialog::Accepted) { return; } QTextDocument doc; -// if (editor->selAvail()) { -// doc.setPlainText(editor->selText()); -// } else { - QStringList lst = contents(); + QStringList lst; + if (dialog.testOption(QAbstractPrintDialog::PrintSelection)) + lst = textToLines(selText()); + else + lst = contents(); for (int i=0;ioptions().isCpp = ui->cbDefaultCpp->isChecked(); project->options().supportXPThemes = ui->cbSupportXPTheme->isChecked(); - qDebug()<= QT_VERSION_CHECK(5,15,0) || ui->lbIcon->pixmap(Qt::ReturnByValue).isNull()) {