adaptive layout checkbox added to settings

This commit is contained in:
John Preston 2016-02-21 17:27:54 +03:00
parent fb0f2971c0
commit fc9d75b4f0
7 changed files with 53 additions and 4 deletions

View file

@ -348,6 +348,7 @@ namespace Sandbox {
struct GlobalDataStruct {
uint64 LaunchId = 0;
Adaptive::Layout AdaptiveLayout = Adaptive::NormalLayout;
bool AdaptiveForWide = true;
};
GlobalDataStruct *GlobalData = 0;
@ -370,5 +371,6 @@ namespace Global {
DefineReadOnlyVar(Global, uint64, LaunchId);
DefineVar(Global, Adaptive::Layout, AdaptiveLayout);
DefineVar(Global, bool, AdaptiveForWide);
};

View file

@ -139,6 +139,7 @@ namespace Global {
DeclareReadOnlyVar(uint64, LaunchId);
DeclareVar(Adaptive::Layout, AdaptiveLayout);
DeclareVar(bool, AdaptiveForWide);
};
@ -150,6 +151,6 @@ namespace Adaptive {
return Global::AdaptiveLayout() == NormalLayout;
}
inline bool Wide() {
return Global::AdaptiveLayout() == WideLayout;
return Global::AdaptiveForWide() && (Global::AdaptiveLayout() == WideLayout);
}
}

View file

@ -4690,6 +4690,7 @@ void HistoryWidget::doneShow() {
void HistoryWidget::updateAdaptiveLayout() {
_sideShadow.setVisible(!Adaptive::OneColumn());
update();
}
void HistoryWidget::animStop() {

View file

@ -1121,6 +1121,14 @@ namespace {
}
} break;
case dbiAdaptiveForWide: {
qint32 v;
stream >> v;
if (!_checkStreamStatus(stream)) return false;
Global::SetAdaptiveForWide(v == 1);
} break;
case dbiAutoLock: {
qint32 v;
stream >> v;
@ -1506,6 +1514,7 @@ namespace {
EncryptedDescriptor data(size);
data.stream << quint32(dbiSendKey) << qint32(cCtrlEnter() ? dbiskCtrlEnter : dbiskEnter);
data.stream << quint32(dbiTileBackground) << qint32(cTileBackground() ? 1 : 0);
data.stream << quint32(dbiAdaptiveForWide) << qint32(Global::AdaptiveForWide() ? 1 : 0);
data.stream << quint32(dbiAutoLock) << qint32(cAutoLock());
data.stream << quint32(dbiReplaceEmojis) << qint32(cReplaceEmojis() ? 1 : 0);
data.stream << quint32(dbiDefaultAttach) << qint32(cDefaultAttach());

View file

@ -187,6 +187,7 @@ SettingsInner::SettingsInner(SettingsWidget *parent) : TWidget(parent)
, _backFromGallery(this, lang(lng_settings_bg_from_gallery))
, _backFromFile(this, lang(lng_settings_bg_from_file))
, _tileBackground(this, lang(lng_settings_bg_tile), cTileBackground())
, _adaptiveForWide(this, lang(lng_settings_adaptive_wide), Global::AdaptiveForWide())
, _needBackgroundUpdate(false)
// advanced
@ -310,6 +311,7 @@ SettingsInner::SettingsInner(SettingsWidget *parent) : TWidget(parent)
connect(&_backFromGallery, SIGNAL(clicked()), this, SLOT(onBackFromGallery()));
connect(&_backFromFile, SIGNAL(clicked()), this, SLOT(onBackFromFile()));
connect(&_tileBackground, SIGNAL(changed()), this, SLOT(onTileBackground()));
connect(&_adaptiveForWide, SIGNAL(changed()), this, SLOT(onAdaptiveForWide()));
// advanced
connect(&_passcodeEdit, SIGNAL(clicked()), this, SLOT(onPasscode()));
@ -635,6 +637,10 @@ void SettingsInner::paintEvent(QPaintEvent *e) {
top += st::setBackgroundSize;
top += st::setLittleSkip;
top += _tileBackground.height();
if (Global::AdaptiveLayout() == Adaptive::WideLayout) {
top += st::setLittleSkip;
top += _adaptiveForWide.height();
}
}
// advanced
@ -753,6 +759,10 @@ void SettingsInner::resizeEvent(QResizeEvent *e) {
top += st::setLittleSkip;
_tileBackground.move(_left, top); top += _tileBackground.height();
if (Global::AdaptiveLayout() == Adaptive::WideLayout) {
top += st::setLittleSkip;
_adaptiveForWide.move(_left, top); top += _adaptiveForWide.height();
}
}
// advanced
@ -855,6 +865,11 @@ void SettingsInner::mousePressEvent(QMouseEvent *e) {
void SettingsInner::contextMenuEvent(QContextMenuEvent *e) {
}
void SettingsInner::updateAdaptiveLayout() {
showAll();
resizeEvent(0);
}
void SettingsInner::step_photo(float64 ms, bool timer) {
float64 dt = ms / st::setPhotoDuration;
if (dt >= 1) {
@ -1093,10 +1108,16 @@ void SettingsInner::showAll() {
_backFromGallery.show();
_backFromFile.show();
_tileBackground.show();
if (Global::AdaptiveLayout() == Adaptive::WideLayout) {
_adaptiveForWide.show();
} else {
_adaptiveForWide.hide();
}
} else {
_backFromGallery.hide();
_backFromFile.hide();
_tileBackground.hide();
_adaptiveForWide.hide();
}
// advanced
@ -1628,6 +1649,16 @@ void SettingsInner::onTileBackground() {
}
}
void SettingsInner::onAdaptiveForWide() {
if (Global::AdaptiveForWide() != _adaptiveForWide.checked()) {
Global::SetAdaptiveForWide(_adaptiveForWide.checked());
if (App::wnd()) {
App::wnd()->updateAdaptiveLayout();
}
Local::writeUserSettings();
}
}
void SettingsInner::onDontAskDownloadPath() {
cSetAskDownloadPath(!_dontAskDownloadPath.checked());
Local::writeUserSettings();
@ -1898,10 +1929,11 @@ void SettingsWidget::updateAdaptiveLayout() {
} else {
_close.show();
}
_inner.updateAdaptiveLayout();
resizeEvent(0);
}
void SettingsWidget::updateDisplayNotify()
{
void SettingsWidget::updateDisplayNotify() {
_inner.enableDisplayNotify(cDesktopNotify());
}

View file

@ -71,6 +71,8 @@ public:
void mousePressEvent(QMouseEvent *e);
void contextMenuEvent(QContextMenuEvent *e);
void updateAdaptiveLayout();
void step_photo(float64 ms, bool timer);
void updateSize(int32 newWidth);
@ -156,6 +158,7 @@ public slots:
void onBackFromGallery();
void onBackFromFile();
void onTileBackground();
void onAdaptiveForWide();
void onLocalStorageClear();
@ -273,7 +276,7 @@ private:
// chat background
QPixmap _background;
LinkButton _backFromGallery, _backFromFile;
FlatCheckbox _tileBackground;
FlatCheckbox _tileBackground, _adaptiveForWide;
bool _needBackgroundUpdate;
// advanced

View file

@ -352,6 +352,7 @@ enum DataBlockId {
dbiSavedGifsLimit = 0x35,
dbiShowingSavedGifs = 0x36,
dbiAutoPlay = 0x37,
dbiAdaptiveForWide = 0x38,
dbiEncryptedWithSalt = 333,
dbiEncrypted = 444,