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

Merge branch 'pr1890'

This commit is contained in:
tux3 2015-06-26 14:13:03 +02:00
commit 79d335ff4c
No known key found for this signature in database
GPG Key ID: 7E086DD661263264
6 changed files with 45 additions and 103 deletions

View File

@ -190,10 +190,7 @@ void Settings::loadGlobal()
s.endGroup(); s.endGroup();
s.beginGroup("GUI"); s.beginGroup("GUI");
enableSmoothAnimation = s.value("smoothAnimation", true).toBool();
smileyPack = s.value("smileyPack", ":/smileys/TwitterEmojiSVG/emoticons.xml").toString(); smileyPack = s.value("smileyPack", ":/smileys/TwitterEmojiSVG/emoticons.xml").toString();
customEmojiFont = s.value("customEmojiFont", true).toBool();
emojiFontFamily = s.value("emojiFontFamily", "DejaVu Sans").toString();
emojiFontPointSize = s.value("emojiFontPointSize", 16).toInt(); emojiFontPointSize = s.value("emojiFontPointSize", 16).toInt();
firstColumnHandlePos = s.value("firstColumnHandlePos", 50).toInt(); firstColumnHandlePos = s.value("firstColumnHandlePos", 50).toInt();
secondColumnHandlePosFromRight = s.value("secondColumnHandlePosFromRight", 50).toInt(); secondColumnHandlePosFromRight = s.value("secondColumnHandlePosFromRight", 50).toInt();
@ -202,7 +199,6 @@ void Settings::loadGlobal()
minimizeOnClose = s.value("minimizeOnClose", false).toBool(); minimizeOnClose = s.value("minimizeOnClose", false).toBool();
minimizeToTray = s.value("minimizeToTray", false).toBool(); minimizeToTray = s.value("minimizeToTray", false).toBool();
lightTrayIcon = s.value("lightTrayIcon", false).toBool(); lightTrayIcon = s.value("lightTrayIcon", false).toBool();
useNativeStyle = s.value("nativeStyle", false).toBool();
useEmoticons = s.value("useEmoticons", true).toBool(); useEmoticons = s.value("useEmoticons", true).toBool();
statusChangeNotificationEnabled = s.value("statusChangeNotificationEnabled", false).toBool(); statusChangeNotificationEnabled = s.value("statusChangeNotificationEnabled", false).toBool();
themeColor = s.value("themeColor", 0).toInt(); themeColor = s.value("themeColor", 0).toInt();
@ -392,14 +388,10 @@ void Settings::saveGlobal()
const QList<QString> widgetNames = widgetSettings.keys(); const QList<QString> widgetNames = widgetSettings.keys();
for (const QString& name : widgetNames) for (const QString& name : widgetNames)
s.setValue(name, widgetSettings.value(name)); s.setValue(name, widgetSettings.value(name));
s.endGroup(); s.endGroup();
s.beginGroup("GUI"); s.beginGroup("GUI");
s.setValue("smoothAnimation", enableSmoothAnimation);
s.setValue("smileyPack", smileyPack); s.setValue("smileyPack", smileyPack);
s.setValue("customEmojiFont", customEmojiFont);
s.setValue("emojiFontFamily", emojiFontFamily);
s.setValue("emojiFontPointSize", emojiFontPointSize); s.setValue("emojiFontPointSize", emojiFontPointSize);
s.setValue("firstColumnHandlePos", firstColumnHandlePos); s.setValue("firstColumnHandlePos", firstColumnHandlePos);
s.setValue("secondColumnHandlePosFromRight", secondColumnHandlePosFromRight); s.setValue("secondColumnHandlePosFromRight", secondColumnHandlePosFromRight);
@ -408,7 +400,6 @@ void Settings::saveGlobal()
s.setValue("minimizeOnClose", minimizeOnClose); s.setValue("minimizeOnClose", minimizeOnClose);
s.setValue("minimizeToTray", minimizeToTray); s.setValue("minimizeToTray", minimizeToTray);
s.setValue("lightTrayIcon", lightTrayIcon); s.setValue("lightTrayIcon", lightTrayIcon);
s.setValue("nativeStyle", useNativeStyle);
s.setValue("useEmoticons", useEmoticons); s.setValue("useEmoticons", useEmoticons);
s.setValue("themeColor", themeColor); s.setValue("themeColor", themeColor);
s.setValue("style", style); s.setValue("style", style);
@ -965,18 +956,6 @@ QByteArray Settings::getWidgetData(const QString& uniqueName) const
return widgetSettings.value(uniqueName); return widgetSettings.value(uniqueName);
} }
bool Settings::isAnimationEnabled() const
{
QMutexLocker locker{&bigLock};
return enableSmoothAnimation;
}
void Settings::setAnimationEnabled(bool newValue)
{
QMutexLocker locker{&bigLock};
enableSmoothAnimation = newValue;
}
QString Settings::getSmileyPack() const QString Settings::getSmileyPack() const
{ {
QMutexLocker locker{&bigLock}; QMutexLocker locker{&bigLock};
@ -990,19 +969,6 @@ void Settings::setSmileyPack(const QString &value)
emit smileyPackChanged(); emit smileyPackChanged();
} }
bool Settings::isCurstomEmojiFont() const
{
QMutexLocker locker{&bigLock};
return customEmojiFont;
}
void Settings::setCurstomEmojiFont(bool value)
{
QMutexLocker locker{&bigLock};
customEmojiFont = value;
emit emojiFontChanged();
}
int Settings::getEmojiFontPointSize() const int Settings::getEmojiFontPointSize() const
{ {
QMutexLocker locker{&bigLock}; QMutexLocker locker{&bigLock};
@ -1064,31 +1030,6 @@ void Settings::setDateFormat(const QString &format)
dateFormat = format; dateFormat = format;
} }
QString Settings::getEmojiFontFamily() const
{
QMutexLocker locker{&bigLock};
return emojiFontFamily;
}
void Settings::setEmojiFontFamily(const QString &value)
{
QMutexLocker locker{&bigLock};
emojiFontFamily = value;
emit emojiFontChanged();
}
bool Settings::getUseNativeStyle() const
{
QMutexLocker locker{&bigLock};
return useNativeStyle;
}
void Settings::setUseNativeStyle(bool value)
{
QMutexLocker locker{&bigLock};
useNativeStyle = value;
}
QByteArray Settings::getWindowGeometry() const QByteArray Settings::getWindowGeometry() const
{ {
QMutexLocker locker{&bigLock}; QMutexLocker locker{&bigLock};

View File

@ -175,9 +175,6 @@ public:
bool isCurstomEmojiFont() const; bool isCurstomEmojiFont() const;
void setCurstomEmojiFont(bool value); void setCurstomEmojiFont(bool value);
QString getEmojiFontFamily() const;
void setEmojiFontFamily(const QString &value);
int getEmojiFontPointSize() const; int getEmojiFontPointSize() const;
void setEmojiFontPointSize(int value); void setEmojiFontPointSize(int value);
@ -211,9 +208,6 @@ public:
void setTypingNotification(bool enabled); void setTypingNotification(bool enabled);
// State // State
bool getUseNativeStyle() const;
void setUseNativeStyle(bool value);
QByteArray getWindowGeometry() const; QByteArray getWindowGeometry() const;
void setWindowGeometry(const QByteArray &value); void setWindowGeometry(const QByteArray &value);
@ -334,13 +328,9 @@ private:
QString globalAutoAcceptDir; QString globalAutoAcceptDir;
// GUI // GUI
bool enableSmoothAnimation;
QString smileyPack; QString smileyPack;
bool customEmojiFont;
QString emojiFontFamily;
int emojiFontPointSize; int emojiFontPointSize;
bool minimizeOnClose; bool minimizeOnClose;
bool useNativeStyle;
QByteArray windowGeometry; QByteArray windowGeometry;
QByteArray windowState; QByteArray windowState;
QByteArray splitterState; QByteArray splitterState;

View File

@ -230,13 +230,17 @@ void ChatForm::onFileRecvRequest(ToxFile file)
ChatMessage::Ptr msg = ChatMessage::createFileTransferMessage(name, file, false, QDateTime::currentDateTime()); ChatMessage::Ptr msg = ChatMessage::createFileTransferMessage(name, file, false, QDateTime::currentDateTime());
insertChatMessage(msg); insertChatMessage(msg);
if (!Settings::getInstance().getAutoAcceptDir(f->getToxId()).isEmpty() if (!Settings::getInstance().getAutoAcceptDir(f->getToxId()).isEmpty()) //per contact autosave
|| Settings::getInstance().getAutoSaveEnabled())
{ {
ChatLineContentProxy* proxy = static_cast<ChatLineContentProxy*>(msg->getContent(1)); ChatLineContentProxy* proxy = static_cast<ChatLineContentProxy*>(msg->getContent(1));
assert(proxy->getWidgetType() == ChatLineContentProxy::FileTransferWidgetType); assert(proxy->getWidgetType() == ChatLineContentProxy::FileTransferWidgetType);
FileTransferWidget* tfWidget = static_cast<FileTransferWidget*>(proxy->getWidget()); FileTransferWidget* tfWidget = static_cast<FileTransferWidget*>(proxy->getWidget());
tfWidget->autoAcceptTransfer(Settings::getInstance().getAutoAcceptDir(f->getToxId())); tfWidget->autoAcceptTransfer(Settings::getInstance().getAutoAcceptDir(f->getToxId()));
} else if (Settings::getInstance().getAutoSaveEnabled()) { //global autosave to global directory
ChatLineContentProxy* proxy = static_cast<ChatLineContentProxy*>(msg->getContent(1));
assert(proxy->getWidgetType() == ChatLineContentProxy::FileTransferWidgetType);
FileTransferWidget* tfWidget = static_cast<FileTransferWidget*>(proxy->getWidget());
tfWidget->autoAcceptTransfer(Settings::getInstance().getGlobalAutoAcceptDir());
} }
Widget::getInstance()->updateFriendActivity(f); Widget::getInstance()->updateFriendActivity(f);

View File

@ -160,7 +160,6 @@ GeneralForm::GeneralForm(SettingsWidget *myParent) :
connect(bodyUI->notifySound, &QCheckBox::stateChanged, this, &GeneralForm::onSetNotifySound); connect(bodyUI->notifySound, &QCheckBox::stateChanged, this, &GeneralForm::onSetNotifySound);
connect(bodyUI->groupAlwaysNotify, &QCheckBox::stateChanged, this, &GeneralForm::onSetGroupAlwaysNotify); connect(bodyUI->groupAlwaysNotify, &QCheckBox::stateChanged, this, &GeneralForm::onSetGroupAlwaysNotify);
connect(bodyUI->autoacceptFiles, &QCheckBox::stateChanged, this, &GeneralForm::onAutoAcceptFileChange); connect(bodyUI->autoacceptFiles, &QCheckBox::stateChanged, this, &GeneralForm::onAutoAcceptFileChange);
if (bodyUI->autoacceptFiles->isChecked())
connect(bodyUI->autoSaveFilesDir, SIGNAL(clicked()), this, SLOT(onAutoSaveDirChange())); connect(bodyUI->autoSaveFilesDir, SIGNAL(clicked()), this, SLOT(onAutoSaveDirChange()));
//theme //theme
connect(bodyUI->useEmoticons, &QCheckBox::stateChanged, this, &GeneralForm::onUseEmoticonsChange); connect(bodyUI->useEmoticons, &QCheckBox::stateChanged, this, &GeneralForm::onUseEmoticonsChange);
@ -291,19 +290,16 @@ void GeneralForm::onAutoAwayChanged()
void GeneralForm::onAutoAcceptFileChange() void GeneralForm::onAutoAcceptFileChange()
{ {
Settings::getInstance().setAutoSaveEnabled(bodyUI->autoacceptFiles->isChecked()); Settings::getInstance().setAutoSaveEnabled(bodyUI->autoacceptFiles->isChecked());
if (bodyUI->autoacceptFiles->isChecked() == true)
connect(bodyUI->autoSaveFilesDir, &QPushButton::clicked, this, &GeneralForm::onAutoSaveDirChange);
else
disconnect(bodyUI->autoSaveFilesDir, &QPushButton::clicked, this, &GeneralForm::onAutoSaveDirChange);
} }
void GeneralForm::onAutoSaveDirChange() void GeneralForm::onAutoSaveDirChange()
{ {
QString previousDir = Settings::getInstance().getGlobalAutoAcceptDir(); QString previousDir = Settings::getInstance().getGlobalAutoAcceptDir();
QString directory = QFileDialog::getExistingDirectory(0, QString directory = QFileDialog::getExistingDirectory(0,
tr("Choose an auto accept directory","popup title")); tr("Choose an auto accept directory", "popup title"), //opens in home directory
if (directory.isEmpty()) QStandardPaths::locate(QStandardPaths::HomeLocation, QString(), QStandardPaths::LocateDirectory)
);
if (directory.isEmpty()) // cancel was pressed
directory = previousDir; directory = previousDir;
Settings::getInstance().setGlobalAutoAcceptDir(directory); Settings::getInstance().setGlobalAutoAcceptDir(directory);

View File

@ -39,8 +39,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>653</width> <width>639</width>
<height>1150</height> <height>1221</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_4" stretch="0,0,0,1"> <layout class="QVBoxLayout" name="verticalLayout_4" stretch="0,0,0,1">
@ -236,6 +236,13 @@ instead of system taskbar.</string>
</item> </item>
<item> <item>
<layout class="QVBoxLayout" name="startupLayout"> <layout class="QVBoxLayout" name="startupLayout">
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string/>
</property>
</widget>
</item>
<item> <item>
<widget class="QCheckBox" name="cbAutorun"> <widget class="QCheckBox" name="cbAutorun">
<property name="toolTip"> <property name="toolTip">
@ -256,21 +263,11 @@ instead of system taskbar.</string>
</layout> </layout>
</item> </item>
<item> <item>
<layout class="QHBoxLayout" name="autoacceptLayout"> <layout class="QFormLayout" name="formLayout_2">
<property name="leftMargin"> <property name="leftMargin">
<number>0</number> <number>0</number>
</property> </property>
<item> <item row="2" column="1">
<widget class="QCheckBox" name="autoacceptFiles">
<property name="toolTip">
<string comment="autoaccept cb tooltip">You can set this on a per-friend basis by right clicking them.</string>
</property>
<property name="text">
<string>Autoaccept and save files:</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="autoSaveFilesDir"> <widget class="QPushButton" name="autoSaveFilesDir">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed"> <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
@ -283,6 +280,23 @@ instead of system taskbar.</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Default directory to save files</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QCheckBox" name="autoacceptFiles">
<property name="toolTip">
<string comment="autoaccept cb tooltip">You can set this on a per-friend basis by right clicking them.</string>
</property>
<property name="text">
<string>Autoaccept files</string>
</property>
</widget>
</item>
</layout> </layout>
</item> </item>
</layout> </layout>

View File

@ -76,15 +76,12 @@ QList<QColor> Style::themeColorColors = {QColor(), QColor("#004aa4"), QColor("#9
QString Style::getStylesheet(const QString &filename) QString Style::getStylesheet(const QString &filename)
{
if (!Settings::getInstance().getUseNativeStyle())
{ {
QFile file(filename); QFile file(filename);
if (file.open(QFile::ReadOnly | QFile::Text)) if (file.open(QFile::ReadOnly | QFile::Text))
return resolve(file.readAll()); return resolve(file.readAll());
else else
qWarning() << "Stylesheet " << filename << " not found"; qWarning() << "Stylesheet " << filename << " not found";
}
return QString(); return QString();
} }