-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
781 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
project(TalcsWidgets VERSION ${TALCS_VERSION} LANGUAGES CXX) | ||
|
||
file(GLOB_RECURSE _src *.h *.cpp) | ||
|
||
talcs_add_library(${PROJECT_NAME} AUTOGEN | ||
SOURCES ${_src} | ||
QT_LINKS Core Gui Widgets | ||
LINKS talcs::Core talcs::Format talcs::Device | ||
QT_INCLUDE_PRIVATE Core Gui Widgets | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/****************************************************************************** | ||
* Copyright (c) 2024 CrSjimo * | ||
* * | ||
* This file is part of TALCS. * | ||
* * | ||
* TALCS is free software: you can redistribute it and/or modify it under the * | ||
* terms of the GNU Lesser General Public License as published by the Free * | ||
* Software Foundation, either version 3 of the License, or (at your option) * | ||
* any later version. * | ||
* * | ||
* TALCS is distributed in the hope that it will be useful, but WITHOUT ANY * | ||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * | ||
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for * | ||
* more details. * | ||
* * | ||
* You should have received a copy of the GNU Lesser General Public License * | ||
* along with TALCS. If not, see <https://www.gnu.org/licenses/>. * | ||
******************************************************************************/ | ||
|
||
#ifndef TALCS_TALCSWIDGETSGLOBAL_H | ||
#define TALCS_TALCSWIDGETSGLOBAL_H | ||
|
||
#include <QtGlobal> | ||
|
||
#ifndef TALCSWIDGETS_EXPORT | ||
# ifdef TALCSWIDGETS_STATIC | ||
# define TALCSWIDGETS_EXPORT | ||
# else | ||
# ifdef TALCSWIDGETS_LIBRARY | ||
# define TALCSWIDGETS_EXPORT Q_DECL_EXPORT | ||
# else | ||
# define TALCSWIDGETS_EXPORT Q_DECL_IMPORT | ||
# endif | ||
# endif | ||
#endif | ||
|
||
#endif //TALCS_TALCSWIDGETSGLOBAL_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/****************************************************************************** | ||
* Copyright (c) 2024 CrSjimo * | ||
* * | ||
* This file is part of TALCS. * | ||
* * | ||
* TALCS is free software: you can redistribute it and/or modify it under the * | ||
* terms of the GNU Lesser General Public License as published by the Free * | ||
* Software Foundation, either version 3 of the License, or (at your option) * | ||
* any later version. * | ||
* * | ||
* TALCS is distributed in the hope that it will be useful, but WITHOUT ANY * | ||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * | ||
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for * | ||
* more details. * | ||
* * | ||
* You should have received a copy of the GNU Lesser General Public License * | ||
* along with TALCS. If not, see <https://www.gnu.org/licenses/>. * | ||
******************************************************************************/ | ||
|
||
#include "AudioFileDialog.h" | ||
|
||
#include <algorithm> | ||
|
||
#include <QFileDialog> | ||
|
||
#include <TalcsFormat/FormatManager.h> | ||
#include <TalcsFormat/FormatEntry.h> | ||
|
||
#include <TalcsWidgets/StandardFormatEntry.h> | ||
|
||
namespace talcs { | ||
AbstractAudioFormatIO *AudioFileDialog::getOpenAudioFileIO(const FormatManager *formatManager, | ||
QString &fileName, QVariant &userData, QString &entryClassName, | ||
QWidget *parent, const QString &caption, const QString &dir) { | ||
QStringList extensionList = formatManager->extensionHints(); | ||
std::transform(extensionList.cbegin(), extensionList.cend(), extensionList.begin(), [](const QString &s) { | ||
return "*." + s; | ||
}); | ||
auto allSupportedFilesFilter = tr("All Supported Files (%1)").arg(extensionList.join(" ")); | ||
auto rawDataFilter = tr("As Raw Data (*)"); | ||
auto allFilesFilter = tr("All Files (*)"); | ||
|
||
auto filters = QStringList{allSupportedFilesFilter} + formatManager->filters() + QStringList{rawDataFilter, allFilesFilter}; | ||
|
||
QString selectedFilter; | ||
fileName = QFileDialog::getOpenFileName(parent, caption, dir, filters.join(";;"), &selectedFilter); | ||
if (fileName.isEmpty()) { | ||
return nullptr; | ||
} | ||
if (selectedFilter == rawDataFilter) { | ||
StandardFormatEntry entry; | ||
userData = QVariantMap({{"raw", true}}); | ||
if (auto io = entry.getFormatOpen(fileName, userData, parent)) { | ||
entryClassName = StandardFormatEntry::staticMetaObject.className(); | ||
return io; | ||
} | ||
return nullptr; | ||
} | ||
auto entries = formatManager->entries(); | ||
{ | ||
auto extension = QFileInfo(fileName).suffix(); | ||
auto hintedEntry = extension.isEmpty() ? nullptr : formatManager->hintFromExtension(extension); | ||
if (hintedEntry) { | ||
entries.removeOne(hintedEntry); | ||
entries.prepend(hintedEntry); | ||
} | ||
} | ||
for (auto entry : entries) { | ||
if (auto io = entry->getFormatOpen(fileName, userData, parent)) { | ||
entryClassName = entry->metaObject()->className(); | ||
return io; | ||
} | ||
} | ||
return nullptr; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/****************************************************************************** | ||
* Copyright (c) 2024 CrSjimo * | ||
* * | ||
* This file is part of TALCS. * | ||
* * | ||
* TALCS is free software: you can redistribute it and/or modify it under the * | ||
* terms of the GNU Lesser General Public License as published by the Free * | ||
* Software Foundation, either version 3 of the License, or (at your option) * | ||
* any later version. * | ||
* * | ||
* TALCS is distributed in the hope that it will be useful, but WITHOUT ANY * | ||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * | ||
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for * | ||
* more details. * | ||
* * | ||
* You should have received a copy of the GNU Lesser General Public License * | ||
* along with TALCS. If not, see <https://www.gnu.org/licenses/>. * | ||
******************************************************************************/ | ||
|
||
#ifndef TALCS_AUDIOFILEDIALOG_H | ||
#define TALCS_AUDIOFILEDIALOG_H | ||
|
||
#include <QVariant> | ||
#include <QObject> | ||
|
||
#include <TalcsWidgets/TalcsWidgetsGlobal.h> | ||
|
||
namespace talcs { | ||
|
||
class AbstractAudioFormatIO; | ||
|
||
class FormatManager; | ||
|
||
class TALCSWIDGETS_EXPORT AudioFileDialog : public QObject { | ||
Q_OBJECT | ||
public: | ||
static AbstractAudioFormatIO *getOpenAudioFileIO(const FormatManager *formatManager, | ||
QString &fileName, QVariant &userData, QString &entryClassName, | ||
QWidget *parent = nullptr, const QString &caption = {}, const QString &dir = {}); | ||
}; | ||
|
||
} // talcs | ||
|
||
#endif //TALCS_AUDIOFILEDIALOG_H |
Oops, something went wrong.