Example #1
0
File: main.cpp Project: Afreeca/qt
int main(int argc, char *argv[])
{
    QApplication app(argc, argv);
    if (!createConnection())
        return 1;

    QSqlQueryModel plainModel;
    EditableSqlModel editableModel;
    CustomSqlModel customModel;

    initializeModel(&plainModel);
    initializeModel(&editableModel);
    initializeModel(&customModel);

#if defined(Q_OS_SYMBIAN) || defined(Q_WS_MAEMO_5) || defined(Q_WS_SIMULATOR)
    QTabWidget *tabWidget = new QTabWidget;
    tabWidget->addTab(createView(&plainModel), QObject::tr("Plain"));
    tabWidget->addTab(createView(&editableModel), QObject::tr("Editable"));
    tabWidget->addTab(createView(&customModel), QObject::tr("Custom"));
    tabWidget->showMaximized();
#else
    createView(&plainModel, QObject::tr("Plain Query Model"));
    createView(&editableModel, QObject::tr("Editable Query Model"));
    createView(&customModel, QObject::tr("Custom Query Model"));
#endif

    return app.exec();
}
Example #2
0
int main(int argc, char *argv[])
{
    QApplication app(argc, argv);
    if (!createConnection())
        return 1;

    QSqlTableModel model;

    initializeModel(&model);

#if defined(Q_OS_SYMBIAN) || defined(Q_WS_MAEMO_5) || defined(Q_WS_SIMULATOR)
    QTabWidget *tabWidget = new QTabWidget;
    tabWidget->addTab(createView(&model), "View 1");
    tabWidget->addTab(createView(&model), "View 2");

    tabWidget->showMaximized();
#else
    QTableView *view1 = createView(&model, QObject::tr("Table Model (View 1)"));
    QTableView *view2 = createView(&model, QObject::tr("Table Model (View 2)"));

    view1->show();
    view2->move(view1->x() + view1->width() + 20, view1->y());
    view2->show();
#endif

    return app.exec();
}
Example #3
0
int main( int argc, char **argv )
{
    QApplication a( argc, argv );
    QTabWidget tab;
    Scribble scribble(&tab, "scribble");
    TabletStats tabStats( &tab, "tablet stats" );
    
    scribble.setMinimumSize( 500, 350 );
    tabStats.setMinimumSize( 500, 350 );
    tab.addTab(&scribble, "Scribble" );
    tab.addTab(&tabStats, "Tablet Stats" );
    
    a.setMainWidget( &tab );
    if ( QApplication::desktop()->width() > 550
	 && QApplication::desktop()->height() > 366 )
	tab.show();
    else
	tab.showMaximized();
    return a.exec();
}
static int dynamicNormalizerGuiMain(int argc, char* argv[])
{
	uint32_t versionMajor, versionMinor, versionPatch;
	MDynamicAudioNormalizer::getVersionInfo(versionMajor, versionMinor, versionPatch);

	//initialize application
	QApplication app(argc, argv);
	app.setWindowIcon(QIcon(":/res/chart_curve.png"));
	app.setStyle(new QPlastiqueStyle());

	//create basic tab widget
	QTabWidget window;
	window.setWindowTitle(QString("Dynamic Audio Normalizer - Log Viewer [%1]").arg(QString().sprintf("v%u.%02u-%u", versionMajor, versionMinor, versionPatch)));
	window.setMinimumSize(640, 480);
	window.show();

	//get arguments
	const QStringList args = app.arguments();
	
	//choose input file
	const QString logFileName = (args.size() < 2) ? QFileDialog::getOpenFileName(&window, "Open Log File", QString(), QString("Log File (*.log)")) : args.at(1);
	if(logFileName.isEmpty())
	{
		return EXIT_FAILURE;
	}

	//check for existence
	if(!(QFileInfo(logFileName).exists() && QFileInfo(logFileName).isFile()))
	{
		QMessageBox::critical(&window, QString().sprintf("Dynamic Audio Normalizer"), QString("Error: The specified log file could not be found!"));
		return EXIT_FAILURE;
	}

	//open the input file
	QFile logFile(logFileName);
	if(!logFile.open(QIODevice::ReadOnly | QIODevice::Text))
	{
		QMessageBox::critical(&window, QString().sprintf("Dynamic Audio Normalizer"), QString("Error: The selected log file could not opened for reading!"));
		return EXIT_FAILURE;
	}

	//wrap into text stream
	QTextStream textStream(&logFile);
	textStream.setCodec("UTF-8");

	double minValue = DBL_MAX;
	double maxValue = 0.0;
	unsigned int channels = 0;

	//parse header
	if(!parseHeader(textStream, channels))
	{
		QMessageBox::critical(&window, QString("Dynamic Audio Normalizer"), QString("Error: Failed to parse the header of the log file!\nProbably the file is of an unsupported type."));
		return EXIT_FAILURE;
	}

	//allocate buffers
	LogFileData *data = new LogFileData[channels];
	QCustomPlot *plot = new QCustomPlot[channels];

	//load data
	parseData(textStream, channels, data, minValue, maxValue);
	logFile.close();

	//check data
	if((data[0].original.size() < 1) || (data[0].minimal.size() < 1) || (data[0].smoothed.size() < 1))
	{
		QMessageBox::critical(&window, QString("Dynamic Audio Normalizer"), QString("Error: Failed to load data. Log file countains no valid data!"));
		delete [] data;
		delete [] plot;
		return EXIT_FAILURE;
	}

	//determine length of data
	unsigned int length = UINT_MAX;
	for(unsigned int c = 0; c < channels; c++)
	{
		length = qMin(length, (unsigned int) data[c].original.count());
		length = qMin(length, (unsigned int) data[c].minimal .count());
		length = qMin(length, (unsigned int) data[c].smoothed.count());
	}

	//create x-axis steps
	QVector<double> steps(length);
	for(unsigned int i = 0; i < length; i++)
	{
		steps[i] = double(i);
	}

	//now create the plots
	for(unsigned int c = 0; c < channels; c++)
	{
		//init the legend
		plot[c].legend->setVisible(true);
		plot[c].legend->setFont(QFont("Helvetica", 9));

		//create graph and assign data to it:
		createGraph(&plot[c], steps, data[c].original, Qt::blue,  Qt::SolidLine, 1);
		createGraph(&plot[c], steps, data[c].minimal,  Qt::green, Qt::SolidLine, 1);
		createGraph(&plot[c], steps, data[c].smoothed, Qt::red,   Qt::DashLine,  2);

		//set plot names
		plot[c].graph(0)->setName("Local Max. Gain");
		plot[c].graph(1)->setName("Minimum Filtered");
		plot[c].graph(2)->setName("Final Smoothed");

		//set axes labels:
		plot[c].xAxis->setLabel("Frame #");
		plot[c].yAxis->setLabel("Gain Factor");
		makeAxisBold(plot[c].xAxis);
		makeAxisBold(plot[c].yAxis);

		//set axes ranges
		plot[c].xAxis->setRange(0.0, length);
		plot[c].yAxis->setRange(minValue - 0.25, maxValue + 0.25);
		plot[c].yAxis->setScaleType(QCPAxis::stLinear);
		plot[c].yAxis->setTickStep(1.0);
		plot[c].yAxis->setAutoTickStep(false);

		//add title
		plot[c].plotLayout()->insertRow(0);
		plot[c].plotLayout()->addElement(0, 0, new QCPPlotTitle(&plot[c], QString("%1 (Channel %2/%3)").arg(QFileInfo(logFile).fileName(), QString::number(c+1), QString::number(channels))));

		//show the plot
		plot[c].replot();
		window.addTab(&plot[c], QString().sprintf("Channel #%u", c + 1));
	}

	//run application
	window.showMaximized();
	app.exec();

	//clean up
	delete [] data;
	delete [] plot;

	return EXIT_SUCCESS;
}