Beispiel #1
0
QString QG_FileDialog::getSaveFile(RS2::FormatType* type){
    setAcceptMode ( QFileDialog::AcceptSave );
    // read default settings:
    RS_SETTINGS->beginGroup("/Paths");
    QString defDir = RS_SETTINGS->readEntry("/Save",
                                              RS_SYSTEM->getHomeDir());
/*    QString defFilter = RS_SETTINGS->readEntry("/SaveFilter",
                                                 "Drawing Exchange DXF 2000 (*.dxf)");*/
    RS_SETTINGS->endGroup();

    if(!defDir.endsWith("/") && !defDir.endsWith("\\"))
        defDir += QDir::separator();

    RS_DEBUG->print("defDir: %s", defDir.toLatin1().data());

    // setup filters
    QStringList filters;

#ifdef USE_DXFRW
    filters << fDxf2000 << fDxfrw2000  << fDxfR12 << fLff << fCxf << fJww;
#else
    filters << fDxf2000 << fDxfR12 << fLff << fCxf << fJww;
#endif

    ftype = RS2::FormatDXF;
    RS_DEBUG->print("defFilter: %s", fDxf2000.toLatin1().data());

    // when defFilter is added the below should use the default extension.
    // generate an untitled name
    QString fn = "Untitled";
    if(QFile::exists( defDir + fn + getExtension( ftype ) ))
    {
        int fileCount = 1;
        while(QFile::exists( defDir + fn + QString("%1").arg(fileCount) +
                             getExtension(ftype)) )
            ++fileCount;
        fn += QString("%1").arg(fileCount);
    }

    // initialize dialog properties
    setWindowTitle(tr("Save %1 As").arg(name));
    setFileMode(QFileDialog::AnyFile);
    setDirectory(defDir);
    setFilters(filters);
#if QT_VERSION >= 0x040400
    selectNameFilter(fDxf2000);
#endif
    selectFile(fn);
    auto&& ext=getExtension(ftype);
    if(ext.size()==4){
        if(ext[0]=='.') ext.remove(0,1);
    }
    if(ext.size()==3) setDefaultSuffix (ext);


    // only return non empty string when we have a complete, user approved, file name.
    if (exec()!=QDialog::Accepted)
        return QString("");

    QStringList fl = selectedFiles();
    if (fl.isEmpty())
        return QString("");

    QFileInfo fi = QFileInfo( fl[0] );
    fn = QDir::convertSeparators( fi.absoluteFilePath() );

    getType(selectedFilter());
    if (type!=NULL)
        *type = ftype;

    // append default extension:
    if (fi.fileName().endsWith(".dxf",Qt::CaseInsensitive)==-1)
        fn += getExtension(ftype);

    // store new default settings:
    RS_SETTINGS->beginGroup("/Paths");
    RS_SETTINGS->writeEntry("/Save", fi.absolutePath());
    //RS_SETTINGS->writeEntry("/SaveFilter", fileDlg->selectedFilter());
    RS_SETTINGS->endGroup();

    return fn;
}
Beispiel #2
0
//shows vcards
void ram(void)
{
	char filename[13];
	uint8_t buf[MAXSIZE];
	FRESULT res;
	UINT readbytes;
	FIL file;
	uint8_t key;
	int i,j=0,lines=0;
	char *beginline=buf;
	char help;

	selectFile(filename,"CRD");
	lcdClear();
	res=f_open(&file, (const char*)filename, FA_OPEN_EXISTING|FA_READ);
	res=f_read(&file, (char *)buf, MAXSIZE, &readbytes);
	for(i=0;i<readbytes;i++)
	{
		if(lines==7)
		{
			lines=0;
			lcdRefresh();
			while(1)
			{
			    	key = getInput();
				if( key == BTN_DOWN){
			            	break;
				}

			}
		}
		if(buf[i]=='\n')
		{
			j=0;
			buf[i]=0;
			lcdPrintln(beginline);
			beginline=&buf[i+1];
			lines++;
		}
		else if(j>13)
		{
			help=buf[i];
			j=0;
			buf[i]=0;
			lcdPrintln(beginline);
			beginline=&buf[i];
			buf[i]=help;
			lines++;
		}
		j++;
		
	}
	lcdRefresh();
	while (1)
	{
	    	key = getInput();
		if( key == BTN_LEFT ){
	            	break;
		}
	}

}
Beispiel #3
0
void Gource::mousetrace(Frustum& frustum, float dt) {
    GLuint	buffer[512];
	GLint	viewport[4];

	glGetIntegerv(GL_VIEWPORT, viewport);
	glSelectBuffer(512, buffer);

    glDepthFunc(GL_LEQUAL);
    glEnable(GL_DEPTH_TEST);

    (void) glRenderMode(GL_SELECT);

    glInitNames();
    glPushName(0);

    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();

    gluPickMatrix((GLdouble) mousepos.x, (GLdouble) (viewport[3]-mousepos.y), 1.0f, 1.0f, viewport);
    gluPerspective(90.0f, (GLfloat)display.width/(GLfloat)display.height, 0.1f, camera.getZFar());
    camera.look();

    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();

    for(std::map<std::string,RUser*>::iterator it = users.begin(); it!=users.end(); it++) {
        it->second->drawSimple(dt);
    }

    glDisable(GL_TEXTURE_2D);
    glColor4f(1.0, 1.0, 1.0, 1.0);

    root->drawSimple(frustum, dt);

    glMatrixMode(GL_MODELVIEW);

    mouse_hits = glRenderMode(GL_RENDER);

    RFile* fileSelection = 0;
    RUser* userSelection = 0;

    if (mouse_hits > 0) {
        int choice   = buffer[3];
        GLuint depth = buffer[1];

        for (int loop = 1; loop < mouse_hits; loop++) {
            if (buffer[loop*4+1] < depth) {
                choice = buffer[loop*4+3];
                depth  = buffer[loop*4+1];
            }
        }

        if(choice != 0) {
            selectionDepth = depth;

            std::map<int, RFile*>::iterator filetest;
            std::map<int, RUser*>::iterator usertest;

            if((filetest = tagfilemap.find(choice)) != tagfilemap.end()) {
                fileSelection = filetest->second;
            }
            else if((usertest = tagusermap.find(choice)) != tagusermap.end()) {
                userSelection = usertest->second;
            }
		}
    }

    glDisable(GL_DEPTH_TEST);

    // is over a file
    if(fileSelection != 0) {
        // un hover a user
        if(hoverUser != 0) {
            hoverUser->setMouseOver(false);
            hoverUser = 0;
        }

        if(fileSelection != hoverFile) {
            //deselect previous selection
            if(hoverFile !=0) hoverFile->setMouseOver(false);

            //select new
            fileSelection->setMouseOver(true);
            hoverFile = fileSelection;
        }

    // is over a user
    } else if(userSelection != 0) {
        // un hover a file
        if(hoverFile != 0) {
            hoverFile->setMouseOver(false);
            hoverFile = 0;
        }

        if(userSelection != hoverUser) {
            //deselect previous selection
            if(hoverUser !=0) hoverUser->setMouseOver(false);

            //select new
            userSelection->setMouseOver(true);
            hoverUser = userSelection;
        }
    } else {
        if(hoverFile!=0) hoverFile->setMouseOver(false);
        if(hoverUser!=0) hoverUser->setMouseOver(false);
        hoverFile=0;
        hoverUser=0;
    }

    if(mouseclicked) {
        if(hoverUser!=0) selectUser(hoverUser);
        else if(hoverFile!=0) selectFile(hoverFile);
        else {
            selectBackground();
        }
    }
}
Beispiel #4
0
void KfOptions::insertPages()
  {
    setFocusPolicy(QWidget::StrongFocus);    

    // First page of tab preferences dialog
    pages[0]= new QWidget(this,"page1");

    formatL     = new QLabel(i18n("File format:"),
			     pages[0],"formatL");
    fileL       = new QLabel(i18n("Save results to file:"),
			     pages[0],"fileL");
    kfindfileL  = new QLabel(i18n(
			      "Save results to file ~/.kfind-results.html"),
			     pages[0],"kfindfileL");
    browseB     = new QPushButton(i18n("Browse"),
			     pages[0],"browseB");
    formatBox   = new QComboBox(                     pages[0],"formatBox");
    fileE       = new QLineEdit(                     pages[0],"fileE");
    kfindfileB  = new QRadioButton(                  pages[0]);
    selectfileB = new QRadioButton(                  pages[0]);
    bg          = new QButtonGroup();

    bg->insert(kfindfileB);
    bg->insert(selectfileB);
    bg->setExclusive(TRUE);

    formatBox->insertItem("HTML");
    formatBox->insertItem(i18n("Plain Text"));
    formatBox->setFixedSize(formatBox    ->sizeHint());

    formatL    ->setFixedSize(formatL    ->sizeHint());
    fileL      ->setFixedSize(fileL      ->sizeHint());
    kfindfileL ->setFixedSize(kfindfileL ->sizeHint());
    kfindfileB ->setFixedSize(kfindfileB ->sizeHint());
    selectfileB->setFixedSize(selectfileB->sizeHint());
    browseB    ->setFixedSize(browseB    ->sizeHint());
    fileE      ->setFixedSize(344-(10+10+fileL->width()+browseB->width()),25);

    kfindfileB ->move(10,20);
    selectfileB->move(10,50);
    kfindfileL ->move(30,20);
    fileL      ->move(30,50);
    fileE      ->move(fileL->x()+fileL->width()+10,fileL->y()-5);
    browseB    ->move(fileE->x()+fileE->width()+10,fileL->y()-5);
    formatL    ->move(30,fileL->y()+fileL->height()+20);
    formatBox  ->move(formatL->x()+formatL->width()+20,formatL->y()-5);

    initFileSelecting();

    connect( kfindfileB  ,SIGNAL(clicked()),
             this, SLOT(setFileSelecting()) );
    connect( selectfileB ,SIGNAL(clicked()),
             this, SLOT(setFileSelecting()) );
    connect( browseB     ,SIGNAL(clicked()),
             this, SLOT(selectFile()) );

    addTab(pages[0],i18n("Saving"));


    // Third page of tab preferences dialog
    pages[1]= new QWidget(this,"page3");

    archiversLBox   = new QListBox(                pages[1],"archivesLBox");
    createL         = new QLabel(i18n("Create Archive:"),
				 pages[1],"createL");
    addL            = new QLabel(i18n("Add to Archive:"),
				 pages[1],"addL");
    createE         = new QLineEdit(               pages[1],"createE");
    addE            = new QLineEdit(               pages[1],"addE");
    paternsL2       = new QLabel(i18n("Patterns:"),
				 pages[1],"paternsL2");
    paternsLBox2    = new QListBox(                pages[1],"paternsLBox2");
    addArchiverB    = new QPushButton(i18n("Add New"),
				      pages[1],"addArchiverB");
    removeArchiverB = new QPushButton(i18n("Remove"),
				      pages[1],"removeArchiverB");

    createE        ->setEnabled(FALSE);
    addE           ->setEnabled(FALSE);
    addArchiverB   ->setEnabled(FALSE);
    removeArchiverB->setEnabled(FALSE);

    archiversLBox->setFixedSize(120,240);
    createL      ->setFixedSize((createL->sizeHint()).width(),25);
    addL         ->setFixedSize(createL->width(),25);
    createE      ->setFixedSize(130,25);
    addE         ->setFixedSize(130,25);
    paternsL2    ->setFixedSize(createL->width(),25);
    paternsLBox2 ->setFixedSize(130,100);

    int tmpP = archiversLBox->x()+archiversLBox->width()+10;

    archiversLBox ->move(10,10);
    createL       ->move(tmpP+15,15);
    addL          ->move(tmpP+15,createL->y()+30);
    paternsL2     ->move(tmpP+15,addL->y()+30);
    addArchiverB  ->move(tmpP+10,
			 10+archiversLBox->height()-removeArchiverB->height());
    removeArchiverB->move(addArchiverB->x()+addArchiverB->width()+35,
			 10+archiversLBox->height()-removeArchiverB->height());

    tmpP = createL->x()+createL->width()+10;

    createE     ->move(tmpP,15);
    addE        ->move(tmpP,createL->y()+30);
    paternsLBox2->move(tmpP,addL->y()+30);
 
     fillArchiverLBox();
     fillArchiverDetail(0);

     connect(archiversLBox,SIGNAL(highlighted(int)),
	     this, SLOT(fillArchiverDetail(int)) );

    addTab(pages[1],i18n("Archivers"));
  };
DFileChooseInput::DFileChooseInput(QWidget *parent) :
    QWidget(parent)
{
    QHBoxLayout * inputlayout = new QHBoxLayout();
    edit_ = new QLineEdit();
    QString style = ""
    "QLineEdit {"
        "color: #b4b4b4;"
        "font-size: 13px;"
        "border-top: 1px solid #080808;"
        "border-bottom: 1px solid #474747;"
        "border-right: 0px solid #474747;"
        "border-left: 1px solid #080808;"
        "border-top-left-radius: 3px;"
        "border-top-right-radius: 0;"
        "border-bottom-right-radius: 0;"
        "border-bottom-left-radius: 3px;"
        "background: qlineargradient(x1: 1, y1: 0, x2: 0, y2: 0,"
                                "stop: 0 rgba(0, 0, 0, 50%), stop: 1 rgba(0, 0, 0, 40%));"
    "}";
    edit_->setStyleSheet(style);
    edit_->setEnabled(false);
    edit_->setFixedHeight(22);

    QPixmap pixmapfile (":/ui/images/loadfile_normal.png");
    btWidth_ = pixmapfile.size().width() + 4;
    bt_ = new QPushButton(this);
    style = "QPushButton{"
        "border-top: 1px solid #080808;"
        "border-bottom: 1px solid #474747;"
        "border-right: 1px solid #080808;"
        "border-left: 1px solid #474747;"
        "border-top-left-radius: 0;"
        "border-top-right-radius: 3px;"
        "border-bottom-right-radius: 3px;"
        "border-bottom-left-radius: 0px;"
        "background:url(:/ui/images/loadfile_normal.png);"
    "}"
    "QPushButton:hover{"
        "border-top: 1px solid #080808;"
        "border-bottom: 1px solid #474747;"
        "border-right: 1px solid #080808;"
        "border-left: 1px solid #474747;"
        "border-top-left-radius: 0;"
        "border-top-right-radius: 3px;"
        "border-bottom-right-radius: 3px;"
        "border-bottom-left-radius: 0px;"
        "background:url(:/ui/images/loadfile_hover.png);"
    "}"
    "QPushButton:pressed{"
        "border-top: 1px solid #080808;"
        "border-bottom: 1px solid #474747;"
        "border-right: 1px solid #080808;"
        "border-left: 1px solid #474747;"
        "border-top-left-radius: 0;"
        "border-top-right-radius: 3px;"
        "border-bottom-right-radius: 3px;"
        "border-bottom-left-radius: 0px;"
        "background:url(:/ui/images/loadfile_press.png);"
    "}";
    bt_->setStyleSheet(style);
    bt_->setFixedHeight(22);
    bt_->setFixedWidth(pixmapfile.size().width() + 4);

    inputlayout->setSpacing(0);
    inputlayout->setMargin(0);
    inputlayout->addWidget(edit_);
    inputlayout->addWidget(bt_);
    inputlayout->addStretch();

    connect(bt_, SIGNAL(clicked()), this, SLOT(selectFile()));

    this->setLayout(inputlayout);
}
Beispiel #6
0
//# MENU image play_animation
void t_ani(void){
    char fname[FLEN];
    selectFile(fname, "AN1");
    lcdShowAnim(fname);
}
Beispiel #7
0
//# MENU image display_image
void t_img(void){
    char fname[FLEN];
    selectFile(fname, "LCD");
    lcdShowImageFile(fname);
    getInputWait();
}