mirror of https://github.com/procxx/kepka.git
Ctrl+1..5 always activate pinned from main chats list.
This commit is contained in:
parent
4dae89310d
commit
aede79640d
|
@ -48,6 +48,30 @@ namespace {
|
||||||
constexpr auto kHashtagResultsLimit = 5;
|
constexpr auto kHashtagResultsLimit = 5;
|
||||||
constexpr auto kStartReorderThreshold = 30;
|
constexpr auto kStartReorderThreshold = 30;
|
||||||
|
|
||||||
|
int FixedOnTopDialogsCount(not_null<Dialogs::IndexedList*> list) {
|
||||||
|
auto result = 0;
|
||||||
|
for (const auto row : *list) {
|
||||||
|
if (!row->entry()->fixedOnTopIndex()) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
++result;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
int PinnedDialogsCount(not_null<Dialogs::IndexedList*> list) {
|
||||||
|
auto result = 0;
|
||||||
|
for (const auto row : *list) {
|
||||||
|
if (row->entry()->fixedOnTopIndex()) {
|
||||||
|
continue;
|
||||||
|
} else if (!row->entry()->isPinnedDialog()) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
++result;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
struct InnerWidget::ImportantSwitch {
|
struct InnerWidget::ImportantSwitch {
|
||||||
|
@ -939,19 +963,6 @@ void InnerWidget::checkReorderPinnedStart(QPoint localPosition) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int InnerWidget::shownPinnedCount() const {
|
|
||||||
auto result = 0;
|
|
||||||
for (const auto row : *shownDialogs()) {
|
|
||||||
if (row->entry()->fixedOnTopIndex()) {
|
|
||||||
continue;
|
|
||||||
} else if (!row->entry()->isPinnedDialog()) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
++result;
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
int InnerWidget::countPinnedIndex(Row *ofRow) {
|
int InnerWidget::countPinnedIndex(Row *ofRow) {
|
||||||
if (!ofRow || !ofRow->entry()->isPinnedDialog()) {
|
if (!ofRow || !ofRow->entry()->isPinnedDialog()) {
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -1012,7 +1023,7 @@ int InnerWidget::updateReorderIndexGetCount() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto count = shownPinnedCount();
|
const auto count = Dialogs::PinnedDialogsCount(shownDialogs());
|
||||||
Assert(index < count);
|
Assert(index < count);
|
||||||
if (count < 2) {
|
if (count < 2) {
|
||||||
stopReorderPinned();
|
stopReorderPinned();
|
||||||
|
@ -2682,11 +2693,13 @@ void InnerWidget::setupShortcuts() {
|
||||||
auto &&pinned = ranges::view::zip(kPinned, ranges::view::ints(0));
|
auto &&pinned = ranges::view::zip(kPinned, ranges::view::ints(0));
|
||||||
for (const auto [command, index] : pinned) {
|
for (const auto [command, index] : pinned) {
|
||||||
request->check(command) && request->handle([=, index = index] {
|
request->check(command) && request->handle([=, index = index] {
|
||||||
const auto count = shownPinnedCount();
|
const auto list = session().data().chatsList()->indexed();
|
||||||
|
const auto count = Dialogs::PinnedDialogsCount(list);
|
||||||
if (index >= count) {
|
if (index >= count) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
const auto row = *(shownDialogs()->cbegin() + index);
|
const auto skip = Dialogs::FixedOnTopDialogsCount(list);
|
||||||
|
const auto row = *(list->cbegin() + skip + index);
|
||||||
return jumpToDialogRow({ row->key(), FullMsgId() });
|
return jumpToDialogRow({ row->key(), FullMsgId() });
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -272,7 +272,6 @@ private:
|
||||||
not_null<IndexedList*> shownDialogs() const;
|
not_null<IndexedList*> shownDialogs() const;
|
||||||
|
|
||||||
void checkReorderPinnedStart(QPoint localPosition);
|
void checkReorderPinnedStart(QPoint localPosition);
|
||||||
int shownPinnedCount() const;
|
|
||||||
int updateReorderIndexGetCount();
|
int updateReorderIndexGetCount();
|
||||||
bool updateReorderPinned(QPoint localPosition);
|
bool updateReorderPinned(QPoint localPosition);
|
||||||
void finishReorderPinned();
|
void finishReorderPinned();
|
||||||
|
|
Loading…
Reference in New Issue