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

feat(settings): add notification signals for changed settings values

Makes changes to settings application wide transparent. The properties section is optional in theory, but comes in very handy, if we decide to access settings e.g. from within a script context.
This commit is contained in:
Nils Fenner 2016-08-08 13:40:55 +02:00
parent e4398c7894
commit f00b9008e6
No known key found for this signature in database
GPG Key ID: 9591A163FF9BE04C
17 changed files with 741 additions and 230 deletions

View File

@ -364,7 +364,7 @@ bool Audio::initInput(const QString& deviceName)
return false;
}
d->setInputGain(Settings::getInstance().getAudioInGain());
d->setInputGain(Settings::getInstance().getAudioInGainDecibel());
qDebug() << "Opened audio input" << deviceName;
alcCaptureStart(alInDev);

View File

@ -52,7 +52,6 @@ public:
void setTypingNotificationVisible(bool visible);
void scrollToLine(ChatLine::Ptr line);
void selectAll();
void forceRelayout();
QString getSelectedText() const;
@ -67,6 +66,13 @@ public:
signals:
void selectionChanged();
public slots:
void forceRelayout();
private slots:
void onSelectionTimerTimeout();
void onWorkerTimeout();
protected:
QRectF calculateSceneRect() const;
QRect getVisibleRect() const;
@ -100,10 +106,6 @@ protected:
ChatLine::Ptr findLineByPosY(qreal yPos) const;
private slots:
void onSelectionTimerTimeout();
void onWorkerTimeout();
private:
void retranslateUi();
bool isActiveFileTransfer(ChatLine::Ptr l);

View File

@ -56,7 +56,7 @@ ChatMessage::Ptr ChatMessage::createChatMessage(const QString &sender, const QSt
text = detectQuotes(detectAnchors(text), type);
//text styling
if (Settings::getInstance().getStylePreference() != NONE)
if (Settings::getInstance().getStylePreference() != Settings::StyleType::NONE)
text = detectStyle(text);
switch(type)
@ -229,7 +229,7 @@ QString ChatMessage::detectStyle(const QString &str)
{
int mul = 0; // Determines how many characters to strip from text
// Set mul depending on styleownPreference
if (Settings::getInstance().getStylePreference() == WITHOUT_CHARS)
if (Settings::getInstance().getStylePreference() == Settings::StyleType::WITHOUT_CHARS)
mul = 2;
// Match captured string to corresponding style format

View File

@ -122,8 +122,8 @@ void Core::makeTox(QByteArray savedata)
// IPv6 needed for LAN discovery, but can crash some weird routers. On by default, can be disabled in options.
bool enableIPv6 = Settings::getInstance().getEnableIPv6();
bool forceTCP = Settings::getInstance().getForceTCP();
ProxyType proxyType = Settings::getInstance().getProxyType();
int proxyPort = Settings::getInstance().getProxyPort();
Settings::ProxyType proxyType = Settings::getInstance().getProxyType();
quint16 proxyPort = Settings::getInstance().getProxyPort();
QString proxyAddr = Settings::getInstance().getProxyAddr();
QByteArray proxyAddrData = proxyAddr.toUtf8();
@ -147,7 +147,7 @@ void Core::makeTox(QByteArray savedata)
toxOptions.savedata_data = (uint8_t*)savedata.data();
toxOptions.savedata_length = savedata.size();
if (proxyType != ProxyType::ptNone)
if (proxyType != Settings::ProxyType::ptNone)
{
if (proxyAddr.length() > 255)
{
@ -157,9 +157,9 @@ void Core::makeTox(QByteArray savedata)
{
qDebug() << "using proxy" << proxyAddr << ":" << proxyPort;
// protection against changings in TOX_PROXY_TYPE enum
if (proxyType == ProxyType::ptSOCKS5)
if (proxyType == Settings::ProxyType::ptSOCKS5)
toxOptions.proxy_type = TOX_PROXY_TYPE_SOCKS5;
else if (proxyType == ProxyType::ptHTTP)
else if (proxyType == Settings::ProxyType::ptHTTP)
toxOptions.proxy_type = TOX_PROXY_TYPE_HTTP;
toxOptions.proxy_host = proxyAddrData.data();
@ -592,7 +592,7 @@ void Core::requestFriendship(const QString& friendAddress, const QString& messag
{
qDebug() << "Requested friendship of "<<friendId;
// Update our friendAddresses
Settings::getInstance().updateFriendAdress(friendAddress);
Settings::getInstance().updateFriendAddress(friendAddress);
QString inviteStr = tr("/me offers friendship.");
if (message.length())
inviteStr = tr("/me offers friendship, \"%1\"").arg(message);
@ -1166,7 +1166,7 @@ bool Core::hasFriendWithPublicKey(const QString &pubkey) const
QString Core::getFriendAddress(uint32_t friendNumber) const
{
QString id = getFriendPublicKey(friendNumber);
QString addr = Settings::getInstance().getFriendAdress(id);
QString addr = Settings::getInstance().getFriendAddress(id);
if (addr.size() > id.size())
return addr;

View File

@ -7,17 +7,40 @@
#define TOX_HEX_ID_LENGTH 2*TOX_ADDRESS_SIZE
/**
@file corestructs.h
@brief Some headers use Core structs but don't need to include all of core.h
They should include this file directly instead to reduce compilation times
*/
* @file corestructs.h
* @brief Some headers use Core structs but don't need to include all of core.h
*
* They should include this file directly instead to reduce compilation times
*
*
* @var ToxFile::fileKind Data file (default) or avatar
*/
/**
@var uint8_t ToxFile::fileKind
@brief Data file (default) or avatar
*/
* @brief Compare equal operator
* @param other the compared instance
* @return true, if equal; false otherwise
*/
bool DhtServer::operator==(const DhtServer& other) const
{
return this == &other ||
(port == other.port && address == other.address &&
userId == other.userId && name == other.name);
}
/**
* @brief Compare not equal operator
* @param other the compared instance
* @return true, if not equal; false otherwise
*/
bool DhtServer::operator!=(const DhtServer& other) const
{
return !(*this == other);
}
/**
* @brief ToxFile constructor
*/
ToxFile::ToxFile(uint32_t fileNum, uint32_t friendId, QByteArray filename, QString filePath, FileDirection Direction)
: fileKind{TOX_FILE_KIND_DATA}, fileNum(fileNum), friendId(friendId), fileName{filename},
filePath{filePath}, file{new QFile(filePath)}, bytesSent{0}, filesize{0},

View File

@ -15,6 +15,9 @@ struct DhtServer
QString userId;
QString address;
quint16 port;
bool operator==(const DhtServer& other) const;
bool operator!=(const DhtServer& other) const;
};
struct ToxFile

View File

@ -25,7 +25,7 @@
#include <QSqlDatabase>
namespace Db {
enum class syncType : int {stOff = 0, stNormal = 1, stFull = 2};
enum class syncType {stOff = 0, stNormal = 1, stFull = 2};
}
class PlainDb : public GenericDdInterface

View File

@ -29,7 +29,10 @@
class Profile;
class GenericDdInterface;
namespace Db { enum class syncType; }
namespace Db {
enum class syncType;
}
class HistoryKeeper
{

File diff suppressed because it is too large Load Diff

View File

@ -32,15 +32,106 @@
class ToxId;
class Profile;
namespace Db { enum class syncType; }
enum ProxyType {ptNone, ptSOCKS5, ptHTTP};
enum StyleType {NONE, WITH_CHARS, WITHOUT_CHARS};
namespace Db {
enum class syncType;
}
class Settings : public QObject
{
Q_OBJECT
Q_ENUMS(ProxyType)
Q_ENUMS(StyleType)
// general
Q_PROPERTY(bool compactLayout READ getCompactLayout WRITE setCompactLayout
NOTIFY compactLayoutChanged FINAL)
Q_PROPERTY(bool autorun READ getAutorun WRITE setAutorun
NOTIFY autorunChanged FINAL)
// GUI
Q_PROPERTY(bool separateWindow READ getSeparateWindow
WRITE setSeparateWindow NOTIFY separateWindowChanged FINAL)
Q_PROPERTY(QString smileyPack READ getSmileyPack WRITE setSmileyPack
NOTIFY smileyPackChanged FINAL)
Q_PROPERTY(int emojiFontPointSize READ getEmojiFontPointSize
WRITE setEmojiFontPointSize NOTIFY emojiFontPointSizeChanged
FINAL)
Q_PROPERTY(bool minimizeOnClose READ getMinimizeOnClose
WRITE setMinimizeOnClose NOTIFY minimizeOnCloseChanged FINAL)
Q_PROPERTY(QByteArray windowGeometry READ getWindowGeometry
WRITE setWindowGeometry NOTIFY windowGeometryChanged FINAL)
Q_PROPERTY(QByteArray windowState READ getWindowState WRITE setWindowState
NOTIFY windowStateChanged FINAL)
Q_PROPERTY(QByteArray splitterState READ getSplitterState
WRITE setSplitterState NOTIFY splitterStateChanged FINAL)
Q_PROPERTY(QByteArray dialogGeometry READ getDialogGeometry
WRITE setDialogGeometry NOTIFY dialogGeometryChanged FINAL)
Q_PROPERTY(QByteArray dialogSplitterState READ getDialogSplitterState
WRITE setDialogSplitterState NOTIFY dialogSplitterStateChanged
FINAL)
Q_PROPERTY(QByteArray dialogSettingsGeometry READ getDialogSettingsGeometry
WRITE setDialogSettingsGeometry
NOTIFY dialogSettingsGeometryChanged FINAL)
Q_PROPERTY(QString style READ getStyle WRITE setStyle NOTIFY styleChanged
FINAL)
Q_PROPERTY(bool showSystemTray READ getShowSystemTray
WRITE setShowSystemTray NOTIFY showSystemTrayChanged FINAL)
// ChatView
Q_PROPERTY(bool groupchatPosition READ getGroupchatPosition
WRITE setGroupchatPosition NOTIFY groupchatPositionChanged FINAL)
Q_PROPERTY(QFont chatMessageFont READ getChatMessageFont
WRITE setChatMessageFont NOTIFY chatMessageFontChanged FINAL)
Q_PROPERTY(StyleType stylePreference READ getStylePreference
WRITE setStylePreference NOTIFY stylePreferenceChanged FINAL)
Q_PROPERTY(QString timestampFormat READ getTimestampFormat
WRITE setTimestampFormat NOTIFY timestampFormatChanged FINAL)
Q_PROPERTY(QString dateFormat READ getDateFormat WRITE setDateFormat
NOTIFY dateFormatChanged FINAL)
Q_PROPERTY(bool statusChangeNotificationEnabled
READ getStatusChangeNotificationEnabled
WRITE setStatusChangeNotificationEnabled
NOTIFY statusChangeNotificationEnabledChanged FINAL)
// Privacy
Q_PROPERTY(bool typingNotification READ getTypingNotification
WRITE setTypingNotification NOTIFY typingNotificationChanged
FINAL)
// Audio
Q_PROPERTY(QString inDev READ getInDev WRITE setInDev
NOTIFY inDevChanged FINAL)
Q_PROPERTY(bool audioInDevEnabled READ getAudioInDevEnabled
WRITE setAudioInDevEnabled NOTIFY audioInDevEnabledChanged FINAL)
Q_PROPERTY(qreal audioInGainDecibel READ getAudioInGainDecibel
WRITE setAudioInGainDecibel NOTIFY audioInGainDecibelChanged
FINAL)
Q_PROPERTY(QString outDev READ getOutDev WRITE setOutDev
NOTIFY outDevChanged FINAL)
Q_PROPERTY(bool audioOutDevEnabled READ getAudioOutDevEnabled
WRITE setAudioOutDevEnabled NOTIFY audioOutDevEnabledChanged
FINAL)
Q_PROPERTY(int outVolume READ getOutVolume WRITE setOutVolume
NOTIFY outVolumeChanged FINAL)
// Video
Q_PROPERTY(QString videoDev READ getVideoDev WRITE setVideoDev
NOTIFY videoDevChanged FINAL)
Q_PROPERTY(QRect camVideoRes READ getCamVideoRes WRITE setCamVideoRes
NOTIFY camVideoResChanged FINAL)
Q_PROPERTY(QRect screenRegion READ getScreenRegion WRITE setScreenRegion
NOTIFY screenRegionChanged FINAL)
Q_PROPERTY(bool screenGrabbed READ getScreenGrabbed WRITE setScreenGrabbed
NOTIFY screenGrabbedChanged FINAL)
Q_PROPERTY(quint16 camVideoFPS READ getCamVideoFPS
WRITE setCamVideoFPS NOTIFY camVideoFPSChanged FINAL)
public:
enum class ProxyType {ptNone = 0, ptSOCKS5 = 1, ptHTTP = 2};
enum class StyleType {NONE = 0, WITH_CHARS = 1, WITHOUT_CHARS = 2};
public:
static Settings& getInstance();
static void destroyInstance();
@ -65,15 +156,89 @@ public:
bool read;
};
public slots:
void saveGlobal();
void sync();
signals:
void dhtServerListChanged();
void smileyPackChanged();
void emojiFontChanged();
// General
void enableIPv6Changed(bool enabled);
void forceTCPChanged(bool enabled);
void proxyTypeChanged(ProxyType type);
void proxyAddressChanged(const QString& address);
void proxyPortChanged(quint16 port);
void dhtServerListChanged(const QList<DhtServer>& servers);
void autorunChanged(bool enabled);
void autoSaveEnabledChanged(bool enabled);
void autostartInTrayChanged(bool enabled);
void showInFrontChanged(bool enabled);
void closeToTrayChanged(bool enabled);
void lightTrayIconChanged(bool enabled);
void minimizeToTrayChanged(bool enabled);
void showWindowChanged(bool enabled);
void makeToxPortableChanged(bool enabled);
void busySoundChanged(bool enabled);
void notifySoundChanged(bool enabled);
void groupAlwaysNotifyChanged(bool enabled);
void translationChanged(const QString& translation);
void toxmeInfoChanged(const QString& info);
void toxmeBioChanged(const QString& bio);
void toxmePrivChanged(bool priv);
void toxmePassChanged();
void currentProfileChanged(const QString& profile);
void currentProfileIdChanged(quint32 id);
void enableLoggingChanged(bool enabled);
void autoAwayTimeChanged(int minutes);
void globalAutoAcceptDirChanged(const QString& path);
void checkUpdatesChanged(bool enabled);
void widgetDataChanged(const QString& key);
// GUI
void autoLoginChanged(bool enabled);
void separateWindowChanged(bool enabled);
void showSystemTrayChanged(bool enabled);
bool minimizeOnCloseChanged(bool enabled);
void windowGeometryChanged(const QByteArray& rect);
void windowStateChanged(const QByteArray& state);
void splitterStateChanged(const QByteArray& state);
void dialogGeometryChanged(const QByteArray& rect);
void dialogSplitterStateChanged(const QByteArray& state);
void dialogSettingsGeometryChanged(const QByteArray& rect);
void styleChanged(const QString& style);
void themeColorChanged(int color);
void compactLayoutChanged(bool enabled);
// ChatView
void useEmoticonsChanged(bool enabled);
void smileyPackChanged(const QString& name);
void emojiFontPointSizeChanged(int size);
void dontGroupWindowsChanged(bool enabled);
void groupchatPositionChanged(bool enabled);
void chatMessageFontChanged(const QFont& font);
void stylePreferenceChanged(StyleType type);
void timestampFormatChanged(const QString& format);
void dateFormatChanged(const QString& format);
void statusChangeNotificationEnabledChanged(bool enabled);
void fauxOfflineMessagingChanged(bool enabled);
// Privacy
void typingNotificationChanged(bool enabled);
void dbSyncTypeChanged(Db::syncType type);
// Audio
void inDevChanged(const QString& name);
void audioInDevEnabledChanged(bool enabled);
void audioInGainDecibelChanged(qreal gain);
void outDevChanged(const QString& name);
void audioOutDevEnabledChanged(bool enabled);
void outVolumeChanged(int volume);
// Video
void videoDevChanged(const QString& name);
void camVideoResChanged(const QRect& resolution);
void screenRegionChanged(const QRect& region);
void screenGrabbedChanged(bool enabled);
void camVideoFPSChanged(quint16 fps);
public:
const QList<DhtServer>& getDhtServerList() const;
@ -104,32 +269,32 @@ public:
void setStyle(const QString& newValue);
bool getShowSystemTray() const;
void setShowSystemTray(const bool& newValue);
void setShowSystemTray(bool newValue);
bool getUseEmoticons() const;
void setUseEmoticons(bool newValue);
QString getCurrentProfile() const;
uint32_t getCurrentProfileId() const;
void setCurrentProfile(QString profile);
void setCurrentProfile(const QString& profile);
QString getTranslation() const;
void setTranslation(QString newValue);
void setTranslation(const QString& newValue);
// Toxme
void deleteToxme();
void setToxme(QString name, QString server, QString bio, bool priv, QString pass = "");
QString getToxmeInfo() const;
void setToxmeInfo(QString info);
void setToxmeInfo(const QString& info);
QString getToxmeBio() const;
void setToxmeBio(QString bio);
void setToxmeBio(const QString& bio);
bool getToxmePriv() const;
void setToxmePriv(bool priv);
QString getToxmePass() const;
void setToxmePass(const QString &pass);
void setToxmePass(const QString& pass);
void setAutoSaveEnabled(bool newValue);
bool getAutoSaveEnabled() const;
@ -143,7 +308,7 @@ public:
void setProxyAddr(const QString& newValue);
ProxyType getProxyType() const;
void setProxyType(int newValue);
void setProxyType(ProxyType newValue);
quint16 getProxyPort() const;
void setProxyPort(quint16 newValue);
@ -152,7 +317,7 @@ public:
void setEnableLogging(bool newValue);
Db::syncType getDbSyncType() const;
void setDbSyncType(int newValue);
void setDbSyncType(Db::syncType newValue);
int getAutoAwayTime() const;
void setAutoAwayTime(int newValue);
@ -187,8 +352,8 @@ public:
bool getAudioOutDevEnabled() const;
void setAudioOutDevEnabled(bool enabled);
qreal getAudioInGain() const;
void setAudioInGain(qreal dB);
qreal getAudioInGainDecibel() const;
void setAudioInGainDecibel(qreal dB);
int getOutVolume() const;
void setOutVolume(int volume);
@ -197,7 +362,7 @@ public:
void setVideoDev(const QString& deviceSpecifier);
QRect getScreenRegion() const;
void setScreenRegion(const QRect &value);
void setScreenRegion(const QRect& value);
bool getScreenGrabbed() const;
void setScreenGrabbed(bool value);
@ -212,10 +377,10 @@ public:
void setAnimationEnabled(bool newValue);
QString getSmileyPack() const;
void setSmileyPack(const QString &value);
void setSmileyPack(const QString& value);
int getThemeColor() const;
void setThemeColor(const int& value);
void setThemeColor(int value);
StyleType getStylePreference() const;
void setStylePreference(StyleType newValue);
@ -239,60 +404,54 @@ public:
const QFont& getChatMessageFont() const;
void setChatMessageFont(const QFont& font);
int getFirstColumnHandlePos() const;
void setFirstColumnHandlePos(const int pos);
int getSecondColumnHandlePosFromRight() const;
void setSecondColumnHandlePosFromRight(const int pos);
const QString& getTimestampFormat() const;
void setTimestampFormat(const QString& format);
const QString& getDateFormat() const;
void setDateFormat(const QString& format);
bool isMinimizeOnCloseEnabled() const;
bool getMinimizeOnClose() const;
void setMinimizeOnClose(bool newValue);
bool getStatusChangeNotificationEnabled() const;
void setStatusChangeNotificationEnabled(bool newValue);
// Privacy
bool isTypingNotificationEnabled() const;
bool getTypingNotification() const;
void setTypingNotification(bool enabled);
// State
QByteArray getWindowGeometry() const;
void setWindowGeometry(const QByteArray &value);
void setWindowGeometry(const QByteArray& value);
QByteArray getWindowState() const;
void setWindowState(const QByteArray &value);
void setWindowState(const QByteArray& value);
QByteArray getSplitterState() const;
void setSplitterState(const QByteArray &value);
void setSplitterState(const QByteArray& value);
QByteArray getDialogGeometry() const;
void setDialogGeometry(const QByteArray& value);
QByteArray getDialogSplitterState() const;
void setDialogSplitterState(const QByteArray &value);
void setDialogSplitterState(const QByteArray& value);
QByteArray getDialogSettingsGeometry() const;
void setDialogSettingsGeometry(const QByteArray& value);
QString getFriendAdress(const QString &publicKey) const;
void updateFriendAdress(const QString &newAddr);
QString getFriendAddress(const QString& publicKey) const;
void updateFriendAddress(const QString& newAddr);
QString getFriendAlias(const ToxId &id) const;
void setFriendAlias(const ToxId &id, const QString &alias);
QString getFriendAlias(const ToxId& id) const;
void setFriendAlias(const ToxId& id, const QString& alias);
int getFriendCircleID(const ToxId &id) const;
void setFriendCircleID(const ToxId &id, int circleID);
int getFriendCircleID(const ToxId& id) const;
void setFriendCircleID(const ToxId& id, int circleID);
QDate getFriendActivity(const ToxId &id) const;
void setFriendActivity(const ToxId &id, const QDate &date);
QDate getFriendActivity(const ToxId& id) const;
void setFriendActivity(const ToxId& id, const QDate &date);
void removeFriendSettings(const ToxId &id);
void removeFriendSettings(const ToxId& id);
bool getFauxOfflineMessaging() const;
void setFauxOfflineMessaging(bool value);
@ -313,14 +472,14 @@ public:
void setAutoLogin(bool state);
int getCircleCount() const;
int addCircle(const QString &name = QString());
int addCircle(const QString& name = QString());
int removeCircle(int id);
QString getCircleName(int id) const;
void setCircleName(int id, const QString &name);
void setCircleName(int id, const QString& name);
bool getCircleExpanded(int id) const;
void setCircleExpanded(int id, bool expanded);
bool addFriendRequest(const QString &friendAddress, const QString &message);
bool addFriendRequest(const QString& friendAddress, const QString& message);
unsigned int getUnreadFriendRequests() const;
Request getFriendRequest(int index) const;
int getFriendRequestSize() const;

View File

@ -165,7 +165,7 @@ void AddFriendForm::onSendTriggered()
if (toxId.toString().isEmpty()) // If it isn't supported
{
qDebug() << "Toxme didn't return a ToxID, trying ToxDNS";
if (Settings::getInstance().getProxyType() != ProxyType::ptNone)
if (Settings::getInstance().getProxyType() != Settings::ProxyType::ptNone)
{
QMessageBox::StandardButton btn = QMessageBox::warning(main, "qTox", tr("qTox needs to use the Tox DNS, but can't do it through a proxy.\n\
Ignore the proxy and connect to the Internet directly?"), QMessageBox::Yes|QMessageBox::No, QMessageBox::No);

View File

@ -163,7 +163,7 @@ void ChatForm::onSendTriggered()
void ChatForm::onTextEditChanged()
{
if (!Settings::getInstance().isTypingNotificationEnabled())
if (!Settings::getInstance().getTypingNotification())
{
if (isTyping)
Core::getInstance()->sendTyping(f->getFriendID(), false);

View File

@ -76,8 +76,10 @@ GenericChatForm::GenericChatForm(QWidget *parent)
chatWidget = new ChatLog(this);
chatWidget->setBusyNotification(ChatMessage::createBusyNotification());
connect(&Settings::getInstance(), &Settings::emojiFontChanged,
this, [this]() { chatWidget->forceRelayout(); });
// settings
const Settings& s = Settings::getInstance();
connect(&s, &Settings::emojiFontPointSizeChanged,
chatWidget, &ChatLog::forceRelayout);
msgEdit = new ChatTextEdit();

View File

@ -537,7 +537,7 @@ void AVForm::on_microphoneSlider_valueChanged(int value)
{
const qreal dB = value / 10.0;
Settings::getInstance().setAudioInGain(dB);
Settings::getInstance().setAudioInGainDecibel(dB);
Audio::getInstance().setInputGain(dB);
}

View File

@ -133,7 +133,7 @@ GeneralForm::GeneralForm(SettingsWidget *myParent)
const QFont chatBaseFont = s.getChatMessageFont();
bodyUI->txtChatFontSize->setValue(QFontInfo(chatBaseFont).pixelSize());
bodyUI->txtChatFont->setCurrentFont(chatBaseFont);
bodyUI->textStyleComboBox->setCurrentIndex(s.getStylePreference());
bodyUI->textStyleComboBox->setCurrentIndex(static_cast<int>(s.getStylePreference()));
bodyUI->cbAutorun->setChecked(s.getAutorun());
bool showSystemTray = s.getShowSystemTray();
@ -407,7 +407,9 @@ void GeneralForm::onUseEmoticonsChange()
void GeneralForm::onStyleUpdated()
{
Settings::getInstance().setStylePreference(static_cast<StyleType>(bodyUI->textStyleComboBox->currentIndex()));
Settings::StyleType styleType =
static_cast<Settings::StyleType>(bodyUI->textStyleComboBox->currentIndex());
Settings::getInstance().setStylePreference(styleType);
}
void GeneralForm::onSetStatusChange()
@ -434,18 +436,16 @@ void GeneralForm::onProxyAddrEdited()
void GeneralForm::onProxyPortEdited(int port)
{
if (port > 0)
Settings::getInstance().setProxyPort(port);
else
Settings::getInstance().setProxyPort(-1);
Settings::getInstance().setProxyPort(static_cast<quint16>(port));
}
void GeneralForm::onUseProxyUpdated()
{
int proxytype = bodyUI->proxyType->currentIndex();
Settings::ProxyType proxytype =
static_cast<Settings::ProxyType>(bodyUI->proxyType->currentIndex());
bodyUI->proxyAddr->setEnabled(proxytype);
bodyUI->proxyPort->setEnabled(proxytype);
bodyUI->proxyAddr->setEnabled(proxytype != Settings::ProxyType::ptNone);
bodyUI->proxyPort->setEnabled(proxytype != Settings::ProxyType::ptNone);
Settings::getInstance().setProxyType(proxytype);
}

View File

@ -93,8 +93,9 @@ void PrivacyForm::setNospam()
void PrivacyForm::showEvent(QShowEvent*)
{
const Settings& s = Settings::getInstance();
bodyUI->nospamLineEdit->setText(Core::getInstance()->getSelfId().noSpam);
bodyUI->cbTypingNotification->setChecked(Settings::getInstance().isTypingNotificationEnabled());
bodyUI->cbTypingNotification->setChecked(s.getTypingNotification());
bodyUI->cbKeepHistory->setChecked(Settings::getInstance().getEnableLogging());
}

View File

@ -640,7 +640,7 @@ void Widget::onFailedToStartCore()
void Widget::onBadProxyCore()
{
Settings::getInstance().setProxyType(0);
Settings::getInstance().setProxyType(Settings::ProxyType::ptNone);
QMessageBox critical(this);
critical.setText(tr("toxcore failed to start with your proxy settings. qTox cannot run; please modify your "
"settings and restart.", "popup text"));