From: Takashi Iwai Date: Fri, 3 Jun 2005 12:31:54 +0000 (+0000) Subject: Various fixes to qlo10k1 X-Git-Tag: v1.0.10rc1~13 X-Git-Url: https://git.alsa-project.org/?a=commitdiff_plain;h=8d95c04c7e73e6ea8d1de3791e55c42312a8d0bd;p=alsa-tools.git Various fixes to qlo10k1 Various fixes by Tim : - ld10k1 0.1.8p1 recommended for best operation. - Fixed link disconnect bug. - Now remembers last file open/save dir. - Now unused IO/FX do not disappear upon refresh. - Refresh/redraw fixups. --- diff --git a/qlo10k1/AUTHORS b/qlo10k1/AUTHORS index a568df6..85de04d 100644 --- a/qlo10k1/AUTHORS +++ b/qlo10k1/AUTHORS @@ -2,3 +2,4 @@ Peter Zubaj Contributors: Eduardo García-Mádico Portabella +Tim \ No newline at end of file diff --git a/qlo10k1/NEWS b/qlo10k1/NEWS index f751581..cdb8c7a 100644 --- a/qlo10k1/NEWS +++ b/qlo10k1/NEWS @@ -1,3 +1,10 @@ +0.1.2p1 + - By Tim... + - ld10k1 0.1.8p1 recommended for best operation. + - Fixed link disconnect bug. + - Now remembers last file open/save dir. + - Now unused IO/FX do not disappear upon refresh. + - Refresh/redraw fixups. 0.1.2 - ld10k1 0.1.8 required - Colors and better object positioning - Eduardo García-Mádico Portabella diff --git a/qlo10k1/configure.in b/qlo10k1/configure.in index afe8209..86c32a0 100644 --- a/qlo10k1/configure.in +++ b/qlo10k1/configure.in @@ -1,5 +1,5 @@ AC_INIT(src/main.cpp) -AM_INIT_AUTOMAKE(qlo10k1, 0.1.2) +AM_INIT_AUTOMAKE(qlo10k1, 0.1.2p1) AC_CONFIG_HEADERS(config.h) AC_PROG_CXX AC_PROG_LD diff --git a/qlo10k1/src/mainwnd.cpp b/qlo10k1/src/mainwnd.cpp index 96ea316..c7372ba 100644 --- a/qlo10k1/src/mainwnd.cpp +++ b/qlo10k1/src/mainwnd.cpp @@ -42,6 +42,8 @@ #include "structure_patch.h" #include "strparam.h" +QString gLastFileDir; + class PatchesListViewItem : public QListViewItem { public: @@ -121,6 +123,12 @@ MainWnd::~MainWnd() delete cardGlobal; } +void MainWnd::closeEvent(QCloseEvent* ce) +{ + saveSettings(); + ce->accept(); +} + void MainWnd::tabMainCurrentChanged(QWidget *tab) { if (!CurrentCard) @@ -163,6 +171,7 @@ void MainWnd::patchesUpdateText() void MainWnd::menuQuitActivated(int /*id*/) { + saveSettings(); qApp->quit(); } @@ -171,15 +180,17 @@ void MainWnd::menuLoadDSPConfigActivated(int id) if (!CurrentCard) return; QFileDialog *fd = new QFileDialog(this, "file dialog", TRUE); + fd->setDir(gLastFileDir); fd->setMode(QFileDialog::ExistingFile); fd->setFilter("DSP config (*.ld10k1)"); fd->setCaption("Save DSP config"); int err = 0; QString fileName; - if (fd->exec() == QDialog::Accepted) + if (fd->exec() == QDialog::Accepted) { - fileName = fd->selectedFile(); + fileName = fd->selectedFile(); + gLastFileDir = fd->dirPath(); delete fd; LD10k1DspFile *dc = NULL; @@ -205,15 +216,17 @@ void MainWnd::menuSaveDSPConfigActivated(int id) if (!CurrentCard) return; QFileDialog *fd = new QFileDialog(this, "file dialog", TRUE); + fd->setDir(gLastFileDir); fd->setMode(QFileDialog::AnyFile); fd->setFilter("DSP config (*.ld10k1)"); fd->setCaption("Save DSP config"); int err = 0; QString fileName; - if (fd->exec() == QDialog::Accepted) + if (fd->exec() == QDialog::Accepted) { fileName = fd->selectedFile(); + gLastFileDir = fd->dirPath(); delete fd; if (!fileName.endsWith(".ld10k1")) @@ -379,17 +392,26 @@ void MainWnd::loadClicked() { QFileDialog *fd = new QFileDialog(this, "file dialog", TRUE); fd->setMode(QFileDialog::ExistingFile); - fd->setFilter("Patches (*.emu10k1 *.ld10k1)"); + QStringList filterlist; + filterlist << QString( "as10k1 Patch files (*.bin *.as10k1 *.emu10k1)" ); + filterlist << QString( "ld10k1 Native effect files (*.ld10k1)" ); + filterlist << QString( "All Files (*)" ); + QString filters = filterlist.join( ";;" ); + fd->setFilters( filters ); + + fd->setDir(gLastFileDir); fd->setCaption("Load patch"); int err = 0; QString fileName; - if ( fd->exec() == QDialog::Accepted ) + if ( fd->exec() == QDialog::Accepted ) { fileName = fd->selectedFile(); + gLastFileDir = fd->dirPath(); delete fd; LD10k1File *ldfile = NULL; - if (fileName.endsWith(".emu10k1")) + /* Try loading as an ld10k1 file first. */ + if ((err = LD10k1File::LoadFromFile(fileName, &ldfile)) < 0) { EMU10k1File *emufile = NULL; if ((err = EMU10k1File::LoadFromFile(fileName, &emufile)) < 0) @@ -417,13 +439,6 @@ void MainWnd::loadClicked() } } } - else - { - if ((err = LD10k1File::LoadFromFile(fileName, &ldfile)) < 0) { - QMessageBox::critical(0, APP_NAME, QString("Couldn't load patch\n(ld10k1 error:%1)").arg(CurrentCard->errorStr(err))); - return; - } - } LoadPatchDlg d(CurrentCard, fileName, ldfile); @@ -480,6 +495,7 @@ void MainWnd::saveSettings() settings.writeEntry("/Version", "0.0.1"); settings.writeEntry("/RepDirSystem", cardGlobal->RepDirSystem); settings.writeEntry("/RepDirUser", cardGlobal->RepDirUser); + settings.writeEntry("/LastDir", gLastFileDir); // first save cards settings.beginGroup("/Cards"); @@ -510,6 +526,7 @@ void MainWnd::loadSettings() // settings doesn't exists cardGlobal->RepDirSystem = ""; cardGlobal->RepDirUser = ""; + gLastFileDir = "./"; CardParam *card = new CardParam(); card->CardName = "Default card"; @@ -524,6 +541,7 @@ void MainWnd::loadSettings() { cardGlobal->RepDirSystem = settings.readEntry("/RepDirSystem", ""); cardGlobal->RepDirUser = settings.readEntry("/RepDirUser", ""); + gLastFileDir = settings.readEntry("/LastDir", "./"); settings.beginGroup("/Cards"); diff --git a/qlo10k1/src/mainwnd.h b/qlo10k1/src/mainwnd.h index 89a06b9..50eec11 100644 --- a/qlo10k1/src/mainwnd.h +++ b/qlo10k1/src/mainwnd.h @@ -52,6 +52,10 @@ public: void loadSettings(); void patchesUpdateText(); + +protected: + void closeEvent(QCloseEvent*); + public slots: // menu void menuLoadDSPConfigActivated(int id); diff --git a/qlo10k1/src/newiodialog.cpp b/qlo10k1/src/newiodialog.cpp index fb1ef4d..81453a9 100644 --- a/qlo10k1/src/newiodialog.cpp +++ b/qlo10k1/src/newiodialog.cpp @@ -62,10 +62,26 @@ NewIODlg::NewIODlg(StrGlobal *glob, DlgType t) connect(pbOK, SIGNAL(clicked()), this, SLOT(okClicked())); connect(pbCancel, SIGNAL(clicked()), this, SLOT(cancelClicked())); +} + +int NewIODlg::init() +{ + int err; QString title; QString columnTitle; + int cnt; + if (dt == In) + err = global->Card->getInputCount(&cnt); + else if (dt == Out) + err = global->Card->getOutputCount(&cnt); + else + err = global->Card->getFXCount(&cnt); + + if(err < 0) + return err; + switch (dt) { case In: @@ -83,17 +99,9 @@ NewIODlg::NewIODlg(StrGlobal *glob, DlgType t) } IOListViewItem *after = NULL; - int cnt; lvIOs->clear(); - if (dt == In) - global->Card->getInputCount(&cnt); - else if (dt == Out) - global->Card->getOutputCount(&cnt); - else - global->Card->getFXCount(&cnt); - for (int i = 0; i < cnt; i++) { QString ioname; @@ -109,12 +117,14 @@ NewIODlg::NewIODlg(StrGlobal *glob, DlgType t) if (!used) { if (dt == In) - global->Card->getInput(i, ioname); + err = global->Card->getInput(i, ioname); else if (dt == Out) - global->Card->getOutput(i, ioname); + err = global->Card->getOutput(i, ioname); else - global->Card->getFX(i, ioname); + err = global->Card->getFX(i, ioname); + if(err < 0) + goto Error; if (after) after = new IOListViewItem(i, ioname, lvIOs, after); @@ -127,9 +137,14 @@ NewIODlg::NewIODlg(StrGlobal *glob, DlgType t) lvIOs->setColumnText(1, columnTitle); connect(lvIOs, SIGNAL(selectionChanged(QListViewItem *)), this, SLOT(ioSelectionChanged(QListViewItem *))); + + return 0; + + Error: + + return err; } - void NewIODlg::okClicked() { done(Accepted); diff --git a/qlo10k1/src/newiodialog.h b/qlo10k1/src/newiodialog.h index b5ff392..29df240 100644 --- a/qlo10k1/src/newiodialog.h +++ b/qlo10k1/src/newiodialog.h @@ -40,6 +40,8 @@ private: QString name; public: NewIODlg(StrGlobal *glob, DlgType t); + + int init(); StrIOBase *getNewIO(); public slots: diff --git a/qlo10k1/src/preferences.cpp b/qlo10k1/src/preferences.cpp index 72811d0..913a28b 100644 --- a/qlo10k1/src/preferences.cpp +++ b/qlo10k1/src/preferences.cpp @@ -79,6 +79,8 @@ void PreferencesDlg::okClicked() for (i = 0; i < cards.count(); i++) global->Cards.append(new CardParam(cards.at(i))); + repDirSystem = leRepSystem->text(); + repDirUser = leRepUser->text(); global->RepDirSystem = repDirSystem; global->RepDirUser = repDirUser; diff --git a/qlo10k1/src/routingwidget.cpp b/qlo10k1/src/routingwidget.cpp index adcc041..ef96cf9 100644 --- a/qlo10k1/src/routingwidget.cpp +++ b/qlo10k1/src/routingwidget.cpp @@ -888,7 +888,7 @@ void RoutingWidget::putNewObjectAt(int xp, int yp) drawing->updateContents(); - modeNormalClicked(); + //modeNormalClicked(); } } diff --git a/qlo10k1/src/routingwidget_menu.cpp b/qlo10k1/src/routingwidget_menu.cpp index 84986ee..dc913ee 100644 --- a/qlo10k1/src/routingwidget_menu.cpp +++ b/qlo10k1/src/routingwidget_menu.cpp @@ -32,12 +32,16 @@ #include "strglobal.h" #include "ld10k1file.h" +extern QString gLastFileDir; + void RoutingWidget::openObjectMenuAt(RSItemBaseWithType *item, MenuMode mm, int xp, int yp, int mxp, int myp) { QPopupMenu *contextMenu = new QPopupMenu(); enum Action {Refresh, ClearDSP, Delete, Rename, Disconnect, DelPoint, AddPoint, Connect, Save}; + int rn = -1; + if (mm == MenuNone) { contextMenu->insertItem(tr("&Refresh"), Refresh); @@ -73,7 +77,24 @@ void RoutingWidget::openObjectMenuAt(RSItemBaseWithType *item, MenuMode mm, int else if (pn < 0) contextMenu->insertItem(tr("A&dd point"), AddPoint); - contextMenu->insertItem(tr("D&isconnect"), Disconnect); + if (item->type() == RSItemBaseWithType::Link) + { + StrLink *lnk = (StrLink *)item; + + rn = lnk->getRouteNumFromPoint(xp, yp); + if(rn >= 0) + { + RSItemIO *io = NULL; + RSItemBaseWithType *own = NULL; + io = lnk->getRoutePoint(rn); + if(io) + { + own = (RSItemBaseWithType*)io->getOwner(); + if(own && (own->type() == RSItemBaseWithType::Patch)) + contextMenu->insertItem(tr("D&isconnect"), Disconnect); + } + } + } contextMenu->insertSeparator(); contextMenu->insertItem(tr("&Delete"), Delete); @@ -128,6 +149,7 @@ void RoutingWidget::openObjectMenuAt(RSItemBaseWithType *item, MenuMode mm, int else if (id == Delete) { drawing->deleteAllSelected(); + structure->loadFromLD(); } else if (id == Connect) { @@ -138,7 +160,7 @@ void RoutingWidget::openObjectMenuAt(RSItemBaseWithType *item, MenuMode mm, int } else if (id == Disconnect) { - RSItemIO *io = NULL; + RSItemIO *io = NULL; if (item->type() == RSItemBaseWithType::Patch) { int err; @@ -150,7 +172,7 @@ void RoutingWidget::openObjectMenuAt(RSItemBaseWithType *item, MenuMode mm, int l->updateContents(drawing, getZoomLevel()); if ((err = structure->disconnectFromLink(io)) < 0) - QMessageBox::critical(0, APP_NAME, QString("Couldn't disconnect !\n(ld10k1 error:%1)").arg(structure->errorStr(err))); + QMessageBox::critical(0, APP_NAME, QString("Couldn't disconnect !\n(ld10k1 error:%1)").arg(structure->errorStr(err))); } else { @@ -164,15 +186,41 @@ void RoutingWidget::openObjectMenuAt(RSItemBaseWithType *item, MenuMode mm, int StrOutput *out = (StrOutput *)item; io = out->getIO(false, 0); } - if (item->type() == RSItemBaseWithType::FX) + else if (item->type() == RSItemBaseWithType::FX) { StrFX *fx = (StrFX *)item; io = fx->getIO(true, 0); } - StrLink *l = io->getConnectedTo(); - structure->deleteOneLink(l); - drawing->updateContents(); + if(io) + { + StrLink *l = io->getConnectedTo(); + structure->deleteOneLink(l); + structure->loadFromLD(); + drawing->updateContents(); + } + else if (item->type() == RSItemBaseWithType::Link) + { + StrLink *lnk = (StrLink *)item; + + if(rn >= 0) + { + io = lnk->getRoutePoint(rn); + if(io) + { + RSItemBaseWithType *own = NULL; + own = (RSItemBaseWithType*)io->getOwner(); + if(own && (own->type() == RSItemBaseWithType::Patch)) + { + int err; + if ((err = structure->disconnectFromLink(io)) < 0) + QMessageBox::critical(0, APP_NAME, QString("Couldn't disconnect !\n(ld10k1 error:%1)").arg(structure->errorStr(err))); + + drawing->updateContents(); + } + } + } + } } } else if (id == ClearDSP) @@ -192,20 +240,22 @@ void RoutingWidget::openObjectMenuAt(RSItemBaseWithType *item, MenuMode mm, int QFileDialog *fd = new QFileDialog(this, "file dialog", TRUE); fd->setMode(QFileDialog::AnyFile); - fd->setFilter("Patch (*.ld10k1)"); + fd->setFilter("ld10k1 Native effect files (*.ld10k1)"); fd->setCaption("Save patch"); + fd->setDir(gLastFileDir); QString fileName; if (fd->exec() == QDialog::Accepted) { fileName = fd->selectedFile(); + gLastFileDir = fd->dirPath(); delete fd; if (!fileName.endsWith(".ld10k1")) fileName += ".ld10k1"; if (QFile::exists(fileName)) { - if (QMessageBox::question(0, APP_NAME, QString("File with name %1 exist. Overwite ?").arg(fileName), QMessageBox::Yes, QMessageBox::Cancel) != QMessageBox::Yes) + if (QMessageBox::question(0, APP_NAME, QString("File with name %1 exists. Overwrite ?").arg(fileName), QMessageBox::Yes, QMessageBox::Cancel) != QMessageBox::Yes) return; } diff --git a/qlo10k1/src/routingwidget_new.cpp b/qlo10k1/src/routingwidget_new.cpp index ddfd0e2..34d708b 100644 --- a/qlo10k1/src/routingwidget_new.cpp +++ b/qlo10k1/src/routingwidget_new.cpp @@ -31,6 +31,7 @@ #include "loadpatchdialog.h" #include "transformpatchdialog.h" +extern QString gLastFileDir; RSItemBaseWithType *RoutingWidget::createNewIO(EditMode em) { @@ -54,6 +55,14 @@ RSItemBaseWithType *RoutingWidget::createNewIO(EditMode em) NewIODlg d(structure, t); + int err; + err = d.init(); + if(err < 0) + { + QMessageBox::critical(0, APP_NAME, QString("Error creating new IO dialog\n(ld10k1 error:%1)").arg(structure->errorStr(err))); + return NULL; + } + if (d.exec() == QDialog::Accepted) return d.getNewIO(); else @@ -64,19 +73,28 @@ RSItemBaseWithType *RoutingWidget::createNewPatch() { QFileDialog *fd = new QFileDialog(this, "file dialog", TRUE); fd->setMode(QFileDialog::ExistingFile); - fd->setFilter("Patches (*.emu10k1 *.ld10k1)"); + QStringList filterlist; + filterlist << QString( "as10k1 Patch files (*.bin *.as10k1 *.emu10k1)" ); + filterlist << QString( "ld10k1 Native effect files (*.ld10k1)" ); + filterlist << QString( "All Files (*)" ); + QString filters = filterlist.join( ";;" ); + fd->setFilters( filters ); + fd->setDir(gLastFileDir); + fd->setCaption("Load patch"); StrPatch *loaded = NULL; int err; QString fileName; - if ( fd->exec() == QDialog::Accepted ) + if ( fd->exec() == QDialog::Accepted ) { fileName = fd->selectedFile(); + gLastFileDir = fd->dirPath(); delete fd; + LD10k1File *ldfile = NULL; - if (fileName.endsWith(".emu10k1")) + if ((err = LD10k1File::LoadFromFile(fileName, &ldfile)) < 0) { EMU10k1File *emufile = NULL; if ((err = EMU10k1File::LoadFromFile(fileName, &emufile)) < 0) @@ -104,13 +122,6 @@ RSItemBaseWithType *RoutingWidget::createNewPatch() } } } - else - { - if ((err = LD10k1File::LoadFromFile(fileName, &ldfile)) < 0) { - QMessageBox::critical(0, APP_NAME, QString("Couldn't load patch\n(ld10k1 error:%1)").arg(structure->errorStr(err))); - return NULL; - } - } LoadPatchDlg d(structure, fileName, ldfile); @@ -262,7 +273,7 @@ void RoutingDrawWidget::connectLinkDrag(int xp, int yp, int mxp, int myp) } stopLinkDrag(); - parent->modeNormalClicked(); + //parent->modeNormalClicked(); } delete contextMenu; diff --git a/qlo10k1/src/strglobal.cpp b/qlo10k1/src/strglobal.cpp index 20d6113..b3b322c 100644 --- a/qlo10k1/src/strglobal.cpp +++ b/qlo10k1/src/strglobal.cpp @@ -129,6 +129,8 @@ int StrGlobal::loadFromLD(void) fx->setName(ioname); fx->setFlagChanged(true); } + // Don't make unconnected IO/FX disappear. + fx->setFlagUsed(true); } else { @@ -154,6 +156,7 @@ int StrGlobal::loadFromLD(void) in->setName(ioname); in->setFlagChanged(true); } + in->setFlagUsed(true); } else { @@ -179,6 +182,7 @@ int StrGlobal::loadFromLD(void) out->setName(ioname); out->setFlagChanged(true); } + out->setFlagUsed(true); } else { diff --git a/qlo10k1/src/structure_link.cpp b/qlo10k1/src/structure_link.cpp index 3920624..bd7e7bb 100644 --- a/qlo10k1/src/structure_link.cpp +++ b/qlo10k1/src/structure_link.cpp @@ -391,6 +391,7 @@ void StrLink::updateOneSegment(QScrollView *sv, int r, float zoom) } } +// Determines whether a point is close enough to a another point, within LINK_SELECT_WH. bool StrLink::containsPointPoint(QPoint &p, int xp, int yp) { QRect r(p.x() - LINK_SELECT_WH / 2, p.y() - LINK_SELECT_WH / 2, @@ -399,6 +400,7 @@ bool StrLink::containsPointPoint(QPoint &p, int xp, int yp) return r.contains(xp, yp); } +// Determines whether a point is on a line segment. bool StrLink::containsPointSegment(QPoint &p1, QPoint &p2, int xp, int yp) { QRect r(p1, p2); @@ -638,3 +640,55 @@ bool StrLink::delSegmentPoint(int num) return false; } + +// Returns route number which segment containing point leads to, else -1 +int StrLink::getRouteNumFromPoint(int xp, int yp) +{ + int i; + unsigned j; + + if (xp < x() || xp > x() + width() || + yp < y() || yp > y() + height()) + return -1; + + if (useMixPoint) + { + if (containsPointPoint(mixPoint, xp, yp)) + return -1; + } + + for (i = 0; i < POINTINFO_MAX_CONN_PER_POINT + 1; i++) + { + if (routes[i]) + { + QPoint fp = routesEndPoints[i]; + if (containsPointPoint(fp, xp, yp)) + return i; + + for (j = 0; j < routesPoints[i].count(); j++) + { + QPoint tmpp = routesPoints[i][j]; + + if (containsPointPoint(tmpp, xp, yp)) + return i; + + if (containsPointSegment(fp, tmpp, xp, yp)) + return i; + fp = tmpp; + } + + if (useMixPoint) + { + if (containsPointSegment(fp, mixPoint, xp, yp)) + return i; + } + else + { + if (containsPointSegment(fp, routesEndPoints[0], xp, yp)) + return i; + } + } + } + return -1; +} + diff --git a/qlo10k1/src/structure_link.h b/qlo10k1/src/structure_link.h index d66b590..dc5c00f 100644 --- a/qlo10k1/src/structure_link.h +++ b/qlo10k1/src/structure_link.h @@ -39,11 +39,13 @@ private: RSItemIO *routes[POINTINFO_MAX_CONN_PER_POINT + 1]; QValueList routesPoints[POINTINFO_MAX_CONN_PER_POINT + 1]; - QPoint routesEndPoints[POINTINFO_MAX_CONN_PER_POINT + 1]; + QPoint routesEndPoints[POINTINFO_MAX_CONN_PER_POINT + 1]; bool useMixPoint; QPoint mixPoint; + // Determines whether a point is close enough to a another point, within LINK_SELECT_WH. bool containsPointPoint(QPoint &p, int xp, int yp); + // Determines whether a point is on a line segment. bool containsPointSegment(QPoint &p1, QPoint &p2, int xp, int yp); public: StrLink(int id, LinkType t); @@ -73,6 +75,9 @@ public: void setRoutePoint(int r, RSItemIO *ri); void clearRoutesPoints(int r); + // Returns route number which segment containing point leads to, else -1 + int getRouteNumFromPoint(int xp, int yp); + virtual void calcSize(); virtual void draw(DrawingParams *dp);