Skip to content

Commit

Permalink
Fixed to previous ugly workaround about roster visibiity
Browse files Browse the repository at this point in the history
  • Loading branch information
Ri0n committed Apr 7, 2024
1 parent 9f3811b commit a44bb72
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 21 deletions.
39 changes: 19 additions & 20 deletions src/mainwin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -374,17 +374,14 @@ MainWin::MainWin(bool _onTop, bool _asTool, PsiCon *psi) :
d->vb_roster->setSpacing(layoutMargin);

if (d->allInOne) {
QString toolOpt = "options.ui.contactlist.toolbars";
const auto &bases = PsiOptions::instance()->getChildOptionNames(toolOpt, true, true);
for (const QString &base : bases) {
// toolbar "Show contacts" is fourth, so check m3
if (base == toolOpt + ".m3") {
d->viewToolBar = new PsiToolBar(base, rosterBar, d->psi->actionList());
d->viewToolBar->initialize();
connect(d->viewToolBar, SIGNAL(customize()), d->psi, SLOT(doToolbars()));
d->vb_roster->addWidget(d->viewToolBar);
break;
}
QString toolOpt = "options.ui.contactlist.toolbars";
const auto &bases = PsiOptions::instance()->getChildOptionNames(toolOpt, true, true);
auto m3ToolOpt = toolOpt + QLatin1String(".m3");
if (bases.contains(m3ToolOpt)) {
d->viewToolBar = new PsiToolBar(m3ToolOpt, rosterBar, d->psi->actionList());
d->viewToolBar->initialize();
connect(d->viewToolBar, &PsiToolBar::customize, d->psi, &PsiCon::doToolbars);
d->vb_roster->addWidget(d->viewToolBar);
}
}

Expand Down Expand Up @@ -574,17 +571,19 @@ MainWin::~MainWin()
void MainWin::qt67visibilityHack(const std::function<void()> &callback)
{
// Q 6.7 has broken something. So every time we add webengine stuff, all the other widgets disappear
QList<QWidget *> widgets = { d->rosterWidget_, d->rosterAvatar };
// widgets += toolbars_;
std::copy(toolbars_.begin(), toolbars_.end(), std::back_inserter(widgets));
QList<bool> visibility;
for (auto w : widgets) {
visibility.append(w->isVisible());
QList<std::tuple<QWidget *, bool>> widgetsVisibility;
for (int i = 0; i < d->vb_roster->count(); i++) {
auto w = d->vb_roster->itemAt(i)->widget();
if (w) {
widgetsVisibility.append({ w, w->isVisible() });
}
}
callback();
for (auto w : widgets) {
w->setVisible(visibility.takeFirst());
}
QTimer::singleShot(0, [widgetsVisibility = std::move(widgetsVisibility)]() {
for (auto [w, vis] : widgetsVisibility) {
w->setVisible(vis);
}
});
}

void MainWin::splitterMoved()
Expand Down
2 changes: 1 addition & 1 deletion src/psiaccount.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5818,7 +5818,7 @@ void PsiAccount::client_groupChatJoined(const Jid &j)

if (r != MUCJoinDlg::MucAutoJoin
|| !PsiOptions::instance()->getOption("options.ui.muc.hide-on-autojoin").toBool()) {
chat->ensureTabbedCorrectly();
d->psi->qt67visibilityHack([chat]() { chat->ensureTabbedCorrectly(); });
chat->bringToFront();
}

Expand Down

0 comments on commit a44bb72

Please sign in to comment.