rename tab on double click
This commit is contained in:
@@ -42,20 +42,7 @@ NotebookTab::NotebookTab(Notebook *notebook)
|
||||
|
||||
this->setMouseTracking(true);
|
||||
|
||||
this->menu_.addAction("Rename", [this]() {
|
||||
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("Rename", [this]() { this->showRenameDialog(); });
|
||||
|
||||
this->menu_.addAction("Close",
|
||||
[=]() { this->notebook_->removePage(this->page); });
|
||||
@@ -70,6 +57,21 @@ NotebookTab::NotebookTab(Notebook *notebook)
|
||||
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()
|
||||
{
|
||||
this->update();
|
||||
@@ -278,21 +280,13 @@ void NotebookTab::paintEvent(QPaintEvent *)
|
||||
Theme::TabColors regular = this->theme->tabs.regular;
|
||||
|
||||
if (this->selected_)
|
||||
{
|
||||
colors = this->theme->tabs.selected;
|
||||
}
|
||||
else if (this->highlightState_ == HighlightState::Highlighted)
|
||||
{
|
||||
colors = this->theme->tabs.highlighted;
|
||||
}
|
||||
else if (this->highlightState_ == HighlightState::NewMessage)
|
||||
{
|
||||
colors = this->theme->tabs.newMessage;
|
||||
}
|
||||
else
|
||||
{
|
||||
colors = this->theme->tabs.regular;
|
||||
}
|
||||
|
||||
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
|
||||
if (!this->selected_ && this->isInLastRow_)
|
||||
{
|
||||
painter.fillRect(0, this->height() - 1, this->width(), 1,
|
||||
app->themes->window.background);
|
||||
}
|
||||
|
||||
// draw mouse over effect
|
||||
if (!this->selected_)
|
||||
{
|
||||
this->fancyPaint(painter);
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
this->mouseOver_ = true;
|
||||
|
||||
Reference in New Issue
Block a user