Exemple #1
0
bool MainWidget::qt_invoke( int _id, QUObject* _o )
{
    switch ( _id - staticMetaObject()->slotOffset() ) {
    case 0: upClicked(); break;
    case 1: downClicked(); break;
    case 2: leftClicked(); break;
    case 3: rightClicked(); break;
    case 4: menuClicked(); break;
    case 5: radioClicked(); break;
    case 6: mp3Clicked(); break;
    case 7: gpsClicked(); break;
    case 8: obdiiClicked(); break;
    case 9: photoClicked(); break;
    case 10: linuxClicked(); break;
    default:
	return QWidget::qt_invoke( _id, _o );
    }
    return TRUE;
}
Exemple #2
0
TemplateImageOpenDialog::TemplateImageOpenDialog(TemplateImage* templ, QWidget* parent)
 : QDialog(parent, Qt::WindowSystemMenuHint | Qt::WindowTitleHint), templ(templ)
{
	setWindowTitle(tr("Opening %1").arg(templ->getTemplateFilename()));
	
	QLabel* size_label = new QLabel("<b>" + tr("Image size:") + QString("</b> %1 x %2")
		.arg(templ->getImage().width()).arg(templ->getImage().height()));
	
	QLabel* desc_label = new QLabel(tr("Specify how to position or scale the image:"));
	
	bool use_meters_per_pixel;
	double meters_per_pixel;
	double dpi;
	double scale;
	templ->getMap()->getImageTemplateDefaults(use_meters_per_pixel, meters_per_pixel, dpi, scale);
	
	QString georef_type_string;
	if (templ->getAvailableGeoreferencing() == TemplateImage::Georeferencing_WorldFile)
		georef_type_string = tr("World file");
	else if (templ->getAvailableGeoreferencing() == TemplateImage::Georeferencing_GeoTiff)
		georef_type_string = tr("GeoTiff");
	else if (templ->getAvailableGeoreferencing() == TemplateImage::Georeferencing_None)
		georef_type_string = tr("no georeferencing information");
	
	georef_radio = new QRadioButton(tr("Georeferenced") +
		(georef_type_string.isEmpty() ? "" : (" (" + georef_type_string + ")")));
	georef_radio->setEnabled(templ->getAvailableGeoreferencing() != TemplateImage::Georeferencing_None);
	
	mpp_radio = new QRadioButton(tr("Meters per pixel:"));
	mpp_edit = new QLineEdit((meters_per_pixel > 0) ? QString::number(meters_per_pixel) : "");
	mpp_edit->setValidator(new DoubleValidator(0, 999999, mpp_edit));
	
	dpi_radio = new QRadioButton(tr("Scanned with"));
	dpi_edit = new QLineEdit((dpi > 0) ? QString::number(dpi) : "");
	dpi_edit->setValidator(new DoubleValidator(1, 999999, dpi_edit));
	QLabel* dpi_label = new QLabel(tr("dpi"));
	
	QLabel* scale_label = new QLabel(tr("Template scale:  1 :"));
	scale_edit = new QLineEdit((scale > 0) ? QString::number(scale) : "");
	scale_edit->setValidator(new QIntValidator(1, 999999, scale_edit));
	
	if (georef_radio->isEnabled())
		georef_radio->setChecked(true);
	else if (use_meters_per_pixel)
		mpp_radio->setChecked(true);
	else
		dpi_radio->setChecked(true);
	
	QHBoxLayout* mpp_layout = new QHBoxLayout();
	mpp_layout->addWidget(mpp_radio);
	mpp_layout->addWidget(mpp_edit);
	mpp_layout->addStretch(1);
	QHBoxLayout* dpi_layout = new QHBoxLayout();
	dpi_layout->addWidget(dpi_radio);
	dpi_layout->addWidget(dpi_edit);
	dpi_layout->addWidget(dpi_label);
	dpi_layout->addStretch(1);
	QHBoxLayout* scale_layout = new QHBoxLayout();
	scale_layout->addSpacing(16);
	scale_layout->addWidget(scale_label);
	scale_layout->addWidget(scale_edit);
	scale_layout->addStretch(1);
	
	QPushButton* cancel_button = new QPushButton(tr("Cancel"));
	open_button = new QPushButton(QIcon(":/images/arrow-right.png"), tr("Open"));
	open_button->setDefault(true);
	
	QHBoxLayout* buttons_layout = new QHBoxLayout();
	buttons_layout->addWidget(cancel_button);
	buttons_layout->addStretch(1);
	buttons_layout->addWidget(open_button);
	
	QVBoxLayout* layout = new QVBoxLayout();
	layout->addWidget(size_label);
	layout->addSpacing(16);
	layout->addWidget(desc_label);
	layout->addWidget(georef_radio);
	layout->addLayout(mpp_layout);
	layout->addLayout(dpi_layout);
	layout->addLayout(scale_layout);
	layout->addSpacing(16);
	layout->addLayout(buttons_layout);
	setLayout(layout);
	
	connect(mpp_edit, SIGNAL(textEdited(QString)), this, SLOT(setOpenEnabled()));
	connect(dpi_edit, SIGNAL(textEdited(QString)), this, SLOT(setOpenEnabled()));
	connect(scale_edit, SIGNAL(textEdited(QString)), this, SLOT(setOpenEnabled()));
	connect(cancel_button, SIGNAL(clicked(bool)), this, SLOT(reject()));
	connect(open_button, SIGNAL(clicked(bool)), this, SLOT(doAccept()));
	connect(georef_radio, SIGNAL(clicked(bool)), this, SLOT(radioClicked()));
	connect(mpp_radio, SIGNAL(clicked(bool)), this, SLOT(radioClicked()));
	connect(dpi_radio, SIGNAL(clicked(bool)), this, SLOT(radioClicked()));
	
	radioClicked();
}