Alpha 1.0.7: Theme editor added to Settings.

This commit is contained in:
John Preston 2017-02-07 20:39:47 +03:00
parent b842761ea3
commit 27a4d0f029
13 changed files with 61 additions and 52 deletions

View File

@ -224,7 +224,6 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
"lng_settings_crop_profile" = "Select a square area for your profile photo"; "lng_settings_crop_profile" = "Select a square area for your profile photo";
"lng_settings_uploading_photo" = "Uploading photo..."; "lng_settings_uploading_photo" = "Uploading photo...";
"lng_settings_edit" = "Edit"; "lng_settings_edit" = "Edit";
"lng_settings_drop_area_subtitle" = "to set it as your photo"; "lng_settings_drop_area_subtitle" = "to set it as your photo";
"lng_username_title" = "Username"; "lng_username_title" = "Username";
@ -296,6 +295,7 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
"lng_settings_bg_use_default" = "Use default color theme"; "lng_settings_bg_use_default" = "Use default color theme";
"lng_settings_bg_from_gallery" = "Choose from gallery"; "lng_settings_bg_from_gallery" = "Choose from gallery";
"lng_settings_bg_from_file" = "Choose from file"; "lng_settings_bg_from_file" = "Choose from file";
"lng_settings_bg_edit_theme" = "Edit theme";
"lng_settings_bg_tile" = "Tile background"; "lng_settings_bg_tile" = "Tile background";
"lng_settings_adaptive_wide" = "Adaptive layout for wide screens"; "lng_settings_adaptive_wide" = "Adaptive layout for wide screens";
@ -1024,7 +1024,7 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
"lng_confirm_phone_enter_code" = "Please enter the code."; "lng_confirm_phone_enter_code" = "Please enter the code.";
"lng_theme_editor_no_keys" = "No keys in the palette yet"; "lng_theme_editor_no_keys" = "No keys in the palette yet";
"lng_theme_editor_cant_change_theme" = "You can not apply themes while you edit a color palette. Please close the palette editor first."; "lng_theme_editor_cant_change_theme" = "You can not apply new themes while you're editing the color palette. Please close the theme editor first.";
"lng_theme_editor_new_keys" = "Not in the palette yet"; "lng_theme_editor_new_keys" = "Not in the palette yet";
"lng_theme_editor_background_image" = "Background image"; "lng_theme_editor_background_image" = "Background image";
"lng_theme_editor_saved_to_jpg" = "Saved to JPEG, {size}"; "lng_theme_editor_saved_to_jpg" = "Saved to JPEG, {size}";
@ -1033,9 +1033,9 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
"lng_theme_editor_export" = "Export"; "lng_theme_editor_export" = "Export";
"lng_theme_editor_choose_image" = "Choose background image"; "lng_theme_editor_choose_image" = "Choose background image";
"lng_theme_editor_save_palette" = "Save palette file"; "lng_theme_editor_save_palette" = "Save palette file";
"lng_theme_editor_choose_name" = "Choose theme filename"; "lng_theme_editor_choose_name" = "Save theme file";
"lng_theme_editor_error" = "Editor encountered an error :( See 'log.txt' for details."; "lng_theme_editor_error" = "The editor encountered an error :( See 'log.txt' for details.";
"lng_theme_editor_done" = "Theme export was successfull!"; "lng_theme_editor_done" = "Theme exported successfully!";
"lng_theme_editor_title" = "Edit color palette"; "lng_theme_editor_title" = "Edit color palette";
"lng_theme_editor_export_button" = "Export theme"; "lng_theme_editor_export_button" = "Export theme";

View File

@ -6,7 +6,7 @@
<Identity Name="TelegramDesktop" <Identity Name="TelegramDesktop"
ProcessorArchitecture="x64" ProcessorArchitecture="x64"
Publisher="CN=Telegram Messenger LLP, O=Telegram Messenger LLP, L=London, C=GB" Publisher="CN=Telegram Messenger LLP, O=Telegram Messenger LLP, L=London, C=GB"
Version="1.0.6.1" /> Version="1.0.7.0" />
<Properties> <Properties>
<DisplayName>Telegram Desktop</DisplayName> <DisplayName>Telegram Desktop</DisplayName>
<PublisherDisplayName>Telegram Messenger LLP</PublisherDisplayName> <PublisherDisplayName>Telegram Messenger LLP</PublisherDisplayName>

View File

@ -34,8 +34,8 @@ IDI_ICON1 ICON "..\\art\\icon256.ico"
// //
VS_VERSION_INFO VERSIONINFO VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,0,6,1 FILEVERSION 1,0,7,0
PRODUCTVERSION 1,0,6,1 PRODUCTVERSION 1,0,7,0
FILEFLAGSMASK 0x3fL FILEFLAGSMASK 0x3fL
#ifdef _DEBUG #ifdef _DEBUG
FILEFLAGS 0x1L FILEFLAGS 0x1L
@ -51,10 +51,10 @@ BEGIN
BLOCK "040904b0" BLOCK "040904b0"
BEGIN BEGIN
VALUE "CompanyName", "Telegram Messenger LLP" VALUE "CompanyName", "Telegram Messenger LLP"
VALUE "FileVersion", "1.0.6.1" VALUE "FileVersion", "1.0.7.0"
VALUE "LegalCopyright", "Copyright (C) 2014-2017" VALUE "LegalCopyright", "Copyright (C) 2014-2017"
VALUE "ProductName", "Telegram Desktop" VALUE "ProductName", "Telegram Desktop"
VALUE "ProductVersion", "1.0.6.1" VALUE "ProductVersion", "1.0.7.0"
END END
END END
BLOCK "VarFileInfo" BLOCK "VarFileInfo"

View File

@ -25,8 +25,8 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
// //
VS_VERSION_INFO VERSIONINFO VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,0,6,1 FILEVERSION 1,0,7,0
PRODUCTVERSION 1,0,6,1 PRODUCTVERSION 1,0,7,0
FILEFLAGSMASK 0x3fL FILEFLAGSMASK 0x3fL
#ifdef _DEBUG #ifdef _DEBUG
FILEFLAGS 0x1L FILEFLAGS 0x1L
@ -43,10 +43,10 @@ BEGIN
BEGIN BEGIN
VALUE "CompanyName", "Telegram Messenger LLP" VALUE "CompanyName", "Telegram Messenger LLP"
VALUE "FileDescription", "Telegram Updater" VALUE "FileDescription", "Telegram Updater"
VALUE "FileVersion", "1.0.6.1" VALUE "FileVersion", "1.0.7.0"
VALUE "LegalCopyright", "Copyright (C) 2014-2017" VALUE "LegalCopyright", "Copyright (C) 2014-2017"
VALUE "ProductName", "Telegram Desktop" VALUE "ProductName", "Telegram Desktop"
VALUE "ProductVersion", "1.0.6.1" VALUE "ProductVersion", "1.0.7.0"
END END
END END
BLOCK "VarFileInfo" BLOCK "VarFileInfo"

View File

@ -1069,8 +1069,8 @@ void AppClass::checkMapVersion() {
if (Local::oldMapVersion() < AppVersion) { if (Local::oldMapVersion() < AppVersion) {
if (Local::oldMapVersion()) { if (Local::oldMapVersion()) {
QString versionFeatures; QString versionFeatures;
if ((cAlphaVersion() || cBetaVersion()) && Local::oldMapVersion() < 1000004) { if ((cAlphaVersion() || cBetaVersion()) && Local::oldMapVersion() < 1000007) {
versionFeatures = QString::fromUtf8("\xe2\x80\x94 Click and drag to reorder pinned chats."); versionFeatures = QString::fromUtf8("\xe2\x80\x94 Added Theme editor to Settings.");
} else if (!(cAlphaVersion() || cBetaVersion()) && Local::oldMapVersion() < 1000005) { } else if (!(cAlphaVersion() || cBetaVersion()) && Local::oldMapVersion() < 1000005) {
versionFeatures = langNewVersionText(); versionFeatures = langNewVersionText();
} else { } else {

View File

@ -22,9 +22,9 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
#include "core/utils.h" #include "core/utils.h"
#define BETA_VERSION_MACRO (1000006001ULL) #define BETA_VERSION_MACRO (0ULL)
constexpr int AppVersion = 1000006; constexpr int AppVersion = 1000007;
constexpr str_const AppVersionStr = "1.0.6"; constexpr str_const AppVersionStr = "1.0.7";
constexpr bool AppAlphaVersion = false; constexpr bool AppAlphaVersion = true;
constexpr uint64 AppBetaVersion = BETA_VERSION_MACRO; constexpr uint64 AppBetaVersion = BETA_VERSION_MACRO;

View File

@ -31,17 +31,20 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
#include "localstorage.h" #include "localstorage.h"
#include "mainwindow.h" #include "mainwindow.h"
#include "window/themes/window_theme.h" #include "window/themes/window_theme.h"
#include "window/themes/window_theme_editor.h"
namespace Settings { namespace Settings {
BackgroundRow::BackgroundRow(QWidget *parent) : TWidget(parent) BackgroundRow::BackgroundRow(QWidget *parent) : TWidget(parent)
, _chooseFromGallery(this, lang(lng_settings_bg_from_gallery), st::boxLinkButton) , _chooseFromGallery(this, lang(lng_settings_bg_from_gallery), st::boxLinkButton)
, _chooseFromFile(this, lang(lng_settings_bg_from_file), st::boxLinkButton) , _chooseFromFile(this, lang(lng_settings_bg_from_file), st::boxLinkButton)
, _editTheme(this, lang(lng_settings_bg_edit_theme), st::boxLinkButton)
, _radial(animation(this, &BackgroundRow::step_radial)) { , _radial(animation(this, &BackgroundRow::step_radial)) {
updateImage(); updateImage();
connect(_chooseFromGallery, SIGNAL(clicked()), this, SIGNAL(chooseFromGallery())); connect(_chooseFromGallery, SIGNAL(clicked()), this, SIGNAL(chooseFromGallery()));
connect(_chooseFromFile, SIGNAL(clicked()), this, SIGNAL(chooseFromFile())); connect(_chooseFromFile, SIGNAL(clicked()), this, SIGNAL(chooseFromFile()));
connect(_editTheme, SIGNAL(clicked()), this, SIGNAL(editTheme()));
checkNonDefaultTheme(); checkNonDefaultTheme();
subscribe(Window::Theme::Background(), [this](const Window::Theme::BackgroundUpdate &update) { subscribe(Window::Theme::Background(), [this](const Window::Theme::BackgroundUpdate &update) {
if (update.type == Window::Theme::BackgroundUpdate::Type::ApplyingTheme) { if (update.type == Window::Theme::BackgroundUpdate::Type::ApplyingTheme) {
@ -108,6 +111,7 @@ int BackgroundRow::resizeGetHeight(int newWidth) {
auto linkWidth = newWidth - linkLeft; auto linkWidth = newWidth - linkLeft;
_chooseFromGallery->resizeToWidth(qMin(linkWidth, _chooseFromGallery->naturalWidth())); _chooseFromGallery->resizeToWidth(qMin(linkWidth, _chooseFromGallery->naturalWidth()));
_chooseFromFile->resizeToWidth(qMin(linkWidth, _chooseFromFile->naturalWidth())); _chooseFromFile->resizeToWidth(qMin(linkWidth, _chooseFromFile->naturalWidth()));
_editTheme->resizeToWidth(qMin(linkWidth, _editTheme->naturalWidth()));
if (_useDefaultTheme) { if (_useDefaultTheme) {
_useDefaultTheme->resizeToWidth(qMin(linkWidth, _useDefaultTheme->naturalWidth())); _useDefaultTheme->resizeToWidth(qMin(linkWidth, _useDefaultTheme->naturalWidth()));
_useDefaultTheme->moveToLeft(linkLeft, linkTop, newWidth); _useDefaultTheme->moveToLeft(linkLeft, linkTop, newWidth);
@ -116,6 +120,8 @@ int BackgroundRow::resizeGetHeight(int newWidth) {
_chooseFromGallery->moveToLeft(linkLeft, linkTop, newWidth); _chooseFromGallery->moveToLeft(linkLeft, linkTop, newWidth);
linkTop += _chooseFromGallery->height() + st::settingsSmallSkip; linkTop += _chooseFromGallery->height() + st::settingsSmallSkip;
_chooseFromFile->moveToLeft(linkLeft, linkTop, newWidth); _chooseFromFile->moveToLeft(linkLeft, linkTop, newWidth);
linkTop += _chooseFromFile->height() + st::settingsSmallSkip;
_editTheme->moveToLeft(linkLeft, linkTop, newWidth);
return st::settingsBackgroundSize; return st::settingsBackgroundSize;
} }
@ -220,6 +226,7 @@ void BackgroundWidget::createControls() {
addChildRow(_background, margin); addChildRow(_background, margin);
connect(_background, SIGNAL(chooseFromGallery()), this, SLOT(onChooseFromGallery())); connect(_background, SIGNAL(chooseFromGallery()), this, SLOT(onChooseFromGallery()));
connect(_background, SIGNAL(chooseFromFile()), this, SLOT(onChooseFromFile())); connect(_background, SIGNAL(chooseFromFile()), this, SLOT(onChooseFromFile()));
connect(_background, SIGNAL(editTheme()), this, SLOT(onEditTheme()));
connect(_background, SIGNAL(useDefault()), this, SLOT(onUseDefaultTheme())); connect(_background, SIGNAL(useDefault()), this, SLOT(onUseDefaultTheme()));
addChildRow(_tile, margin, lang(lng_settings_bg_tile), SLOT(onTile()), Window::Theme::Background()->tile()); addChildRow(_tile, margin, lang(lng_settings_bg_tile), SLOT(onTile()), Window::Theme::Background()->tile());
@ -246,6 +253,10 @@ void BackgroundWidget::onChooseFromFile() {
_chooseFromFileQueryId = FileDialog::queryReadFile(lang(lng_choose_image), filters.join(qsl(";;"))); _chooseFromFileQueryId = FileDialog::queryReadFile(lang(lng_choose_image), filters.join(qsl(";;")));
} }
void BackgroundWidget::onEditTheme() {
Window::Theme::Editor::Start();
}
void BackgroundWidget::onUseDefaultTheme() { void BackgroundWidget::onUseDefaultTheme() {
Window::Theme::ApplyDefault(); Window::Theme::ApplyDefault();
} }

View File

@ -42,6 +42,7 @@ protected:
signals: signals:
void chooseFromGallery(); void chooseFromGallery();
void chooseFromFile(); void chooseFromFile();
void editTheme();
void useDefault(); void useDefault();
private: private:
@ -58,6 +59,7 @@ private:
object_ptr<Ui::LinkButton> _useDefaultTheme = { nullptr }; object_ptr<Ui::LinkButton> _useDefaultTheme = { nullptr };
object_ptr<Ui::LinkButton> _chooseFromGallery; object_ptr<Ui::LinkButton> _chooseFromGallery;
object_ptr<Ui::LinkButton> _chooseFromFile; object_ptr<Ui::LinkButton> _chooseFromFile;
object_ptr<Ui::LinkButton> _editTheme;
Ui::RadialAnimation _radial; Ui::RadialAnimation _radial;
@ -72,6 +74,7 @@ public:
private slots: private slots:
void onChooseFromGallery(); void onChooseFromGallery();
void onChooseFromFile(); void onChooseFromFile();
void onEditTheme();
void onUseDefaultTheme(); void onUseDefaultTheme();
void onTile(); void onTile();
void onAdaptive(); void onAdaptive();

View File

@ -100,14 +100,7 @@ void fillCodes() {
}); });
}); });
Codes.insert(qsl("edittheme"), []() { Codes.insert(qsl("edittheme"), []() {
auto palettePath = Local::themePaletteAbsolutePath(); Window::Theme::Editor::Start();
if (palettePath.isEmpty()) {
FileDialog::askWritePath(lang(lng_theme_editor_save_palette), "Palette (*.tdesktop-palette)", "colors.tdesktop-palette", [](const QString &path) {
Window::Theme::Editor::StartFromCurrentTheme(path);
});
} else {
Window::Theme::Editor::Start(palettePath);
}
}); });
} }

View File

@ -731,18 +731,6 @@ Editor::Editor(QWidget*, const QString &path)
resizeToWidth(st::windowMinWidth); resizeToWidth(st::windowMinWidth);
} }
void Editor::StartFromCurrentTheme(const QString &path) {
if (!Local::copyThemeColorsToPalette(path)) {
writeDefaultPalette(path);
}
if (!Apply(path)) {
Ui::show(Box<InformBox>(lang(lng_theme_editor_error)));
return;
}
KeepApplied();
Start(path);
}
void Editor::resizeEvent(QResizeEvent *e) { void Editor::resizeEvent(QResizeEvent *e) {
_export->resizeToWidth(width()); _export->resizeToWidth(width());
_close->moveToRight(0, 0); _close->moveToRight(0, 0);
@ -801,9 +789,24 @@ void Editor::paintEvent(QPaintEvent *e) {
p.drawTextLeft(st::themeEditorMargin.left(), st::themeEditorMargin.top(), width(), lang(lng_theme_editor_title)); p.drawTextLeft(st::themeEditorMargin.left(), st::themeEditorMargin.top(), width(), lang(lng_theme_editor_title));
} }
void Editor::Start(const QString &path) { void Editor::Start() {
if (auto window = App::wnd()) { auto palettePath = Local::themePaletteAbsolutePath();
window->showRightColumn(Box<Editor>(path)); if (palettePath.isEmpty()) {
FileDialog::askWritePath(lang(lng_theme_editor_save_palette), "Palette (*.tdesktop-palette)", "colors.tdesktop-palette", [](const QString &path) {
if (!Local::copyThemeColorsToPalette(path)) {
writeDefaultPalette(path);
}
if (!Apply(path)) {
Ui::show(Box<InformBox>(lang(lng_theme_editor_error)));
return;
}
KeepApplied();
if (auto window = App::wnd()) {
window->showRightColumn(Box<Editor>(path));
}
});
} else if (auto window = App::wnd()) {
window->showRightColumn(Box<Editor>(palettePath));
} }
} }

View File

@ -38,8 +38,7 @@ class Editor : public TWidget {
public: public:
Editor(QWidget*, const QString &path); Editor(QWidget*, const QString &path);
static void StartFromCurrentTheme(const QString &path); static void Start();
static void Start(const QString &path);
protected: protected:
void paintEvent(QPaintEvent *e) override; void paintEvent(QPaintEvent *e) override;

View File

@ -175,8 +175,8 @@ if %BuildUWP% equ 0 (
if %errorlevel% neq 0 goto error if %errorlevel% neq 0 goto error
if %BetaVersion% neq 0 ( if %BetaVersion% neq 0 (
set "UpdateFile=%UpdateFile%_%BetaSignature%" set "UpdateFile=!UpdateFile!_!BetaSignature!"
set "PortableFile=tbeta%BetaVersion%_%BetaSignature%.zip" set "PortableFile=tbeta!BetaVersion!_!BetaSignature!.zip"
) )
) )

View File

@ -1,6 +1,6 @@
AppVersion 1000006 AppVersion 1000007
AppVersionStrMajor 1.0 AppVersionStrMajor 1.0
AppVersionStrSmall 1.0.6 AppVersionStrSmall 1.0.7
AppVersionStr 1.0.6 AppVersionStr 1.0.7
AlphaChannel 0 AlphaChannel 1
BetaVersion 1000006001 BetaVersion 0