view src/sidebar.cpp @ 6:1d82f6e04d7d

Update: add first parts to the settings dialog
author Paper <mrpapersonic@gmail.com>
date Wed, 16 Aug 2023 00:49:17 -0400
parents 1ae666fdf9e2
children 07a9095eaeed
line wrap: on
line source

#include <QListWidget>
#include <QListWidgetItem>
#include <QFrame>
#include "sidebar.h"

SideBar::SideBar(QWidget *parent)
    : QListWidget(parent)
{
	setObjectName("sidebar");
	setFrameShape(QFrame::NoFrame);
    setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
	viewport()->setAutoFillBackground(false);
	setStyleSheet("font-size: 12px");
}

QListWidgetItem* SideBar::AddItem(QString name, QIcon icon) {
    QListWidgetItem* item = new QListWidgetItem(this);
    item->setText(name);
	if (!icon.isNull())
		item->setIcon(icon);
	return item;
}

QListWidgetItem* SideBar::AddSeparator() {
	QListWidgetItem* item = new QListWidgetItem(this);
	item->setFlags(item->flags() & ~Qt::ItemIsEnabled);
	setStyleSheet("QListWidget::item:disabled {background: transparent;}");
	QFrame* line = new QFrame(this);
	line->setFrameShape(QFrame::HLine);
	line->setFrameShadow(QFrame::Sunken);
	line->setEnabled(false);
	setItemWidget(item, line);
	return item;
}