コード例 #1
0
ファイル: weddoc.cpp プロジェクト: akavel/wed-editor
void CWedDoc::SaveBackup(const char *docname)

{
	CString	 num, filename = docname;
    PathToFname(filename);

	if(access(docname, 0) < 0)
		{
		num.Format("File %s does not exist, did make auto backup ", filename);
		message(num);
		//AfxMessageBox(num);
		return;
		}

	// Save only if smaller then 2 Meg
	if(docstat.st_size > MAX_BACKUP)
		{
		num.Format("File is too large for auto backup ", filename);
		message(num);
		return;
		}

	// Truncate up tp the first backslash
	int idx; CString tfn(docname);

	idx = tfn.Find("\\\\");
	if(idx >= 0)
		{
		tfn = tfn.Right(tfn.GetLength() - (idx + 1) );
		}
	else
		{
		idx = tfn.Find('\\');
		if(idx >= 0)
			{
			tfn = tfn.Right(tfn.GetLength() - (idx) );
			}
		}

	CString fbackup;
	//int hhh = HashString(docname);

	fbackup.Format("%sbackup%s", dataroot, tfn);
	create_full_dir(fbackup);

	CString fbdir(fbackup);
	PathToDir(fbdir);
	fbdir += "history\\"; fbdir += filename;

	//P2N("Sent backup copy to: %s\r\n", fbackup);

	// See if backup file exists already
    struct _stat docstat_o, docstat_b;

	_stat(docname, &docstat_o);

	CTime ct(docstat_o.st_mtime);
	CString datestr = ct.Format(".%a_%b_%d_%Y--%H_%M");
	fbdir += datestr;

	//P2N("Sent backup history to: %s\r\n", fbdir);

	// If backup is less than ....
	if(_stat(fbackup, &docstat_b) >=0)
		{
		//P2N("Document %s m_time=%d BackupFile m_time=%d \r\n",
        //              docname, docstat_o.st_mtime,  docstat_b.st_mtime );

		//if((docstat_o.st_mtime -  docstat_b.st_mtime) > 10)
			{
			//P2N("***Backing up: %s\r\n", fbackup);
			create_full_dir(fbdir);
			rename(fbackup, fbdir);
			}
		}

 	CFile cf;
	if(cf.Open(fbackup, CFile::modeCreate | CFile::modeWrite ))
		{
		num.Format("Saving backup copy %s ", filename);
		message(num);
		CArchive ar(&cf, CArchive::store);
		Serialize(ar, fbackup);
		}
	else
		{
		num.Format("Could not create backup copy of %s ", filename);
		message(num);
		//P2N("Cannot create backup copy of: %s\r\n", droot);
		}
}
コード例 #2
0
void page_fluxbox_settings::LoadSettings(int){
  emit HasPendingChanges(false);
  emit ChangePageTitle( tr("Window Manager Settings") );
  loading = true;
  if(ui->radio_simple->isChecked()){
    ui->stackedWidget->setCurrentWidget(ui->page_simple); //ensure the proper page is visible
    ui->combo_session_wfocus->clear();
    ui->combo_session_wfocus->addItem( tr("Click To Focus"), "ClickToFocus");
    ui->combo_session_wfocus->addItem( tr("Active Mouse Focus"), "MouseFocus");
    ui->combo_session_wfocus->addItem( tr("Strict Mouse Focus"), "StrictMouseFocus");

    ui->combo_session_wloc->clear();
    ui->combo_session_wloc->addItem( tr("Align in a Row"), "RowSmartPlacement");
    ui->combo_session_wloc->addItem( tr("Align in a Column"), "ColSmartPlacement");
    ui->combo_session_wloc->addItem( tr("Cascade"), "CascadePlacement");
    ui->combo_session_wloc->addItem( tr("Underneath Mouse"), "UnderMousePlacement");

    ui->combo_session_wtheme->clear();
    QStringList dirs; dirs << LOS::AppPrefix()+"share/fluxbox/styles" << QDir::homePath()+"/.fluxbox/styles";
    QFileInfoList fbstyles; 
    for(int i=0; i<dirs.length(); i++){
      QDir fbdir(dirs[i]);
      fbstyles << fbdir.entryInfoList(QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name | QDir::IgnoreCase);
    }
    QString lastdir;
    for(int i=0; i<fbstyles.length(); i++){
      if(lastdir!=fbstyles[i].absolutePath()){
        lastdir = fbstyles[i].absolutePath(); //save for checking later
        if(ui->combo_session_wtheme->count()>0){ ui->combo_session_wtheme->insertSeparator(ui->combo_session_wtheme->count()); }
      }
      ui->combo_session_wtheme->addItem(fbstyles[i].fileName(), fbstyles[i].absoluteFilePath());
    }

    QStringList FB = readFile(QString(getenv("XDG_CONFIG_HOME"))+"/lumina-desktop/fluxbox-init");
    QString val;
    //Do the window placement
    val = FB.filter("session.screen0.windowPlacement:").join("").section(":",1,1).simplified();
    //qDebug() << "Window Placement:" << val;
    int index = ui->combo_session_wloc->findData(val);
    if(index<0){ index = 0;} //use the default
    ui->combo_session_wloc->setCurrentIndex(index);

    //Do the window focus
    val = FB.filter("session.screen0.focusModel:").join("").section(":",1,1).simplified();
    //qDebug() << "Window Focus:" <<  val;
    index = ui->combo_session_wfocus->findData(val);
    if(index<0){ index = 0;} //use the default
    ui->combo_session_wfocus->setCurrentIndex(index);

    //Do the window theme
    val = FB.filter("session.styleFile:").join("").section(":",1,1).simplified();
    //qDebug() << "Window Theme:" << val;
    index = ui->combo_session_wtheme->findData(val);
    if(index<0){ index = 0;} //use the default
    ui->combo_session_wtheme->setCurrentIndex(index);

    //Now the number of workspaces
    val = FB.filter("session.screen0.workspaces:").join("").section(":",1,1).simplified();
    //qDebug() << "Number of Workspaces:" << val;
    if(!val.isEmpty()){ ui->spin_session_wkspaces->setValue(val.toInt()); }
  }else{
    //Advanced editor
    ui->stackedWidget->setCurrentWidget(ui->page_advanced); //ensure the proper page is visible
    ui->text_file->setPlainText( readFile(QString(getenv("XDG_CONFIG_HOME"))+"/lumina-desktop/fluxbox-init").join("\n") );
  }
  QApplication::processEvents();
  loading = false;
}