forked from qt-creator/qt-creator
Help documents list: Only show close button when closing is possible.
This commit is contained in:
@@ -68,7 +68,8 @@ void OpenPagesDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opt
|
|||||||
|
|
||||||
QStyledItemDelegate::paint(painter, option, index);
|
QStyledItemDelegate::paint(painter, option, index);
|
||||||
|
|
||||||
if (index.column() == 1 && option.state & QStyle::State_MouseOver) {
|
if (index.column() == 1 && index.model()->rowCount() > 1
|
||||||
|
&& option.state & QStyle::State_MouseOver) {
|
||||||
QIcon icon((option.state & QStyle::State_Selected)
|
QIcon icon((option.state & QStyle::State_Selected)
|
||||||
? ":/core/images/closebutton.png" : ":/core/images/darkclosebutton.png");
|
? ":/core/images/closebutton.png" : ":/core/images/darkclosebutton.png");
|
||||||
|
|
||||||
@@ -137,10 +138,12 @@ void OpenPagesWidget::allowContextMenu(bool ok)
|
|||||||
|
|
||||||
void OpenPagesWidget::contextMenuRequested(QPoint pos)
|
void OpenPagesWidget::contextMenuRequested(QPoint pos)
|
||||||
{
|
{
|
||||||
const QModelIndex &index = indexAt(pos);
|
QModelIndex index = indexAt(pos);
|
||||||
if (!index.isValid() || !m_allowContextMenu)
|
if (!index.isValid() || !m_allowContextMenu)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (index.column() == 1)
|
||||||
|
index = index.sibling(index.row(), 0);
|
||||||
QMenu contextMenu;
|
QMenu contextMenu;
|
||||||
QAction *closeEditor = contextMenu.addAction(tr("Close %1").arg(index.data()
|
QAction *closeEditor = contextMenu.addAction(tr("Close %1").arg(index.data()
|
||||||
.toString()));
|
.toString()));
|
||||||
|
|||||||
Reference in New Issue
Block a user