2016-05-20 15:35:58 +00:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
|
|
|
the official desktop version of Telegram messaging app, see https://telegram.org
|
|
|
|
|
|
|
|
Telegram Desktop is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
It is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
In addition, as a special exception, the copyright holders give permission
|
|
|
|
to link the code of portions of this program with the OpenSSL library.
|
|
|
|
|
|
|
|
Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE
|
2017-01-11 18:31:31 +00:00
|
|
|
Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
|
2016-05-20 15:35:58 +00:00
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
2017-04-06 14:38:10 +00:00
|
|
|
#include "base/observer.h"
|
2016-06-02 13:02:55 +00:00
|
|
|
|
2016-05-20 15:35:58 +00:00
|
|
|
namespace Profile {
|
|
|
|
|
2016-10-23 21:03:10 +00:00
|
|
|
class SectionMemento;
|
|
|
|
|
2016-10-26 16:43:13 +00:00
|
|
|
class BlockWidget : public TWidget, protected base::Subscriber {
|
2016-05-20 15:35:58 +00:00
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
BlockWidget(QWidget *parent, PeerData *peer, const QString &title);
|
|
|
|
|
2016-10-23 21:03:10 +00:00
|
|
|
virtual void showFinished() {
|
|
|
|
}
|
|
|
|
|
2017-08-17 08:31:24 +00:00
|
|
|
virtual void saveState(not_null<SectionMemento*> memento) {
|
2016-10-23 21:03:10 +00:00
|
|
|
}
|
2017-08-17 08:31:24 +00:00
|
|
|
virtual void restoreState(not_null<SectionMemento*> memento) {
|
2016-10-23 21:03:10 +00:00
|
|
|
}
|
|
|
|
|
2016-05-20 15:35:58 +00:00
|
|
|
protected:
|
|
|
|
void paintEvent(QPaintEvent *e) override;
|
|
|
|
virtual void paintContents(Painter &p) {
|
|
|
|
}
|
|
|
|
|
2016-05-31 19:27:11 +00:00
|
|
|
// Where does the block content start (after the title).
|
|
|
|
int contentTop() const;
|
|
|
|
|
2016-05-20 15:35:58 +00:00
|
|
|
// Resizes content and counts natural widget height for the desired width.
|
2016-06-17 18:18:01 +00:00
|
|
|
int resizeGetHeight(int newWidth) override = 0;
|
2016-05-20 15:35:58 +00:00
|
|
|
|
2016-05-31 19:27:11 +00:00
|
|
|
void contentSizeUpdated() {
|
2016-10-23 21:03:10 +00:00
|
|
|
auto oldHeight = height();
|
2016-05-31 19:27:11 +00:00
|
|
|
resizeToWidth(width());
|
|
|
|
emit heightUpdated();
|
|
|
|
}
|
|
|
|
|
2016-05-20 15:35:58 +00:00
|
|
|
PeerData *peer() const {
|
|
|
|
return _peer;
|
|
|
|
}
|
|
|
|
|
2016-06-17 18:18:01 +00:00
|
|
|
bool emptyTitle() const {
|
|
|
|
return _title.isEmpty();
|
|
|
|
}
|
|
|
|
|
2016-05-20 15:35:58 +00:00
|
|
|
private:
|
2016-06-17 18:18:01 +00:00
|
|
|
void paintTitle(Painter &p);
|
|
|
|
|
2016-05-20 15:35:58 +00:00
|
|
|
PeerData *_peer;
|
|
|
|
QString _title;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2016-06-02 13:02:55 +00:00
|
|
|
int defaultOutlineButtonLeft();
|
|
|
|
|
2016-05-20 15:35:58 +00:00
|
|
|
} // namespace Profile
|