mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
Make dir chooser work in aboutUser, code cleanup
This commit is contained in:
parent
b85e12b0fc
commit
8d1197903c
|
@ -5,13 +5,19 @@
|
|||
#include <QDir>
|
||||
#include <QFileDialog>
|
||||
|
||||
AboutUser::AboutUser(QWidget *parent) :
|
||||
AboutUser::AboutUser(ToxId &toxId, QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::AboutUser)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
connect(ui->buttonBox, &QDialogButtonBox::accepted, this, &AboutUser::onAcceptedClicked);
|
||||
connect(ui->autoaccept, &QCheckBox::clicked, this, &AboutUser::onAutoAcceptClicked);
|
||||
connect(ui->selectSaveDir, &QPushButton::clicked, this, &AboutUser::onSelectDirClicked);
|
||||
|
||||
this->toxId = toxId;
|
||||
QString dir = Settings::getInstance().getAutoAcceptDir(this->toxId);
|
||||
ui->autoaccept->setChecked(!dir.isEmpty());
|
||||
ui->selectSaveDir->setEnabled(ui->autoaccept->isChecked());
|
||||
}
|
||||
|
||||
void AboutUser::setFriend(Friend *f)
|
||||
|
@ -20,6 +26,7 @@ void AboutUser::setFriend(Friend *f)
|
|||
ui->userName->setText(f->getDisplayedName());
|
||||
ui->publicKey->setText(QString(f->getToxId().toString()));
|
||||
ui->note->setPlainText(Settings::getInstance().getContactNote(f->getToxId()));
|
||||
|
||||
QPixmap avatar = Settings::getInstance().getSavedAvatar(f->getToxId().toString());
|
||||
ui->statusMessage->setText(f->getStatusMessage());
|
||||
if(!avatar.isNull()) {
|
||||
|
@ -30,19 +37,6 @@ void AboutUser::setFriend(Friend *f)
|
|||
|
||||
}
|
||||
|
||||
void AboutUser::setToxId(ToxId &id)
|
||||
{
|
||||
this->toxId = id;
|
||||
QString dir = Settings::getInstance().getAutoAcceptDir(this->toxId);
|
||||
ui->autoaccept->setChecked(!dir.isEmpty());
|
||||
}
|
||||
|
||||
void AboutUser::onAcceptedClicked()
|
||||
{
|
||||
Settings::getInstance().setContactNote(ui->publicKey->text(), ui->note->toPlainText());
|
||||
Settings::getInstance().saveGlobal();
|
||||
}
|
||||
|
||||
void AboutUser::onAutoAcceptClicked()
|
||||
{
|
||||
QString dir;
|
||||
|
@ -51,6 +45,7 @@ void AboutUser::onAutoAcceptClicked()
|
|||
dir = QDir::homePath();
|
||||
ui->autoaccept->setChecked(false);
|
||||
Settings::getInstance().setAutoAcceptDir(this->toxId, "");
|
||||
ui->selectSaveDir->setText("Auto accept for this contact is disabled");
|
||||
}
|
||||
else if (ui->autoaccept->isChecked())
|
||||
{
|
||||
|
@ -58,8 +53,30 @@ void AboutUser::onAutoAcceptClicked()
|
|||
"popup title"), dir);
|
||||
ui->autoaccept->setChecked(true);
|
||||
Settings::getInstance().setAutoAcceptDir(this->toxId, dir);
|
||||
ui->selectSaveDir->setText(Settings::getInstance().getAutoAcceptDir(this->toxId));
|
||||
}
|
||||
Settings::getInstance().saveGlobal();
|
||||
ui->selectSaveDir->setEnabled(ui->autoaccept->isChecked());
|
||||
}
|
||||
|
||||
void AboutUser::onSelectDirClicked()
|
||||
{
|
||||
QString dir;
|
||||
dir = QFileDialog::getExistingDirectory(this, tr("Choose an auto accept directory",
|
||||
"popup title"), dir);
|
||||
ui->autoaccept->setChecked(true);
|
||||
Settings::getInstance().setAutoAcceptDir(this->toxId, dir);
|
||||
Settings::getInstance().saveGlobal();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief AboutUser::onAcceptedClicked When users clicks the bottom OK button,
|
||||
* save all settings
|
||||
*/
|
||||
void AboutUser::onAcceptedClicked()
|
||||
{
|
||||
Settings::getInstance().setContactNote(ui->publicKey->text(), ui->note->toPlainText());
|
||||
Settings::getInstance().saveGlobal();
|
||||
}
|
||||
|
||||
AboutUser::~AboutUser()
|
||||
|
|
|
@ -14,10 +14,9 @@ class AboutUser : public QDialog
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit AboutUser(QWidget *parent = 0);
|
||||
explicit AboutUser(ToxId &toxID, QWidget *parent = 0);
|
||||
~AboutUser();
|
||||
void setFriend(Friend *f);
|
||||
void setToxId(ToxId &id);
|
||||
|
||||
private:
|
||||
Ui::AboutUser *ui;
|
||||
|
@ -26,6 +25,7 @@ private:
|
|||
private slots:
|
||||
void onAcceptedClicked();
|
||||
void onAutoAcceptClicked();
|
||||
void onSelectDirClicked();
|
||||
};
|
||||
|
||||
#endif // ABOUTUSER_H
|
||||
|
|
|
@ -149,27 +149,27 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QPushButton" name="selectSaveDir">
|
||||
<property name="text">
|
||||
<string>SELECT DIR</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<item row="3" 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" colspan="2">
|
||||
<item row="2" column="0">
|
||||
<widget class="QCheckBox" name="autoaccept">
|
||||
<property name="text">
|
||||
<string>Auto accept files</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QPushButton" name="selectSaveDir">
|
||||
<property name="text">
|
||||
<string>Auto accept for this contact is disabled</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
|
|
|
@ -201,9 +201,8 @@ void FriendWidget::contextMenuEvent(QContextMenuEvent * event)
|
|||
}
|
||||
}
|
||||
else if (selectedItem == aboutWindow) {
|
||||
AboutUser *aboutUser = new AboutUser(this);
|
||||
AboutUser *aboutUser = new AboutUser(id, this);
|
||||
aboutUser->setFriend(FriendList::findFriend(friendId));
|
||||
aboutUser->setToxId(id);
|
||||
aboutUser->show();
|
||||
}
|
||||
else if (selectedItem == newCircleAction)
|
||||
|
|
Loading…
Reference in New Issue
Block a user