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

refactor: returned correct code style

This commit is contained in:
noavarice 2017-04-19 21:42:45 +03:00
parent 7e1f8cb23e
commit a83f8d1dfd
6 changed files with 36 additions and 47 deletions

View File

@ -69,11 +69,8 @@ ContentDialog::ContentDialog(SettingsWidget* settingsWidget, QWidget* parent)
friendLayout->setMargin(0);
friendLayout->setSpacing(0);
layouts = {
friendLayout->getLayoutOnline(),
groupLayout.getLayout(),
friendLayout->getLayoutOffline()
};
layouts = {friendLayout->getLayoutOnline(), groupLayout.getLayout(),
friendLayout->getLayoutOffline()};
if (s.getGroupchatPosition()) {
layouts.swap(0, 1);
@ -141,8 +138,9 @@ ContentDialog::ContentDialog(SettingsWidget* settingsWidget, QWidget* parent)
Translator::registerHandler(std::bind(&ContentDialog::retranslateUi, this), this);
}
void ContentDialog::removeCurrent(QHash<int, ContactInfo>& infos) {
for (auto it = infos.begin(); it != infos.end(); ) {
void ContentDialog::removeCurrent(QHash<int, ContactInfo>& infos)
{
for (auto it = infos.begin(); it != infos.end();) {
if (std::get<0>(*it) == this) {
it = infos.erase(it);
} else {
@ -352,9 +350,9 @@ void ContentDialog::cycleContacts(bool forward, bool inverse)
bool isCurOffline = currentLayout == friendLayout->getLayoutOffline();
bool isCurOnline = currentLayout == friendLayout->getLayoutOnline();
bool isCurGroup = currentLayout == groupLayout.getLayout();
bool nextIsEmpty = (isCurOnline && offlineEmpty && (groupsEmpty || groupsOnTop)) ||
(isCurGroup && offlineEmpty && (onlineEmpty || !groupsOnTop)) ||
isCurOffline;
bool nextIsEmpty = (isCurOnline && offlineEmpty && (groupsEmpty || groupsOnTop))
|| (isCurGroup && offlineEmpty && (onlineEmpty || !groupsOnTop))
|| isCurOffline;
if (nextIsEmpty) {
forward = !forward;
@ -507,12 +505,10 @@ void ContentDialog::updateTitleAndStatusIcon()
Status currentStatus = activeChatroomWidget->getFriend()->getStatus();
QMap<Status, QIcon> icons {
{Status::Online, QIcon(":/img/status/dot_online.svg")},
{Status::Away, QIcon(":/img/status/dot_away.svg")},
{Status::Busy, QIcon(":/img/status/dot_busy.svg")},
{Status::Offline, QIcon(":/img/status/dot_offline.svg")}
};
QMap<Status, QIcon> icons{{Status::Online, QIcon(":/img/status/dot_online.svg")},
{Status::Away, QIcon(":/img/status/dot_away.svg")},
{Status::Busy, QIcon(":/img/status/dot_busy.svg")},
{Status::Offline, QIcon(":/img/status/dot_offline.svg")}};
setWindowIcon(icons[currentStatus]);
}
@ -819,8 +815,7 @@ bool ContentDialog::hasWidget(int id, GenericChatroomWidget* chatroomWidget,
return false;
}
return std::get<0>(*iter) == this &&
std::get<1>(*iter) == chatroomWidget;
return std::get<0>(*iter) == this && std::get<1>(*iter) == chatroomWidget;
}
/**

View File

@ -112,8 +112,7 @@ private:
QLayout* nextLayout(QLayout* layout, bool forward) const;
int getCurrentLayout(QLayout*& layout);
bool hasWidget(int id, GenericChatroomWidget* chatroomWidget,
const QHash<int, ContactInfo>& list);
bool hasWidget(int id, GenericChatroomWidget* chatroomWidget, const QHash<int, ContactInfo>& list);
void removeCurrent(QHash<int, ContactInfo>& infos);
static bool existsWidget(int id, const QHash<int, ContactInfo>& list);
static void focusDialog(int id, const QHash<int, ContactInfo>& list);

View File

@ -443,8 +443,8 @@ void GenericChatForm::addMessage(const ToxPk& author, const QString& message, co
/**
* @brief Inserts int ChatLog message that you have sent
*/
void GenericChatForm::addSelfMessage(const QString& message, const QDateTime& datetime,
bool isAction, bool isSent)
void GenericChatForm::addSelfMessage(const QString& message, const QDateTime& datetime,
bool isAction, bool isSent)
{
insertChatMessage(createSelfMessage(message, datetime, isAction, isSent));
}

View File

@ -68,8 +68,7 @@ public:
void addMessage(const ToxPk& author, const QString& message, const QDateTime& datetime,
bool isAction, bool isSent);
void addSelfMessage(const QString& message, const QDateTime& datetime,
bool isAction, bool isSent);
void addSelfMessage(const QString& message, const QDateTime& datetime, bool isAction, bool isSent);
void addSystemInfoMessage(const QString& message, ChatMessage::SystemMessageType type,
const QDateTime& datetime);
void addAlertMessage(const ToxPk& author, const QString& message, const QDateTime& datetime);

View File

@ -57,16 +57,12 @@ Time getTime(const QDate& date)
}
QDate today = QDate::currentDate();
const QMap<Time, QDate> dates {
{ Time::Today, today.addDays(0) },
{ Time::Yesterday, today.addDays(-1) },
{ Time::ThisWeek, today.addDays(-6) },
{ Time::ThisMonth, today.addMonths(-1) },
{ Time::Month1Ago, today.addMonths(-2) },
{ Time::Month2Ago, today.addMonths(-3) },
{ Time::Month3Ago, today.addMonths(-4) },
{ Time::Month4Ago, today.addMonths(-5) },
{ Time::Month5Ago, today.addMonths(-6) },
const QMap<Time, QDate> dates{
{Time::Today, today.addDays(0)}, {Time::Yesterday, today.addDays(-1)},
{Time::ThisWeek, today.addDays(-6)}, {Time::ThisMonth, today.addMonths(-1)},
{Time::Month1Ago, today.addMonths(-2)}, {Time::Month2Ago, today.addMonths(-3)},
{Time::Month3Ago, today.addMonths(-4)}, {Time::Month4Ago, today.addMonths(-5)},
{Time::Month5Ago, today.addMonths(-6)},
};
for (Time time : dates.keys()) {
@ -193,18 +189,18 @@ void FriendListWidget::setMode(Mode mode)
QLocale ql(Settings::getInstance().getTranslation());
QDate today = QDate::currentDate();
#define COMMENT "Category for sorting friends by activity"
const QMap<Time, QString> names {
{ Time::Today, tr("Today", COMMENT) },
{ Time::Yesterday, tr("Yesterday", COMMENT) },
{ Time::ThisWeek, tr("Last 7 days", COMMENT) },
{ Time::ThisMonth, tr("This month", COMMENT) },
{ Time::LongAgo, tr("Older than 6 Months", COMMENT) },
{ Time::Never, tr("Never", COMMENT) },
{ Time::Month1Ago, ql.monthName(today.addMonths(-1).month()) },
{ Time::Month2Ago, ql.monthName(today.addMonths(-2).month()) },
{ Time::Month3Ago, ql.monthName(today.addMonths(-3).month()) },
{ Time::Month4Ago, ql.monthName(today.addMonths(-4).month()) },
{ Time::Month5Ago, ql.monthName(today.addMonths(-5).month()) },
const QMap<Time, QString> names{
{Time::Today, tr("Today", COMMENT)},
{Time::Yesterday, tr("Yesterday", COMMENT)},
{Time::ThisWeek, tr("Last 7 days", COMMENT)},
{Time::ThisMonth, tr("This month", COMMENT)},
{Time::LongAgo, tr("Older than 6 Months", COMMENT)},
{Time::Never, tr("Never", COMMENT)},
{Time::Month1Ago, ql.monthName(today.addMonths(-1).month())},
{Time::Month2Ago, ql.monthName(today.addMonths(-2).month())},
{Time::Month3Ago, ql.monthName(today.addMonths(-3).month())},
{Time::Month4Ago, ql.monthName(today.addMonths(-4).month())},
{Time::Month5Ago, ql.monthName(today.addMonths(-5).month())},
};
#undef COMMENT

View File

@ -1463,7 +1463,7 @@ ContentDialog* Widget::createContentDialog() const
connect(&s, &Settings::groupchatPositionChanged, contentDialog, &ContentDialog::reorderLayouts);
#ifdef Q_OS_MAC
Nexus &n = Nexus::getInstance();
Nexus& n = Nexus::getInstance();
connect(contentDialog, &ContentDialog::destroyed, &n, &Nexus::updateWindowsClosed);
connect(contentDialog, &ContentDialog::windowStateChanged, &n, &Nexus::onWindowStateChanged);
connect(contentDialog->windowHandle(), &QWindow::windowTitleChanged, &n, &Nexus::updateWindows);