mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
rename tab on double click
This commit is contained in:
parent
3db0b5f95c
commit
25aab4cdeb
4 changed files with 36 additions and 32 deletions
|
@ -334,7 +334,7 @@ void Notebook::setShowAddButton(bool value)
|
||||||
|
|
||||||
void Notebook::scaleChangedEvent(float scale)
|
void Notebook::scaleChangedEvent(float scale)
|
||||||
{
|
{
|
||||||
float h = NOTEBOOK_TAB_HEIGHT * this->getScale();
|
float h = (NOTEBOOK_TAB_HEIGHT - 1) * this->getScale();
|
||||||
|
|
||||||
this->addButton_->setFixedSize(h, h);
|
this->addButton_->setFixedSize(h, h);
|
||||||
|
|
||||||
|
@ -367,7 +367,7 @@ void Notebook::performLayout(bool animated)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
btn->setFixedSize(tabHeight, tabHeight);
|
btn->setFixedSize(tabHeight, tabHeight - 1);
|
||||||
btn->move(x, 0);
|
btn->move(x, 0);
|
||||||
x += tabHeight;
|
x += tabHeight;
|
||||||
}
|
}
|
||||||
|
|
|
@ -159,9 +159,7 @@ void NotebookButton::mouseReleaseEvent(QMouseEvent *event)
|
||||||
void NotebookButton::dragEnterEvent(QDragEnterEvent *event)
|
void NotebookButton::dragEnterEvent(QDragEnterEvent *event)
|
||||||
{
|
{
|
||||||
if (!event->mimeData()->hasFormat("chatterino/split"))
|
if (!event->mimeData()->hasFormat("chatterino/split"))
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
event->acceptProposedAction();
|
event->acceptProposedAction();
|
||||||
|
|
||||||
|
|
|
@ -42,20 +42,7 @@ NotebookTab::NotebookTab(Notebook *notebook)
|
||||||
|
|
||||||
this->setMouseTracking(true);
|
this->setMouseTracking(true);
|
||||||
|
|
||||||
this->menu_.addAction("Rename", [this]() {
|
this->menu_.addAction("Rename", [this]() { this->showRenameDialog(); });
|
||||||
TextInputDialog d(this);
|
|
||||||
|
|
||||||
d.setWindowTitle(
|
|
||||||
"Change tab title (Leave empty for default behaviour)");
|
|
||||||
d.setText(this->getCustomTitle());
|
|
||||||
d.highlightText();
|
|
||||||
|
|
||||||
if (d.exec() == QDialog::Accepted)
|
|
||||||
{
|
|
||||||
QString newTitle = d.getText();
|
|
||||||
this->setCustomTitle(newTitle);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
this->menu_.addAction("Close",
|
this->menu_.addAction("Close",
|
||||||
[=]() { this->notebook_->removePage(this->page); });
|
[=]() { this->notebook_->removePage(this->page); });
|
||||||
|
@ -70,6 +57,21 @@ NotebookTab::NotebookTab(Notebook *notebook)
|
||||||
this->menu_.addAction(highlightNewMessagesAction_);
|
this->menu_.addAction(highlightNewMessagesAction_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NotebookTab::showRenameDialog()
|
||||||
|
{
|
||||||
|
TextInputDialog d(this);
|
||||||
|
|
||||||
|
d.setWindowTitle("Choose tab title (Empty for default)");
|
||||||
|
d.setText(this->getCustomTitle());
|
||||||
|
d.highlightText();
|
||||||
|
|
||||||
|
if (d.exec() == QDialog::Accepted)
|
||||||
|
{
|
||||||
|
QString newTitle = d.getText();
|
||||||
|
this->setCustomTitle(newTitle);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void NotebookTab::themeChangedEvent()
|
void NotebookTab::themeChangedEvent()
|
||||||
{
|
{
|
||||||
this->update();
|
this->update();
|
||||||
|
@ -278,21 +280,13 @@ void NotebookTab::paintEvent(QPaintEvent *)
|
||||||
Theme::TabColors regular = this->theme->tabs.regular;
|
Theme::TabColors regular = this->theme->tabs.regular;
|
||||||
|
|
||||||
if (this->selected_)
|
if (this->selected_)
|
||||||
{
|
|
||||||
colors = this->theme->tabs.selected;
|
colors = this->theme->tabs.selected;
|
||||||
}
|
|
||||||
else if (this->highlightState_ == HighlightState::Highlighted)
|
else if (this->highlightState_ == HighlightState::Highlighted)
|
||||||
{
|
|
||||||
colors = this->theme->tabs.highlighted;
|
colors = this->theme->tabs.highlighted;
|
||||||
}
|
|
||||||
else if (this->highlightState_ == HighlightState::NewMessage)
|
else if (this->highlightState_ == HighlightState::NewMessage)
|
||||||
{
|
|
||||||
colors = this->theme->tabs.newMessage;
|
colors = this->theme->tabs.newMessage;
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
|
||||||
colors = this->theme->tabs.regular;
|
colors = this->theme->tabs.regular;
|
||||||
}
|
|
||||||
|
|
||||||
bool windowFocused = this->window() == QApplication::activeWindow();
|
bool windowFocused = this->window() == QApplication::activeWindow();
|
||||||
|
|
||||||
|
@ -387,18 +381,18 @@ void NotebookTab::paintEvent(QPaintEvent *)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// draw mouse over effect
|
||||||
|
if (!this->selected_)
|
||||||
|
{
|
||||||
|
this->fancyPaint(painter);
|
||||||
|
}
|
||||||
|
|
||||||
// draw line at bottom
|
// draw line at bottom
|
||||||
if (!this->selected_ && this->isInLastRow_)
|
if (!this->selected_ && this->isInLastRow_)
|
||||||
{
|
{
|
||||||
painter.fillRect(0, this->height() - 1, this->width(), 1,
|
painter.fillRect(0, this->height() - 1, this->width(), 1,
|
||||||
app->themes->window.background);
|
app->themes->window.background);
|
||||||
}
|
}
|
||||||
|
|
||||||
// draw mouse over effect
|
|
||||||
if (!this->selected_)
|
|
||||||
{
|
|
||||||
this->fancyPaint(painter);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NotebookTab::hasXButton()
|
bool NotebookTab::hasXButton()
|
||||||
|
@ -477,6 +471,15 @@ void NotebookTab::mouseReleaseEvent(QMouseEvent *event)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NotebookTab::mouseDoubleClickEvent(QMouseEvent *event)
|
||||||
|
{
|
||||||
|
if (event->button() == Qt::LeftButton &&
|
||||||
|
this->notebook_->getAllowUserTabManagement())
|
||||||
|
{
|
||||||
|
this->showRenameDialog();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void NotebookTab::enterEvent(QEvent *event)
|
void NotebookTab::enterEvent(QEvent *event)
|
||||||
{
|
{
|
||||||
this->mouseOver_ = true;
|
this->mouseOver_ = true;
|
||||||
|
|
|
@ -58,6 +58,7 @@ protected:
|
||||||
|
|
||||||
virtual void mousePressEvent(QMouseEvent *event) override;
|
virtual void mousePressEvent(QMouseEvent *event) override;
|
||||||
virtual void mouseReleaseEvent(QMouseEvent *event) override;
|
virtual void mouseReleaseEvent(QMouseEvent *event) override;
|
||||||
|
virtual void mouseDoubleClickEvent(QMouseEvent *event) override;
|
||||||
virtual void enterEvent(QEvent *) override;
|
virtual void enterEvent(QEvent *) override;
|
||||||
virtual void leaveEvent(QEvent *) override;
|
virtual void leaveEvent(QEvent *) override;
|
||||||
|
|
||||||
|
@ -67,6 +68,8 @@ protected:
|
||||||
virtual void wheelEvent(QWheelEvent *event) override;
|
virtual void wheelEvent(QWheelEvent *event) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void showRenameDialog();
|
||||||
|
|
||||||
bool hasXButton();
|
bool hasXButton();
|
||||||
bool shouldDrawXButton();
|
bool shouldDrawXButton();
|
||||||
QRect getXRect();
|
QRect getXRect();
|
||||||
|
|
Loading…
Reference in a new issue