int64_t video_output_qt::wait_for_subtitle_renderer() { if (_subtitle_renderer.is_initialized()) { return 0; } int64_t wait_start = timer::get_microseconds(timer::monotonic); exc init_exception; QDialog *mbox = NULL; // Show a dialog only in GUI mode if (_container_is_external && !dispatch::parameters().fullscreen()) { mbox = new QDialog(_container_widget); mbox->setModal(true); mbox->setWindowTitle(_("Please wait")); QGridLayout *mbox_layout = new QGridLayout; QLabel *mbox_label = new QLabel(_("Waiting for subtitle renderer initialization...")); mbox_layout->addWidget(mbox_label, 0, 0); mbox->setLayout(mbox_layout); mbox->show(); } else { msg::wrn(_("Waiting for subtitle renderer initialization...")); } QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); try { while (!_subtitle_renderer.is_initialized()) { process_events(); usleep(10000); } } catch (std::exception &e) { init_exception = e; } QApplication::restoreOverrideCursor(); if (mbox) { mbox->hide(); delete mbox; } if (!init_exception.empty()) { throw init_exception; } int64_t wait_stop = timer::get_microseconds(timer::monotonic); return (wait_stop - wait_start); }
void Replacer::advance() { SubtitleCompositeActionExecutor executor(*m_subtitle, i18n("Replace")); KFind::Result res = KFind::NoMatch; bool selection = m_replace->options() & KFind::SelectedText; bool backwards = m_replace->options() & KFind::FindBackwards; QDialog *replaceNextDialog = this->replaceNextDialog(); // creates the dialog if it didn't existed before do { if(m_replace->needData()) { SubtitleLine *dataLine = m_iterator->current(); if(dataLine) { if(!m_translationMode || m_targetRadioButtons[SubtitleLine::Primary]->isChecked()) { m_feedingPrimary = true; m_replace->setData(dataLine->primaryText().string()); } else if(m_targetRadioButtons[SubtitleLine::Secondary]->isChecked()) { m_feedingPrimary = false; m_replace->setData(dataLine->secondaryText().string()); } else { // m_translationMode && m_targetRadioButtons[SubtitleLine::Both]->isChecked() m_feedingPrimary = !m_feedingPrimary; // we alternate the source of data m_replace->setData((m_feedingPrimary ? dataLine->primaryText() : dataLine->secondaryText()).string()); } } } res = m_replace->replace(); if(res == KFind::NoMatch && (!m_translationMode || !m_targetRadioButtons[SubtitleLine::Both]->isChecked() || !m_feedingPrimary)) { if(backwards) --(*m_iterator); else ++(*m_iterator); if(m_firstIndex == m_iterator->index() || (backwards ? (m_firstIndex == m_iterator->lastIndex() && m_iterator->index() == SubtitleIterator::BehindFirst) : (m_firstIndex == m_iterator->firstIndex() && m_iterator->index() == SubtitleIterator::AfterLast))) { if(replaceNextDialog) replaceNextDialog->hide(); if(m_instancesFound && m_replace->numReplacements()) KMessageBox::information(parentWidget(), i18np("1 replacement done.", "%1 replacements done.", m_replace->numReplacements()), i18n("Replace") ); else // special case KMessageBox::sorry(parentWidget(), i18n("No instances of '%1' found!", m_replace->pattern()), i18n("Replace") ); m_replace->resetCounts(); break; } if(m_iterator->index() < 0) { if(backwards) m_iterator->toLast(); else m_iterator->toFirst(); int numReplacements = m_replace->numReplacements(); m_replace->resetCounts(); if(KMessageBox::warningContinueCancel(parentWidget(), i18np("1 replacement done.", "%1 replacements done.", numReplacements) + "\n\n" + (backwards ? (selection ? i18n("Beginning of selection reached.\nContinue from the end?") : i18n("Beginning of subtitle reached.\nContinue from the end?")) : (selection ? i18n("End of selection reached.\nContinue from the beginning?") : i18n("End of subtitle reached.\nContinue from the beginning?"))), i18n("Replace") ) != KMessageBox::Continue) { if(replaceNextDialog) replaceNextDialog->hide(); break; } } } } while(res != KFind::Match); }
SimpleClient::SimpleClient(QWidget * parent) : QMainWindow(parent), m_actions(this), m_script_editor(NULL), m_dlgSeqTool(NULL), m_seqTool(NULL) { corbasim::gui::initialize(); QWidget * central = new QWidget; QVBoxLayout * layout = new QVBoxLayout; // Menu m_menu = new QMenuBar; setMenuBar(m_menu); // Menu File QMenu * menuFile = m_menu->addMenu("&File"); QMenu * editMenu = m_menu->addMenu("&Edit"); // Menu Operations m_operations_menu = m_menu->addMenu("&Operations"); // Menu window QMenu * menuWindow = m_menu->addMenu("&Window"); m_mainSplitter = new QSplitter(Qt::Vertical); layout->addWidget(m_mainSplitter); // IOR QGroupBox * gb = new QGroupBox("Reference"); QAction * act = menuWindow->addAction("&Reference"); act->setCheckable(true); act->setChecked(true); connect(act, SIGNAL(toggled(bool)), gb, SLOT(setVisible(bool))); QHBoxLayout * gbLayout = new QHBoxLayout; m_ref = new ObjrefWidget; gbLayout->addWidget(m_ref); gb->setLayout(gbLayout); m_mainSplitter->addWidget(gb); // Operations gb = new QGroupBox("Operations"); act = menuWindow->addAction("&Operations"); act->setCheckable(true); act->setChecked(true); connect(act, SIGNAL(toggled(bool)), gb, SLOT(setVisible(bool))); QVBoxLayout * opsLayout = new QVBoxLayout; m_tab = new QTabWidget; opsLayout->addWidget(m_tab); gb->setLayout(opsLayout); m_mainSplitter->addWidget(gb); // Events gb = new QGroupBox("Events"); act = menuWindow->addAction("&Events"); act->setCheckable(true); act->setChecked(true); connect(act, SIGNAL(toggled(bool)), gb, SLOT(setVisible(bool))); gbLayout = new QHBoxLayout; m_tree = new TreeView(); m_tree->setModel(&m_log_model); gbLayout->addWidget(m_tree); gb->setLayout(gbLayout); m_mainSplitter->addWidget(gb); // Filtered log QDialog * filteredLogDlg = new QDialog(this); QVBoxLayout * filteredLayout = new QVBoxLayout(); m_filteredLog = new FilteredLogView(); m_filteredLog->setLogModel(&m_log_model); filteredLayout->setMargin(0); filteredLayout->addWidget(m_filteredLog); filteredLogDlg->setLayout(filteredLayout); filteredLogDlg->hide(); // Load QAction * loadAction = new QAction( style()->standardIcon(QStyle::SP_DialogOpenButton), "&Load configuration", this); loadAction->setShortcut(QKeySequence::Open); connect(loadAction, SIGNAL(triggered()), this, SLOT(doLoad())); // Save QAction * saveAction = new QAction( style()->standardIcon(QStyle::SP_DialogSaveButton), "&Save configuration", this); saveAction->setShortcut(QKeySequence::SaveAs); connect(saveAction, SIGNAL(triggered()), this, SLOT(doSave())); menuFile->addAction(loadAction); menuFile->addAction(saveAction); menuFile->addSeparator(); menuFile->addAction("&Script editor", this, SLOT(showScriptEditor())); menuFile->addAction("&Operation sequence", this, SLOT(showOperationSequenceTool())); menuFile->addAction("&Filtered log", filteredLogDlg, SLOT(show())); menuFile->addSeparator(); menuFile->addAction("&Close", this, SLOT(close())); // Actions QAction * pasteAction = new QAction("Paste &IOR from clipboard", this); pasteAction->setShortcut(QKeySequence::Paste); connect(pasteAction, SIGNAL(triggered()), this, SLOT(pasteIOR())); QAction * clearAction = new QAction("&Clear", this); clearAction->setShortcut(QKeySequence::Cut); connect(clearAction, SIGNAL(triggered()), this, SLOT(clearAll())); QAction * clearLogAction = new QAction("&Clear log", this); connect(clearLogAction, SIGNAL(triggered()), &m_log_model, SLOT(clearLog())); QAction * stopAction = new QAction("&Stop all timers", this); // stopAction->setShortcut(QKeySequence::Cut); connect(stopAction, SIGNAL(triggered()), this, SLOT(stopAllTimers())); editMenu->addAction(pasteAction); editMenu->addAction(clearAction); editMenu->addAction(clearLogAction); editMenu->addAction(stopAction); central->setLayout(layout); setCentralWidget(central); connect(&m_buttons, SIGNAL(buttonClicked(int)), this, SLOT(showDialog(int))); connect(&m_actions, SIGNAL(triggered(QAction *)), this, SLOT(showDialog(QAction *))); setWindowIcon(QIcon(":/resources/images/csu.png")); }