mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
Multi-window: Translate all dialogs correctly, don't allow remove friend on dialogs
This commit is contained in:
parent
6a5fb9f518
commit
f825985856
|
@ -33,6 +33,7 @@
|
||||||
#include "src/core/core.h"
|
#include "src/core/core.h"
|
||||||
#include "src/widget/friendlistlayout.h"
|
#include "src/widget/friendlistlayout.h"
|
||||||
#include "src/widget/form/settingswidget.h"
|
#include "src/widget/form/settingswidget.h"
|
||||||
|
#include "src/widget/translator.h"
|
||||||
#include <QBoxLayout>
|
#include <QBoxLayout>
|
||||||
#include <QSplitter>
|
#include <QSplitter>
|
||||||
#include <QGuiApplication>
|
#include <QGuiApplication>
|
||||||
|
@ -120,6 +121,8 @@ ContentDialog::ContentDialog(SettingsWidget* settingsWidget, QWidget* parent)
|
||||||
new QShortcut(Qt::CTRL + Qt::Key_PageDown, this, SLOT(nextContact()));
|
new QShortcut(Qt::CTRL + Qt::Key_PageDown, this, SLOT(nextContact()));
|
||||||
|
|
||||||
connect(Core::getInstance(), &Core::usernameSet, this, &ContentDialog::updateTitleUsername);
|
connect(Core::getInstance(), &Core::usernameSet, this, &ContentDialog::updateTitleUsername);
|
||||||
|
|
||||||
|
Translator::registerHandler(std::bind(&ContentDialog::retranslateUi, this), this);
|
||||||
}
|
}
|
||||||
|
|
||||||
ContentDialog::~ContentDialog()
|
ContentDialog::~ContentDialog()
|
||||||
|
@ -150,6 +153,8 @@ ContentDialog::~ContentDialog()
|
||||||
}
|
}
|
||||||
++groupIt;
|
++groupIt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Translator::unregister(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
FriendWidget* ContentDialog::addFriend(int friendId, QString id)
|
FriendWidget* ContentDialog::addFriend(int friendId, QString id)
|
||||||
|
@ -573,6 +578,11 @@ void ContentDialog::onGroupchatPositionChanged(bool top)
|
||||||
friendLayout->insertLayout(1, groupLayout.getLayout());
|
friendLayout->insertLayout(1, groupLayout.getLayout());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ContentDialog::retranslateUi()
|
||||||
|
{
|
||||||
|
updateTitleUsername(Core::getInstance()->getUsername());
|
||||||
|
}
|
||||||
|
|
||||||
void ContentDialog::saveDialogGeometry()
|
void ContentDialog::saveDialogGeometry()
|
||||||
{
|
{
|
||||||
Settings::getInstance().setDialogGeometry(saveGeometry());
|
Settings::getInstance().setDialogGeometry(saveGeometry());
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
#include "src/widget/genericchatitemlayout.h"
|
#include "src/widget/genericchatitemlayout.h"
|
||||||
|
|
||||||
template <typename K, typename V> class QHash;
|
template <typename K, typename V> class QHash;
|
||||||
|
template <typename T> class QSet;
|
||||||
|
|
||||||
class QSplitter;
|
class QSplitter;
|
||||||
class QVBoxLayout;
|
class QVBoxLayout;
|
||||||
|
@ -86,6 +87,7 @@ private slots:
|
||||||
void onGroupchatPositionChanged(bool top);
|
void onGroupchatPositionChanged(bool top);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void retranslateUi();
|
||||||
void saveDialogGeometry();
|
void saveDialogGeometry();
|
||||||
void saveSplitterState();
|
void saveSplitterState();
|
||||||
QLayout* nextLayout(QLayout* layout, bool forward) const;
|
QLayout* nextLayout(QLayout* layout, bool forward) const;
|
||||||
|
|
|
@ -40,7 +40,7 @@
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>639</width>
|
<width>639</width>
|
||||||
<height>1221</height>
|
<height>1388</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">
|
||||||
|
@ -387,7 +387,7 @@ instead of system taskbar.</string>
|
||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Don't group chat wndows.</string>
|
<string>Don't group chat windows.</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
|
|
@ -147,7 +147,10 @@ void FriendWidget::contextMenuEvent(QContextMenuEvent * event)
|
||||||
autoAccept->setChecked(!dir.isEmpty());
|
autoAccept->setChecked(!dir.isEmpty());
|
||||||
menu.addSeparator();
|
menu.addSeparator();
|
||||||
|
|
||||||
QAction* removeFriendAction = menu.addAction(tr("Remove friend", "Menu to remove the friend from our friendlist"));
|
QAction* removeFriendAction = nullptr;
|
||||||
|
|
||||||
|
if (contentDialog == nullptr || !contentDialog->hasFriendWidget(friendId, this))
|
||||||
|
removeFriendAction = menu.addAction(tr("Remove friend", "Menu to remove the friend from our friendlist"));
|
||||||
|
|
||||||
QAction* selectedItem = menu.exec(pos);
|
QAction* selectedItem = menu.exec(pos);
|
||||||
|
|
||||||
|
|
|
@ -592,7 +592,7 @@ void Widget::onSeparateWindowChanged(bool separate, bool clicked)
|
||||||
|
|
||||||
if (clicked)
|
if (clicked)
|
||||||
{
|
{
|
||||||
ContentLayout* contentLayout = createContentDialog(tr("Settings"));
|
ContentLayout* contentLayout = createContentDialog((SettingDialog));
|
||||||
contentLayout->parentWidget()->resize(size);
|
contentLayout->parentWidget()->resize(size);
|
||||||
contentLayout->parentWidget()->move(pos);
|
contentLayout->parentWidget()->move(pos);
|
||||||
settingsWidget->show(contentLayout);
|
settingsWidget->show(contentLayout);
|
||||||
|
@ -628,7 +628,7 @@ void Widget::onAddClicked()
|
||||||
{
|
{
|
||||||
if (!addFriendForm->isShown())
|
if (!addFriendForm->isShown())
|
||||||
{
|
{
|
||||||
addFriendForm->show(createContentDialog(tr("Add friend")));
|
addFriendForm->show(createContentDialog(AddDialog));
|
||||||
setActiveToolMenuButton(Widget::None);
|
setActiveToolMenuButton(Widget::None);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -636,7 +636,7 @@ void Widget::onAddClicked()
|
||||||
{
|
{
|
||||||
hideMainForms(nullptr);
|
hideMainForms(nullptr);
|
||||||
addFriendForm->show(contentLayout);
|
addFriendForm->show(contentLayout);
|
||||||
setWindowTitle(tr("Add friend"));
|
setWindowTitle(fromDialogType(AddDialog));
|
||||||
setActiveToolMenuButton(Widget::AddButton);
|
setActiveToolMenuButton(Widget::AddButton);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -652,7 +652,7 @@ void Widget::onTransferClicked()
|
||||||
{
|
{
|
||||||
if (!filesForm->isShown())
|
if (!filesForm->isShown())
|
||||||
{
|
{
|
||||||
filesForm->show(createContentDialog(tr("File transfers")));
|
filesForm->show(createContentDialog(TransferDialog));
|
||||||
setActiveToolMenuButton(Widget::None);
|
setActiveToolMenuButton(Widget::None);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -660,7 +660,7 @@ void Widget::onTransferClicked()
|
||||||
{
|
{
|
||||||
hideMainForms(nullptr);
|
hideMainForms(nullptr);
|
||||||
filesForm->show(contentLayout);
|
filesForm->show(contentLayout);
|
||||||
setWindowTitle(tr("File transfers"));
|
setWindowTitle(fromDialogType(TransferDialog));
|
||||||
setActiveToolMenuButton(Widget::TransferButton);
|
setActiveToolMenuButton(Widget::TransferButton);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -741,7 +741,7 @@ void Widget::onSettingsClicked()
|
||||||
{
|
{
|
||||||
if (!settingsWidget->isShown())
|
if (!settingsWidget->isShown())
|
||||||
{
|
{
|
||||||
settingsWidget->show(createContentDialog(tr("Settings")));
|
settingsWidget->show(createContentDialog(SettingDialog));
|
||||||
setActiveToolMenuButton(Widget::None);
|
setActiveToolMenuButton(Widget::None);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -749,7 +749,7 @@ void Widget::onSettingsClicked()
|
||||||
{
|
{
|
||||||
hideMainForms(nullptr);
|
hideMainForms(nullptr);
|
||||||
settingsWidget->show(contentLayout);
|
settingsWidget->show(contentLayout);
|
||||||
setWindowTitle(tr("Settings"));
|
setWindowTitle(fromDialogType(SettingDialog));
|
||||||
setActiveToolMenuButton(Widget::SettingButton);
|
setActiveToolMenuButton(Widget::SettingButton);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -760,7 +760,7 @@ void Widget::showProfile() // onAvatarClicked, onUsernameClicked
|
||||||
{
|
{
|
||||||
if (!profileForm->isShown())
|
if (!profileForm->isShown())
|
||||||
{
|
{
|
||||||
profileForm->show(createContentDialog(tr("Profile")));
|
profileForm->show(createContentDialog(ProfileDialog));
|
||||||
setActiveToolMenuButton(Widget::None);
|
setActiveToolMenuButton(Widget::None);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -768,7 +768,7 @@ void Widget::showProfile() // onAvatarClicked, onUsernameClicked
|
||||||
{
|
{
|
||||||
hideMainForms(nullptr);
|
hideMainForms(nullptr);
|
||||||
profileForm->show(contentLayout);
|
profileForm->show(contentLayout);
|
||||||
setWindowTitle(tr("Profile"));
|
setWindowTitle(fromDialogType(ProfileDialog));
|
||||||
setActiveToolMenuButton(Widget::None);
|
setActiveToolMenuButton(Widget::None);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1141,6 +1141,23 @@ bool Widget::newGroupMessageAlert(int groupId)
|
||||||
return newMessageAlert(currentWindow, hasActive);
|
return newMessageAlert(currentWindow, hasActive);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString Widget::fromDialogType(DialogType type)
|
||||||
|
{
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case AddDialog:
|
||||||
|
return tr("Add friend");
|
||||||
|
case TransferDialog:
|
||||||
|
return tr("File transfers");
|
||||||
|
case SettingDialog:
|
||||||
|
return tr("Settings");
|
||||||
|
case ProfileDialog:
|
||||||
|
return tr("Profile");
|
||||||
|
default:
|
||||||
|
return QString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool Widget::newMessageAlert(QWidget* currentWindow, bool isActive)
|
bool Widget::newMessageAlert(QWidget* currentWindow, bool isActive)
|
||||||
{
|
{
|
||||||
bool inactiveWindow = isMinimized() || !currentWindow->isActiveWindow();
|
bool inactiveWindow = isMinimized() || !currentWindow->isActiveWindow();
|
||||||
|
@ -1277,15 +1294,32 @@ ContentDialog* Widget::createContentDialog() const
|
||||||
return new ContentDialog(settingsWidget);
|
return new ContentDialog(settingsWidget);
|
||||||
}
|
}
|
||||||
|
|
||||||
ContentLayout* Widget::createContentDialog(const QString &title) const
|
ContentLayout* Widget::createContentDialog(DialogType type) const
|
||||||
{
|
{
|
||||||
class Dialog : public QDialog
|
class Dialog : public QDialog
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Dialog()
|
Dialog(DialogType type)
|
||||||
: QDialog()
|
: QDialog()
|
||||||
|
, type(type)
|
||||||
{
|
{
|
||||||
restoreGeometry(Settings::getInstance().getDialogSettingsGeometry());
|
restoreGeometry(Settings::getInstance().getDialogSettingsGeometry());
|
||||||
|
Translator::registerHandler(std::bind(&Dialog::retranslateUi, this), this);
|
||||||
|
retranslateUi();
|
||||||
|
|
||||||
|
connect(Core::getInstance(), &Core::usernameSet, this, &Dialog::retranslateUi);
|
||||||
|
}
|
||||||
|
|
||||||
|
~Dialog()
|
||||||
|
{
|
||||||
|
Translator::unregister(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
|
||||||
|
void retranslateUi()
|
||||||
|
{
|
||||||
|
setWindowTitle(Core::getInstance()->getUsername() + QStringLiteral(" - ") + Widget::fromDialogType(type));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -1300,9 +1334,12 @@ ContentLayout* Widget::createContentDialog(const QString &title) const
|
||||||
Settings::getInstance().setDialogSettingsGeometry(saveGeometry());
|
Settings::getInstance().setDialogSettingsGeometry(saveGeometry());
|
||||||
QDialog::moveEvent(event);
|
QDialog::moveEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
DialogType type;
|
||||||
};
|
};
|
||||||
|
|
||||||
QDialog* dialog = new Dialog();
|
QDialog* dialog = new Dialog(type);
|
||||||
dialog->setAttribute(Qt::WA_DeleteOnClose);
|
dialog->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
ContentLayout* contentLayoutDialog = new ContentLayout(dialog);
|
ContentLayout* contentLayoutDialog = new ContentLayout(dialog);
|
||||||
|
|
||||||
|
@ -1312,7 +1349,6 @@ ContentLayout* Widget::createContentDialog(const QString &title) const
|
||||||
dialog->layout()->setSpacing(0);
|
dialog->layout()->setSpacing(0);
|
||||||
dialog->setMinimumSize(720, 400);
|
dialog->setMinimumSize(720, 400);
|
||||||
dialog->setAttribute(Qt::WA_DeleteOnClose);
|
dialog->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
dialog->setWindowTitle(title);
|
|
||||||
dialog->show();
|
dialog->show();
|
||||||
|
|
||||||
return contentLayoutDialog;
|
return contentLayoutDialog;
|
||||||
|
@ -1971,7 +2007,9 @@ void Widget::retranslateUi()
|
||||||
statusOnline->setText(tr("Online", "Button to set your status to 'Online'"));
|
statusOnline->setText(tr("Online", "Button to set your status to 'Online'"));
|
||||||
statusAway->setText(tr("Away", "Button to set your status to 'Away'"));
|
statusAway->setText(tr("Away", "Button to set your status to 'Away'"));
|
||||||
statusBusy->setText(tr("Busy", "Button to set your status to 'Busy'"));
|
statusBusy->setText(tr("Busy", "Button to set your status to 'Busy'"));
|
||||||
//setWindowTitle(tr("Settings"));
|
|
||||||
|
if (!Settings::getInstance().getSeparateWindow())
|
||||||
|
setWindowTitle(fromDialogType(SettingDialog));
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef Q_OS_MAC
|
#ifdef Q_OS_MAC
|
||||||
|
|
|
@ -72,8 +72,18 @@ public:
|
||||||
bool getIsWindowMinimized();
|
bool getIsWindowMinimized();
|
||||||
void updateIcons();
|
void updateIcons();
|
||||||
void clearContactsList();
|
void clearContactsList();
|
||||||
|
|
||||||
|
enum DialogType
|
||||||
|
{
|
||||||
|
AddDialog,
|
||||||
|
TransferDialog,
|
||||||
|
SettingDialog,
|
||||||
|
ProfileDialog
|
||||||
|
};
|
||||||
|
|
||||||
|
static QString fromDialogType(DialogType type);
|
||||||
ContentDialog* createContentDialog() const;
|
ContentDialog* createContentDialog() const;
|
||||||
ContentLayout* createContentDialog(const QString& title) const;
|
ContentLayout* createContentDialog(DialogType type) const;
|
||||||
|
|
||||||
static void confirmExecutableOpen(const QFileInfo file);
|
static void confirmExecutableOpen(const QFileInfo file);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user