did first requested refactors

This commit is contained in:
TranRed 2019-08-25 14:57:31 +02:00
parent a893be796c
commit 288ea5036b
2 changed files with 13 additions and 14 deletions

View file

@ -30,14 +30,14 @@
namespace { namespace {
const auto kBorderColor = QColor(255, 255, 255, 80); const auto borderColor = QColor(255, 255, 255, 80);
int calculateTimeoutDuration(int durationPerUnit, const QString &unit) int calculateTimeoutDuration(TimeoutButton timeout)
{ {
static const QMap<QString, int> durations{ static const QMap<QString, int> durations{
{"s", 1}, {"m", 60}, {"h", 3600}, {"d", 86400}, {"w", 604800}, {"s", 1}, {"m", 60}, {"h", 3600}, {"d", 86400}, {"w", 604800},
}; };
return durationPerUnit * durations[unit]; return timeout.second * durations[timeout.first];
} }
} // namespace } // namespace
@ -104,8 +104,8 @@ UserInfoPopup::UserInfoPopup()
auto usercard = user.emplace<EffectLabel2>(this); auto usercard = user.emplace<EffectLabel2>(this);
usercard->getLabel().setText("Usercard"); usercard->getLabel().setText("Usercard");
usercard->setBorderColor(kBorderColor); usercard->setBorderColor(borderColor);
viewLogs->setBorderColor(kBorderColor); viewLogs->setBorderColor(borderColor);
auto mod = user.emplace<Button>(this); auto mod = user.emplace<Button>(this);
mod->setPixmap(app->resources->buttons.mod); mod->setPixmap(app->resources->buttons.mod);
@ -528,16 +528,14 @@ UserInfoPopup::TimeoutWidget::TimeoutWidget()
a->getLabel().setText(QString::number(item.second) + item.first); a->getLabel().setText(QString::number(item.second) + item.first);
a->setScaleIndependantSize(buttonWidth, buttonHeight); a->setScaleIndependantSize(buttonWidth, buttonHeight);
a->setBorderColor(kBorderColor); a->setBorderColor(borderColor);
const auto pair = std::make_pair( const auto pair =
Action::Timeout, std::make_pair(Action::Timeout, calculateTimeoutDuration(item));
calculateTimeoutDuration(item.second, item.first));
QObject::connect( QObject::connect(
a.getElement(), &EffectLabel2::leftClicked, [this, pair] { a.getElement(), &EffectLabel2::leftClicked,
this->buttonClicked.invoke(pair); [this, pair] { this->buttonClicked.invoke(pair); });
});
} }
}; };
@ -560,7 +558,8 @@ void UserInfoPopup::fillLatestMessages()
{ {
LimitedQueueSnapshot<MessagePtr> snapshot = LimitedQueueSnapshot<MessagePtr> snapshot =
this->channel_->getMessageSnapshot(); this->channel_->getMessageSnapshot();
ChannelPtr channelPtr(new Channel("search", Channel::Type::None)); ChannelPtr channelPtr(
new Channel(this->channel_->getName(), Channel::Type::None));
for (size_t i = 0; i < snapshot.size(); i++) for (size_t i = 0; i < snapshot.size(); i++)
{ {
MessagePtr message = snapshot[i]; MessagePtr message = snapshot[i];

View file

@ -37,7 +37,7 @@ private:
QString userName_; QString userName_;
QString userId_; QString userId_;
ChannelPtr channel_; ChannelPtr channel_;
ChannelView *latestMessages_; ChannelView *latestMessages_{};
pajlada::Signals::NoArgSignal userStateChanged_; pajlada::Signals::NoArgSignal userStateChanged_;