Esempio n. 1
1
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent)
{
    QMenu *file;
    QMenu *edit;
    QMenu *effect;
    QMenu *tools;
    QMenu *help;
    QAction *newa = new QAction(tr("&New"), this);
    QAction *open = new QAction(tr("&Open"), this);
    QAction *save = new QAction(tr("&Save"), this);
    QAction *saveas = new QAction(tr("&Save as"), this);
    QAction *import = new QAction(tr("&Import sample"), this);
    QAction *quit = new QAction(tr("&Quit"), this);
    QAction *play = new QAction(tr("&Play"), this);
    QAction *stop = new QAction(tr("&Stop"), this);
    QAction *pause = new QAction(tr("&Pause"), this);
    QAction *record= new QAction(tr("&Record"), this);
    QAction *zoomin  = new QAction(tr("Zoom in"), this);
    QAction *zoomout = new QAction(tr("Zoom out"), this);
    QAction *settings = new QAction(tr("&Settings"), this);
    QToolBar *toolbar = addToolBar("Main ToolBar");
    QLCDNumber *lcd = new QLCDNumber();
    QLabel * play_v = new QLabel(), * rec_v = new QLabel();
    QSlider * play_slider = new QSlider(Qt::Horizontal), * rec_slider = new QSlider(Qt::Horizontal);
    wave = new Wave();
    fileName = "";
    changed = false;
    newa->setIcon(QIcon::fromTheme("document-new"));
    newa->setShortcut(tr("CTRL+N"));
    open->setIcon(QIcon::fromTheme("document-open"));
    open->setShortcut(tr("CTRL+O"));
    save->setIcon(QIcon::fromTheme("document-save"));
    save->setShortcut(tr("CTRL+S"));
    saveas->setIcon(QIcon::fromTheme("document-save-as"));
    import->setIcon(QIcon::fromTheme("audio-x-generic"));
    zoomin->setIcon(QIcon::fromTheme("zoom-in"));
    zoomin->setShortcut(tr("CTRL+Up"));
    zoomout->setIcon(QIcon::fromTheme("zoom-out"));
    zoomout->setShortcut(tr("CTRL+Down"));
    play->setIcon(QIcon::fromTheme("media-playback-start"));
    play->setShortcut(tr("Space"));
    play->setCheckable(true);
    stop->setIcon(QIcon::fromTheme("media-playback-stop"));
    pause->setIcon(QIcon::fromTheme("media-playback-pause"));
    record->setIcon(QIcon::fromTheme("media-record"));
    record->setShortcut(tr("Ctrl+Space"));
    record->setCheckable(true);
    quit->setIcon(QIcon::fromTheme("application-exit"));
    quit->setShortcut(tr("CTRL+Q"));
    lcd->setDigitCount(8);
    lcd->display("00:00:00");
    lcd->setStyleSheet("background: black; color: #00FF00");
    lcd->setFixedSize(100, 30);
    play_v->setText(tr("Playback volume:"));
    rec_v->setText(tr("Record volume:"));
    play_slider->setMaximumWidth(50);
    play_slider->setRange(0, 100);
    rec_slider->setMaximumWidth(50);
    rec_slider->setRange(0, 100);
    file = menuBar()->addMenu(tr("&File"));
    file->addAction(newa);
    file->addAction(open);
    file->addAction(save);
    file->addAction(saveas);
    file->addSeparator();
    file->addAction(import);
    file->addSeparator();
    file->addAction(quit);
    edit = menuBar()->addMenu(tr("&Edit"));
    effect = menuBar()->addMenu(tr("&Effects"));
    tools = menuBar()->addMenu(tr("&Tools"));
    settings->setIcon(QIcon::fromTheme("multimedia-volume-control"));
    tools->addAction(settings);
    help = menuBar()->addMenu(tr("&Help"));

    toolbar->addAction(newa);
    toolbar->addAction(open);
    toolbar->addAction(save);
    toolbar->addSeparator();
    toolbar->addAction(import);
    toolbar->addAction(zoomin);
    toolbar->addAction(zoomout);
    toolbar->addSeparator();
    toolbar->addAction(stop);
    toolbar->addAction(pause);
    toolbar->addAction(play);
    toolbar->addAction(record);
    toolbar->addSeparator();
    toolbar->addWidget(play_v);
    toolbar->addWidget(play_slider);
    toolbar->addWidget(rec_v);
    toolbar->addWidget(rec_slider);
    toolbar->addWidget(lcd);
    connect(newa, SIGNAL(triggered()), this, SLOT(newFile()));
    connect(open, SIGNAL(triggered()), this, SLOT(openFile()));
    connect(save, SIGNAL(triggered()), this, SLOT(saveFile()));
    connect(saveas, SIGNAL(triggered()), this, SLOT(saveFileAs()));
    connect(quit, SIGNAL(triggered()), qApp, SLOT(quit()));

    connect(zoomin, SIGNAL(triggered()), this, SLOT(zoomIn()));
    connect(zoomout, SIGNAL(triggered()), this, SLOT(zoomOut()));

    connect(settings, SIGNAL(triggered()), this, SLOT(settings()));
    setCentralWidget(wave);
    float * buffer;
    buffer = (float*)malloc(44100*sizeof(float));
    for (unsigned int i=0; i<44100; i++)
    {
        buffer[i]=sin(1*(2*M_PI)*i/44100);
    }
    wave->setSampleRate(44100);
    wave->setBytesPerSecond(1000);
    wave->setBuffer(buffer, 44100);
}
Esempio n. 2
0
int main(int argc, char *argv[])
{
	QApplication app(argc, argv);
	QMainWindow *window = new QMainWindow();    
    
        window->setWindowTitle(QString::fromUtf8("QLCDnumber Show Milliseconds Time"));
        window->resize(800, 250);
	QWidget* centralWidget = new QWidget();
	
	QVBoxLayout* verticalLayout = new QVBoxLayout();
	centralWidget->setLayout(verticalLayout);
        
	QLCDNumber *number = new QLCDNumber();	
	
	verticalLayout->addWidget(number);
	
	
	number->setFixedSize(-800, 245);
	number->setDigitCount(12);
	number->display(QTime::currentTime().toString(QString("hh:mm:ss.zzz")));
	
	
	window->setCentralWidget(centralWidget);
	window->show();
	return app.exec();
}