mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
fix duplicating tabs
This commit is contained in:
parent
5f862c5e5e
commit
8745d0740f
3 changed files with 33 additions and 41 deletions
|
@ -204,7 +204,7 @@ void Notebook::duplicatePage(QWidget *page)
|
|||
{
|
||||
newTabPosition = tabPosition + 1;
|
||||
}
|
||||
auto newTabHighlightState = item->tab->highlightState();
|
||||
|
||||
QString newTabTitle = "";
|
||||
if (item->tab->hasCustomTitle())
|
||||
{
|
||||
|
@ -213,7 +213,7 @@ void Notebook::duplicatePage(QWidget *page)
|
|||
|
||||
auto *tab =
|
||||
this->addPageAt(newContainer, newTabPosition, newTabTitle, false);
|
||||
tab->setHighlightState(newTabHighlightState);
|
||||
tab->copyHighlightStateAndSourcesFrom(item->tab);
|
||||
|
||||
newContainer->setTab(tab);
|
||||
}
|
||||
|
|
|
@ -304,15 +304,14 @@ bool NotebookTab::isSelected() const
|
|||
return this->selected_;
|
||||
}
|
||||
|
||||
void NotebookTab::updateHighlightSources(
|
||||
const HighlightSources &removedHighlightSources)
|
||||
void NotebookTab::removeHighlightSources(const HighlightSources &toRemove)
|
||||
{
|
||||
for (const auto &source : removedHighlightSources.newMessageSource)
|
||||
for (const auto &source : toRemove.newMessageSource)
|
||||
{
|
||||
this->highlightSources_.newMessageSource.erase(source);
|
||||
}
|
||||
|
||||
for (const auto &source : removedHighlightSources.highlightedSource)
|
||||
for (const auto &source : toRemove.highlightedSource)
|
||||
{
|
||||
this->highlightSources_.highlightedSource.erase(source);
|
||||
}
|
||||
|
@ -341,6 +340,31 @@ void NotebookTab::updateHighlightSources(
|
|||
}
|
||||
}
|
||||
|
||||
void NotebookTab::copyHighlightStateAndSourcesFrom(const NotebookTab *sourceTab)
|
||||
{
|
||||
if (this->isSelected())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
this->highlightSources_ = sourceTab->highlightSources_;
|
||||
|
||||
if (!this->highlightEnabled_ &&
|
||||
sourceTab->highlightState_ == HighlightState::NewMessage)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (this->highlightState_ == sourceTab->highlightState_ ||
|
||||
this->highlightState_ == HighlightState::Highlighted)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
this->highlightState_ = sourceTab->highlightState_;
|
||||
this->update();
|
||||
}
|
||||
|
||||
void NotebookTab::setSelected(bool value)
|
||||
{
|
||||
this->selected_ = value;
|
||||
|
@ -359,7 +383,7 @@ void NotebookTab::setSelected(bool value)
|
|||
auto *tab = splitContainer->getTab();
|
||||
if (tab && tab != this)
|
||||
{
|
||||
tab->updateHighlightSources(this->highlightSources_);
|
||||
tab->removeHighlightSources(this->highlightSources_);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -420,30 +444,6 @@ bool NotebookTab::isLive() const
|
|||
return this->isLive_;
|
||||
}
|
||||
|
||||
void NotebookTab::setHighlightState(HighlightState newHighlightStyle)
|
||||
{
|
||||
// change this to "copy" highlight state, its used by duplicating a tab
|
||||
if (this->isSelected())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this->highlightEnabled_ &&
|
||||
newHighlightStyle == HighlightState::NewMessage)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (this->highlightState_ == newHighlightStyle ||
|
||||
this->highlightState_ == HighlightState::Highlighted)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
this->highlightState_ = newHighlightStyle;
|
||||
this->update();
|
||||
}
|
||||
|
||||
void NotebookTab::setHighlightState(HighlightState newHighlightStyle,
|
||||
const ChannelView &channelViewSource,
|
||||
const MessagePtr &message)
|
||||
|
@ -533,11 +533,6 @@ bool NotebookTab::shouldMessageHighlight(const ChannelView &channelViewSource,
|
|||
return true;
|
||||
}
|
||||
|
||||
HighlightState NotebookTab::highlightState() const
|
||||
{
|
||||
return this->highlightState_;
|
||||
}
|
||||
|
||||
void NotebookTab::setHighlightsEnabled(const bool &newVal)
|
||||
{
|
||||
this->highlightNewMessagesAction_->setChecked(newVal);
|
||||
|
|
|
@ -60,12 +60,10 @@ public:
|
|||
**/
|
||||
bool isLive() const;
|
||||
|
||||
void setHighlightState(HighlightState style);
|
||||
void setHighlightState(HighlightState style,
|
||||
const ChannelView &channelViewSource,
|
||||
const MessagePtr &message);
|
||||
HighlightState highlightState() const;
|
||||
|
||||
void copyHighlightStateAndSourcesFrom(const NotebookTab *sourceTab);
|
||||
void setHighlightsEnabled(const bool &newVal);
|
||||
bool hasHighlightsEnabled() const;
|
||||
|
||||
|
@ -126,8 +124,7 @@ private:
|
|||
|
||||
} highlightSources_;
|
||||
|
||||
void updateHighlightSources(
|
||||
const HighlightSources &removedHighlightSources);
|
||||
void removeHighlightSources(const HighlightSources &toRemove);
|
||||
|
||||
QPropertyAnimation positionChangedAnimation_;
|
||||
QPoint positionAnimationDesiredPoint_;
|
||||
|
|
Loading…
Reference in a new issue