64 lines
1.4 KiB
C++
64 lines
1.4 KiB
C++
#include "recentprojectwidget.h"
|
|
#include "ui_recentprojectwidget.h"
|
|
|
|
namespace Ember {
|
|
|
|
RecentProjectWidget::RecentProjectWidget(RecentProject project, QWidget *parent) :
|
|
QWidget(parent),
|
|
ui(new Ui::RecentProjectWidget),
|
|
m_project(project),
|
|
m_selected(false)
|
|
{
|
|
ui->setupUi(this);
|
|
setupActions();
|
|
setSelected(false);
|
|
}
|
|
|
|
RecentProjectWidget::~RecentProjectWidget()
|
|
{
|
|
delete ui;
|
|
}
|
|
|
|
void RecentProjectWidget::setupUi()
|
|
{
|
|
ui->text->setText(QString::fromStdString(m_project.name));
|
|
ui->buttonPin->setChecked(m_project.pinned);
|
|
}
|
|
|
|
void RecentProjectWidget::setupActions()
|
|
{
|
|
connect(ui->buttonDelete, &QToolButton::clicked, this, &RecentProjectWidget::onDeleteClicked);
|
|
connect(ui->buttonPin, &QToolButton::toggled, this, &RecentProjectWidget::onPinToggled);
|
|
}
|
|
|
|
const RecentProject& RecentProjectWidget::project() const
|
|
{
|
|
return m_project;
|
|
}
|
|
|
|
void RecentProjectWidget::setSelected(bool selected)
|
|
{
|
|
m_selected = selected;
|
|
ui->buttonPin->setVisible(selected);
|
|
ui->buttonDelete->setVisible(selected);
|
|
ui->textPin->setVisible(!selected && ui->buttonPin->isChecked());
|
|
}
|
|
|
|
void RecentProjectWidget::onDeleteClicked()
|
|
{
|
|
emit deleted(m_project);
|
|
}
|
|
|
|
void RecentProjectWidget::onPinToggled(bool pinned)
|
|
{
|
|
ui->textPin->setVisible(!m_selected && pinned);
|
|
if (m_project.pinned != pinned)
|
|
{
|
|
m_project.pinned = pinned;
|
|
emit pinToggled(m_project, pinned);
|
|
}
|
|
}
|
|
|
|
|
|
}
|