Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions include/SideBarWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include <QPixmap>
#include <QVBoxLayout>
#include <QWidget>
#include <QPushButton>


class SideBarWidget : public QWidget
Expand All @@ -47,6 +48,8 @@ class SideBarWidget : public QWidget
return m_title;
}

signals:
void closeButtonClicked();

protected:
virtual void paintEvent( QPaintEvent * _pe );
Expand Down Expand Up @@ -75,6 +78,8 @@ class SideBarWidget : public QWidget
QVBoxLayout * m_layout;
QString m_title;
QPixmap m_icon;
QPushButton * m_closeBtn;
const QSize m_buttonSize;

} ;

Expand Down
3 changes: 3 additions & 0 deletions src/gui/widgets/SideBar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,9 @@ void SideBar::appendTab( SideBarWidget *widget )
widget->setMinimumWidth( 200 );

ToolTip::add( button, widget->title() );

connect(widget, &SideBarWidget::closeButtonClicked,
[=]() { button->click(); });
}


Expand Down
13 changes: 11 additions & 2 deletions src/gui/widgets/SideBarWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,31 @@
*
*/

#include "SideBarWidget.h"

#include <QApplication>
#include <QFontMetrics>
#include <QPainter>

#include "SideBarWidget.h"
#include "embed.h"


SideBarWidget::SideBarWidget( const QString & _title, const QPixmap & _icon,
QWidget * _parent ) :
QWidget( _parent ),
m_title( _title ),
m_icon( _icon )
m_icon(_icon),
m_buttonSize(17, 17)
{
m_contents = new QWidget( this );
m_layout = new QVBoxLayout( m_contents );
m_layout->setSpacing( 5 );
m_layout->setMargin( 0 );
m_closeBtn = new QPushButton(embed::getIconPixmap("close"), QString(), this);
m_closeBtn->resize(m_buttonSize);
m_closeBtn->setToolTip(tr("Close"));
connect(m_closeBtn, &QPushButton::clicked,
[=]() { this->closeButtonClicked(); });
}


Expand Down Expand Up @@ -80,6 +88,7 @@ void SideBarWidget::resizeEvent( QResizeEvent * )
const int MARGIN = 6;
m_contents->setGeometry( MARGIN, 40 + MARGIN, width() - MARGIN * 2,
height() - MARGIN * 2 - 40 );
m_closeBtn->move(m_contents->geometry().width() - MARGIN - 5, 5);
}


Expand Down