This commit is contained in:
John Preston 2016-02-21 17:45:17 +03:00
commit 533452acf7
17 changed files with 95 additions and 34 deletions

View File

@ -262,6 +262,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
"lng_settings_bg_from_gallery" = "Choose from gallery";
"lng_settings_bg_from_file" = "Choose from file";
"lng_settings_bg_tile" = "Tile background";
"lng_settings_adaptive_wide" = "Adaptive layout for wide screens";
"lng_backgrounds_header" = "Choose your new chat background";
@ -836,7 +837,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
"lng_new_version_wrap" = "Telegram Desktop was updated to version {version}\n\n{changes}\n\nFull version history is available here:\n{link}";
"lng_new_version_minor" = "— Bug fixes and other minor improvements";
"lng_new_version_text" = "— New waveform visualizations for voice messages\n— Sticker suggestions when you type an emoji";
"lng_new_version_text" = "— Adaptive layout for wide screens switch added to Settings\n— Linux version crash fix";
"lng_menu_insert_unicode" = "Insert Unicode control character";

View File

@ -346,7 +346,9 @@ void ApiWrap::gotUserFull(PeerData *peer, const MTPUserFull &result, mtpRequestI
App::feedUsers(MTP_vector<MTPUser>(1, d.vuser), false);
App::feedPhoto(d.vprofile_photo);
App::feedUserLink(MTP_int(peerToUser(peer->id)), d.vlink.c_contacts_link().vmy_link, d.vlink.c_contacts_link().vforeign_link, false);
App::main()->gotNotifySetting(MTP_inputNotifyPeer(peer->input), d.vnotify_settings);
if (App::main()) {
App::main()->gotNotifySetting(MTP_inputNotifyPeer(peer->input), d.vnotify_settings);
}
peer->asUser()->setBotInfo(d.vbot_info);
peer->asUser()->blocked = mtpIsTrue(d.vblocked) ? UserIsBlocked : UserIsNotBlocked;

View File

@ -925,7 +925,9 @@ void AppClass::checkLocalTime() {
void AppClass::onAppStateChanged(Qt::ApplicationState state) {
checkLocalTime();
_window->updateIsActive((state == Qt::ApplicationActive) ? cOnlineFocusTimeout() : cOfflineBlurTimeout());
if (_window) {
_window->updateIsActive((state == Qt::ApplicationActive) ? cOnlineFocusTimeout() : cOfflineBlurTimeout());
}
if (state != Qt::ApplicationActive) {
PopupTooltip::Hide();
}

View File

@ -1366,6 +1366,8 @@ void DialogsInner::selectSkipPage(int32 pixels, int32 direction) {
}
void DialogsInner::loadPeerPhotos(int32 yFrom) {
if (!parentWidget()) return;
int32 yTo = yFrom + parentWidget()->height() * 5;
MTP::clearLoaderPriorities();
if (_state == DefaultState) {

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

@ -844,10 +844,10 @@ void HistoryInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) {
} else {
uint16 symbol, selFrom = (_selected.cbegin().value() >> 16) & 0xFFFF, selTo = _selected.cbegin().value() & 0xFFFF;
hasSelected = (selTo > selFrom) ? 1 : 0;
if (_dragItem && _dragItem == App::hoveredItem()) {
QPoint mousePos(mapMouseToItem(mapFromGlobal(_dragPos), _dragItem));
if (App::mousedItem() && App::mousedItem() == App::hoveredItem()) {
QPoint mousePos(mapMouseToItem(mapFromGlobal(_dragPos), App::mousedItem()));
bool afterDragSymbol, uponSymbol;
_dragItem->getSymbol(symbol, afterDragSymbol, uponSymbol, mousePos.x(), mousePos.y());
App::mousedItem()->getSymbol(symbol, afterDragSymbol, uponSymbol, mousePos.x(), mousePos.y());
if (uponSymbol && symbol >= selFrom && symbol < selTo) {
isUponSelected = 1;
}
@ -4690,6 +4690,7 @@ void HistoryWidget::doneShow() {
void HistoryWidget::updateAdaptiveLayout() {
_sideShadow.setVisible(!Adaptive::OneColumn());
update();
}
void HistoryWidget::animStop() {
@ -7148,7 +7149,7 @@ void HistoryWidget::drawRecording(Painter &p) {
}
void HistoryWidget::paintEvent(QPaintEvent *e) {
if (App::wnd() && App::wnd()->contentOverlapped(this, e)) return;
if (!App::main() || (App::wnd() && App::wnd()->contentOverlapped(this, e))) return;
Painter p(this);
QRect r(e->rect());

View File

@ -525,7 +525,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
"lng_profile_migrate_reached" = "Limit von {count:_not_used_|# Mitglied|# Mitgliedern} erreicht";
"lng_profile_migrate_about" = "Für weitere Funktionen und um das Limit aufzuheben in Supergruppe ändern:";
"lng_profile_migrate_feature1" = "— Bis zu {count:_not_used_|# Mitglied|# ;Mitglieder} sind nun möglich";
"lng_profile_migrate_feature1" = "— Bis zu {count:_not_used_|# Mitglied|# Mitglieder} sind nun möglich";
"lng_profile_migrate_feature2" = "— Neue Mitglieder sehen gesamten Verlauf";
"lng_profile_migrate_feature3" = "— Admins können alle Nachrichten löschen";
"lng_profile_migrate_feature4" = "— Mitteilungen sind standardmäßig stumm";

View File

@ -33,7 +33,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
"lng_open_from_tray" = "Apri Telegram";
"lng_minimize_to_tray" = "Riduci a icona";
"lng_quit_from_tray" = "Chiudi Telegram";
"lng_tray_icon_text" = "Telegram è ancora attivo qui,\npuoi cambiarlo nelle impostazioni.\nSe l'icona scompare dall'area di notifica,\npuoi ripristinarla dalle icone nascoste.";
"lng_tray_icon_text" = "Telegram è ancora attivo qui,\npuoi cambiarlo nelle impostazioni.\nSe l'icona scompare dall'area di notifica,\npuoi trascinarla qui dalle icone nascoste.";
"lng_month1" = "Gennaio";
"lng_month2" = "Febbraio";
@ -276,7 +276,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
"lng_download_path_dir_radio" = "Cartella personalizzata, pulita a mano";
"lng_download_path_choose" = "Scegli il percorso di download";
"lng_sure_clear_downloads" = "Vuoi eliminare tutti i file scaricati nella cartella temporanea? Sarà fatto automaticamente alla disconnessione o alla disinstallazione del programma";
"lng_download_path_failed" = "Il download del file non può iniziare. Potrebbe accadere a causa di un'errata posizione di download.\n\nPuoi cambiare il percorso di download nelle Impostazioni.";
"lng_download_path_failed" = "Il download del file non può iniziare. La causa potrebbe essere una posizione sbagliata per i download.\n\nPuoi cambiare il percorso di download nelle Impostazioni.";
"lng_download_path_settings" = "Impostazioni";
"lng_download_finish_failed" = "Il download del file non può essere concluso.\n\nVuoi riprovare?";
"lng_download_path_clearing" = "Eliminazione..";

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

@ -560,8 +560,9 @@ void OverviewInner::dragActionFinish(const QPoint &screenPos, Qt::MouseButton bu
}
}
if (needClick) {
needClick->onClick(button);
DEBUG_LOG(("Will click link: %1 (%2) %3").arg(needClick->text()).arg(needClick->readable()).arg(needClick->encoded()));
dragActionCancel();
App::activateTextLink(needClick, button);
return;
}
if (_dragAction == PrepareSelect && !needClick && !_dragWasInactive && !_selected.isEmpty() && _selected.cbegin().value() == FullSelection) {

View File

@ -1077,6 +1077,15 @@ void ProfileInner::mouseReleaseEvent(QMouseEvent *e) {
connect(box, SIGNAL(confirmed()), this, SLOT(onKickConfirm()));
Ui::showLayer(box);
}
_kickDown = 0;
if (!_photoLink && (_peerUser || (_peerChat && !_peerChat->canEdit()) || (_peerChannel && !_amCreator))) {
setCursor((_kickOver || _kickDown || textlnkOver()) ? style::cur_pointer : style::cur_default);
} else {
setCursor((_kickOver || _kickDown || _photoOver || textlnkOver()) ? style::cur_pointer : style::cur_default);
}
update();
if (textlnkDown()) {
TextLinkPtr lnk = textlnkDown();
textlnkDown(TextLinkPtr());
@ -1087,17 +1096,10 @@ void ProfileInner::mouseReleaseEvent(QMouseEvent *e) {
if (reBotCommand().match(lnk->encoded()).hasMatch()) {
Ui::showPeerHistory(_peer, ShowAtTheEndMsgId);
}
lnk->onClick(e->button());
App::activateTextLink(lnk, e->button());
}
}
}
_kickDown = 0;
if (!_photoLink && (_peerUser || (_peerChat && !_peerChat->canEdit()) || (_peerChannel && !_amCreator))) {
setCursor((_kickOver || _kickDown || textlnkOver()) ? style::cur_pointer : style::cur_default);
} else {
setCursor((_kickOver || _kickDown || _photoOver || textlnkOver()) ? style::cur_pointer : style::cur_default);
}
update();
}
void ProfileInner::onKickConfirm() {

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

@ -688,11 +688,12 @@ void PhotoCancelLink::onClick(Qt::MouseButton button) const {
if (!data->date) return;
if (data->uploading()) {
HistoryItem *item = App::hoveredLinkItem() ? App::hoveredLinkItem() : (App::contextItem() ? App::contextItem() : 0);
if (HistoryMessage *msg = item->toHistoryMessage()) {
if (msg->getMedia() && msg->getMedia()->type() == MediaTypePhoto && static_cast<HistoryPhoto*>(msg->getMedia())->photo() == data) {
App::contextItem(item);
App::main()->deleteLayer(-2);
if (HistoryItem *item = App::hoveredLinkItem() ? App::hoveredLinkItem() : (App::contextItem() ? App::contextItem() : 0)) {
if (HistoryMessage *msg = item->toHistoryMessage()) {
if (msg->getMedia() && msg->getMedia()->type() == MediaTypePhoto && static_cast<HistoryPhoto*>(msg->getMedia())->photo() == data) {
App::contextItem(item);
App::main()->deleteLayer(-2);
}
}
}
} else {
@ -964,11 +965,12 @@ void DocumentCancelLink::onClick(Qt::MouseButton button) const {
if (!data->date) return;
if (data->uploading()) {
HistoryItem *item = App::hoveredLinkItem() ? App::hoveredLinkItem() : (App::contextItem() ? App::contextItem() : 0);
if (HistoryMessage *msg = item->toHistoryMessage()) {
if (msg->getMedia() && msg->getMedia()->getDocument() == data) {
App::contextItem(item);
App::main()->deleteLayer(-2);
if (HistoryItem *item = App::hoveredLinkItem() ? App::hoveredLinkItem() : (App::contextItem() ? App::contextItem() : 0)) {
if (HistoryMessage *msg = item->toHistoryMessage()) {
if (msg->getMedia() && msg->getMedia()->getDocument() == data) {
App::contextItem(item);
App::main()->deleteLayer(-2);
}
}
}
} else {

View File

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

View File

@ -2730,7 +2730,7 @@ void LastCrashedWindow::onUpdateFailed() {
void LastCrashedWindow::onContinue() {
if (SignalHandlers::restart() == SignalHandlers::CantOpen) {
new NotStartedWindow();
} else {
} else if (!Global::started()) {
Sandbox::launch();
}
close();