From c6a197feca1ad7e8b6a5ca7b8e929165fac01b43 Mon Sep 17 00:00:00 2001 From: sudden6 Date: Sat, 10 Nov 2018 02:43:37 +0100 Subject: [PATCH] refactor: re-format and cleanup --- CMakeLists.txt | 4 +- src/persistence/history.h | 6 +-- src/widget/form/settings/aboutform.cpp | 4 +- src/widget/form/settings/advancedform.cpp | 7 ++-- src/widget/form/settings/avform.cpp | 37 +++++++++++-------- src/widget/form/settings/generalform.cpp | 5 ++- src/widget/form/settings/privacyform.cpp | 2 +- .../form/settings/userinterfaceform.cpp | 4 +- .../tool}/recursivesignalblocker.cpp | 0 .../tool}/recursivesignalblocker.h | 0 10 files changed, 37 insertions(+), 32 deletions(-) rename src/{core => widget/tool}/recursivesignalblocker.cpp (100%) rename src/{core => widget/tool}/recursivesignalblocker.h (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 08f44bba7..2f6c08b6a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -258,8 +258,6 @@ set(${PROJECT_NAME}_SOURCES src/core/dhtserver.cpp src/core/dhtserver.h src/core/icoresettings.h - src/core/recursivesignalblocker.cpp - src/core/recursivesignalblocker.h src/core/toxcall.cpp src/core/toxcall.h src/core/toxencrypt.cpp @@ -472,6 +470,8 @@ set(${PROJECT_NAME}_SOURCES src/widget/tool/movablewidget.h src/widget/tool/profileimporter.cpp src/widget/tool/profileimporter.h + src/widget/tool/recursivesignalblocker.cpp + src/widget/tool/recursivesignalblocker.h src/widget/tool/removefrienddialog.cpp src/widget/tool/removefrienddialog.h src/widget/tool/screengrabberchooserrectitem.cpp diff --git a/src/persistence/history.h b/src/persistence/history.h index b6cf34ab6..5da854378 100644 --- a/src/persistence/history.h +++ b/src/persistence/history.h @@ -71,7 +71,6 @@ public: ~History(); bool isValid(); - void import(const HistoryKeeper& oldHistory); bool isHistoryExistence(const QString& friendPk); @@ -82,10 +81,11 @@ public: const std::function& insertIdCallback = {}); QList getChatHistoryFromDate(const QString& friendPk, const QDateTime& from, - const QDateTime& to); + const QDateTime& to); QList getChatHistoryDefaultNum(const QString& friendPk); QList getChatHistoryCounts(const ToxPk& friendPk, const QDate& from, const QDate& to); - QDateTime getDateWhereFindPhrase(const QString& friendPk, const QDateTime& from, QString phrase, const ParameterSearch ¶meter); + QDateTime getDateWhereFindPhrase(const QString& friendPk, const QDateTime& from, QString phrase, + const ParameterSearch& parameter); QDateTime getStartDateChatHistory(const QString& friendPk); void markAsSent(qint64 messageId); diff --git a/src/widget/form/settings/aboutform.cpp b/src/widget/form/settings/aboutform.cpp index eaf766194..3e1e3b43b 100644 --- a/src/widget/form/settings/aboutform.cpp +++ b/src/widget/form/settings/aboutform.cpp @@ -24,8 +24,8 @@ #include #include -#include "src/core/recursivesignalblocker.h" #include "src/net/autoupdate.h" +#include "src/widget/tool/recursivesignalblocker.h" #include "src/widget/translator.h" /** @@ -110,7 +110,7 @@ void AboutForm::replaceVersions() "More information on how to write good bug reports in the wiki: " "https://github.com/qTox/qTox/wiki/Writing-Useful-Bug-Reports.\n\n" "Please remove any unnecessary template section before submitting.") - .arg(QSysInfo::prettyProductName(), GIT_DESCRIBE, GIT_VERSION, + .arg(QSysInfo::prettyProductName(), GIT_DESCRIBE, GIT_VERSION, TOXCORE_VERSION, QT_VERSION_STR); issueBody.replace("#", "%23").replace(":", "%3A"); diff --git a/src/widget/form/settings/advancedform.cpp b/src/widget/form/settings/advancedform.cpp index 045a30184..61d284d08 100644 --- a/src/widget/form/settings/advancedform.cpp +++ b/src/widget/form/settings/advancedform.cpp @@ -29,11 +29,11 @@ #include "src/core/core.h" #include "src/core/coreav.h" -#include "src/core/recursivesignalblocker.h" #include "src/nexus.h" #include "src/persistence/profile.h" #include "src/persistence/settings.h" #include "src/widget/gui.h" +#include "src/widget/tool/recursivesignalblocker.h" #include "src/widget/translator.h" /** @@ -157,9 +157,8 @@ void AdvancedForm::on_btnCopyDebug_clicked() void AdvancedForm::on_resetButton_clicked() { const QString titile = tr("Reset settings"); - bool result = - GUI::askQuestion(titile, tr("All settings will be reset to default. Are you sure?"), - tr("Yes"), tr("No")); + bool result = GUI::askQuestion(titile, tr("All settings will be reset to default. Are you sure?"), + tr("Yes"), tr("No")); if (!result) return; diff --git a/src/widget/form/settings/avform.cpp b/src/widget/form/settings/avform.cpp index 4c8f947a9..b0037ad08 100644 --- a/src/widget/form/settings/avform.cpp +++ b/src/widget/form/settings/avform.cpp @@ -31,11 +31,11 @@ #include "src/audio/iaudiosettings.h" #include "src/core/core.h" #include "src/core/coreav.h" -#include "src/core/recursivesignalblocker.h" #include "src/video/cameradevice.h" #include "src/video/camerasource.h" #include "src/video/ivideosettings.h" #include "src/video/videosurface.h" +#include "src/widget/tool/recursivesignalblocker.h" #include "src/widget/tool/screenshotgrabber.h" #include "src/widget/translator.h" @@ -43,8 +43,8 @@ #define ALC_ALL_DEVICES_SPECIFIER ALC_DEVICE_SPECIFIER #endif -AVForm::AVForm(Audio* audio, CoreAV* coreAV, CameraSource& camera, - IAudioSettings* audioSettings, IVideoSettings* videoSettings) +AVForm::AVForm(Audio* audio, CoreAV* coreAV, CameraSource& camera, IAudioSettings* audioSettings, + IVideoSettings* videoSettings) : GenericForm(QPixmap(":/img/settings/av.png")) , audio{audio} , coreAV{coreAV} @@ -72,7 +72,8 @@ AVForm::AVForm(Audio* audio, CoreAV* coreAV, CameraSource& camera, playbackSlider->setTracking(false); playbackSlider->setMaximum(totalSliderSteps); playbackSlider->setValue(getStepsFromValue(audioSettings->getOutVolume(), - audioSettings->getOutVolumeMin(), audioSettings->getOutVolumeMax())); + audioSettings->getOutVolumeMin(), + audioSettings->getOutVolumeMax())); playbackSlider->installEventFilter(this); microphoneSlider->setToolTip(tr("Use slider to set the gain of your input device ranging" @@ -85,13 +86,15 @@ AVForm::AVForm(Audio* audio, CoreAV* coreAV, CameraSource& camera, microphoneSlider->setTickInterval(totalSliderSteps / numTicks); microphoneSlider->setTracking(false); microphoneSlider->installEventFilter(this); - microphoneSlider->setValue(getStepsFromValue(audio->inputGain(), audio->minInputGain(), audio->maxInputGain())); + microphoneSlider->setValue( + getStepsFromValue(audio->inputGain(), audio->minInputGain(), audio->maxInputGain())); audioThresholdSlider->setToolTip(tr("Use slider to set the activation volume for your" - " input device.")); + " input device.")); audioThresholdSlider->setMaximum(totalSliderSteps); audioThresholdSlider->setValue(getStepsFromValue(audioSettings->getAudioThreshold(), - audio->minInputThreshold(), audio->maxInputThreshold())); + audio->minInputThreshold(), + audio->maxInputThreshold())); audioThresholdSlider->setTracking(false); audioThresholdSlider->installEventFilter(this); @@ -167,7 +170,8 @@ void AVForm::rescanDevices() void AVForm::setVolume(float value) { - volumeDisplay->setValue(getStepsFromValue(value, audio->minOutputVolume(), audio->maxOutputVolume())); + volumeDisplay->setValue( + getStepsFromValue(value, audio->minOutputVolume(), audio->maxOutputVolume())); } void AVForm::on_cbEnableBackend2_stateChanged() @@ -335,7 +339,7 @@ int AVForm::searchPreferredIndex() for (int i = 0; i < videoModes.size(); ++i) { VideoMode mode = videoModes[i]; if (mode.width == prefRes.width() && mode.height == prefRes.height() - && (qAbs(mode.FPS - prefFPS) < 0.0001f)) { + && (qAbs(mode.FPS - prefFPS) < 0.0001f)) { return i; } } @@ -544,7 +548,6 @@ void AVForm::on_inDevCombobox_currentIndexChanged(int deviceIndex) if (!inputEnabled) { volumeDisplay->setValue(volumeDisplay->minimum()); } - } void AVForm::on_outDevCombobox_currentIndexChanged(int deviceIndex) @@ -561,18 +564,19 @@ void AVForm::on_outDevCombobox_currentIndexChanged(int deviceIndex) audio->reinitOutput(deviceName); playbackSlider->setEnabled(outputEnabled); - playbackSlider->setSliderPosition(getStepsFromValue(audio->outputVolume(), - audio->minOutputVolume(), audio->maxOutputVolume())); + playbackSlider->setSliderPosition( + getStepsFromValue(audio->outputVolume(), audio->minOutputVolume(), audio->maxOutputVolume())); } void AVForm::on_playbackSlider_valueChanged(int sliderSteps) { - const int settingsVolume = getValueFromSteps(sliderSteps, - audioSettings->getOutVolumeMin(),audioSettings->getOutVolumeMax()); + const int settingsVolume = getValueFromSteps(sliderSteps, audioSettings->getOutVolumeMin(), + audioSettings->getOutVolumeMax()); audioSettings->setOutVolume(settingsVolume); if (audio->isOutputReady()) { - const qreal volume = getValueFromSteps(sliderSteps, audio->minOutputVolume(), audio->maxOutputVolume()); + const qreal volume = + getValueFromSteps(sliderSteps, audio->minOutputVolume(), audio->maxOutputVolume()); audio->setOutputVolume(volume); if (cbEnableTestSound->isChecked()) @@ -597,7 +601,8 @@ void AVForm::on_microphoneSlider_valueChanged(int sliderSteps) void AVForm::on_audioThresholdSlider_valueChanged(int sliderSteps) { - const qreal normThreshold = getValueFromSteps(sliderSteps, audio->minInputThreshold(), audio->maxInputThreshold()); + const qreal normThreshold = + getValueFromSteps(sliderSteps, audio->minInputThreshold(), audio->maxInputThreshold()); audioSettings->setAudioThreshold(normThreshold); Audio::getInstance().setInputThreshold(normThreshold); } diff --git a/src/widget/form/settings/generalform.cpp b/src/widget/form/settings/generalform.cpp index cb2b7754a..613c986f1 100644 --- a/src/widget/form/settings/generalform.cpp +++ b/src/widget/form/settings/generalform.cpp @@ -25,13 +25,13 @@ #include "src/core/core.h" #include "src/core/coreav.h" -#include "src/core/recursivesignalblocker.h" #include "src/net/autoupdate.h" #include "src/persistence/profile.h" #include "src/persistence/settings.h" #include "src/persistence/smileypack.h" #include "src/widget/form/settingswidget.h" #include "src/widget/style.h" +#include "src/widget/tool/recursivesignalblocker.h" #include "src/widget/translator.h" #include "src/widget/widget.h" @@ -153,7 +153,8 @@ GeneralForm::GeneralForm(SettingsWidget* myParent) #ifndef QTOX_PLATFORM_EXT - bodyUI->autoAwayLabel->setEnabled(false); // these don't seem to change the appearance of the widgets, + bodyUI->autoAwayLabel->setEnabled( + false); // these don't seem to change the appearance of the widgets, bodyUI->autoAwaySpinBox->setEnabled(false); // though they are unusable #endif diff --git a/src/widget/form/settings/privacyform.cpp b/src/widget/form/settings/privacyform.cpp index 431ab0025..5ee574d47 100644 --- a/src/widget/form/settings/privacyform.cpp +++ b/src/widget/form/settings/privacyform.cpp @@ -25,7 +25,6 @@ #include #include "src/core/core.h" -#include "src/core/recursivesignalblocker.h" #include "src/nexus.h" #include "src/persistence/history.h" #include "src/persistence/profile.h" @@ -33,6 +32,7 @@ #include "src/widget/form/setpassworddialog.h" #include "src/widget/form/settingswidget.h" #include "src/widget/gui.h" +#include "src/widget/tool/recursivesignalblocker.h" #include "src/widget/translator.h" #include "src/widget/widget.h" diff --git a/src/widget/form/settings/userinterfaceform.cpp b/src/widget/form/settings/userinterfaceform.cpp index 25cf5c34d..0eb0c9498 100644 --- a/src/widget/form/settings/userinterfaceform.cpp +++ b/src/widget/form/settings/userinterfaceform.cpp @@ -32,13 +32,13 @@ #include "src/core/core.h" #include "src/core/coreav.h" -#include "src/core/recursivesignalblocker.h" #include "src/net/autoupdate.h" #include "src/persistence/profile.h" #include "src/persistence/settings.h" #include "src/persistence/smileypack.h" #include "src/widget/form/settingswidget.h" #include "src/widget/style.h" +#include "src/widget/tool/recursivesignalblocker.h" #include "src/widget/translator.h" #include "src/widget/widget.h" @@ -142,7 +142,7 @@ UserInterfaceForm::UserInterfaceForm(SettingsWidget* myParent) QStringList dateFormats; dateFormats << QStringLiteral("yyyy-MM-dd") // ISO 8601 - // format strings from system locale + // format strings from system locale << ql.dateFormat(QLocale::LongFormat) << ql.dateFormat(QLocale::ShortFormat) << ql.dateFormat(QLocale::NarrowFormat) << "dd-MM-yyyy" << "d-MM-yyyy" diff --git a/src/core/recursivesignalblocker.cpp b/src/widget/tool/recursivesignalblocker.cpp similarity index 100% rename from src/core/recursivesignalblocker.cpp rename to src/widget/tool/recursivesignalblocker.cpp diff --git a/src/core/recursivesignalblocker.h b/src/widget/tool/recursivesignalblocker.h similarity index 100% rename from src/core/recursivesignalblocker.h rename to src/widget/tool/recursivesignalblocker.h