Skip to content

Commit

Permalink
Fix topbar breaking on watch view error
Browse files Browse the repository at this point in the history
Also using hide() and show() instead of setVisible(false) and
setVisible(true)
  • Loading branch information
BowDown097 committed Nov 29, 2023
1 parent a8b724c commit 549ee91
Show file tree
Hide file tree
Showing 13 changed files with 43 additions and 44 deletions.
8 changes: 4 additions & 4 deletions src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ MainWindow::MainWindow(const QCommandLineParser& parser, QWidget* parent) : QMai
m_topbar = new TopBar(this);

notificationMenu = new ContinuableListWidget(this);
notificationMenu->hide();
notificationMenu->setContinuationThreshold(5);
notificationMenu->setVisible(false);

findbar = new FindBar(this);
connect(ui->centralwidget, &QStackedWidget::currentChanged, this, [this] { if (findbar->isVisible()) { findbar->setReveal(false); } });
Expand Down Expand Up @@ -128,7 +128,7 @@ void MainWindow::keyPressEvent(QKeyEvent* event)
{
bool ctrlPressed = event->modifiers() & Qt::ControlModifier;
if ((ctrlPressed && event->key() == Qt::Key_F) || event->key() == Qt::Key_Escape)
findbar->setReveal(!findbar->isVisible());
findbar->setReveal(findbar->isHidden());
}

QWidget::keyPressEvent(event);
Expand Down Expand Up @@ -376,12 +376,12 @@ void MainWindow::showNotifications()
{
m_topbar->setAlwaysShow(ui->centralwidget->currentIndex() == 0);
notificationMenu->clear();
notificationMenu->setVisible(false);
notificationMenu->hide();
return;
}

m_topbar->setAlwaysShow(true);
notificationMenu->setVisible(true);
notificationMenu->show();
BrowseHelper::instance()->browseNotificationMenu(notificationMenu);
}

Expand Down
19 changes: 10 additions & 9 deletions src/ui/forms/emojimenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ EmojiMenu::EmojiMenu(QWidget* parent) : QWidget(parent), ui(new Ui::EmojiMenu)
{
setAttribute(Qt::WA_DeleteOnClose);
ui->setupUi(this);
ui->filteredScrollArea->setVisible(false);
ui->filteredScrollArea->hide();
connect(ui->emojiSearch, &QLineEdit::textEdited, this, &EmojiMenu::filterEmojis);

filteredLayout = new FlowLayout(ui->filteredScrollAreaContents);
Expand Down Expand Up @@ -78,18 +78,19 @@ void EmojiMenu::filterEmojis()
for (TubeLabel* label : ui->filteredScrollAreaContents->findChildren<TubeLabel*>())
layout->addWidget(label);

if (ui->emojiSearch->text().isEmpty())
{
ui->filteredScrollArea->setVisible(false);
ui->scrollArea->setVisible(true);
}
else
bool searchingEmojis = !ui->emojiSearch->text().isEmpty();
ui->filteredScrollArea->setVisible(searchingEmojis);
ui->scrollArea->setVisible(!searchingEmojis);

if (searchingEmojis)
{
ui->filteredScrollArea->setVisible(true);
ui->scrollArea->setVisible(false);
for (TubeLabel* label : ui->scrollAreaContents->findChildren<TubeLabel*>())
{
if (label->toolTip().contains(ui->emojiSearch->text()))
{
filteredLayout->addWidget(label);
}
}
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/ui/forms/livechat/livechatwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,9 @@ void LiveChatWindow::initialize(const InnertubeObjects::LiveChat& liveChatData,

if (liveChatData.isReplay)
{
emojiMenuLabel->setVisible(false);
ui->messageBox->setVisible(false);
ui->sendButton->setVisible(false);
emojiMenuLabel->hide();
ui->messageBox->hide();
ui->sendButton->hide();

using namespace std::placeholders;
connect(player, &WatchViewPlayer::progressChanged, this, std::bind(&LiveChatWindow::chatReplayTick, this, _1, _2));
Expand Down
2 changes: 1 addition & 1 deletion src/ui/forms/settings/settingsform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ SettingsForm::SettingsForm(QWidget* parent) : QWidget(parent), ui(new Ui::Settin
ui->newpipeRadio->setProperty("id", 4);

#ifndef Q_OS_LINUX
ui->vaapi->setVisible(false);
ui->vaapi->hide();
#endif

SettingsStore& store = qtTubeApp->settings();
Expand Down
1 change: 1 addition & 0 deletions src/ui/views/viewcontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,5 +76,6 @@ void ViewController::loadVideo(const QString& videoId, int progress)
QMessageBox::critical(nullptr, "Failed to load video", ie.message());
watchView->deleteLater();
MainWindow::topbar()->setAlwaysShow(true);
MainWindow::topbar()->show();
});
}
6 changes: 3 additions & 3 deletions src/ui/views/watchview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ WatchView::~WatchView()

WatchView::WatchView(const QString& videoId, int progress, QWidget* parent) : QWidget(parent), ui(new Ui::WatchView)
{
MainWindow::topbar()->hide();
MainWindow::topbar()->setAlwaysShow(false);
MainWindow::topbar()->setVisible(false);

ui->setupUi(this);

Expand Down Expand Up @@ -177,7 +177,7 @@ void WatchView::processNext(const InnertubeEndpoints::Next& endpoint)

ui->subscribeWidget->setSubscribeButton(nextResp.secondaryInfo.subscribeButton);
ui->subscribeWidget->setSubscriberCount(nextResp.secondaryInfo.owner.subscriberCountText.text, nextResp.secondaryInfo.subscribeButton.channelId);
ui->subscribeWidget->subscribersCountLabel->setVisible(true);
ui->subscribeWidget->subscribersCountLabel->show();
ui->viewCount->setText(qtTubeApp->settings().condensedCounts && !nextResp.primaryInfo.viewCount.isLive
? nextResp.primaryInfo.viewCount.extraShortViewCount.text + " views"
: nextResp.primaryInfo.viewCount.viewCount.text);
Expand Down Expand Up @@ -355,7 +355,7 @@ void WatchView::setDislikes(const HttpReply& reply)
ui->likeBar->setValue(likes);
}

ui->likeBar->setVisible(true);
ui->likeBar->show();

#ifdef QTTUBE_HAS_ICU
if (qtTubeApp->settings().condensedCounts)
Expand Down
5 changes: 2 additions & 3 deletions src/ui/views/watchview_ui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,9 @@ void WatchView_Ui::setupMenu(QWidget* watchView)
likeBarWrapper->setAlignment(Qt::AlignRight | Qt::AlignVCenter);

likeBar = new QProgressBar(watchView);
likeBar->hide();
likeBar->setFixedSize(155, 2);
likeBar->setStyleSheet(likeBarStyle);
likeBar->setTextVisible(false);
likeBar->setVisible(false);
likeBarWrapper->addWidget(likeBar);

menuVbox->addLayout(likeBarWrapper);
Expand Down Expand Up @@ -144,7 +143,7 @@ void WatchView_Ui::setupPrimaryInfo(QWidget* watchView)

subscribeWidget = new SubscribeWidget(watchView);
subscribeWidget->layout->addStretch();
subscribeWidget->subscribersCountLabel->setVisible(false);
subscribeWidget->subscribersCountLabel->hide();
primaryInfoVbox->addWidget(subscribeWidget);

primaryInfoHbox->addLayout(primaryInfoVbox);
Expand Down
4 changes: 2 additions & 2 deletions src/ui/widgets/accountmenu/accountmenuwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ void AccountMenuWidget::initialize(const InnertubeEndpoints::AccountMenu& endpoi

void AccountMenuWidget::gotoChannel(const QString& channelId)
{
setVisible(false);
hide();
ViewController::loadChannel(channelId);
emit closeRequested();
}
Expand All @@ -71,7 +71,7 @@ void AccountMenuWidget::setAvatar(const HttpReply& reply)

void AccountMenuWidget::triggerSignOut()
{
setVisible(false);
hide();
MainWindow::topbar()->signOut();
emit closeRequested();
}
4 changes: 2 additions & 2 deletions src/ui/widgets/accountmenu/accountswitcherwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ AccountSwitcherWidget::AccountSwitcherWidget(QWidget* parent)

void AccountSwitcherWidget::addAccount()
{
setVisible(false);
hide();
InnerTube::instance().unauthenticate();
MainWindow::topbar()->trySignIn();
emit closeRequested();
}

void AccountSwitcherWidget::switchAccount(const CredentialSet& credSet)
{
setVisible(false);
hide();
qtTubeApp->creds().populateAuthStore(credSet);
MainWindow::topbar()->postSignInSetup();
emit closeRequested();
Expand Down
2 changes: 1 addition & 1 deletion src/ui/widgets/findbar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ FindBar::FindBar(QWidget* parent)

hbox->addWidget(matchesLabel);

hide();
setAutoFillBackground(true);
setPalette(qApp->palette().alternateBase().color());
setVisible(false);

connect(nextButton, &QPushButton::clicked, this, &FindBar::goToNext);
connect(previousButton, &QPushButton::clicked, this, &FindBar::goToPrevious);
Expand Down
12 changes: 5 additions & 7 deletions src/ui/widgets/renderers/video/videothumbnailwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ VideoThumbnailWidget::VideoThumbnailWidget(QWidget* parent)
setMinimumSize(1, 1);
setScaledContents(true);

lengthLabel->hide();
lengthLabel->setFont(QFont(qApp->font().toString(), 9, QFont::Bold));
lengthLabel->setStyleSheet("background: rgba(0, 0, 0, 0.75); color: #fff; padding: 0 1px");
lengthLabel->setVisible(false);

progressBar->hide();
progressBar->setFixedHeight(3);
progressBar->setStyleSheet(progressStyle);
progressBar->setVisible(false);
}

#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
Expand All @@ -46,14 +46,12 @@ void VideoThumbnailWidget::mousePressEvent(QMouseEvent* event)

void VideoThumbnailWidget::resizeEvent(QResizeEvent* event)
{
if (!lengthLabel->isVisible() && !lengthLabel->text().isEmpty())
lengthLabel->setVisible(true);
if (!progressBar->isVisible() && progressBar->value() > 0)
progressBar->setVisible(true);
lengthLabel->setVisible(lengthLabel->isHidden() && !lengthLabel->text().isEmpty());
progressBar->setVisible(progressBar->isHidden() && progressBar->value() > 0);

lengthLabel->move(event->size().width() - lengthLabel->width() - 3, event->size().height() - lengthLabel->height() - 3);

progressBar->move(0, event->size().height() - 3);

progressBar->setFixedWidth(event->size().width());
}

Expand Down
2 changes: 1 addition & 1 deletion src/ui/widgets/subscribe/subscribewidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ SubscribeWidget::SubscribeWidget(QWidget* parent)

layout->addWidget(subscribeLabel);

notificationBell->setVisible(false);
notificationBell->hide();
layout->addWidget(notificationBell);

subscribersCountLabel->setFixedHeight(24);
Expand Down
16 changes: 8 additions & 8 deletions src/ui/widgets/topbar/topbar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ TopBar::TopBar(QWidget* parent)
animation->setDuration(250);
animation->setEasingCurve(QEasingCurve::InOutQuint);

avatarButton->hide();
avatarButton->move(673, 3);
avatarButton->resize(30, 30);
avatarButton->setClickable(true, false);
avatarButton->setVisible(false);

logo->move(10, 2);
logo->resize(134, 30);
Expand Down Expand Up @@ -90,8 +90,8 @@ void TopBar::handleMouseEvent(QMouseEvent* event)

void TopBar::postSignInSetup(bool emitSignal)
{
avatarButton->setVisible(true);
signInButton->setVisible(false);
avatarButton->show();
signInButton->hide();
setUpAvatarButton();
setUpNotifications();

Expand Down Expand Up @@ -140,7 +140,7 @@ void TopBar::setUpNotifications()
if (InnerTube::instance().hasAuthenticated())
updateNotificationCount();
else
notificationBell->setVisible(false);
notificationBell->hide();
}

void TopBar::showSettings()
Expand All @@ -153,8 +153,8 @@ void TopBar::signOut()
{
InnerTube::instance().unauthenticate();
setUpNotifications();
avatarButton->setVisible(false);
signInButton->setVisible(true);
avatarButton->hide();
signInButton->show();
emit signInStatusChanged();
qtTubeApp->creds().clear();
}
Expand Down Expand Up @@ -197,8 +197,8 @@ void TopBar::updateNotificationCount()
auto reply = InnerTube::instance().get<InnertubeEndpoints::UnseenCount>();
connect(reply, &InnertubeReply<InnertubeEndpoints::UnseenCount>::finished, this, [this](const InnertubeEndpoints::UnseenCount& endpoint)
{
notificationBell->show();
notificationBell->updatePixmap(endpoint.unseenCount > 0, palette());
notificationBell->setVisible(true);
notificationBell->updateCount(endpoint.unseenCount);
});
}
Expand All @@ -212,5 +212,5 @@ void TopBar::updatePalette(const QPalette& palette)
settingsButton->setPixmap(UIUtils::pixmapThemed("settings", false, QSize(), palette));

if (!InnerTube::instance().hasAuthenticated())
notificationBell->setVisible(false);
notificationBell->hide();
}

0 comments on commit 549ee91

Please sign in to comment.