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

View File

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

View File

@ -23,10 +23,14 @@
#include "src/core.h" #include "src/core.h"
#include <QMessageBox> #include <QMessageBox>
#include <QStyleFactory> #include <QStyleFactory>
#include <QTime>
#include <QFileDialog>
static QStringList locales = {"bg", "de", "en", "fr", "it", "mannol", "pirate", "pl", "ru", "fi", "uk"}; 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 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) : GeneralForm::GeneralForm(SettingsWidget *myParent) :
GenericForm(tr("General"), QPixmap(":/img/settings/general.png")) GenericForm(tr("General"), QPixmap(":/img/settings/general.png"))
{ {
@ -44,7 +48,11 @@ GeneralForm::GeneralForm(SettingsWidget *myParent) :
bodyUI->closeToTray->setChecked(Settings::getInstance().getCloseToTray()); bodyUI->closeToTray->setChecked(Settings::getInstance().getCloseToTray());
bodyUI->minimizeToTray->setChecked(Settings::getInstance().getMinimizeToTray()); bodyUI->minimizeToTray->setChecked(Settings::getInstance().getMinimizeToTray());
bodyUI->statusChanges->setChecked(Settings::getInstance().getStatusChangeNotificationEnabled()); 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()) for (auto entry : SmileyPack::listSmileyPacks())
{ {
bodyUI->smileyPackBrowser->addItem(entry.first, entry.second); bodyUI->smileyPackBrowser->addItem(entry.first, entry.second);
@ -60,6 +68,19 @@ GeneralForm::GeneralForm(SettingsWidget *myParent) :
else else
bodyUI->styleBrowser->setCurrentText(tr("None")); 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->autoAwaySpinBox->setValue(Settings::getInstance().getAutoAwayTime());
bodyUI->cbEnableUDP->setChecked(!Settings::getInstance().getForceTCP()); bodyUI->cbEnableUDP->setChecked(!Settings::getInstance().getForceTCP());
@ -71,21 +92,27 @@ GeneralForm::GeneralForm(SettingsWidget *myParent) :
bodyUI->cbUseProxy->setChecked(Settings::getInstance().getUseProxy()); bodyUI->cbUseProxy->setChecked(Settings::getInstance().getUseProxy());
onUseProxyUpdated(); onUseProxyUpdated();
connect(bodyUI->cbEnableIPv6, &QCheckBox::stateChanged, this, &GeneralForm::onEnableIPv6Updated); //general
connect(bodyUI->transComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(onTranslationUpdated())); connect(bodyUI->transComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(onTranslationUpdated()));
connect(bodyUI->cbMakeToxPortable, &QCheckBox::stateChanged, this, &GeneralForm::onMakeToxPortableUpdated); connect(bodyUI->cbMakeToxPortable, &QCheckBox::stateChanged, this, &GeneralForm::onMakeToxPortableUpdated);
connect(bodyUI->startInTray, &QCheckBox::stateChanged, this, &GeneralForm::onSetAutostartInTray); connect(bodyUI->startInTray, &QCheckBox::stateChanged, this, &GeneralForm::onSetAutostartInTray);
connect(bodyUI->closeToTray, &QCheckBox::stateChanged, this, &GeneralForm::onSetCloseToTray); connect(bodyUI->closeToTray, &QCheckBox::stateChanged, this, &GeneralForm::onSetCloseToTray);
connect(bodyUI->minimizeToTray, &QCheckBox::stateChanged, this, &GeneralForm::onSetMinimizeToTray); connect(bodyUI->minimizeToTray, &QCheckBox::stateChanged, this, &GeneralForm::onSetMinimizeToTray);
connect(bodyUI->statusChanges, &QCheckBox::stateChanged, this, &GeneralForm::onSetStatusChange); 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))); 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->cbEnableUDP, &QCheckBox::stateChanged, this, &GeneralForm::onUDPUpdated);
connect(bodyUI->cbUseProxy, &QCheckBox::stateChanged, this, &GeneralForm::onUseProxyUpdated);
connect(bodyUI->proxyAddr, &QLineEdit::editingFinished, this, &GeneralForm::onProxyAddrEdited); connect(bodyUI->proxyAddr, &QLineEdit::editingFinished, this, &GeneralForm::onProxyAddrEdited);
connect(bodyUI->proxyPort, SIGNAL(valueChanged(int)), this, SLOT(onProxyPortEdited(int))); 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); connect(bodyUI->reconnectButton, &QPushButton::clicked, this, &GeneralForm::onReconnectClicked);
} }
@ -136,6 +163,17 @@ void GeneralForm::onStyleSelected(QString style)
parent->setBodyHeadStyle(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() void GeneralForm::onAutoAwayChanged()
{ {
int minutes = bodyUI->autoAwaySpinBox->value(); int minutes = bodyUI->autoAwaySpinBox->value();
@ -143,6 +181,34 @@ void GeneralForm::onAutoAwayChanged()
Widget::getInstance()->setIdleTimer(minutes); 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() void GeneralForm::onSetStatusChange()
{ {
Settings::getInstance().setStatusChangeNotificationEnabled(bodyUI->statusChanges->isChecked()); Settings::getInstance().setStatusChangeNotificationEnabled(bodyUI->statusChanges->isChecked());

View File

@ -35,17 +35,22 @@ private slots:
void onTranslationUpdated(); void onTranslationUpdated();
void onMakeToxPortableUpdated(); void onMakeToxPortableUpdated();
void onSetAutostartInTray(); void onSetAutostartInTray();
void onSetCloseToTray(); void onSetCloseToTray();
void onSmileyBrowserIndexChanged(int index); void onSmileyBrowserIndexChanged(int index);
void onUDPUpdated(); void onUDPUpdated();
void onProxyAddrEdited(); void onProxyAddrEdited();
void onProxyPortEdited(int port); void onProxyPortEdited(int port);
void onUseProxyUpdated(); void onUseProxyUpdated();
void onStyleSelected(QString style); void onEmoticonSizeChanged();
void onStyleSelected(QString style);
void onTimestampSelected(int index);
void onSetStatusChange(); void onSetStatusChange();
void onAutoAwayChanged(); void onAutoAwayChanged();
void onUseEmoticonsChange();
void onSetMinimizeToTray(); void onSetMinimizeToTray();
void onReconnectClicked(); void onReconnectClicked();
void onAutoAcceptFileChange();
void onAutoSaveDirChange();
private: private:
Ui::GeneralSettings *bodyUI; Ui::GeneralSettings *bodyUI;

View File

@ -39,8 +39,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>525</width> <width>511</width>
<height>624</height> <height>739</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_4" stretch="0,0,1"> <layout class="QVBoxLayout" name="verticalLayout_4" stretch="0,0,1">
@ -64,7 +64,7 @@
<string>The translation may not load until qTox restarts.</string> <string>The translation may not load until qTox restarts.</string>
</property> </property>
<property name="text"> <property name="text">
<string>Translation:</string> <string>Translation</string>
</property> </property>
</widget> </widget>
</item> </item>
@ -132,7 +132,7 @@
<enum>Qt::LeftToRight</enum> <enum>Qt::LeftToRight</enum>
</property> </property>
<property name="text"> <property name="text">
<string>Auto away after (0 to disable):</string> <string>Auto away after (0 to disable)</string>
</property> </property>
</widget> </widget>
</item> </item>
@ -163,6 +163,37 @@
</item> </item>
</layout> </layout>
</item> </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> </layout>
</widget> </widget>
</item> </item>
@ -172,12 +203,19 @@
<string>Theme</string> <string>Theme</string>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QCheckBox" name="useEmoticons">
<property name="text">
<string>Use emoticons</string>
</property>
</widget>
</item>
<item> <item>
<layout class="QHBoxLayout" name="smileyHLayout"> <layout class="QHBoxLayout" name="smileyHLayout">
<item> <item>
<widget class="QLabel" name="smileyPackLabel"> <widget class="QLabel" name="smileyPackLabel">
<property name="text"> <property name="text">
<string extracomment="Text on smiley pack label">Smiley Pack:</string> <string extracomment="Text on smiley pack label">Smiley Pack</string>
</property> </property>
</widget> </widget>
</item> </item>
@ -255,7 +293,7 @@
<item> <item>
<widget class="QLabel" name="styleLabel"> <widget class="QLabel" name="styleLabel">
<property name="text"> <property name="text">
<string>Style:</string> <string>Style</string>
</property> </property>
</widget> </widget>
</item> </item>
@ -271,6 +309,63 @@
</item> </item>
</layout> </layout>
</item> </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> </layout>
</widget> </widget>
</item> </item>