Skip to content

Commit

Permalink
added seconds in time for chats (w/out translations as for now)
Browse files Browse the repository at this point in the history
  • Loading branch information
xmdnx committed Feb 24, 2024
1 parent 8e0654a commit ac9ba74
Show file tree
Hide file tree
Showing 9 changed files with 61 additions and 7 deletions.
8 changes: 7 additions & 1 deletion Telegram/SourceFiles/dialogs/ui/dialogs_layout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ For license and copyright information please follow this link:
*/
#include "dialogs/ui/dialogs_layout.h"

#include "rabbit/settings/rabbit_settings.h"

#include "data/data_drafts.h"
#include "data/data_forum_topic.h"
#include "data/data_saved_sublist.h"
Expand Down Expand Up @@ -94,7 +96,11 @@ void PaintRowDate(
const auto dt = [&] {
if ((lastDate == nowDate)
|| (qAbs(lastTime.secsTo(now)) < kRecentlyInSeconds)) {
return QLocale().toString(lastTime.time(), QLocale::ShortFormat);
return QLocale().toString(
lastTime.time(),
RabbitSettings::JsonSettings::GetBool("show_seconds")
? QLocale::system().timeFormat(QLocale::LongFormat).remove(" t")
: QLocale::system().timeFormat(QLocale::ShortFormat));
} else if (qAbs(lastDate.daysTo(nowDate)) < 7) {
return langDayOfWeek(lastDate);
} else {
Expand Down
8 changes: 7 additions & 1 deletion Telegram/SourceFiles/history/history_inner_widget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ For license and copyright information please follow this link:
*/
#include "history/history_inner_widget.h"

#include "rabbit/settings/rabbit_settings.h"

#include "core/file_utilities.h"
#include "core/click_handler_types.h"
#include "history/history_item_helpers.h"
Expand Down Expand Up @@ -2853,7 +2855,11 @@ TextForMimeData HistoryInner::getSelectedText() const {
const auto i = texts.emplace(item->position(), Part{
.name = item->author()->name(),
.time = QString(", [%1]\n").arg(
QLocale().toString(ItemDateTime(item), QLocale::ShortFormat)),
QLocale().toString(
ItemDateTime(item),
RabbitSettings::JsonSettings::GetBool("show_seconds")
? QLocale::system().timeFormat(QLocale::LongFormat).remove(" t")
: QLocale::system().timeFormat(QLocale::ShortFormat))),
.unwrapped = std::move(unwrapped),
}).first;
fullSize += i->second.name.size()
Expand Down
6 changes: 5 additions & 1 deletion Telegram/SourceFiles/history/history_item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ For license and copyright information please follow this link:
*/
#include "history/history_item.h"

#include "rabbit/settings/rabbit_settings.h"

#include "lang/lang_keys.h"
#include "mainwidget.h"
#include "calls/calls_instance.h" // Core::App().calls().joinGroupCall.
Expand Down Expand Up @@ -5323,7 +5325,9 @@ PreparedServiceText HistoryItem::prepareCallScheduledText(
};
const auto time = QLocale().toString(
scheduled.time(),
QLocale::ShortFormat);
RabbitSettings::JsonSettings::GetBool("show_seconds")
? QLocale::system().timeFormat(QLocale::LongFormat).remove(" t")
: QLocale::system().timeFormat(QLocale::ShortFormat));
const auto prepareGeneric = [&] {
prepareWithDate(tr::lng_group_call_starts_date(
tr::now,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ For license and copyright information please follow this link:
*/
#include "history/view/history_view_bottom_info.h"

#include "rabbit/settings/rabbit_settings.h"

#include "ui/chat/message_bubble.h"
#include "ui/chat/chat_style.h"
#include "ui/effects/reaction_fly_animation.h"
Expand Down Expand Up @@ -471,7 +473,9 @@ void BottomInfo::layoutDateText() {
const auto prefix = !author.isEmpty() ? u", "_q : QString();
const auto date = edited + QLocale().toString(
_data.date.time(),
QLocale::ShortFormat);
RabbitSettings::JsonSettings::GetBool("show_seconds")
? QLocale::system().timeFormat(QLocale::LongFormat).remove(" t")
: QLocale::system().timeFormat(QLocale::ShortFormat));
const auto afterAuthor = prefix + date;
const auto afterAuthorWidth = st::msgDateFont->width(afterAuthor);
const auto authorWidth = st::msgDateFont->width(author);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ For license and copyright information please follow this link:
*/
#include "history/view/history_view_list_widget.h"

#include "rabbit/settings/rabbit_settings.h"

#include "base/unixtime.h"
#include "base/qt/qt_key_modifiers.h"
#include "base/qt/qt_common_adapters.h"
Expand Down Expand Up @@ -2337,7 +2339,11 @@ TextForMimeData ListWidget::getSelectedText() const {
not_null<HistoryItem*> item,
TextForMimeData &&unwrapped) {
auto time = QString(", [%1]\n").arg(
QLocale().toString(ItemDateTime(item), QLocale::ShortFormat));
QLocale().toString(
ItemDateTime(item),
RabbitSettings::JsonSettings::GetBool("show_seconds")
? QLocale::system().timeFormat(QLocale::LongFormat).remove(" t")
: QLocale::system().timeFormat(QLocale::ShortFormat)));
auto part = TextForMimeData();
auto size = item->author()->name().size()
+ time.size()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ For license and copyright information please follow this link:
*/
#include "history/view/media/history_view_call.h"

#include "rabbit/settings/rabbit_settings.h"

#include "lang/lang_keys.h"
#include "ui/chat/chat_style.h"
#include "ui/text/format_values.h"
Expand Down Expand Up @@ -48,7 +50,9 @@ Call::Call(
_text = Data::MediaCall::Text(item, _reason, _video);
_status = QLocale().toString(
parent->dateTime().time(),
QLocale::ShortFormat);
RabbitSettings::JsonSettings::GetBool("show_seconds")
? QLocale::system().timeFormat(QLocale::LongFormat).remove(" t")
: QLocale::system().timeFormat(QLocale::ShortFormat));
if (_duration) {
_status = tr::lng_call_duration_info(
tr::now,
Expand Down
8 changes: 7 additions & 1 deletion Telegram/SourceFiles/media/player/media_player_widget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ For license and copyright information please follow this link:
*/
#include "media/player/media_player_widget.h"

#include "rabbit/settings/rabbit_settings.h"

#include "platform/platform_specific.h"
#include "data/data_document.h"
#include "data/data_session.h"
Expand Down Expand Up @@ -683,7 +685,11 @@ void Widget::handleSongChange() {
const auto date = [item] {
const auto parsed = ItemDateTime(item);
const auto date = parsed.date();
const auto time = QLocale().toString(parsed.time(), QLocale::ShortFormat);
const auto time = QLocale().toString(
parsed.time(),
RabbitSettings::JsonSettings::GetBool("show_seconds")
? QLocale::system().timeFormat(QLocale::LongFormat).remove(" t")
: QLocale::system().timeFormat(QLocale::ShortFormat));
const auto today = QDateTime::currentDateTime().date();
if (date == today) {
return tr::lng_player_message_today(
Expand Down
3 changes: 3 additions & 0 deletions Telegram/SourceFiles/rabbit/settings/rabbit_settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,9 @@ const std::map<QString, Definition, std::greater<QString>> DefinitionMap {
.type = SettingType::IntSetting,
.defaultValue = 170,
.limitHandler = IntLimit(64, 256, 170), }},
{ "show_seconds", {
.type = SettingType::BoolSetting,
.defaultValue = false, }},
{ "comma_after_mention", {
.type = SettingType::BoolSetting,
.defaultValue = false, }},
Expand Down
15 changes: 15 additions & 0 deletions Telegram/SourceFiles/rabbit/settings_menu/rabbit_settings_menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,21 @@ namespace Settings {
::RabbitSettings::JsonSettings::GetInt("sticker_height"),
updateStickerHeight);
updateStickerHeightLabel(::RabbitSettings::JsonSettings::GetInt("sticker_height"));

AddButtonWithIcon(
container,
rktr("rtg_mute_for_selected_time"),
st::settingsButton,
IconDescriptor{ &st::menuIconReschedule }
)->toggleOn(
rpl::single(::RabbitSettings::JsonSettings::GetBool("show_seconds"))
)->toggledValue(
) | rpl::filter([](bool enabled) {
return (enabled != ::RabbitSettings::JsonSettings::GetBool("show_seconds"));
}) | rpl::start_with_next([](bool enabled) {
::RabbitSettings::JsonSettings::Set("show_seconds", enabled);
::RabbitSettings::JsonSettings::Write();
}, container->lifetime());

SettingsMenuJsonSwitch(rtg_settings_comma_after_mention, comma_after_mention);
}
Expand Down

0 comments on commit ac9ba74

Please sign in to comment.