JBoolean
JX2DPlotPrintEPSDialog::OKToDeactivate()
{
	if (!JXEPSPrintSetupDialog::OKToDeactivate())
		{
		return kJFalse;
		}
	else if (Cancelled())
		{
		return kJTrue;
		}
	else if (!itsWidthInput->InputValid())
		{
		itsWidthInput->Focus();
		return kJFalse;
		}
	else if (!itsHeightInput->InputValid())
		{
		itsHeightInput->Focus();
		return kJFalse;
		}

	JCoordinate w,h;
	Unit u;
	GetPlotSize(&w, &h, &u);
	if (w < 50 || h < 50)
		{
		(JGetUserNotification())->ReportError(JGetString(kTooSmallID));
		return kJFalse;
		}
	else
		{
		return kJTrue;
		}
}
JBoolean
JXGetNewDirDialog::OKToDeactivate()
{
	if (!JXGetStringDialog::OKToDeactivate())
		{
		return kJFalse;
		}
	else if (Cancelled())
		{
		return kJTrue;
		}

	const JString pathName = GetNewDirName();
	if (JDirectoryExists(pathName))
		{
		(JGetUserNotification())->ReportError(JGetString(kDirectoryExistsID));
		return kJFalse;
		}
	else if (JNameUsed(pathName))
		{
		(JGetUserNotification())->ReportError(JGetString(kNameUsedID));
		return kJFalse;
		}
	else
		{
		return kJTrue;
		}
}
Example #3
0
  TransferState Downloader::Wait(const unsigned ms)
  {
    boost::unique_lock<boost::mutex> lock(LockResult);

    typedef boost::chrono::system_clock time;
    time::time_point te = time::now() + boost::chrono::milliseconds(ms);

    while (!Done)
    {
      if (CondDone.wait_for(lock,  te - time::now()) == boost::cv_status::timeout)
      {
        return STATE_TIMEOUT;
      }
    }

    if (Cancelled())
    {
      return STATE_CANCELLED;
    }
    else if (Result)
    {
      return STATE_SUCCESS;
    }

    return STATE_ERROR;
  }
Example #4
0
void ProgressReporter::throwIfCancelled()
{
    if (m_isCancelled) {
        m_isCancelled = false;
        throw Cancelled();
    }
}
JBoolean
TestInputFieldsDialog::OKToDeactivate()
{
JInteger v1,v2;

	if (!JXDialogDirector::OKToDeactivate())
		{
		return kJFalse;
		}
	else if (Cancelled())
		{
		return kJTrue;
		}

	else if (itsLowerValue->GetValue(&v1) &&
			 itsUpperValue->GetValue(&v2) &&
			 v1 >= v2)
		{
		(JGetUserNotification())->ReportError("Low must be less than high.");
		itsLowerValue->Focus();
		return kJFalse;
		}

	else
		{
		return kJTrue;
		}
}
JBoolean
JXChooseFileDialog::OKToDeactivate()
{
    if (!JXCSFDialogBase::OKToDeactivate())
    {
        return kJFalse;
    }
    else if (Cancelled())
    {
        return kJTrue;
    }

    JXPathInput* pathInput = GetPathInput();
    if (pathInput->HasFocus())
    {
        GoToItsPath();
        return kJFalse;
    }

    JXInputField* filterInput = GetFilterInput();
    if (filterInput->HasFocus())
    {
        AdjustFilter();
        return kJFalse;
    }

    JXDirTable* fileBrowser = GetFileBrowser();
    if (fileBrowser->GoToSelectedDirectory())
    {
        return kJFalse;
    }

    JPtrArray<JDirEntry> entryList(JPtrArrayT::kDeleteAll);
    if (fileBrowser->GetSelection(&entryList))
    {
        const JSize count = entryList.GetElementCount();
        for (JIndex i=1; i<=count; i++)
        {
            JDirEntry* entry = entryList.NthElement(i);
            entry->ForceUpdate();	// check that link hasn't been broken behind our back
            if (!entry->IsFile())
            {
                (GetDirInfo())->ForceUpdate();
                return kJFalse;
            }
        }
        return kJTrue;
    }
    else
    {
        return kJFalse;
    }
}
JBoolean
JXEPSPrintSetupDialog::OKToDeactivate()
{
	if (!JXDialogDirector::OKToDeactivate())
		{
		return kJFalse;
		}
	else if (Cancelled())
		{
		return kJTrue;
		}

	return JXPSPrintSetupDialog::OKToDeactivate(itsFileInput->GetText());
}
JBoolean 
GXCreatePlotDialog::OKToDeactivate()
{
	if (Cancelled())
		{
		return kJTrue;
		}
	if (GetLabel().IsEmpty())
		{
		JGetUserNotification()->ReportError("You must specify a curve label.");
		return kJFalse;
		}
	return kJTrue;
}
JBoolean
GXTransformFunctionDialog::OKToDeactivate()
{
	if (Cancelled())
		{
		return kJTrue;
		}
	JFunction* f = NULL;
	if (JParseFunction(itsFunctionString->GetText(), itsList, &f))
		{
		jdelete f;
		return kJTrue;
		}
	return kJFalse;
}
JBoolean
CMEditCommandsDialog::OKToDeactivate()
{
	if (Cancelled())
		{
		return kJTrue;
		}

	if (!itsWidget->EndEditing())
		{
		return kJFalse;
		}

	(CMGetPrefsManager())->SetCmdList(*itsCommands);
	return kJTrue;
}
JBoolean
JX2DCurveOptionsDialog::OKToDeactivate()
{
	if (!JXDialogDirector::OKToDeactivate())
		{
		return kJFalse;
		}
	else if (Cancelled())
		{
		return kJTrue;
		}
	else
		{
		SaveSettings();
		return kJTrue;
		}
}
bool CNewFilesBox::OnNewFrame(const CFrameInfo &frame, bool *try_again)
{
	int res;
	bool retval;

	// Initialization
	if (!m_Proc) {
		m_Proc = new CUpdateProc();
		if (m_Proc->Init(m_Con)!=0) {
			delete m_Proc;
			m_Proc = NULL;
			m_StopThread = TRUE;
		}
		if (!m_Proc)
			return false;
	}

	// Process file
	g_mutex_lock(m_DataMutex);
	m_State = STATE_WORK;
	PushMessage(EVENT_UPDATE, 0);
	g_mutex_unlock(m_DataMutex);
	g_Project->Lock();
	if (!g_Project->FileInProject(frame.FullPath())) {
		GtkTreePath *path = g_Project->AddFile(frame);
		if (path) {
			g_Project->Unlock();
			res = m_Proc->Execute(path);
			if (res==CMPACK_ERR_CANT_OPEN_SRC)
				*try_again = TRUE;
			if (res==0) {
				m_Delay = false;
				m_OutFiles++;
			}
			g_Project->Lock();
			gtk_tree_path_free(path);
		}
	}
	g_Project->Unlock();
	g_mutex_lock(m_DataMutex);
	retval = !Cancelled();
	g_mutex_unlock(m_DataMutex);
	return retval;
}
JBoolean
JXPTPrintSetupDialog::OKToDeactivate()
{
	if (!JXDialogDirector::OKToDeactivate())
		{
		return kJFalse;
		}
	else if (Cancelled())
		{
		return kJTrue;
		}

	if (itsDestination->GetSelectedItem() == kPrintToFileID)
		{
		return JXPSPrintSetupDialog::OKToDeactivate(itsFileInput->GetText());
		}
	else
		{
		return kJTrue;
		}
}
JBoolean
SCEditVarValueDialog::OKToDeactivate()
{
	if (!JXDialogDirector::OKToDeactivate())
		{
		return kJFalse;
		}
	else if (Cancelled())
		{
		return kJTrue;
		}

	else
		{
		JFloat value;
		JBoolean ok = itsValue->GetValue(&value);
		assert( ok );
		ok = itsVarList->SetValue(itsVarIndex, value);
		assert( ok );
		return kJTrue;
		}
}
JBoolean
GLPolyFitDialog::OKToDeactivate()
{
	if (!JXDialogDirector::OKToDeactivate())
		{
		return kJFalse;
		}
	if (Cancelled())
		{
		return kJTrue;
		}
	JString name	= itsNameInput->GetText();
	name.TrimWhitespace();
	if (name.IsEmpty())
		{
		JGetUserNotification()->ReportError("You must specify a name for this fit.");
		itsNameInput->Focus();
		return kJFalse;
		}

	JBoolean checked	= kJFalse;
	const JSize count	= 10;
	for (JIndex i = 1; i <= count; i++)
		{
		if (itsCB[i-1]->IsChecked())
			{
			checked		= kJTrue;
			break;
			}
		}

	if (!checked)
		{
		JGetUserNotification()->ReportError("You must add at least one power.");
		}

	return checked;
}
JBoolean
SVNDuplicateRepoItemDialog::OKToDeactivate()
{
	if (!JXGetStringDialog::OKToDeactivate())
		{
		return kJFalse;
		}
	else if (Cancelled())
		{
		return kJTrue;
		}

	const JString& name = GetString();
	JNamedTreeNode* node;
	if ((itsSrcNode->GetNamedParent())->FindNamedChild(name, &node))
		{
		(JGetUserNotification())->ReportError(JGetString("NameUsed::SVNDuplicateRepoItemDialog"));
		return kJFalse;
		}
	else
		{
		return kJTrue;
		}
}
void CNewFilesBox::OnThreadProc(void)
{
	GTimeVal time;

	g_mutex_lock(m_DataMutex);
	while (!Cancelled()) {
		m_Delay = true;
		g_mutex_unlock(m_DataMutex);
		m_Checker.Check(NewFrameCB, this);
		g_mutex_lock(m_DataMutex);
		if (m_Delay && !m_StopThread) {
			if (m_State!=STATE_WAIT) {
				m_State = STATE_WAIT;
				PushMessage(EVENT_UPDATE, 0);
			}
			g_get_current_time(&time);
			g_time_val_add(&time, 3000000);
			g_cond_timed_wait(m_Cond, m_DataMutex, &time);
		}
	}
	m_State = STATE_STOP;
	PushMessage(EVENT_UPDATE, 0);
	g_mutex_unlock(m_DataMutex);
}
JBoolean
JXSaveFileDialog::OKToDeactivate()
{
	if (!JXCSFDialogBase::OKToDeactivate())
		{
		return kJFalse;
		}
	else if (Cancelled())
		{
		return kJTrue;
		}

	JXPathInput* pathInput = GetPathInput();
	if (pathInput->HasFocus())
		{
		GoToItsPath();
		return kJFalse;
		}

	JXInputField* filterInput = GetFilterInput();
	if (filterInput->HasFocus())
		{
		AdjustFilter();
		return kJFalse;
		}

	JXDirTable* fileBrowser = GetFileBrowser();
	if (fileBrowser->HasFocus() && fileBrowser->GoToSelectedDirectory())
		{
		return kJFalse;
		}

	const JString& fileName = itsFileNameInput->GetText();
	if (fileName.IsEmpty())
		{
		(JGetUserNotification())->ReportError("You need to enter a file name.");
		return kJFalse;
		}

	const JString& path     = GetPath();
	const JString fullName  = path + fileName;

	const JBoolean fileExists = JFileExists(fullName);

	if (JDirectoryExists(fullName))
		{
		(JGetUserNotification())->ReportError(
			"This name is already used for a directory.");
		return kJFalse;
		}
	else if (!JDirectoryWritable(path) && !fileExists)
		{
		(JGetUserNotification())->ReportError(
			"You are not allowed to write to this directory.");
		return kJFalse;
		}
	else if (!fileExists)
		{
		*itsFileName = fileName;
		return kJTrue;
		}
	else if (!JFileWritable(fullName))
		{
		(JGetUserNotification())->ReportError(
			"You are not allowed to write to this file.");
		return kJFalse;
		}
	else if ((JGetUserNotification())->AskUserNo("That file already exists.  Replace it?"))
		{
		*itsFileName = fileName;
		return kJTrue;
		}
	else
		{
		return kJFalse;
		}
}
JBoolean
CBNewProjectSaveFileDialog::OKToDeactivate()
{
	if (!JXSaveFileDialog::OKToDeactivate())
		{
		return kJFalse;
		}
	else if (Cancelled())
		{
		return kJTrue;
		}

	const CBBuildManager::MakefileMethod method = GetMakefileMethod();
	if (method == CBBuildManager::kManual)
		{
		return kJTrue;
		}

	// ask if OK to replace Make.files

	if (method == CBBuildManager::kMakemake)
		{
		const JString makeFilesName = CBBuildManager::GetMakeFilesName(GetPath());
		if (JFileExists(makeFilesName) &&
			!OKToReplaceFile(makeFilesName, JGetString("CBName")))
			{
			return kJFalse;
			}
		}

	// ask if OK to replace CMakeLists.txt

	if (method == CBBuildManager::kCMake)
		{
		JString projFileName, projRoot, projSuffix;
		GetFileName(&projFileName);
		JSplitRootAndSuffix(projFileName, &projRoot, &projSuffix);

		const JString cmakeInputName = CBBuildManager::GetCMakeInputName(GetPath(), projRoot);
		if (JFileExists(cmakeInputName) &&
			!OKToReplaceFile(cmakeInputName, JGetString("CBName")))
			{
			return kJFalse;
			}
		}

	// ask if OK to replace .pro

	if (method == CBBuildManager::kQMake)
		{
		JString projFileName, projRoot, projSuffix;
		GetFileName(&projFileName);
		JSplitRootAndSuffix(projFileName, &projRoot, &projSuffix);

		const JString qmakeInputName = CBBuildManager::GetQMakeInputName(GetPath(), projRoot);
		if (JFileExists(qmakeInputName) &&
			!OKToReplaceFile(qmakeInputName, JGetString("CBName")))
			{
			return kJFalse;
			}
		}

	// ask if OK to replace existing Makefile

	JPtrArray<JString> makefileList(JPtrArrayT::kDeleteAll);
	CBBuildManager::GetMakefileNames(GetPath(), &makefileList);

	const JSize count = makefileList.GetElementCount();
	for (JIndex i=1; i<=count; i++)
		{
		const JString* fullName = makefileList.NthElement(i);
		if (JFileExists(*fullName) &&
			!OKToReplaceFile(*fullName, CBBuildManager::GetMakefileMethodName(GetMakefileMethod())))
			{
			return kJFalse;
			}
		}

	return kJTrue;
}
Example #20
0
 void Cancel() {
     Cancelled(this);
 }
Example #21
0
RipCDDialog::RipCDDialog(QWidget* parent)
    : QDialog(parent),
      ui_(new Ui_RipCDDialog),
      ripper_(new Ripper(this)),
      working_(false) {
  // Init
  ui_->setupUi(this);

  // Set column widths in the QTableWidget.
  ui_->tableWidget->horizontalHeader()->setResizeMode(
      kCheckboxColumn, QHeaderView::ResizeToContents);
  ui_->tableWidget->horizontalHeader()->setResizeMode(
      kTrackNumberColumn, QHeaderView::ResizeToContents);
  ui_->tableWidget->horizontalHeader()->setResizeMode(kTrackTitleColumn,
                                                      QHeaderView::Stretch);

  // Add a rip button
  rip_button_ = ui_->button_box->addButton(tr("Start ripping"),
                                           QDialogButtonBox::ActionRole);
  cancel_button_ = ui_->button_box->button(QDialogButtonBox::Cancel);
  close_button_ = ui_->button_box->button(QDialogButtonBox::Close);

  // Hide elements
  cancel_button_->hide();
  ui_->progress_group->hide();

  connect(ui_->select_all_button, SIGNAL(clicked()), SLOT(SelectAll()));
  connect(ui_->select_none_button, SIGNAL(clicked()), SLOT(SelectNone()));
  connect(ui_->invert_selection_button, SIGNAL(clicked()),
          SLOT(InvertSelection()));
  connect(rip_button_, SIGNAL(clicked()), SLOT(ClickedRipButton()));
  connect(cancel_button_, SIGNAL(clicked()), ripper_, SLOT(Cancel()));
  connect(close_button_, SIGNAL(clicked()), SLOT(hide()));

  connect(ui_->options, SIGNAL(clicked()), SLOT(Options()));
  connect(ui_->select, SIGNAL(clicked()), SLOT(AddDestination()));

  connect(ripper_, SIGNAL(Finished()), SLOT(Finished()));
  connect(ripper_, SIGNAL(Cancelled()), SLOT(Cancelled()));
  connect(ripper_, SIGNAL(ProgressInterval(int, int)),
          SLOT(SetupProgressBarLimits(int, int)));
  connect(ripper_, SIGNAL(Progress(int)), SLOT(UpdateProgressBar(int)));

  setWindowTitle(tr("Rip CD"));
  AddDestinationDirectory(QDir::homePath());

  // Get presets
  QList<TranscoderPreset> presets = Transcoder::GetAllPresets();
  qSort(presets.begin(), presets.end(), ComparePresetsByName);
  for (const TranscoderPreset& preset : presets) {
    ui_->format->addItem(
        QString("%1 (.%2)").arg(preset.name_).arg(preset.extension_),
        QVariant::fromValue(preset));
  }

  // Load settings
  QSettings s;
  s.beginGroup(kSettingsGroup);
  last_add_dir_ = s.value("last_add_dir", QDir::homePath()).toString();

  QString last_output_format = s.value("last_output_format", "ogg").toString();
  for (int i = 0; i < ui_->format->count(); ++i) {
    if (last_output_format ==
        ui_->format->itemData(i).value<TranscoderPreset>().extension_) {
      ui_->format->setCurrentIndex(i);
      break;
    }
  }
}