mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
Merge branch 'pr634'
This commit is contained in:
commit
aa98222e11
|
@ -209,7 +209,10 @@ bool isFileWritable(QString& path)
|
||||||
void FileTransferInstance::acceptRecvRequest()
|
void FileTransferInstance::acceptRecvRequest()
|
||||||
{
|
{
|
||||||
QString path = Settings::getInstance().getAutoAcceptDir(Core::getInstance()->getFriendAddress(friendId));
|
QString path = Settings::getInstance().getAutoAcceptDir(Core::getInstance()->getFriendAddress(friendId));
|
||||||
if (path.isEmpty()) path = Settings::getInstance().getGlobalAutoAcceptDir();
|
|
||||||
|
if (path.isEmpty())
|
||||||
|
path = Settings::getInstance().getGlobalAutoAcceptDir();
|
||||||
|
|
||||||
if (!path.isEmpty())
|
if (!path.isEmpty())
|
||||||
{
|
{
|
||||||
QDir dir(path);
|
QDir dir(path);
|
||||||
|
|
|
@ -104,7 +104,7 @@ void Settings::load()
|
||||||
|
|
||||||
s.beginGroup("General");
|
s.beginGroup("General");
|
||||||
enableIPv6 = s.value("enableIPv6", true).toBool();
|
enableIPv6 = s.value("enableIPv6", true).toBool();
|
||||||
translation = s.value("translation", "").toString();
|
translation = s.value("translation", "en").toString();
|
||||||
makeToxPortable = s.value("makeToxPortable", false).toBool();
|
makeToxPortable = s.value("makeToxPortable", false).toBool();
|
||||||
autostartInTray = s.value("autostartInTray", false).toBool();
|
autostartInTray = s.value("autostartInTray", false).toBool();
|
||||||
closeToTray = s.value("closeToTray", false).toBool();
|
closeToTray = s.value("closeToTray", false).toBool();
|
||||||
|
@ -114,8 +114,6 @@ 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");
|
||||||
|
@ -156,7 +154,11 @@ void Settings::load()
|
||||||
s.endGroup();
|
s.endGroup();
|
||||||
|
|
||||||
s.beginGroup("AutoAccept");
|
s.beginGroup("AutoAccept");
|
||||||
globalAutoAcceptDir = s.value("globalAutoAcceptDir", "").toString();
|
autoSaveEnabled = s.value("autoSaveEnabled", false).toBool();
|
||||||
|
globalAutoAcceptDir = s.value("globalAutoAcceptDir",
|
||||||
|
QStandardPaths::locate(QStandardPaths::HomeLocation, QString(), QStandardPaths::LocateDirectory)
|
||||||
|
).toString();
|
||||||
|
|
||||||
for (auto& key : s.childKeys())
|
for (auto& key : s.childKeys())
|
||||||
autoAccept[key] = s.value(key).toString();
|
autoAccept[key] = s.value(key).toString();
|
||||||
s.endGroup();
|
s.endGroup();
|
||||||
|
@ -166,10 +168,6 @@ void Settings::load()
|
||||||
outDev = s.value("outDev", "").toString();
|
outDev = s.value("outDev", "").toString();
|
||||||
s.endGroup();
|
s.endGroup();
|
||||||
|
|
||||||
// try to set a smiley pack if none is selected
|
|
||||||
if (!SmileyPack::isValid(smileyPack) && !SmileyPack::listSmileyPacks().isEmpty())
|
|
||||||
smileyPack = SmileyPack::listSmileyPacks()[0].second;
|
|
||||||
|
|
||||||
// Read the embedded DHT bootsrap nodes list if needed
|
// Read the embedded DHT bootsrap nodes list if needed
|
||||||
if (dhtServerList.isEmpty())
|
if (dhtServerList.isEmpty())
|
||||||
{
|
{
|
||||||
|
@ -241,8 +239,6 @@ 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");
|
||||||
|
@ -283,6 +279,7 @@ void Settings::save(QString path)
|
||||||
s.endGroup();
|
s.endGroup();
|
||||||
|
|
||||||
s.beginGroup("AutoAccept");
|
s.beginGroup("AutoAccept");
|
||||||
|
s.setValue("autoSaveEnabled", autoSaveEnabled);
|
||||||
s.setValue("globalAutoAcceptDir", globalAutoAcceptDir);
|
s.setValue("globalAutoAcceptDir", globalAutoAcceptDir);
|
||||||
for (auto& id : autoAccept.keys())
|
for (auto& id : autoAccept.keys())
|
||||||
s.setValue(id, autoAccept.value(id));
|
s.setValue(id, autoAccept.value(id));
|
||||||
|
@ -475,17 +472,6 @@ 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;
|
||||||
|
|
|
@ -70,9 +70,6 @@ public:
|
||||||
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);
|
void setAutoSaveEnabled(bool newValue);
|
||||||
bool getAutoSaveEnabled() const;
|
bool getAutoSaveEnabled() const;
|
||||||
|
|
||||||
|
@ -210,13 +207,11 @@ 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 useEmoticons;
|
||||||
bool autoSaveEnabled;
|
|
||||||
|
|
||||||
bool forceTCP;
|
bool forceTCP;
|
||||||
|
|
||||||
|
@ -234,6 +229,7 @@ private:
|
||||||
|
|
||||||
QHash<QString, QByteArray> widgetSettings;
|
QHash<QString, QByteArray> widgetSettings;
|
||||||
QHash<QString, QString> autoAccept;
|
QHash<QString, QString> autoAccept;
|
||||||
|
bool autoSaveEnabled;
|
||||||
QString globalAutoAcceptDir;
|
QString globalAutoAcceptDir;
|
||||||
|
|
||||||
// GUI
|
// GUI
|
||||||
|
|
|
@ -202,7 +202,7 @@ void ChatForm::onFileRecvRequest(ToxFile file)
|
||||||
QTime::currentTime().toString("hh:mm"), false)));
|
QTime::currentTime().toString("hh:mm"), false)));
|
||||||
|
|
||||||
if (!Settings::getInstance().getAutoAcceptDir(Core::getInstance()->getFriendAddress(f->friendId)).isEmpty()
|
if (!Settings::getInstance().getAutoAcceptDir(Core::getInstance()->getFriendAddress(f->friendId)).isEmpty()
|
||||||
|| !Settings::getInstance().getGlobalAutoAcceptDir().isEmpty())
|
|| Settings::getInstance().getAutoSaveEnabled())
|
||||||
fileTrans->pressFromHtml("btnB");
|
fileTrans->pressFromHtml("btnB");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -51,7 +51,7 @@ GeneralForm::GeneralForm(SettingsWidget *myParent) :
|
||||||
bodyUI->statusChanges->setChecked(Settings::getInstance().getStatusChangeNotificationEnabled());
|
bodyUI->statusChanges->setChecked(Settings::getInstance().getStatusChangeNotificationEnabled());
|
||||||
bodyUI->useEmoticons->setChecked(Settings::getInstance().getUseEmoticons());
|
bodyUI->useEmoticons->setChecked(Settings::getInstance().getUseEmoticons());
|
||||||
bodyUI->autoacceptFiles->setChecked(Settings::getInstance().getAutoSaveEnabled());
|
bodyUI->autoacceptFiles->setChecked(Settings::getInstance().getAutoSaveEnabled());
|
||||||
bodyUI->autoSaveFilesDir->setText(Settings::getInstance().getAutoSaveFilesDir());
|
bodyUI->autoSaveFilesDir->setText(Settings::getInstance().getGlobalAutoAcceptDir());
|
||||||
|
|
||||||
for (auto entry : SmileyPack::listSmileyPacks())
|
for (auto entry : SmileyPack::listSmileyPacks())
|
||||||
{
|
{
|
||||||
|
@ -172,8 +172,7 @@ void GeneralForm::onEmoticonSizeChanged()
|
||||||
|
|
||||||
void GeneralForm::onTimestampSelected(int)
|
void GeneralForm::onTimestampSelected(int)
|
||||||
{
|
{
|
||||||
Settings::getInstance().setTimestampFormat(
|
Settings::getInstance().setTimestampFormat(timeFormats[index]);
|
||||||
bodyUI->timestamp->currentText().split(" ").at(0));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GeneralForm::onAutoAwayChanged()
|
void GeneralForm::onAutoAwayChanged()
|
||||||
|
@ -185,26 +184,22 @@ void GeneralForm::onAutoAwayChanged()
|
||||||
|
|
||||||
void GeneralForm::onAutoAcceptFileChange()
|
void GeneralForm::onAutoAcceptFileChange()
|
||||||
{
|
{
|
||||||
|
Settings::getInstance().setAutoSaveEnabled(bodyUI->autoacceptFiles->isChecked());
|
||||||
|
|
||||||
if(bodyUI->autoacceptFiles->isChecked() == true)
|
if(bodyUI->autoacceptFiles->isChecked() == true)
|
||||||
{
|
|
||||||
Settings::getInstance().setAutoSaveEnabled(true);
|
|
||||||
connect(bodyUI->autoSaveFilesDir, SIGNAL(clicked()), this, SLOT(onAutoSaveDirChange()));
|
connect(bodyUI->autoSaveFilesDir, SIGNAL(clicked()), this, SLOT(onAutoSaveDirChange()));
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
|
||||||
Settings::getInstance().setAutoSaveEnabled(false);
|
|
||||||
disconnect(bodyUI->autoSaveFilesDir, SIGNAL(clicked()),this, SLOT(onAutoSaveDirChange()));
|
disconnect(bodyUI->autoSaveFilesDir, SIGNAL(clicked()),this, SLOT(onAutoSaveDirChange()));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void GeneralForm::onAutoSaveDirChange()
|
void GeneralForm::onAutoSaveDirChange()
|
||||||
{
|
{
|
||||||
QString previousDir = Settings::getInstance().getAutoSaveFilesDir();
|
QString previousDir = Settings::getInstance().getGlobalAutoAcceptDir();
|
||||||
QString directory = QFileDialog::getExistingDirectory(0, tr("Choose an auto accept directory","popup title"));
|
QString directory = QFileDialog::getExistingDirectory(0, tr("Choose an auto accept directory","popup title"));
|
||||||
if(directory.isEmpty())
|
if(directory.isEmpty())
|
||||||
directory = previousDir;
|
directory = previousDir;
|
||||||
|
|
||||||
Settings::getInstance().setAutoSaveFilesDir(directory);
|
Settings::getInstance().setGlobalAutoAcceptDir(directory);
|
||||||
bodyUI->autoSaveFilesDir->setText(directory);
|
bodyUI->autoSaveFilesDir->setText(directory);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -49,28 +49,26 @@ void FriendWidget::contextMenuEvent(QContextMenuEvent * event)
|
||||||
QPoint pos = event->globalPos();
|
QPoint pos = event->globalPos();
|
||||||
QString id = Core::getInstance()->getFriendAddress(friendId);
|
QString id = Core::getInstance()->getFriendAddress(friendId);
|
||||||
QString dir = Settings::getInstance().getAutoAcceptDir(id);
|
QString dir = Settings::getInstance().getAutoAcceptDir(id);
|
||||||
QString globalDir = Settings::getInstance().getGlobalAutoAcceptDir();
|
|
||||||
QMenu menu;
|
QMenu menu;
|
||||||
QMenu* inviteMenu = menu.addMenu(tr("Invite to group","Menu to invite a friend to a groupchat"));
|
QMenu* inviteMenu = menu.addMenu(tr("Invite to group","Menu to invite a friend to a groupchat"));
|
||||||
QAction* copyId = menu.addAction(tr("Copy friend ID","Menu to copy the Tox ID of that friend"));
|
QAction* copyId = menu.addAction(tr("Copy friend ID","Menu to copy the Tox ID of that friend"));
|
||||||
QMap<QAction*, Group*> groupActions;
|
QMap<QAction*, Group*> groupActions;
|
||||||
|
|
||||||
for (Group* group : GroupList::groupList)
|
for (Group* group : GroupList::groupList)
|
||||||
{
|
{
|
||||||
QAction* groupAction = inviteMenu->addAction(group->widget->getName());
|
QAction* groupAction = inviteMenu->addAction(group->widget->getName());
|
||||||
groupActions[groupAction] = group;
|
groupActions[groupAction] = group;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (groupActions.isEmpty())
|
if (groupActions.isEmpty())
|
||||||
inviteMenu->setEnabled(false);
|
inviteMenu->setEnabled(false);
|
||||||
|
|
||||||
menu.addSeparator();
|
menu.addSeparator();
|
||||||
QAction* autoAccept = menu.addAction(tr("Auto accept files from this friend", "context menu entry"));
|
QAction* autoAccept = menu.addAction(tr("Auto accept files from this friend", "context menu entry"));
|
||||||
QAction* disableAutoAccept = menu.addAction(tr("Manually accept files from this friend", "context menu entry"));
|
autoAccept->setCheckable(true);
|
||||||
QAction* globalAA = menu.addAction(tr("Auto accept files from all friends", "context menu entry"));
|
autoAccept->setChecked(!dir.isEmpty());
|
||||||
QAction* disableGlobalAA = menu.addAction(tr("Disable global auto accept", "context menu entry"));
|
|
||||||
if (dir.isEmpty())
|
|
||||||
disableAutoAccept->setEnabled(false);
|
|
||||||
if (globalDir.isEmpty())
|
|
||||||
disableGlobalAA->setEnabled(false);
|
|
||||||
menu.addSeparator();
|
menu.addSeparator();
|
||||||
|
|
||||||
QAction* removeFriendAction = menu.addAction(tr("Remove friend", "Menu to remove the friend from our friendlist"));
|
QAction* removeFriendAction = menu.addAction(tr("Remove friend", "Menu to remove the friend from our friendlist"));
|
||||||
|
|
||||||
QAction* selectedItem = menu.exec(pos);
|
QAction* selectedItem = menu.exec(pos);
|
||||||
|
@ -91,34 +89,22 @@ void FriendWidget::contextMenuEvent(QContextMenuEvent * event)
|
||||||
}
|
}
|
||||||
else if (selectedItem == autoAccept)
|
else if (selectedItem == autoAccept)
|
||||||
{
|
{
|
||||||
if (dir.isEmpty())
|
if (!autoAccept->isChecked())
|
||||||
dir = QDir::homePath();
|
|
||||||
dir = QFileDialog::getExistingDirectory(0, tr("Choose an auto accept directory","popup title"), dir);
|
|
||||||
if (!dir.isEmpty())
|
|
||||||
{
|
{
|
||||||
|
qDebug() << "not checked";
|
||||||
|
dir = QDir::homePath();
|
||||||
|
autoAccept->setChecked(false);
|
||||||
|
Settings::getInstance().setAutoAcceptDir(id, "");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (autoAccept->isChecked())
|
||||||
|
{
|
||||||
|
dir = QFileDialog::getExistingDirectory(0, tr("Choose an auto accept directory","popup title"), dir);
|
||||||
|
autoAccept->setChecked(true);
|
||||||
qDebug() << "FriendWidget: setting auto accept dir for" << friendId << "to" << dir;
|
qDebug() << "FriendWidget: setting auto accept dir for" << friendId << "to" << dir;
|
||||||
Settings::getInstance().setAutoAcceptDir(id, dir);
|
Settings::getInstance().setAutoAcceptDir(id, dir);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (selectedItem == disableAutoAccept)
|
|
||||||
{
|
|
||||||
Settings::getInstance().setAutoAcceptDir(id, "");
|
|
||||||
}
|
|
||||||
else if (selectedItem == globalAA)
|
|
||||||
{
|
|
||||||
if (globalDir.isEmpty())
|
|
||||||
globalDir = QDir::homePath();
|
|
||||||
globalDir = QFileDialog::getExistingDirectory(0, tr("Choose an auto accept directory","popup title"), dir);
|
|
||||||
if (!globalDir.isEmpty())
|
|
||||||
{
|
|
||||||
qDebug() << "FriendWidget: setting global auto accept dir to" << globalDir;
|
|
||||||
Settings::getInstance().setGlobalAutoAcceptDir(globalDir);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (selectedItem == disableGlobalAA)
|
|
||||||
{
|
|
||||||
Settings::getInstance().setGlobalAutoAcceptDir("");
|
|
||||||
}
|
|
||||||
else if (groupActions.contains(selectedItem))
|
else if (groupActions.contains(selectedItem))
|
||||||
{
|
{
|
||||||
Group* group = groupActions[selectedItem];
|
Group* group = groupActions[selectedItem];
|
||||||
|
|
|
@ -518,6 +518,7 @@ void Widget::onAddClicked()
|
||||||
{
|
{
|
||||||
hideMainForms();
|
hideMainForms();
|
||||||
addFriendForm->show(*ui);
|
addFriendForm->show(*ui);
|
||||||
|
setWindowTitle(tr("Add friend") + " - qTox");
|
||||||
}
|
}
|
||||||
|
|
||||||
void Widget::onGroupClicked()
|
void Widget::onGroupClicked()
|
||||||
|
@ -529,6 +530,7 @@ void Widget::onTransferClicked()
|
||||||
{
|
{
|
||||||
hideMainForms();
|
hideMainForms();
|
||||||
filesForm->show(*ui);
|
filesForm->show(*ui);
|
||||||
|
setWindowTitle(tr("File transfers") + " - qTox");
|
||||||
activeChatroomWidget = nullptr;
|
activeChatroomWidget = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -553,6 +555,7 @@ void Widget::onSettingsClicked()
|
||||||
{
|
{
|
||||||
hideMainForms();
|
hideMainForms();
|
||||||
settingsWidget->show(*ui);
|
settingsWidget->show(*ui);
|
||||||
|
setWindowTitle(tr("Settings") + " - qTox");
|
||||||
activeChatroomWidget = nullptr;
|
activeChatroomWidget = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -712,6 +715,7 @@ void Widget::onChatroomWidgetClicked(GenericChatroomWidget *widget)
|
||||||
}
|
}
|
||||||
activeChatroomWidget = widget;
|
activeChatroomWidget = widget;
|
||||||
widget->setAsActiveChatroom();
|
widget->setAsActiveChatroom();
|
||||||
|
setWindowTitle(widget->getName() + " - qTox");
|
||||||
widget->resetEventFlags();
|
widget->resetEventFlags();
|
||||||
widget->updateStatusLight();
|
widget->updateStatusLight();
|
||||||
}
|
}
|
||||||
|
@ -959,10 +963,7 @@ bool Widget::isFriendWidgetCurActiveWidget(Friend* f)
|
||||||
if (!f)
|
if (!f)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (activeChatroomWidget == static_cast<GenericChatroomWidget*>(f->widget))
|
return (activeChatroomWidget == static_cast<GenericChatroomWidget*>(f->widget));
|
||||||
return true;
|
|
||||||
else
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Widget::event(QEvent * e)
|
bool Widget::event(QEvent * e)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user