void PdfImageGenerator::startGeneration(void) { int page; QRectF highlight; QImage img; QPair<int,QRectF> demand; while (!this->requestedPages.isEmpty()) { demand = requestedPages.takeLast(); page = demand.first; highlight = demand.second; img = generateImage(page); if (!img.isNull()) { /* image size estimation */ if (this->passes < this->minpasses) { ++passes; avgw += img.width(); avgh += img.height(); } /* search result highlight * cuts out the highlighted word and darkens the rest of the page */ if (highlight.isValid()) { QRect highlightRect = scaleHighlightRect(highlight); highlightRect.adjust(-2, -2, 2, 2); QImage hImage = img.copy(highlightRect); QPainter painter; painter.begin(&img); painter.fillRect(img.rect(), QColor(0, 0, 0, 32)); painter.drawImage(highlightRect, hImage); painter.end(); } emit imageFinished(img, page); } } if (this->passes == minpasses) { pageSize.setWidth((int)(avgw/passes)); pageSize.setHeight((int)(avgh/passes)); ++passes; emit newPageSize(pageSize); } emit generationFinished(); }
void FormMain::createConnections() { // General connections. connect(qApp, SIGNAL(aboutToQuit()), this, SLOT(onAboutToQuit())); connect(m_ui->m_actionQuit, SIGNAL(triggered()), this, SLOT(close())); connect(m_ui->m_actionCheckForUpdates, SIGNAL(triggered()), this, SLOT(showUpdates())); connect(m_ui->m_actionAboutToolkit, SIGNAL(triggered()), this, SLOT(showAbout())); connect(m_ui->m_actionSettings, SIGNAL(triggered()), this, SLOT(showSettings())); connect(m_ui->m_actionHelp, SIGNAL(triggered()), this, SLOT(showHelp())); // View connections. connect(m_ui->m_actionViewSimulatorWindow, SIGNAL(toggled(bool)), this, SLOT(switchSimulatorWindow(bool))); connect(m_ui->m_actionStickSimulatorWindow, SIGNAL(toggled(bool)), m_simulatorWindow, SLOT(setIsSticked(bool))); // Extra simulator connections. connect(m_simulatorWindow, SIGNAL(closed()), this, SLOT(onSimulatorWindowClosed())); connect(m_simulatorWindow, SIGNAL(stopEnableChanged(bool)), m_ui->m_actionSimulatorStop, SLOT(setEnabled(bool))); connect(m_ui->m_actionSimulatorStop, SIGNAL(triggered()), m_simulatorWindow->m_ui->m_btnStopSimulation, SLOT(click())); connect(m_ui->m_actionSimulatorRun, SIGNAL(triggered()), this, SLOT(startSimulation())); connect(m_ui->m_actionSimulatorGoBack, SIGNAL(triggered()), this, SLOT(takeSimulationOneStepBack())); // Project connections. connect(m_ui->m_actionNewProject, SIGNAL(triggered()), this ,SLOT(openNewProjectDialog())); connect(m_ui->m_actionSaveProject, SIGNAL(triggered()), this ,SLOT(openSaveProjectDialog())); connect(m_ui->m_actionSaveProjectAs, SIGNAL(triggered()), this, SLOT(openSaveProjectAsDialog())); connect(m_ui->m_actionLoadProject, SIGNAL(triggered()), this ,SLOT(openLoadProjectDialog())); connect(m_ui->m_actionOpenOutputDirectory, SIGNAL(triggered()), this, SLOT(openOutputDirectory())); // Template system connections. connect(qApp->templateManager(), SIGNAL(newTemplateCoreCreated(TemplateCore*)), this, SLOT(setTemplateCore(TemplateCore*))); connect(qApp, SIGNAL(externalApplicationsRechecked()), this, SLOT(onExternalApplicationsChanged())); connect(m_ui->m_actionGenerateMobileApplication, SIGNAL(triggered()), this, SLOT(generateMobileApplication())); connect(m_ui->m_actionUploadApplicationToStore, SIGNAL(triggered()), this, SLOT(uploadMobileApplicationToStore())); connect(qApp->templateManager()->generator(), SIGNAL(generationStarted()), this, SLOT(onGenerationStarted())); connect(qApp->templateManager()->generator(), SIGNAL(generationFinished(TemplateCore::GenerationResult,QString)), this, SLOT(onGenerationDone(TemplateCore::GenerationResult,QString))); connect(qApp->templateManager()->generator(), SIGNAL(generationProgress(int,QString)), this, SLOT(onGenerationProgress(int,QString))); }
/** * @brief TrayIcon::TrayIcon * @param MainWindow* _parent * @param Controller* _ctrl */ TrayIcon::TrayIcon(MainWindow* _parent, Controller* _ctrl) : QSystemTrayIcon(_parent), m_ctrl(_ctrl), m_parent(_parent) { connect(m_parent, SIGNAL(showHidden(bool)), this, SLOT(onWindowShown(bool))); connect(m_ctrl, SIGNAL(startedPaused(bool)), this, SLOT(onStartPause(bool))); connect(m_ctrl, SIGNAL(lockToggled(bool)), this, SLOT(setLocked(bool))); connect(m_parent, &MainWindow::settingsChanged, this, [this]{ setLockEnabled(m_ctrl->lockEnabled() == UM::LOCK_ALL); }); connect(m_ctrl, SIGNAL(generationFinished()), this, SLOT(onListChanged())); connect(this, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(onActivated(QSystemTrayIcon::ActivationReason))); QMenu* menu = new QMenu(); m_actionPause = menu->addAction(QIcon(":/images/icons/play_pause.png"), tr("Pause")); QAction* actionRefresh = menu->addAction(QIcon(":/images/icons/refresh.png"), tr("Refresh")); m_actionHide = menu->addAction(QIcon(":/images/icons/hide.png"), tr("Hide")); m_actionLock = menu->addAction(QIcon(":/images/icons/lock.png"), tr("Lock")); m_actionUnlock = menu->addAction(QIcon(":/images/icons/lock.png"), tr("Unlock")); m_quickMenu = menu->addMenu(QIcon(":/images/icons/quick.png"), tr("Quick switch")); menu->addSeparator(); QAction* actionQuit = menu->addAction(QIcon(":/images/icons/quit.png"), tr("Quit")); connect(actionQuit, SIGNAL(triggered()), m_parent, SLOT(quit())); connect(m_actionHide, SIGNAL(triggered()), m_parent, SLOT(toggleWindow())); connect(m_actionPause, SIGNAL(triggered()), m_ctrl, SLOT(startPause())); connect(actionRefresh, SIGNAL(triggered()), m_ctrl, SLOT(update())); connect(m_actionLock, SIGNAL(triggered()), m_ctrl, SLOT(lock())); connect(m_actionUnlock,SIGNAL(triggered()), m_parent, SLOT(openUnlockDialog())); setToolTip(APP_NAME); setContextMenu(menu); onListChanged(); setLockEnabled(m_ctrl->lockEnabled() == UM::LOCK_ALL); updateIcon(); }