2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 06:26:18 +00:00

Alpha 1.0.1: resize chats list with mouse press-and-drag.

Also fixed drag-n-drop images from Firefox in Windows.
Also some additional colors added to themes palette:
HistoryToDown button now has separate colors.
Windows title bar and buttons have separate active/inactive colors.
This commit is contained in:
John Preston
2017-01-16 16:27:11 +03:00
parent 47aa03ce37
commit 041e366df7
23 changed files with 185 additions and 80 deletions

View File

@@ -59,11 +59,11 @@ TitleWidget::TitleWidget(MainWindow *parent, int height) : Window::TitleWidget(p
void TitleWidget::paintEvent(QPaintEvent *e) {
Painter p(this);
p.fillRect(rect(), st::titleBg);
auto active = isActiveWindow();
p.fillRect(rect(), active ? st::titleBgActive : st::titleBg);
p.setPen(isActiveWindow() ? st::titleFgActive : st::titleFg);
p.setFont(_font);
p.setPen(active ? st::titleFgActive : st::titleFg);
p.drawText(rect(), static_cast<MainWindow*>(parentWidget())->titleText(), style::al_center);
}
@@ -121,7 +121,7 @@ QImage PreviewWindowSystemButton(QColor inner, QColor border) {
void PreviewWindowTitle(Painter &p, const style::palette &palette, QRect body, int titleHeight, int outerWidth) {
auto titleRect = QRect(body.x(), body.y() - titleHeight, body.width(), titleHeight);
p.fillRect(titleRect, QColor(0, 0, 0));
p.fillRect(titleRect, st::titleBg[palette]);
p.fillRect(titleRect, st::titleBgActive[palette]);
p.fillRect(titleRect.x(), titleRect.y() + titleRect.height() - st::lineWidth, titleRect.width(), st::lineWidth, st::titleShadow[palette]);
auto useSystemFont = false;

View File

@@ -661,16 +661,19 @@ int32 MainWindow::screenNameChecksum(const QString &name) const {
}
void MainWindow::psRefreshTaskbarIcon() {
QWidget *w = new QWidget(this);
w->setWindowFlags(static_cast<Qt::WindowFlags>(Qt::Tool) | Qt::FramelessWindowHint);
w->setGeometry(x() + 1, y() + 1, 1, 1);
QPalette p(w->palette());
p.setColor(QPalette::Background, st::titleBg->c);
QWindow *wnd = w->windowHandle();
w->setPalette(p);
w->show();
w->activateWindow();
delete w;
auto refresher = object_ptr<QWidget>(this);
auto guard = base::scope_guard([&refresher] {
refresher.destroy();
});
refresher->setWindowFlags(static_cast<Qt::WindowFlags>(Qt::Tool) | Qt::FramelessWindowHint);
refresher->setGeometry(x() + 1, y() + 1, 1, 1);
auto palette = refresher->palette();
palette.setColor(QPalette::Background, (isActiveWindow() ? st::titleBgActive : st::titleBg)->c);
refresher->setPalette(palette);
refresher->show();
refresher->activateWindow();
updateIconCounters();
}
void MainWindow::psTrayMenuUpdated() {

View File

@@ -32,14 +32,14 @@ TitleWidget::TitleWidget(QWidget *parent) : Window::TitleWidget(parent)
, _maximizeRestore(this, st::titleButtonMaximize)
, _close(this, st::titleButtonClose)
, _shadow(this, st::titleShadow)
, _maximized(parent->window()->windowState() & Qt::WindowMaximized) {
, _maximizedState(parent->window()->windowState() & Qt::WindowMaximized) {
_minimize->setClickedCallback([this]() {
window()->setWindowState(Qt::WindowMinimized);
_minimize->clearState();
});
_minimize->setPointerCursor(false);
_maximizeRestore->setClickedCallback([this]() {
window()->setWindowState(_maximized ? Qt::WindowNoState : Qt::WindowMaximized);
window()->setWindowState(_maximizedState ? Qt::WindowNoState : Qt::WindowMaximized);
_maximizeRestore->clearState();
});
_maximizeRestore->setPointerCursor(false);
@@ -55,12 +55,18 @@ TitleWidget::TitleWidget(QWidget *parent) : Window::TitleWidget(parent)
void TitleWidget::init() {
connect(window()->windowHandle(), SIGNAL(windowStateChanged(Qt::WindowState)), this, SLOT(onWindowStateChanged(Qt::WindowState)));
_maximized = (window()->windowState() & Qt::WindowMaximized);
updateMaximizeRestoreButton();
_maximizedState = (window()->windowState() & Qt::WindowMaximized);
_activeState = isActiveWindow();
updateButtonsState();
}
void TitleWidget::paintEvent(QPaintEvent *e) {
Painter(this).fillRect(rect(), st::titleBg);
auto active = isActiveWindow();
if (_activeState != active) {
_activeState = active;
updateButtonsState();
}
Painter(this).fillRect(rect(), active ? st::titleBgActive : st::titleBg);
}
void TitleWidget::updateControlsPosition() {
@@ -84,18 +90,20 @@ void TitleWidget::onWindowStateChanged(Qt::WindowState state) {
if (state == Qt::WindowMinimized) return;
auto maximized = (state == Qt::WindowMaximized);
if (_maximized != maximized) {
_maximized = maximized;
updateMaximizeRestoreButton();
if (_maximizedState != maximized) {
_maximizedState = maximized;
updateButtonsState();
}
}
void TitleWidget::updateMaximizeRestoreButton() {
if (_maximized) {
_maximizeRestore->setIconOverride(&st::titleButtonRestoreIcon, &st::titleButtonRestoreIconOver);
void TitleWidget::updateButtonsState() {
_minimize->setIconOverride(_activeState ? &st::titleButtonMinimizeIconActive : nullptr, _activeState ? &st::titleButtonMinimizeIconActiveOver : nullptr);
if (_maximizedState) {
_maximizeRestore->setIconOverride(_activeState ? &st::titleButtonRestoreIconActive : &st::titleButtonRestoreIcon, _activeState ? &st::titleButtonRestoreIconActiveOver : &st::titleButtonRestoreIconOver);
} else {
_maximizeRestore->setIconOverride(nullptr, nullptr);
_maximizeRestore->setIconOverride(_activeState ? &st::titleButtonMaximizeIconActive : nullptr, _activeState ? &st::titleButtonMaximizeIconActiveOver : nullptr);
}
_close->setIconOverride(_activeState ? &st::titleButtonCloseIconActive : nullptr, _activeState ? &st::titleButtonCloseIconActiveOver : nullptr);
}
Window::HitTestResult TitleWidget::hitTest(const QPoint &p) const {

View File

@@ -57,7 +57,7 @@ protected:
void resizeEvent(QResizeEvent *e) override;
private:
void updateMaximizeRestoreButton();
void updateButtonsState();
void updateControlsPosition();
object_ptr<Ui::IconButton> _minimize;
@@ -65,7 +65,8 @@ private:
object_ptr<Ui::IconButton> _close;
object_ptr<Ui::PlainShadow> _shadow;
bool _maximized = false;
bool _maximizedState = false;
bool _activeState = false;
};