1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

refactor(cmake): change folder structure

The new folder structure will be like this:

/<module>/CMakeLists.txt
/<module>/src/file.cpp
/<module>/include/<module>/file.h
/<module>/<subdir>/<...>
This commit is contained in:
sudden6 2020-04-29 20:06:41 +02:00
parent f3a10815ed
commit a90f0762d9
No known key found for this signature in database
GPG Key ID: 279509B499E032B9
46 changed files with 143 additions and 71 deletions

View File

@ -257,18 +257,6 @@ execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different
${CMAKE_CURRENT_BINARY_DIR}/translations.qrc) ${CMAKE_CURRENT_BINARY_DIR}/translations.qrc)
set(${PROJECT_NAME}_SOURCES set(${PROJECT_NAME}_SOURCES
src/audio/audio.cpp
src/audio/audio.h
src/audio/backend/alsink.cpp
src/audio/backend/alsink.h
src/audio/backend/alsource.cpp
src/audio/backend/alsource.h
src/audio/backend/openal.cpp
src/audio/backend/openal.h
src/audio/iaudiosettings.h
src/audio/iaudiocontrol.h
src/audio/iaudiosink.h
src/audio/iaudiosource.h
src/chatlog/chatlinecontent.cpp src/chatlog/chatlinecontent.cpp
src/chatlog/chatlinecontent.h src/chatlog/chatlinecontent.h
src/chatlog/chatlinecontentproxy.cpp src/chatlog/chatlinecontentproxy.cpp
@ -368,7 +356,6 @@ set(${PROJECT_NAME}_SOURCES
src/model/group.h src/model/group.h
src/model/status.cpp src/model/status.cpp
src/model/status.h src/model/status.h
src/model/interface.h
src/model/profile/iprofileinfo.h src/model/profile/iprofileinfo.h
src/model/profile/profileinfo.cpp src/model/profile/profileinfo.cpp
src/model/profile/profileinfo.h src/model/profile/profileinfo.h
@ -659,6 +646,9 @@ MESSAGE( STATUS "CMAKE_C_FLAGS: " ${CMAKE_C_FLAGS} )
# the compiler flags for compiling C++ sources # the compiler flags for compiling C++ sources
MESSAGE( STATUS "CMAKE_CXX_FLAGS: " ${CMAKE_CXX_FLAGS} ) MESSAGE( STATUS "CMAKE_CXX_FLAGS: " ${CMAKE_CXX_FLAGS} )
add_subdirectory(util)
add_subdirectory(audio)
add_library(${PROJECT_NAME}_static add_library(${PROJECT_NAME}_static
STATIC STATIC
${${PROJECT_NAME}_FORMS} ${${PROJECT_NAME}_FORMS}
@ -669,6 +659,9 @@ target_link_libraries(${PROJECT_NAME}_static
${CMAKE_REQUIRED_LIBRARIES} ${CMAKE_REQUIRED_LIBRARIES}
${ALL_LIBRARIES}) ${ALL_LIBRARIES})
target_link_libraries(${PROJECT_NAME}_static util_library)
target_link_libraries(${PROJECT_NAME}_static audio_library)
add_executable(${PROJECT_NAME} add_executable(${PROJECT_NAME}
WIN32 WIN32
MACOSX_BUNDLE MACOSX_BUNDLE

45
audio/CMakeLists.txt Normal file
View File

@ -0,0 +1,45 @@
# Copyright © 2020 by The qTox Project Contributors
#
# This file is part of qTox, a Qt-based graphical interface for Tox.
# qTox is libre software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# qTox 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with qTox. If not, see <http://www.gnu.org/licenses/>
set(SOURCE_FILES
"include/audio/audio.h"
"include/audio/iaudiocontrol.h"
"include/audio/iaudiosettings.h"
"include/audio/iaudiosink.h"
"include/audio/iaudiosource.h"
"src/audio.cpp"
"src/backend/alsink.cpp"
"src/backend/alsink.h"
"src/backend/alsource.cpp"
"src/backend/alsource.h"
"src/backend/openal.cpp"
"src/backend/openal.h")
add_library(audio_library STATIC ${SOURCE_FILES})
qt5_add_resources(
audio_library
res.qrc
OPTIONS ${RCC_OPTIONS}
)
# We need this directory, and users of our library will need it too
target_include_directories(audio_library PUBLIC include/)
target_link_libraries(audio_library util_library)
target_link_libraries(audio_library Qt5::Core)
target_link_libraries(audio_library ${OPENAL_LIBRARIES})

View File

@ -19,7 +19,7 @@
#pragma once #pragma once
#include "src/model/interface.h" #include "util/interface.h"
#include <QString> #include <QString>

View File

@ -23,7 +23,7 @@
#include <QObject> #include <QObject>
#include "src/model/interface.h" #include "util/interface.h"
/** /**
* @brief The IAudioSink class represents an interface to devices that can play audio. * @brief The IAudioSink class represents an interface to devices that can play audio.

8
audio/resources/res.qrc Normal file
View File

@ -0,0 +1,8 @@
<RCC>
<qresource prefix="/audio">
<file>notification.s16le.pcm</file>
<file>ToxIncomingCall.s16le.pcm</file>
<file>ToxOutgoingCall.s16le.pcm</file>
<file>ToxEndCall.s16le.pcm</file>
</qresource>
</RCC>

View File

@ -19,9 +19,9 @@
#include <memory> #include <memory>
#include "src/audio/audio.h" #include "audio/audio.h"
#include "src/audio/iaudiosettings.h" #include "audio/iaudiosettings.h"
#include "src/audio/backend/openal.h" #include "backend/openal.h"
/** /**
* @brief Select the audio backend * @brief Select the audio backend
@ -30,5 +30,5 @@
*/ */
std::unique_ptr<IAudioControl> Audio::makeAudio(IAudioSettings& settings) std::unique_ptr<IAudioControl> Audio::makeAudio(IAudioSettings& settings)
{ {
return std::unique_ptr<IAudioControl>(new OpenAL()); return std::unique_ptr<IAudioControl>(new OpenAL(settings));
} }

View File

@ -17,8 +17,8 @@
along with qTox. If not, see <http://www.gnu.org/licenses/>. along with qTox. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "src/audio/backend/alsink.h" #include "audio/src/backend/alsink.h"
#include "src/audio/backend/openal.h" #include "audio/src/backend/openal.h"
#include <QDebug> #include <QDebug>
#include <QMutexLocker> #include <QMutexLocker>

View File

@ -22,8 +22,8 @@
#include <QMutex> #include <QMutex>
#include <QObject> #include <QObject>
#include "src/model/interface.h" #include "util/interface.h"
#include "src/audio/iaudiosink.h" #include "audio/iaudiosink.h"
class OpenAL; class OpenAL;
class QMutex; class QMutex;

View File

@ -17,8 +17,8 @@
along with qTox. If not, see <http://www.gnu.org/licenses/>. along with qTox. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "src/audio/backend/alsource.h" #include "audio/src/backend/alsource.h"
#include "src/audio/backend/openal.h" #include "audio/src/backend/openal.h"
/** /**
* @brief Emits audio frames captured by an input device or other audio source. * @brief Emits audio frames captured by an input device or other audio source.

View File

@ -19,7 +19,7 @@
#pragma once #pragma once
#include "src/audio/iaudiosource.h" #include "audio/iaudiosource.h"
#include <QMutex> #include <QMutex>
#include <QObject> #include <QObject>

View File

@ -18,7 +18,8 @@
*/ */
#include "openal.h" #include "openal.h"
#include "src/persistence/settings.h"
#include "audio/iaudiosettings.h"
#include <QDebug> #include <QDebug>
#include <QFile> #include <QFile>
@ -56,8 +57,9 @@ void applyGain(int16_t* buffer, uint32_t bufferSize, qreal gainFactor)
static const unsigned int BUFFER_COUNT = 16; static const unsigned int BUFFER_COUNT = 16;
static const uint32_t AUDIO_CHANNELS = 2; static const uint32_t AUDIO_CHANNELS = 2;
OpenAL::OpenAL() OpenAL::OpenAL(IAudioSettings& _settings)
: audioThread{new QThread} : settings{_settings}
, audioThread{new QThread}
{ {
// initialize OpenAL error stack // initialize OpenAL error stack
alGetError(); alGetError();
@ -370,7 +372,7 @@ void OpenAL::destroySource(AlSource& source)
*/ */
bool OpenAL::autoInitInput() bool OpenAL::autoInitInput()
{ {
return alInDev ? true : initInput(Settings::getInstance().getInDev()); return alInDev ? true : initInput(settings.getInDev());
} }
/** /**
@ -380,7 +382,7 @@ bool OpenAL::autoInitInput()
*/ */
bool OpenAL::autoInitOutput() bool OpenAL::autoInitOutput()
{ {
return alOutDev ? true : initOutput(Settings::getInstance().getOutDev()); return alOutDev ? true : initOutput(settings.getOutDev());
} }
bool OpenAL::initInput(const QString& deviceName) bool OpenAL::initInput(const QString& deviceName)
@ -390,7 +392,7 @@ bool OpenAL::initInput(const QString& deviceName)
bool OpenAL::initInput(const QString& deviceName, uint32_t channels) bool OpenAL::initInput(const QString& deviceName, uint32_t channels)
{ {
if (!Settings::getInstance().getAudioInDevEnabled()) { if (!settings.getAudioInDevEnabled()) {
return false; return false;
} }
@ -417,8 +419,8 @@ bool OpenAL::initInput(const QString& deviceName, uint32_t channels)
} }
inputBuffer = new int16_t[AUDIO_FRAME_SAMPLE_COUNT_TOTAL]; inputBuffer = new int16_t[AUDIO_FRAME_SAMPLE_COUNT_TOTAL];
setInputGain(Settings::getInstance().getAudioInGainDecibel()); setInputGain(settings.getAudioInGainDecibel());
setInputThreshold(Settings::getInstance().getAudioThreshold()); setInputThreshold(settings.getAudioThreshold());
qDebug() << "Opened audio input" << deviceName; qDebug() << "Opened audio input" << deviceName;
alcCaptureStart(alInDev); alcCaptureStart(alInDev);
@ -435,7 +437,7 @@ bool OpenAL::initOutput(const QString& deviceName)
assert(sinks.size() == 0); assert(sinks.size() == 0);
outputInitialized = false; outputInitialized = false;
if (!Settings::getInstance().getAudioOutDevEnabled()) if (!settings.getAudioOutDevEnabled())
return false; return false;
qDebug() << "Opening audio output" << deviceName; qDebug() << "Opening audio output" << deviceName;
@ -460,7 +462,7 @@ bool OpenAL::initOutput(const QString& deviceName)
} }
// init master volume // init master volume
alListenerf(AL_GAIN, Settings::getInstance().getOutVolume() * 0.01f); alListenerf(AL_GAIN, settings.getOutVolume() * 0.01f);
checkAlError(); checkAlError();
outputInitialized = true; outputInitialized = true;

View File

@ -20,9 +20,9 @@
#pragma once #pragma once
#include "src/audio/iaudiocontrol.h" #include "audio/iaudiocontrol.h"
#include "src/audio/backend/alsink.h" #include "alsink.h"
#include "src/audio/backend/alsource.h" #include "alsource.h"
#include <memory> #include <memory>
#include <unordered_set> #include <unordered_set>
@ -44,12 +44,14 @@
#include <AL/alext.h> #include <AL/alext.h>
#endif #endif
class IAudioSettings;
class OpenAL : public IAudioControl class OpenAL : public IAudioControl
{ {
Q_OBJECT Q_OBJECT
public: public:
OpenAL(); OpenAL(IAudioSettings& _settings);
virtual ~OpenAL(); virtual ~OpenAL();
qreal maxOutputVolume() const qreal maxOutputVolume() const
@ -131,6 +133,7 @@ private:
float getVolume(); float getVolume();
protected: protected:
IAudioSettings& settings;
QThread* audioThread; QThread* audioThread;
mutable QMutex audioLock{QMutex::Recursive}; mutable QMutex audioLock{QMutex::Recursive};
QString inDev{}; QString inDev{};

View File

@ -6,10 +6,6 @@
<file alias="DejaVuSans.ttf">res/font/DejaVuSans.ttf</file> <file alias="DejaVuSans.ttf">res/font/DejaVuSans.ttf</file>
</qresource> </qresource>
<qresource prefix="/"> <qresource prefix="/">
<file>audio/notification.s16le.pcm</file>
<file>audio/ToxIncomingCall.s16le.pcm</file>
<file>audio/ToxOutgoingCall.s16le.pcm</file>
<file>audio/ToxEndCall.s16le.pcm</file>
<file>img/add.svg</file> <file>img/add.svg</file>
<file>img/avatar_mask.svg</file> <file>img/avatar_mask.svg</file>
<file>img/contact.svg</file> <file>img/contact.svg</file>

View File

@ -31,7 +31,7 @@
#include "src/model/ibootstraplistgenerator.h" #include "src/model/ibootstraplistgenerator.h"
#include "src/nexus.h" #include "src/nexus.h"
#include "src/persistence/profile.h" #include "src/persistence/profile.h"
#include "src/util/strongtype.h" #include "util/strongtype.h"
#include <QCoreApplication> #include <QCoreApplication>
#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)) #if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0))

View File

@ -30,7 +30,7 @@
#include "toxid.h" #include "toxid.h"
#include "toxpk.h" #include "toxpk.h"
#include "src/util/strongtype.h" #include "util/strongtype.h"
#include "src/model/status.h" #include "src/model/status.h"
#include <tox/tox.h> #include <tox/tox.h>

View File

@ -19,7 +19,7 @@
#pragma once #pragma once
#include "src/model/interface.h" #include "util/interface.h"
#include <QList> #include <QList>
#include <QNetworkProxy> #include <QNetworkProxy>

View File

@ -19,7 +19,7 @@
#pragma once #pragma once
#include "src/util/strongtype.h" #include "util/strongtype.h"
#include <QMetaType> #include <QMetaType>
#include <cstdint> #include <cstdint>

View File

@ -18,7 +18,7 @@
*/ */
#include "src/core/toxcall.h" #include "src/core/toxcall.h"
#include "src/audio/audio.h" #include "audio/audio.h"
#include "src/core/coreav.h" #include "src/core/coreav.h"
#include "src/persistence/settings.h" #include "src/persistence/settings.h"
#include "src/video/camerasource.h" #include "src/video/camerasource.h"

View File

@ -19,9 +19,9 @@
#pragma once #pragma once
#include "src/audio/iaudiocontrol.h" #include "audio/iaudiocontrol.h"
#include "src/audio/iaudiosink.h" #include "audio/iaudiosink.h"
#include "src/audio/iaudiosource.h" #include "audio/iaudiosource.h"
#include <src/core/toxpk.h> #include <src/core/toxpk.h>
#include <tox/toxav.h> #include <tox/toxav.h>

View File

@ -17,7 +17,7 @@
along with qTox. If not, see <http://www.gnu.org/licenses/>. along with qTox. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "src/audio/audio.h" #include "audio/audio.h"
#include "src/ipc.h" #include "src/ipc.h"
#include "src/net/toxuri.h" #include "src/net/toxuri.h"
#include "src/nexus.h" #include "src/nexus.h"

View File

@ -20,7 +20,7 @@
#pragma once #pragma once
#include "iaboutfriend.h" #include "iaboutfriend.h"
#include "src/model/interface.h" #include "util/interface.h"
#include "src/persistence/ifriendsettings.h" #include "src/persistence/ifriendsettings.h"
#include <QObject> #include <QObject>

View File

@ -19,7 +19,7 @@
#pragma once #pragma once
#include "src/model/interface.h" #include "util/interface.h"
#include "src/persistence/ifriendsettings.h" #include "src/persistence/ifriendsettings.h"
#include <QObject> #include <QObject>

View File

@ -29,7 +29,7 @@
#include "src/model/friend.h" #include "src/model/friend.h"
#include "src/model/group.h" #include "src/model/group.h"
#include "src/persistence/history.h" #include "src/persistence/history.h"
#include "src/util/strongtype.h" #include "util/strongtype.h"
#include "src/widget/searchtypes.h" #include "src/widget/searchtypes.h"
#include <cassert> #include <cassert>

View File

@ -19,7 +19,7 @@
#pragma once #pragma once
#include "src/model/interface.h" #include "util/interface.h"
#include <QObject> #include <QObject>

View File

@ -20,7 +20,7 @@
#pragma once #pragma once
#include <QObject> #include <QObject>
#include "src/model/interface.h" #include "util/interface.h"
#include "src/core/toxpk.h" #include "src/core/toxpk.h"
#include "iprofileinfo.h" #include "iprofileinfo.h"

View File

@ -35,7 +35,7 @@
#include <QDesktopWidget> #include <QDesktopWidget>
#include <QThread> #include <QThread>
#include <cassert> #include <cassert>
#include <src/audio/audio.h> #include "audio/audio.h"
#include <vpx/vpx_image.h> #include <vpx/vpx_image.h>
#ifdef Q_OS_MAC #ifdef Q_OS_MAC

View File

@ -22,7 +22,7 @@
#include <QObject> #include <QObject>
#include "src/audio/iaudiocontrol.h" #include "audio/iaudiocontrol.h"
class Widget; class Widget;
class Profile; class Profile;

View File

@ -19,7 +19,7 @@
#pragma once #pragma once
#include "src/util/strongtype.h" #include "util/strongtype.h"
#include <QByteArray> #include <QByteArray>
#include <QMutex> #include <QMutex>

View File

@ -19,7 +19,7 @@
#pragma once #pragma once
#include "src/model/interface.h" #include "util/interface.h"
#include <QObject> #include <QObject>
#include <QFlag> #include <QFlag>

View File

@ -20,7 +20,7 @@
#pragma once #pragma once
#include "src/audio/iaudiosettings.h" #include "audio/iaudiosettings.h"
#include "src/core/icoresettings.h" #include "src/core/icoresettings.h"
#include "src/core/toxencrypt.h" #include "src/core/toxencrypt.h"
#include "src/core/toxfile.h" #include "src/core/toxfile.h"

View File

@ -19,7 +19,7 @@
#pragma once #pragma once
#include "src/model/interface.h" #include "util/interface.h"
#include <QString> #include <QString>
#include <QRect> #include <QRect>

View File

@ -27,9 +27,9 @@
#include <QScreen> #include <QScreen>
#include <QShowEvent> #include <QShowEvent>
#include "src/audio/audio.h" #include "audio/audio.h"
#include "src/audio/iaudiosettings.h" #include "audio/iaudiosettings.h"
#include "src/audio/iaudiosource.h" #include "audio/iaudiosource.h"
#include "src/core/core.h" #include "src/core/core.h"
#include "src/core/coreav.h" #include "src/core/coreav.h"
#include "src/video/cameradevice.h" #include "src/video/cameradevice.h"

View File

@ -19,7 +19,7 @@
#include "settingswidget.h" #include "settingswidget.h"
#include "src/audio/audio.h" #include "audio/audio.h"
#include "src/core/core.h" #include "src/core/core.h"
#include "src/core/coreav.h" #include "src/core/coreav.h"
#include "src/net/updatecheck.h" #include "src/net/updatecheck.h"

View File

@ -38,6 +38,7 @@
#include <QWindow> #include <QWindow>
#endif #endif
#include "audio/audio.h"
#include "circlewidget.h" #include "circlewidget.h"
#include "contentdialog.h" #include "contentdialog.h"
#include "contentlayout.h" #include "contentlayout.h"
@ -47,7 +48,6 @@
#include "maskablepixmapwidget.h" #include "maskablepixmapwidget.h"
#include "splitterrestorer.h" #include "splitterrestorer.h"
#include "form/groupchatform.h" #include "form/groupchatform.h"
#include "src/audio/audio.h"
#include "src/chatlog/content/filetransferwidget.h" #include "src/chatlog/content/filetransferwidget.h"
#include "src/core/core.h" #include "src/core/core.h"
#include "src/core/coreav.h" #include "src/core/coreav.h"

View File

@ -28,8 +28,8 @@
#include "genericchatitemwidget.h" #include "genericchatitemwidget.h"
#include "src/audio/iaudiocontrol.h" #include "audio/iaudiocontrol.h"
#include "src/audio/iaudiosink.h" #include "audio/iaudiosink.h"
#include "src/core/core.h" #include "src/core/core.h"
#include "src/core/groupid.h" #include "src/core/groupid.h"
#include "src/core/toxfile.h" #include "src/core/toxfile.h"

25
util/CMakeLists.txt Normal file
View File

@ -0,0 +1,25 @@
# Copyright © 2020 by The qTox Project Contributors
#
# This file is part of qTox, a Qt-based graphical interface for Tox.
# qTox is libre software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# qTox 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with qTox. If not, see <http://www.gnu.org/licenses/>
set(HEADER_LIST
"include/util/interface.h"
"include/util/strongtype.h")
add_library(util_library STATIC ${HEADER_LIST})
# We need this directory, and users of our library will need it too
target_include_directories(util_library PUBLIC include/)