removed the chrome style tabs

This commit is contained in:
fourtf 2018-04-01 16:41:32 +02:00
parent dca11406b9
commit 05335c6440
6 changed files with 62 additions and 40 deletions

View file

@ -117,7 +117,7 @@ void MessageLayout::actuallyLayout(int width, MessageElement::Flags flags)
this->deleteBuffer(); this->deleteBuffer();
} }
this->container.finish(); this->container.end();
this->height = this->container.getHeight(); this->height = this->container.getHeight();
} }

View file

@ -142,7 +142,7 @@ void MessageLayoutContainer::breakLine()
} }
this->lineStart = this->elements.size(); this->lineStart = this->elements.size();
this->currentX = 0; this->currentX = (int)(this->scale * 8);
this->currentY += this->lineHeight; this->currentY += this->lineHeight;
this->height = this->currentY + (this->margin.bottom * this->scale); this->height = this->currentY + (this->margin.bottom * this->scale);
this->lineHeight = 0; this->lineHeight = 0;
@ -158,7 +158,7 @@ bool MessageLayoutContainer::fitsInLine(int _width)
return this->currentX + _width <= this->width - this->margin.left - this->margin.right; return this->currentX + _width <= this->width - this->margin.left - this->margin.right;
} }
void MessageLayoutContainer::finish() void MessageLayoutContainer::end()
{ {
if (!this->atStartOfLine()) { if (!this->atStartOfLine()) {
this->breakLine(); this->breakLine();

View file

@ -56,7 +56,7 @@ public:
// methods // methods
void begin(int width, float scale, Message::MessageFlags flags); void begin(int width, float scale, Message::MessageFlags flags);
void finish(); void end();
void clear(); void clear();
void addElement(MessageLayoutElement *element); void addElement(MessageLayoutElement *element);

View file

@ -89,7 +89,7 @@ void ThemeManager::actuallyUpdate(double hue, double multiplier)
// tabs // tabs
// text, {regular, hover, unfocused} // text, {regular, hover, unfocused}
this->windowBg = "#ccc"; // this->windowBg = "#ccc";
this->tabs.border = "#999"; this->tabs.border = "#999";
this->tabs.regular = {tabFg, {windowBg, blendColors(windowBg, "#999", 0.5), windowBg}}; this->tabs.regular = {tabFg, {windowBg, blendColors(windowBg, "#999", 0.5), windowBg}};
@ -107,7 +107,7 @@ void ThemeManager::actuallyUpdate(double hue, double multiplier)
{blendColors(themeColor, windowBg, 0.7), blendColors(themeColor, windowBg, 0.5), {blendColors(themeColor, windowBg, 0.7), blendColors(themeColor, windowBg, 0.5),
blendColors(themeColorNoSat, windowBg, 0.7)}}; blendColors(themeColorNoSat, windowBg, 0.7)}};
this->windowBg = "#fff"; // this->windowBg = "#fff";
// Split // Split
bool flat = isLight; bool flat = isLight;

View file

@ -83,12 +83,12 @@ void NotebookTab::updateSize()
QString qTitle(qS(this->title)); QString qTitle(qS(this->title));
if (singletons::SettingManager::getInstance().hideTabX) { if (singletons::SettingManager::getInstance().hideTabX) {
width = (int)((fontMetrics().width(qTitle) + 16 + 16) * scale); width = (int)((fontMetrics().width(qTitle) + 16 /*+ 16*/) * scale);
} else { } else {
width = (int)((fontMetrics().width(qTitle) + 8 + 24 + 16) * scale); width = (int)((fontMetrics().width(qTitle) + 8 + 24 /*+ 16*/) * scale);
} }
this->resize(std::min((int)(150 * scale), width), (int)(48 * scale)); this->resize(std::min((int)(150 * scale), width), (int)(24 * scale));
if (this->parent() != nullptr) { if (this->parent() != nullptr) {
(static_cast<Notebook *>(this->parent()))->performLayout(true); (static_cast<Notebook *>(this->parent()))->performLayout(true);
@ -176,7 +176,7 @@ void NotebookTab::paintEvent(QPaintEvent *)
float scale = this->getScale(); float scale = this->getScale();
int height = (int)(scale * 24); int height = (int)(scale * 24);
int fullHeight = (int)(scale * 48); // int fullHeight = (int)(scale * 48);
// select the right tab colors // select the right tab colors
singletons::ThemeManager::TabColors colors; singletons::ThemeManager::TabColors colors;
@ -199,35 +199,47 @@ void NotebookTab::paintEvent(QPaintEvent *)
: (windowFocused ? colors.backgrounds.regular : (windowFocused ? colors.backgrounds.regular
: colors.backgrounds.unfocused); : colors.backgrounds.unfocused);
if (false) { if (true) {
painter.fillRect(rect(), this->mouseOver ? regular.backgrounds.hover painter.fillRect(rect(), this->mouseOver ? regular.backgrounds.hover
: (windowFocused ? regular.backgrounds.regular : (windowFocused ? regular.backgrounds.regular
: regular.backgrounds.unfocused)); : regular.backgrounds.unfocused));
// fill the tab background // fill the tab background
painter.fillRect(rect(), tabBackground); painter.fillRect(rect(), tabBackground);
} else {
// draw border
painter.setPen(QPen("#ccc"));
QPainterPath path(QPointF(0, height)); QPainterPath path(QPointF(0, height));
path.lineTo(8 * scale, 0); path.lineTo(0, 0);
path.lineTo(this->width() - 8 * scale, 0); path.lineTo(this->width() - 1, 0);
path.lineTo(this->width(), height); path.lineTo(this->width() - 1, this->height() - 1);
painter.fillPath(path, this->mouseOver ? regular.backgrounds.hover path.lineTo(0, this->height() - 1);
: (windowFocused ? regular.backgrounds.regular
: regular.backgrounds.unfocused));
// fill the tab background
painter.fillPath(path, tabBackground);
painter.setPen(QColor("#FFF"));
painter.setRenderHint(QPainter::Antialiasing);
painter.drawPath(path); painter.drawPath(path);
// painter.setBrush(QColor("#000")); } else {
// QPainterPath path(QPointF(0, height));
// path.lineTo(8 * scale, 0);
// path.lineTo(this->width() - 8 * scale, 0);
// path.lineTo(this->width(), height);
// painter.fillPath(path, this->mouseOver ? regular.backgrounds.hover
// : (windowFocused ?
// regular.backgrounds.regular
// :
// regular.backgrounds.unfocused));
QLinearGradient gradient(0, height, 0, fullHeight); // // fill the tab background
gradient.setColorAt(0, tabBackground.color()); // painter.fillPath(path, tabBackground);
gradient.setColorAt(1, "#fff"); // painter.setPen(QColor("#FFF"));
// painter.setRenderHint(QPainter::Antialiasing);
// painter.drawPath(path);
// // painter.setBrush(QColor("#000"));
QBrush brush(gradient); // QLinearGradient gradient(0, height, 0, fullHeight);
painter.fillRect(0, height, this->width(), fullHeight - height, brush); // gradient.setColorAt(0, tabBackground.color());
// gradient.setColorAt(1, "#fff");
// QBrush brush(gradient);
// painter.fillRect(0, height, this->width(), fullHeight - height,
// brush);
} }
// set the pen color // set the pen color
@ -238,14 +250,20 @@ void NotebookTab::paintEvent(QPaintEvent *)
QRect rect(0, 0, this->width() - rectW, height); QRect rect(0, 0, this->width() - rectW, height);
// draw text // draw text
if (false) { // legacy if (true) { // legacy
painter.drawText(rect, this->getTitle(), QTextOption(Qt::AlignCenter)); // painter.drawText(rect, this->getTitle(), QTextOption(Qt::AlignCenter));
} else { int offset = (int)(scale * 8);
QRect textRect(offset, 0, this->width() - offset - offset, height);
QTextOption option(Qt::AlignLeft | Qt::AlignVCenter); QTextOption option(Qt::AlignLeft | Qt::AlignVCenter);
option.setWrapMode(QTextOption::NoWrap); option.setWrapMode(QTextOption::NoWrap);
int offset = (int)(scale * 16);
QRect textRect(offset, 0, this->width() - offset - offset, height);
painter.drawText(textRect, this->getTitle(), option); painter.drawText(textRect, this->getTitle(), option);
} else {
// QTextOption option(Qt::AlignLeft | Qt::AlignVCenter);
// option.setWrapMode(QTextOption::NoWrap);
// int offset = (int)(scale * 16);
// QRect textRect(offset, 0, this->width() - offset - offset, height);
// painter.drawText(textRect, this->getTitle(), option);
} }
// draw close x // draw close x
@ -264,7 +282,7 @@ void NotebookTab::paintEvent(QPaintEvent *)
painter.drawLine(xRect.topLeft() + QPoint(a, a), xRect.bottomRight() + QPoint(-a, -a)); painter.drawLine(xRect.topLeft() + QPoint(a, a), xRect.bottomRight() + QPoint(-a, -a));
painter.drawLine(xRect.topRight() + QPoint(-a, a), xRect.bottomLeft() + QPoint(a, -a)); painter.drawLine(xRect.topRight() + QPoint(-a, a), xRect.bottomLeft() + QPoint(a, -a));
} }
} } // namespace widgets
void NotebookTab::mousePressEvent(QMouseEvent *event) void NotebookTab::mousePressEvent(QMouseEvent *event)
{ {

View file

@ -162,7 +162,7 @@ SplitContainer *Notebook::tabAt(QPoint point, int &index, int maxWidth)
for (auto *page : this->pages) { for (auto *page : this->pages) {
QRect rect = page->getTab()->getDesiredRect(); QRect rect = page->getTab()->getDesiredRect();
rect.setHeight((int)(this->getScale() * 22)); rect.setHeight((int)(this->getScale() * 24));
rect.setWidth(std::min(maxWidth, rect.width())); rect.setWidth(std::min(maxWidth, rect.width()));
@ -244,8 +244,8 @@ void Notebook::performLayout(bool animated)
for (auto &i : this->pages) { for (auto &i : this->pages) {
if (!first && if (!first &&
(i == this->pages.last() ? tabHeight : 0) + x + i->getTab()->width() > width()) { (i == this->pages.last() ? tabHeight : 0) + x + i->getTab()->width() > width()) {
// y += i->getTab()->height(); y += i->getTab()->height() - 1;
y += 20; // y += 20;
i->getTab()->moveAnimated(QPoint(0, y), animated); i->getTab()->moveAnimated(QPoint(0, y), animated);
x = i->getTab()->width(); x = i->getTab()->width();
} else { } else {
@ -253,15 +253,19 @@ void Notebook::performLayout(bool animated)
x += i->getTab()->width(); x += i->getTab()->width();
} }
x -= (int)(8 * scale); // x -= (int)(8 * scale);
x += 1;
first = false; first = false;
} }
x += (int)(8 * scale); // x += (int)(8 * scale);
// x += 1;
this->addButton.move(x, y); this->addButton.move(x, y);
y -= 1;
for (auto &i : this->pages) { for (auto &i : this->pages) {
i->getTab()->raise(); i->getTab()->raise();
} }