From df80c1f82140e57965f38d0a50ad2a843cf60ff5 Mon Sep 17 00:00:00 2001 From: deva Date: Tue, 24 Nov 2009 20:03:31 +0000 Subject: Initial attempt on some GUI layout... --- dgedit/audioextractor.cc | 4 +-- dgedit/audioextractor.h | 4 +-- dgedit/canvas.cc | 3 ++ dgedit/mainwindow.cc | 85 +++++++++++++++++++++++++++++++++++++++++------- dgedit/mainwindow.h | 9 +++-- 5 files changed, 87 insertions(+), 18 deletions(-) (limited to 'dgedit') diff --git a/dgedit/audioextractor.cc b/dgedit/audioextractor.cc index bde661a..8a08135 100644 --- a/dgedit/audioextractor.cc +++ b/dgedit/audioextractor.cc @@ -141,12 +141,12 @@ void AudioExtractor::removeFile(QString file) } } -void AudioExtractor::setOutputPrefix(QString p) +void AudioExtractor::setOutputPrefix(const QString &p) { prefix = p; } -void AudioExtractor::setExportPath(QString path) +void AudioExtractor::setExportPath(const QString &path) { exportpath = path; } diff --git a/dgedit/audioextractor.h b/dgedit/audioextractor.h index 40fc8fd..5254aa4 100644 --- a/dgedit/audioextractor.h +++ b/dgedit/audioextractor.h @@ -41,11 +41,11 @@ public: void addFile(QString file, QString name); void removeFile(QString file); - void setExportPath(QString path); - void setOutputPrefix(QString prefix); public slots: void exportSelections(Selections selections); + void setExportPath(const QString &path); + void setOutputPrefix(const QString &prefix); private: float *load(QString file, size_t *size); diff --git a/dgedit/canvas.cc b/dgedit/canvas.cc index a487e27..23cd96e 100644 --- a/dgedit/canvas.cc +++ b/dgedit/canvas.cc @@ -132,6 +132,9 @@ void Canvas::load(QString file) mipmaps[dev] = lookup; } + + updateWav(); + update(); } diff --git a/dgedit/mainwindow.cc b/dgedit/mainwindow.cc index db442e6..a15bf73 100644 --- a/dgedit/mainwindow.cc +++ b/dgedit/mainwindow.cc @@ -30,6 +30,12 @@ #include #include +#include +#include +#include +#include +#include +#include #define MAXVAL 10000000L #define SINGLESTEP MAXVAL/100000 @@ -37,14 +43,17 @@ MainWindow::MainWindow() { + QWidget *central = new QWidget(); QHBoxLayout *lh = new QHBoxLayout(); QVBoxLayout *lv = new QVBoxLayout(); - setLayout(lv); + central->setLayout(lv); + setCentralWidget(central); extractor = new AudioExtractor(this); canvas = new Canvas(this); lh->addWidget(canvas); + QWidget *dock = new QWidget(); yoffset = new QScrollBar(Qt::Vertical); yoffset->setRange(0, MAXVAL); yoffset->setPageStep(PAGESTEP); @@ -69,6 +78,8 @@ MainWindow::MainWindow() xoffset->setSingleStep(SINGLESTEP); connect(xoffset, SIGNAL(valueChanged(int)), this, SLOT(setXOffset(int))); + QHBoxLayout *btns = new QHBoxLayout(); + QPushButton *autosel = new QPushButton(); autosel->setText("Auto"); connect(autosel, SIGNAL(clicked()), canvas, SLOT(clearSelections())); @@ -82,23 +93,51 @@ MainWindow::MainWindow() exportsel->setText("Export"); connect(exportsel, SIGNAL(clicked()), this, SLOT(doExport())); + QPushButton *loadbtn = new QPushButton(); + loadbtn->setText("Load"); + connect(loadbtn, SIGNAL(clicked()), this, SLOT(loadFile())); + + btns->addWidget(autosel); + btns->addWidget(clearsel); + btns->addWidget(exportsel); + btns->addWidget(loadbtn); + + QVBoxLayout *configs = new QVBoxLayout(); + + configs->addWidget(new QLabel("Prefix:")); + QLineEdit *prefix = new QLineEdit(); + connect(prefix, SIGNAL(textChanged(const QString &)), + extractor, SLOT(setOutputPrefix(const QString &))); + prefix->setText("china"); + configs->addWidget(prefix); + + configs->addWidget(new QLabel("Export path:")); + QLineEdit *exportp = new QLineEdit(); + connect(exportp, SIGNAL(textChanged(const QString &)), + extractor, SLOT(setExportPath(const QString &))); + exportp->setText("/home/deva/tmp/drumgizmoexport"); + configs->addWidget(exportp); + + configs->addWidget(new QLabel("Files:")); + filelist = new QListWidget(); + addFile("/home/deva/aasimonster/tmp/china/Amb L-20.wav", "amb-l"); + addFile("/home/deva/aasimonster/tmp/china/Amb R-20.wav", "amb-r"); + addFile("/home/deva/aasimonster/tmp/china/OH L-20.wav", "oh-l"); + addFile("/home/deva/aasimonster/tmp/china/OH R-20.wav", "oh-r"); + configs->addWidget(filelist); + lh->addWidget(yscale); lh->addWidget(yoffset); lv->addLayout(lh); lv->addWidget(xscale); lv->addWidget(xoffset); - lv->addWidget(autosel); - lv->addWidget(clearsel); - lv->addWidget(exportsel); - - extractor->setExportPath("/home/deva/tmp/drumgizmoexport"); - extractor->setOutputPrefix("china"); - extractor->addFile("/home/deva/aasimonster/tmp/china/Amb L-20.wav", "amb-l"); - extractor->addFile("/home/deva/aasimonster/tmp/china/Amb R-20.wav", "amb-r"); - extractor->addFile("/home/deva/aasimonster/tmp/china/OH L-20.wav", "oh-l"); - extractor->addFile("/home/deva/aasimonster/tmp/china/OH R-20.wav", "oh-r"); + lv->addLayout(btns); - canvas->load("/home/deva/aasimonster/tmp/china/OH L-20.wav"); + QDockWidget *dockWidget = new QDockWidget(tr("Dock Widget"), this); + dockWidget->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea); + dockWidget->setWidget(dock); + addDockWidget(Qt::LeftDockWidgetArea, dockWidget); + dock->setLayout(configs); yscale->setValue(MAXVAL); yoffset->setValue(MAXVAL/2); @@ -106,6 +145,7 @@ MainWindow::MainWindow() xoffset->setValue(0); resize(800, 600); + statusBar()->showMessage("Ready"); } void MainWindow::setXScale(int sz) @@ -143,3 +183,24 @@ void MainWindow::doExport() { extractor->exportSelections(canvas->selections()); } + +void MainWindow::loadFile() +{ + QString filename = + QFileDialog::getOpenFileName(this, tr("Open file"), + "", tr("Audio Files (*.wav)")); + statusBar()->showMessage("Loading..."); + qApp->processEvents(); + canvas->load(filename); + statusBar()->showMessage("Ready"); +} + +void MainWindow::addFile(QString file, QString name) +{ + QListWidgetItem *item = new QListWidgetItem(); + item->setText(file); + item->setData(Qt::UserRole, name); + filelist->addItem(item); + + extractor->addFile(file, name); +} diff --git a/dgedit/mainwindow.h b/dgedit/mainwindow.h index af17970..246a40f 100644 --- a/dgedit/mainwindow.h +++ b/dgedit/mainwindow.h @@ -27,23 +27,27 @@ #ifndef __DRUMGIZMO_MAINWINDOW_H__ #define __DRUMGIZMO_MAINWINDOW_H__ -#include +#include #include +#include #include "canvas.h" #include "audioextractor.h" -class MainWindow : public QWidget { +class MainWindow : public QMainWindow { Q_OBJECT public: MainWindow(); + void addFile(QString file, QString name); + public slots: void setXScale(int); void setYScale(int); void setXOffset(int); void setYOffset(int); void doExport(); + void loadFile(); private: Canvas *canvas; @@ -52,6 +56,7 @@ private: QScrollBar *yscale; QScrollBar *xscale; QScrollBar *xoffset; + QListWidget *filelist; }; #endif/*__DRUMGIZMO_MAINWINDOW_H__*/ -- cgit v1.2.3