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

autosaveDir, useEmoicons, selectTimestamp added to GUI and settings

This commit is contained in:
agilob 2014-11-05 15:20:32 +00:00
parent 866a8a147e
commit 3dbbbd1caf
No known key found for this signature in database
GPG Key ID: 34568050DBCCB997
5 changed files with 231 additions and 16 deletions

View File

@ -114,6 +114,8 @@ void Settings::load()
proxyPort = s.value("proxyPort", 0).toInt();
currentProfile = s.value("currentProfile", "").toString();
autoAwayTime = s.value("autoAwayTime", 10).toInt();
autoSaveEnabled = s.value("autoSaveEnabled", false).toBool();
autoSaveDir = s.value("autoSaveDir", QStandardPaths::locate(QStandardPaths::HomeLocation, QString(), QStandardPaths::LocateDirectory)).toString();
s.endGroup();
s.beginGroup("Widgets");
@ -135,6 +137,7 @@ void Settings::load()
minimizeOnClose = s.value("minimizeOnClose", false).toBool();
minimizeToTray = s.value("minimizeToTray", false).toBool();
useNativeStyle = s.value("nativeStyle", false).toBool();
useEmoticons = s.value("useEmoticons", true).toBool();
style = s.value("style", "None").toString();
statusChangeNotificationEnabled = s.value("statusChangeNotificationEnabled", false).toBool();
s.endGroup();
@ -238,6 +241,8 @@ void Settings::save(QString path)
s.setValue("proxyPort", proxyPort);
s.setValue("currentProfile", currentProfile);
s.setValue("autoAwayTime", autoAwayTime);
s.setValue("autoSaveEnabled", autoSaveEnabled);
s.setValue("autoSaveDir", autoSaveDir);
s.endGroup();
s.beginGroup("Widgets");
@ -259,6 +264,7 @@ void Settings::save(QString path)
s.setValue("minimizeOnClose", minimizeOnClose);
s.setValue("minimizeToTray", minimizeToTray);
s.setValue("nativeStyle", useNativeStyle);
s.setValue("useEmoticons", useEmoticons);
s.setValue("style", style);
s.setValue("statusChangeNotificationEnabled", statusChangeNotificationEnabled);
s.endGroup();
@ -403,6 +409,26 @@ void Settings::setStyle(const QString& newStyle)
style = newStyle;
}
void Settings::setUseEmoticons(bool newValue)
{
useEmoticons = newValue;
}
bool Settings::getUseEmoticons() const
{
return useEmoticons;
}
void Settings::setAutoSaveEnabled(bool newValue)
{
autoSaveEnabled = newValue;
}
bool Settings::getAutoSaveEnabled() const
{
return autoSaveEnabled;
}
void Settings::setAutostartInTray(bool newValue)
{
autostartInTray = newValue;
@ -449,6 +475,17 @@ void Settings::setTranslation(QString newValue)
translation = newValue;
}
QString Settings::getAutoSaveFilesDir() const
{
return autoSaveDir;
}
void Settings::setAutoSaveFilesDir(QString newValue)
{
autoSaveDir = newValue;
}
bool Settings::getForceTCP() const
{
return forceTCP;

View File

@ -61,12 +61,21 @@ public:
QString getStyle() const;
void setStyle(const QString& newValue);
bool getUseEmoticons() const;
void setUseEmoticons(bool newValue);
QString getCurrentProfile() const;
void setCurrentProfile(QString profile);
QString getTranslation() const;
void setTranslation(QString newValue);
QString getAutoSaveFilesDir() const;
void setAutoSaveFilesDir(QString newValue);
void setAutoSaveEnabled(bool newValue);
bool getAutoSaveEnabled() const;
bool getForceTCP() const;
void setForceTCP(bool newValue);
@ -201,10 +210,13 @@ private:
bool enableIPv6;
QString translation;
QString autoSaveDir;
static bool makeToxPortable;
bool autostartInTray;
bool closeToTray;
bool minimizeToTray;
bool useEmoticons;
bool autoSaveEnabled;
bool forceTCP;

View File

@ -23,10 +23,14 @@
#include "src/core.h"
#include <QMessageBox>
#include <QStyleFactory>
#include <QTime>
#include <QFileDialog>
static QStringList locales = {"bg", "de", "en", "fr", "it", "mannol", "pirate", "pl", "ru", "fi", "uk"};
static QStringList langs = {"Български", "Deustch", "English", "Français", "Italiano", "mannol", "Pirate", "Polski", "Русский", "Suomi", "Українська"};
static QStringList timeFormats = {"hh:mm AP", "hh:mm", "hh:mm:ss AP", "hh:mm:ss"};
GeneralForm::GeneralForm(SettingsWidget *myParent) :
GenericForm(tr("General"), QPixmap(":/img/settings/general.png"))
{
@ -44,6 +48,10 @@ GeneralForm::GeneralForm(SettingsWidget *myParent) :
bodyUI->closeToTray->setChecked(Settings::getInstance().getCloseToTray());
bodyUI->minimizeToTray->setChecked(Settings::getInstance().getMinimizeToTray());
bodyUI->statusChanges->setChecked(Settings::getInstance().getStatusChangeNotificationEnabled());
bodyUI->useEmoticons->setChecked(Settings::getInstance().getUseEmoticons());
bodyUI->autoacceptFiles->setChecked(Settings::getInstance().getAutoSaveEnabled());
bodyUI->autoSaveFilesDir->setEnabled(Settings::getInstance().getAutoSaveEnabled());
bodyUI->autoSaveFilesDir->setText(Settings::getInstance().getAutoSaveFilesDir());
for (auto entry : SmileyPack::listSmileyPacks())
{
@ -60,6 +68,19 @@ GeneralForm::GeneralForm(SettingsWidget *myParent) :
else
bodyUI->styleBrowser->setCurrentText(tr("None"));
bodyUI->emoticonSize->setValue(Settings::getInstance().getEmojiFontPointSize());
QStringList timestamps;
timestamps << QString("%1 - %2").arg(timeFormats[0],QTime::currentTime().toString(timeFormats[0]))
<< QString("%1 - %2").arg(timeFormats[1],QTime::currentTime().toString(timeFormats[1]))
<< QString("%1 - %2").arg(timeFormats[2],QTime::currentTime().toString(timeFormats[2]))
<< QString("%1 - %2").arg(timeFormats[3],QTime::currentTime().toString(timeFormats[3]));
bodyUI->timestamp->addItems(timestamps);
bodyUI->timestamp->setCurrentText(QString("%1 - %2").arg(Settings::getInstance().getTimestampFormat(),
QTime::currentTime().toString(Settings::getInstance().getTimestampFormat()))
); //idiot proof enough?
bodyUI->autoAwaySpinBox->setValue(Settings::getInstance().getAutoAwayTime());
bodyUI->cbEnableUDP->setChecked(!Settings::getInstance().getForceTCP());
@ -71,21 +92,27 @@ GeneralForm::GeneralForm(SettingsWidget *myParent) :
bodyUI->cbUseProxy->setChecked(Settings::getInstance().getUseProxy());
onUseProxyUpdated();
connect(bodyUI->cbEnableIPv6, &QCheckBox::stateChanged, this, &GeneralForm::onEnableIPv6Updated);
//general
connect(bodyUI->transComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(onTranslationUpdated()));
connect(bodyUI->cbMakeToxPortable, &QCheckBox::stateChanged, this, &GeneralForm::onMakeToxPortableUpdated);
connect(bodyUI->startInTray, &QCheckBox::stateChanged, this, &GeneralForm::onSetAutostartInTray);
connect(bodyUI->closeToTray, &QCheckBox::stateChanged, this, &GeneralForm::onSetCloseToTray);
connect(bodyUI->minimizeToTray, &QCheckBox::stateChanged, this, &GeneralForm::onSetMinimizeToTray);
connect(bodyUI->statusChanges, &QCheckBox::stateChanged, this, &GeneralForm::onSetStatusChange);
connect(bodyUI->autoAwaySpinBox, SIGNAL(editingFinished()), this, SLOT(onAutoAwayChanged()));
connect(bodyUI->autoacceptFiles, &QCheckBox::stateChanged, this, &GeneralForm::onAutoAcceptFileChange);
//theme
connect(bodyUI->useEmoticons, &QCheckBox::stateChanged, this, &GeneralForm::onUseEmoticonsChange);
connect(bodyUI->smileyPackBrowser, SIGNAL(currentIndexChanged(int)), this, SLOT(onSmileyBrowserIndexChanged(int)));
// new syntax can't handle overloaded signals... (at least not in a pretty way)
connect(bodyUI->styleBrowser, SIGNAL(currentTextChanged(QString)), this, SLOT(onStyleSelected(QString)));
connect(bodyUI->emoticonSize, SIGNAL(editingFinished()), this, SLOT(onEmoticonSizeChanged()));
connect(bodyUI->timestamp, SIGNAL(currentIndexChanged(int)), this, SLOT(onTimestampSelected(int)));
//connection
connect(bodyUI->cbEnableIPv6, &QCheckBox::stateChanged, this, &GeneralForm::onEnableIPv6Updated);
connect(bodyUI->cbEnableUDP, &QCheckBox::stateChanged, this, &GeneralForm::onUDPUpdated);
connect(bodyUI->cbUseProxy, &QCheckBox::stateChanged, this, &GeneralForm::onUseProxyUpdated);
connect(bodyUI->proxyAddr, &QLineEdit::editingFinished, this, &GeneralForm::onProxyAddrEdited);
connect(bodyUI->proxyPort, SIGNAL(valueChanged(int)), this, SLOT(onProxyPortEdited(int)));
connect(bodyUI->cbUseProxy, &QCheckBox::stateChanged, this, &GeneralForm::onUseProxyUpdated);
connect(bodyUI->styleBrowser, SIGNAL(currentTextChanged(QString)), this, SLOT(onStyleSelected(QString)));
connect(bodyUI->autoAwaySpinBox, SIGNAL(editingFinished()), this, SLOT(onAutoAwayChanged()));
connect(bodyUI->reconnectButton, &QPushButton::clicked, this, &GeneralForm::onReconnectClicked);
}
@ -136,6 +163,17 @@ void GeneralForm::onStyleSelected(QString style)
parent->setBodyHeadStyle(style);
}
void GeneralForm::onEmoticonSizeChanged()
{
Settings::getInstance().setEmojiFontPointSize(bodyUI->emoticonSize->value());
}
void GeneralForm::onTimestampSelected(int index)
{
Settings::getInstance().setTimestampFormat(
bodyUI->timestamp->currentText().split(" ").at(0));
}
void GeneralForm::onAutoAwayChanged()
{
int minutes = bodyUI->autoAwaySpinBox->value();
@ -143,6 +181,34 @@ void GeneralForm::onAutoAwayChanged()
Widget::getInstance()->setIdleTimer(minutes);
}
void GeneralForm::onAutoAcceptFileChange()
{
if(bodyUI->autoacceptFiles->isChecked() == true)
{
Settings::getInstance().setAutoSaveEnabled(true);
bodyUI->autoSaveFilesDir->setEnabled(true);
connect(bodyUI->autoSaveFilesDir, SIGNAL(clicked()), this, SLOT(onAutoSaveDirChange()));
}
else
{
Settings::getInstance().setAutoSaveEnabled(false);
bodyUI->autoSaveFilesDir->setEnabled(false);
disconnect(bodyUI->autoSaveFilesDir, SIGNAL(clicked()),this, SLOT(onAutoSaveDirChange()));
}
}
void GeneralForm::onAutoSaveDirChange()
{
QString directory = QFileDialog::getExistingDirectory(0, tr("Choose an auto accept directory","popup title"));
Settings::getInstance().setAutoSaveFilesDir(directory);
bodyUI->autoSaveFilesDir->setText(directory);
}
void GeneralForm::onUseEmoticonsChange()
{
Settings::getInstance().setUseEmoticons(bodyUI->useEmoticons->isChecked());
}
void GeneralForm::onSetStatusChange()
{
Settings::getInstance().setStatusChangeNotificationEnabled(bodyUI->statusChanges->isChecked());

View File

@ -41,11 +41,16 @@ private slots:
void onProxyAddrEdited();
void onProxyPortEdited(int port);
void onUseProxyUpdated();
void onEmoticonSizeChanged();
void onStyleSelected(QString style);
void onTimestampSelected(int index);
void onSetStatusChange();
void onAutoAwayChanged();
void onUseEmoticonsChange();
void onSetMinimizeToTray();
void onReconnectClicked();
void onAutoAcceptFileChange();
void onAutoSaveDirChange();
private:
Ui::GeneralSettings *bodyUI;

View File

@ -39,8 +39,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>525</width>
<height>624</height>
<width>511</width>
<height>739</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4" stretch="0,0,1">
@ -64,7 +64,7 @@
<string>The translation may not load until qTox restarts.</string>
</property>
<property name="text">
<string>Translation:</string>
<string>Translation</string>
</property>
</widget>
</item>
@ -132,7 +132,7 @@
<enum>Qt::LeftToRight</enum>
</property>
<property name="text">
<string>Auto away after (0 to disable):</string>
<string>Auto away after (0 to disable)</string>
</property>
</widget>
</item>
@ -163,6 +163,37 @@
</item>
</layout>
</item>
<item>
<widget class="QCheckBox" name="autoacceptFiles">
<property name="text">
<string>Autoaccept files</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="saveFilesHLayout">
<item>
<widget class="QLabel" name="autoSaveFilesDirLabel">
<property name="text">
<string>Save files in</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="autoSaveFilesDir">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>PushButton</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
@ -172,12 +203,19 @@
<string>Theme</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QCheckBox" name="useEmoticons">
<property name="text">
<string>Use emoticons</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="smileyHLayout">
<item>
<widget class="QLabel" name="smileyPackLabel">
<property name="text">
<string extracomment="Text on smiley pack label">Smiley Pack:</string>
<string extracomment="Text on smiley pack label">Smiley Pack</string>
</property>
</widget>
</item>
@ -255,7 +293,7 @@
<item>
<widget class="QLabel" name="styleLabel">
<property name="text">
<string>Style:</string>
<string>Style</string>
</property>
</widget>
</item>
@ -271,6 +309,63 @@
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="emoiticonHLayout">
<item>
<widget class="QLabel" name="emoticonSizeLabel">
<property name="text">
<string>Emoticon size</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="emoticonSize">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="specialValueText">
<string/>
</property>
<property name="suffix">
<string> px</string>
</property>
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>2147483647</number>
</property>
<property name="value">
<number>25</number>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="timestampHLayout">
<item>
<widget class="QLabel" name="timestampLabel">
<property name="text">
<string>Timestamp format</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="timestamp">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>