some VCard polishing, missing icons and translations

This commit is contained in:
Blue 2019-11-07 14:17:46 +03:00
parent 2c13f0d77c
commit dfa4d10c36
24 changed files with 727 additions and 247 deletions

View file

@ -52,7 +52,7 @@ QVariant UI::VCard::EMailsModel::data(const QModelIndex& index, int role) const
case 1:
switch (role) {
case Qt::DisplayRole:
return tr(Shared::VCard::Email::roleNames[deque[index.row()].role].toStdString().c_str());
return QCoreApplication::translate("Global", Shared::VCard::Email::roleNames[deque[index.row()].role].toStdString().c_str());
case Qt::EditRole:
return deque[index.row()].role;
default:

View file

@ -52,7 +52,7 @@ QVariant UI::VCard::PhonesModel::data(const QModelIndex& index, int role) const
case 1:
switch (role) {
case Qt::DisplayRole:
return tr(Shared::VCard::Phone::roleNames[deque[index.row()].role].toStdString().c_str());
return QCoreApplication::translate("Global", Shared::VCard::Phone::roleNames[deque[index.row()].role].toStdString().c_str());
case Qt::EditRole:
return deque[index.row()].role;
default:
@ -62,7 +62,7 @@ QVariant UI::VCard::PhonesModel::data(const QModelIndex& index, int role) const
case 2:
switch (role) {
case Qt::DisplayRole:
return tr(Shared::VCard::Phone::typeNames[deque[index.row()].type].toStdString().c_str());
return QCoreApplication::translate("Global", Shared::VCard::Phone::typeNames[deque[index.row()].type].toStdString().c_str());
case Qt::EditRole:
return deque[index.row()].type;
default:

View file

@ -55,17 +55,17 @@ VCard::VCard(const QString& jid, bool edit, QWidget* parent):
setAvatar->setEnabled(true);
clearAvatar->setEnabled(false);
roleDelegate->addEntry(tr(Shared::VCard::Email::roleNames[0].toStdString().c_str()));
roleDelegate->addEntry(tr(Shared::VCard::Email::roleNames[1].toStdString().c_str()));
roleDelegate->addEntry(tr(Shared::VCard::Email::roleNames[2].toStdString().c_str()));
roleDelegate->addEntry(QCoreApplication::translate("Global", Shared::VCard::Email::roleNames[0].toStdString().c_str()));
roleDelegate->addEntry(QCoreApplication::translate("Global", Shared::VCard::Email::roleNames[1].toStdString().c_str()));
roleDelegate->addEntry(QCoreApplication::translate("Global", Shared::VCard::Email::roleNames[2].toStdString().c_str()));
phoneTypeDelegate->addEntry(tr(Shared::VCard::Phone::typeNames[0].toStdString().c_str()));
phoneTypeDelegate->addEntry(tr(Shared::VCard::Phone::typeNames[1].toStdString().c_str()));
phoneTypeDelegate->addEntry(tr(Shared::VCard::Phone::typeNames[2].toStdString().c_str()));
phoneTypeDelegate->addEntry(tr(Shared::VCard::Phone::typeNames[3].toStdString().c_str()));
phoneTypeDelegate->addEntry(tr(Shared::VCard::Phone::typeNames[4].toStdString().c_str()));
phoneTypeDelegate->addEntry(tr(Shared::VCard::Phone::typeNames[5].toStdString().c_str()));
phoneTypeDelegate->addEntry(tr(Shared::VCard::Phone::typeNames[6].toStdString().c_str()));
phoneTypeDelegate->addEntry(QCoreApplication::translate("Global", Shared::VCard::Phone::typeNames[0].toStdString().c_str()));
phoneTypeDelegate->addEntry(QCoreApplication::translate("Global", Shared::VCard::Phone::typeNames[1].toStdString().c_str()));
phoneTypeDelegate->addEntry(QCoreApplication::translate("Global", Shared::VCard::Phone::typeNames[2].toStdString().c_str()));
phoneTypeDelegate->addEntry(QCoreApplication::translate("Global", Shared::VCard::Phone::typeNames[3].toStdString().c_str()));
phoneTypeDelegate->addEntry(QCoreApplication::translate("Global", Shared::VCard::Phone::typeNames[4].toStdString().c_str()));
phoneTypeDelegate->addEntry(QCoreApplication::translate("Global", Shared::VCard::Phone::typeNames[5].toStdString().c_str()));
phoneTypeDelegate->addEntry(QCoreApplication::translate("Global", Shared::VCard::Phone::typeNames[6].toStdString().c_str()));
m_ui->emailsView->setContextMenuPolicy(Qt::CustomContextMenu);
m_ui->emailsView->setModel(&emails);
@ -317,7 +317,7 @@ void VCard::onContextMenu(const QPoint& point)
if (selectionSize == 1) {
int row = sm->selectedRows().at(0).row();
if (emails.isPreferred(row)) {
QAction* rev = contextMenu->addAction(Shared::icon("view-media-favorite"), tr("Unset this email as preferred"));
QAction* rev = contextMenu->addAction(Shared::icon("unfavorite"), tr("Unset this email as preferred"));
connect(rev, &QAction::triggered, std::bind(&UI::VCard::EMailsModel::revertPreferred, &emails, row));
} else {
QAction* rev = contextMenu->addAction(Shared::icon("favorite"), tr("Set this email as preferred"));
@ -325,12 +325,12 @@ void VCard::onContextMenu(const QPoint& point)
}
}
QAction* del = contextMenu->addAction(Shared::icon("remove"), tr("Remove selected email addresses"));
QAction* del = contextMenu->addAction(Shared::icon("edit-delete"), tr("Remove selected email addresses"));
connect(del, &QAction::triggered, this, &VCard::onRemoveEmail);
}
}
QAction* cp = contextMenu->addAction(Shared::icon("copy"), tr("Copy selected emails to clipboard"));
QAction* cp = contextMenu->addAction(Shared::icon("edit-copy"), tr("Copy selected emails to clipboard"));
connect(cp, &QAction::triggered, this, &VCard::onCopyEmail);
} else if (snd == m_ui->phonesView) {
hasMenu = true;
@ -353,12 +353,12 @@ void VCard::onContextMenu(const QPoint& point)
}
}
QAction* del = contextMenu->addAction(Shared::icon("remove"), tr("Remove selected phone numbers"));
QAction* del = contextMenu->addAction(Shared::icon("edit-delete"), tr("Remove selected phone numbers"));
connect(del, &QAction::triggered, this, &VCard::onRemovePhone);
}
}
QAction* cp = contextMenu->addAction(Shared::icon("copy"), tr("Copy selected phones to clipboard"));
QAction* cp = contextMenu->addAction(Shared::icon("edit-copy"), tr("Copy selected phones to clipboard"));
connect(cp, &QAction::triggered, this, &VCard::onCopyPhone);
}
@ -431,32 +431,30 @@ void VCard::onRemovePhone()
void VCard::onCopyEmail()
{
QItemSelection selection(m_ui->emailsView->selectionModel()->selection());
QList<QModelIndex> selection(m_ui->emailsView->selectionModel()->selectedRows());
QList<QString> addrs;
for (const QModelIndex& index : selection.indexes()) {
for (const QModelIndex& index : selection) {
addrs.push_back(emails.getEmail(index.row()));
}
QString list = addrs.join("\n");
qDebug() << list;
QClipboard* cb = QApplication::clipboard();
cb->setText(list);
}
void VCard::onCopyPhone()
{
QItemSelection selection(m_ui->phonesView->selectionModel()->selection());
QList<QModelIndex> selection(m_ui->phonesView->selectionModel()->selectedRows());
QList<QString> phs;
for (const QModelIndex& index : selection.indexes()) {
for (const QModelIndex& index : selection) {
phs.push_back(phones.getPhone(index.row()));
}
QString list = phs.join("\n");
qDebug() << list;
QClipboard* cb = QApplication::clipboard();
cb->setText(list);
}

View file

@ -124,10 +124,10 @@
</sizepolicy>
</property>
<property name="styleSheet">
<string notr="true"/>
<string notr="true">font: 600 16pt;</string>
</property>
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-size:16pt; font-weight:600;&quot;&gt;Organization&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
<string>Organization</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
@ -418,8 +418,11 @@
</item>
<item row="0" column="0" colspan="4">
<widget class="QLabel" name="generalHeading">
<property name="styleSheet">
<string notr="true">font: 600 24pt ;</string>
</property>
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-size:24pt; font-weight:600;&quot;&gt;General&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
<string>General</string>
</property>
</widget>
</item>
@ -445,7 +448,7 @@
</sizepolicy>
</property>
<property name="styleSheet">
<string notr="true"/>
<string notr="true">font: 600 16pt;</string>
</property>
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
@ -454,7 +457,7 @@
<enum>QFrame::Plain</enum>
</property>
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-size:16pt; font-weight:600;&quot;&gt;Personal information&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
<string>Personal information</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
@ -536,8 +539,11 @@
</property>
<item>
<widget class="QLabel" name="contactHeading">
<property name="styleSheet">
<string notr="true">font: 600 24pt ;</string>
</property>
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-size:24pt; font-weight:600;&quot;&gt;Contact&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
<string>Contact</string>
</property>
</widget>
</item>
@ -561,7 +567,7 @@
<x>0</x>
<y>0</y>
<width>566</width>
<height>497</height>
<height>498</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_3" columnstretch="1,3,1">
@ -640,8 +646,11 @@
</item>
<item row="8" column="1">
<widget class="QLabel" name="addressesHeading">
<property name="styleSheet">
<string notr="true">font: 600 16pt;</string>
</property>
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-size:16pt; font-weight:600;&quot;&gt;Addresses&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
<string>Addresses</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
@ -666,8 +675,11 @@
</item>
<item row="2" column="1">
<widget class="QLabel" name="emailsHeading">
<property name="styleSheet">
<string notr="true">font: 600 16pt;</string>
</property>
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-size:16pt; font-weight:600;&quot;&gt;E-Mail addresses&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
<string>E-Mail addresses</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
@ -748,8 +760,11 @@
</item>
<item row="5" column="1">
<widget class="QLabel" name="phenesHeading">
<property name="styleSheet">
<string notr="true">font: 600 16pt;</string>
</property>
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-size:16pt; font-weight:600;&quot;&gt;Phone numbers&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
<string>Phone numbers</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
@ -800,8 +815,11 @@
</property>
<item row="0" column="0">
<widget class="QLabel" name="descriptionHeading">
<property name="styleSheet">
<string notr="true">font: 600 24pt ;</string>
</property>
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-size:24pt; font-weight:600;&quot;&gt;Description&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
<string>Description</string>
</property>
</widget>
</item>