updated settingsdialog
This commit is contained in:
+60
-24
@@ -10,6 +10,8 @@ namespace widgets {
|
||||
|
||||
NotebookTab::NotebookTab(Notebook *notebook)
|
||||
: QWidget(notebook)
|
||||
// , posAnimation(this, "pos")
|
||||
// , posAnimated(false)
|
||||
, notebook(notebook)
|
||||
, text("<no title>")
|
||||
, selected(false)
|
||||
@@ -19,36 +21,56 @@ NotebookTab::NotebookTab(Notebook *notebook)
|
||||
, mouseDownX(false)
|
||||
, highlightStyle(HighlightNone)
|
||||
{
|
||||
calcSize();
|
||||
this->calcSize();
|
||||
this->setAcceptDrops(true);
|
||||
|
||||
setAcceptDrops(true);
|
||||
|
||||
QObject::connect(&settings::Settings::getHideTabX(),
|
||||
SIGNAL(settings::BoolSetting::valueChanged(bool)), this,
|
||||
SLOT(NotebookTab::hideTabXChanged(bool)));
|
||||
|
||||
this->installEventFilter(this);
|
||||
QObject::connect(&settings::Settings::getInstance().getHideTabX(),
|
||||
&settings::BoolSetting::valueChanged, this,
|
||||
&NotebookTab::hideTabXChanged);
|
||||
|
||||
this->setMouseTracking(true);
|
||||
}
|
||||
|
||||
NotebookTab::~NotebookTab()
|
||||
{
|
||||
QObject::disconnect(&settings::Settings::getHideTabX(),
|
||||
SIGNAL(settings::BoolSetting::valueChanged(bool)), this,
|
||||
SLOT(NotebookTab::hideTabXChanged(bool)));
|
||||
QObject::disconnect(&settings::Settings::getInstance().getHideTabX(),
|
||||
&settings::BoolSetting::valueChanged, this,
|
||||
&NotebookTab::hideTabXChanged);
|
||||
}
|
||||
|
||||
void
|
||||
NotebookTab::calcSize()
|
||||
{
|
||||
if (settings::Settings::getHideTabX().get()) {
|
||||
if (settings::Settings::getInstance().getHideTabX().get()) {
|
||||
this->resize(this->fontMetrics().width(this->text) + 8, 24);
|
||||
} else {
|
||||
this->resize(this->fontMetrics().width(this->text) + 8 + 24, 24);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
NotebookTab::moveAnimated(QPoint pos)
|
||||
{
|
||||
move(pos);
|
||||
|
||||
// if (posAnimated == false) {
|
||||
// move(pos);
|
||||
|
||||
// posAnimated = true;
|
||||
// return;
|
||||
// }
|
||||
|
||||
// if (this->posAnimation.endValue() == pos) {
|
||||
// return;
|
||||
// }
|
||||
|
||||
// this->posAnimation.stop();
|
||||
// this->posAnimation.setDuration(50);
|
||||
// this->posAnimation.setStartValue(this->pos());
|
||||
// this->posAnimation.setEndValue(pos);
|
||||
// this->posAnimation.start();
|
||||
}
|
||||
|
||||
void
|
||||
NotebookTab::paintEvent(QPaintEvent *)
|
||||
{
|
||||
@@ -77,25 +99,28 @@ NotebookTab::paintEvent(QPaintEvent *)
|
||||
|
||||
painter.setPen(fg);
|
||||
|
||||
QRect rect(0, 0,
|
||||
width() - (settings::Settings::getHideTabX().get() ? 0 : 16),
|
||||
height());
|
||||
QRect rect(
|
||||
0, 0,
|
||||
width() -
|
||||
(settings::Settings::getInstance().getHideTabX().get() ? 0 : 16),
|
||||
height());
|
||||
|
||||
painter.drawText(rect, this->text, QTextOption(Qt::AlignCenter));
|
||||
|
||||
if (!settings::Settings::getHideTabX().get() && (mouseOver || selected)) {
|
||||
if (mouseOverX) {
|
||||
painter.fillRect(getXRect(), QColor(0, 0, 0, 64));
|
||||
if (!settings::Settings::getInstance().getHideTabX().get() &&
|
||||
(this->mouseOver || this->selected)) {
|
||||
if (this->mouseOverX) {
|
||||
painter.fillRect(this->getXRect(), QColor(0, 0, 0, 64));
|
||||
|
||||
if (mouseDownX) {
|
||||
painter.fillRect(getXRect(), QColor(0, 0, 0, 64));
|
||||
if (this->mouseDownX) {
|
||||
painter.fillRect(this->getXRect(), QColor(0, 0, 0, 64));
|
||||
}
|
||||
}
|
||||
|
||||
painter.drawLine(getXRect().topLeft() + QPoint(4, 4),
|
||||
getXRect().bottomRight() + QPoint(-4, -4));
|
||||
painter.drawLine(getXRect().topRight() + QPoint(-4, 4),
|
||||
getXRect().bottomLeft() + QPoint(4, -4));
|
||||
painter.drawLine(this->getXRect().topLeft() + QPoint(4, 4),
|
||||
this->getXRect().bottomRight() + QPoint(-4, -4));
|
||||
painter.drawLine(this->getXRect().topRight() + QPoint(-4, 4),
|
||||
this->getXRect().bottomLeft() + QPoint(4, -4));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -156,6 +181,17 @@ NotebookTab::mouseMoveEvent(QMouseEvent *event)
|
||||
|
||||
this->repaint();
|
||||
}
|
||||
|
||||
if (this->mouseDown && !this->rect().contains(event->pos())) {
|
||||
QPoint relPoint = this->mapToParent(event->pos());
|
||||
|
||||
int index;
|
||||
NotebookPage *page = notebook->tabAt(relPoint, index);
|
||||
|
||||
if (page != nullptr && page != this->page) {
|
||||
notebook->rearrangePage(this->page, index);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user