mirror of
				https://github.com/subsurface/subsurface.git
				synced 2025-02-19 22:16:15 +00:00 
			
		
		
		
	Printing: check the print type in the preview section
Preview output should be identical to the actual printing code, so call the flow rendering method for all flow templates. Also don't create new pages while rendering a one page preview, just exit after the first page is full. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Gehad elrobey <gehadelrobey@gmail.com>
This commit is contained in:
		
							parent
							
								
									13febc1eee
								
							
						
					
					
						commit
						c516421bc2
					
				
					 1 changed files with 19 additions and 3 deletions
				
			
		
							
								
								
									
										22
									
								
								printer.cpp
									
										
									
									
									
								
							
							
						
						
									
										22
									
								
								printer.cpp
									
										
									
									
									
								
							|  | @ -95,7 +95,14 @@ void Printer::flowRender() | |||
| 
 | ||||
| 			// rendering progress is 4/5 of total work
 | ||||
| 			emit(progessUpdated((end * 80.0 / fullPageResolution) + done)); | ||||
| 			static_cast<QPrinter*>(paintDevice)->newPage(); | ||||
| 
 | ||||
| 			// add new pages only in print mode, while previewing we don't add new pages
 | ||||
| 			if (printMode == Printer::PRINT) | ||||
| 				static_cast<QPrinter*>(paintDevice)->newPage(); | ||||
| 			else { | ||||
| 				painter.end(); | ||||
| 				return; | ||||
| 			} | ||||
| 			start = dontbreakElement.geometry().y(); | ||||
| 		} | ||||
| 	} | ||||
|  | @ -297,7 +304,16 @@ void Printer::previewOnePage() | |||
| 		templateOptions->border_width = std::max(1, pageSize.width() / 1000); | ||||
| 		webView->setHtml(t.generate()); | ||||
| 
 | ||||
| 		// render only one page
 | ||||
| 		render(1); | ||||
| 		bool ok; | ||||
| 		int divesPerPage = webView->page()->mainFrame()->findFirstElement("body").attribute("data-numberofdives").toInt(&ok); | ||||
| 		if (!ok) { | ||||
| 			divesPerPage = 1; // print each dive in a single page if the attribute is missing or malformed
 | ||||
| 			//TODO: show warning
 | ||||
| 		} | ||||
| 		if (divesPerPage == 0) { | ||||
| 			flowRender(); | ||||
| 		} else { | ||||
| 			render(1); | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue