From e1f2886f9dda2880cca91b7841a882a9b01f6a78 Mon Sep 17 00:00:00 2001 From: John Preston Date: Thu, 24 Jul 2014 18:00:35 +0200 Subject: [PATCH] linux version stores data to home dir, fixed keyboard layout switch, fixed notify windows, version 0.5.10 --- QTCREATOR.md | 6 +- Telegram/PrepareLinux.sh | 4 +- Telegram/PrepareLinux32.sh | 4 +- Telegram/PrepareMac.sh | 4 +- Telegram/Setup.iss | 6 +- Telegram/SourceFiles/config.h | 4 +- Telegram/SourceFiles/gui/filedialog.cpp | 28 ++++++++- Telegram/SourceFiles/logs.cpp | 59 ++++++++++++++++-- Telegram/SourceFiles/mainwidget.cpp | 2 +- Telegram/SourceFiles/pspecific_linux.cpp | 7 ++- Telegram/SourceFiles/window.cpp | 2 +- Telegram/Telegram.plist | 2 +- Telegram/Telegram.pro | 5 +- Telegram/Telegram.rc | Bin 5558 -> 5566 bytes Telegram/Telegram.xcodeproj/project.pbxproj | 12 ++-- .../qtmultimedia/src/plugins/alsa/alsa.pro | 23 +++++++ 16 files changed, 133 insertions(+), 35 deletions(-) create mode 100644 Telegram/_qt_5_3_1_patch/qtmultimedia/src/plugins/alsa/alsa.pro diff --git a/QTCREATOR.md b/QTCREATOR.md index 74942a793c9b4..e76a600f0c3fa 100644 --- a/QTCREATOR.md +++ b/QTCREATOR.md @@ -22,7 +22,7 @@ Choose a folder for the future build, for example **/home/user/TBuild** There yo By git – in Terminal go to **/home/user/TBuild** and run - git clone https://github.com/telegramdesktop/tdesktop.git + git clone https://github.com/telegramdesktop/tdesktop.git or download in ZIP and extract to **/home/user/TBuild** rename **tdesktop-master** to **tdesktop** to have **/home/user/TBuild/tdesktop/Telegram/Telegram.pro** project @@ -44,11 +44,11 @@ Apply patch – copy (with overwrite!) everything from **/home/user/TBuild/tdesk Install some packages for Qt (see **/home/user/TBuild/Libraries/QtStatic/qtbase/src/plugins/platforms/xcb/README**) - sudo apt-get install libxcb1-dev libxcb-image0-dev libxcb-keysyms1-dev libxcb-icccm4-dev libxcb-render-util0-dev libxcb-util0-dev libxrender-dev libpulse-dev libxcb-sync0-dev libxcb-xfixes0-dev libxcb-randr0-dev libx11-xcb-dev + sudo apt-get install libxcb1-dev libxcb-image0-dev libxcb-keysyms1-dev libxcb-icccm4-dev libxcb-render-util0-dev libxcb-util0-dev libxrender-dev libasound-dev libpulse-dev libxcb-sync0-dev libxcb-xfixes0-dev libxcb-randr0-dev libx11-xcb-dev In Terminal go to **/home/user/TBuild/Libraries/QtStatic** and there run - ./configure -release -opensource -no-opengl -static -nomake examples -skip qtquick1 -skip qtdeclarative + ./configure -release -opensource -confirm-license -qt-xcb -no-opengl -static -nomake examples -skip qtquick1 -skip qtdeclarative y make sudo make install diff --git a/Telegram/PrepareLinux.sh b/Telegram/PrepareLinux.sh index dfa0a2a3a675d..e1e0c3f92de1b 100755 --- a/Telegram/PrepareLinux.sh +++ b/Telegram/PrepareLinux.sh @@ -1,5 +1,5 @@ -AppVersionStr=0.5.9 -AppVersion=5009 +AppVersionStr=0.5.10 +AppVersion=5010 if [ -d "./../Linux/Release/deploy/$AppVersionStr" ]; then echo "Deploy folder for version $AppVersionStr already exists!" diff --git a/Telegram/PrepareLinux32.sh b/Telegram/PrepareLinux32.sh index ef4d22c249769..cf9fc4cfb99cf 100755 --- a/Telegram/PrepareLinux32.sh +++ b/Telegram/PrepareLinux32.sh @@ -1,5 +1,5 @@ -AppVersionStr=0.5.9 -AppVersion=5009 +AppVersionStr=0.5.10 +AppVersion=5010 if [ -d "./../Linux/Release/deploy/$AppVersionStr" ]; then echo "Deploy folder for version $AppVersionStr already exists!" diff --git a/Telegram/PrepareMac.sh b/Telegram/PrepareMac.sh index 79d056d423e68..4b1c7fcc859d9 100755 --- a/Telegram/PrepareMac.sh +++ b/Telegram/PrepareMac.sh @@ -1,5 +1,5 @@ -AppVersionStr=0.5.9 -AppVersion=5009 +AppVersionStr=0.5.10 +AppVersion=5010 if [ -d "./../Mac/Release/deploy/$AppVersionStr" ]; then echo "Deploy folder for version $AppVersionStr already exists!" diff --git a/Telegram/Setup.iss b/Telegram/Setup.iss index 1803535ddd337..1c91de999e4cf 100644 --- a/Telegram/Setup.iss +++ b/Telegram/Setup.iss @@ -3,9 +3,9 @@ #define MyAppShortName "Telegram" #define MyAppName "Telegram Win (Unofficial)" -#define MyAppVersion "0.5.9" -#define MyAppVersionZero "0.5.9" -#define MyAppFullVersion "0.5.9.0" +#define MyAppVersion "0.5.10" +#define MyAppVersionZero "0.5.10" +#define MyAppFullVersion "0.5.10.0" #define MyAppPublisher "Telegram (Unofficial)" #define MyAppURL "https://tdesktop.com" #define MyAppExeName "Telegram.exe" diff --git a/Telegram/SourceFiles/config.h b/Telegram/SourceFiles/config.h index 043acd43502cc..ca44939cdbf66 100644 --- a/Telegram/SourceFiles/config.h +++ b/Telegram/SourceFiles/config.h @@ -17,8 +17,8 @@ Copyright (c) 2014 John Preston, https://tdesktop.com */ #pragma once -static const int32 AppVersion = 5009; -static const wchar_t *AppVersionStr = L"0.5.9"; +static const int32 AppVersion = 5010; +static const wchar_t *AppVersionStr = L"0.5.10"; #ifdef Q_OS_WIN static const wchar_t *AppName = L"Telegram Win (Unofficial)"; #else diff --git a/Telegram/SourceFiles/gui/filedialog.cpp b/Telegram/SourceFiles/gui/filedialog.cpp index e51b41db12188..41552d0aacd48 100644 --- a/Telegram/SourceFiles/gui/filedialog.cpp +++ b/Telegram/SourceFiles/gui/filedialog.cpp @@ -62,14 +62,36 @@ void filedialogInit() { } } -// multipleFiles: 1 - multi open, 0 - single open, -1 - single save +// multipleFiles: 1 - multi open, 0 - single open, -1 - single save, -2 - select dir bool _filedialogGetFiles(QStringList &files, QByteArray &remoteContent, const QString &caption, const QString &filter, int multipleFiles, const QString &startFile = QString()) { - filedialogInit(); +#if defined Q_OS_LINUX || defined Q_OS_MAC // use native + remoteContent = QByteArray(); + QString file; + if (multipleFiles >= 0) { + files = QFileDialog::getOpenFileNames(App::wnd(), caption, startFile, filter); + return !files.isEmpty(); + } else if (multipleFiles < -1) { + file = QFileDialog::getExistingDirectory(App::wnd(), caption); + } else if (multipleFiles < 0) { + file = QFileDialog::getSaveFileName(App::wnd(), caption, startFile, filter); + } else { + file = QFileDialog::getOpenFileName(App::wnd(), caption, startFile, filter); + } + if (file.isEmpty()) { + files = QStringList(); + return false; + } else { + files = QStringList(file); + return true; + } +#endif + + filedialogInit(); // hack for fast non-native dialog create QFileDialog dialog(App::wnd(), caption, cDialogHelperPathFinal(), filter); - dialog.setModal(true); + dialog.setModal(true); if (multipleFiles >= 0) { // open file or files dialog.setFileMode(multipleFiles ? QFileDialog::ExistingFiles : QFileDialog::ExistingFile); dialog.setAcceptMode(QFileDialog::AcceptOpen); diff --git a/Telegram/SourceFiles/logs.cpp b/Telegram/SourceFiles/logs.cpp index 6511348f856a1..70ecef462b626 100644 --- a/Telegram/SourceFiles/logs.cpp +++ b/Telegram/SourceFiles/logs.cpp @@ -118,12 +118,61 @@ void logWrite(const QString &v) { void logsInit() { static _StreamCreator streamCreator; if (mainLogStream) return; - -#if defined Q_OS_MAC && !defined _DEBUG - cForceWorkingDir(psAppDataPath()); + + QString wasDir = cWorkingDir(); +#if (defined Q_OS_MAC || defined Q_OS_LINUX) && !defined _DEBUG + cForceWorkingDir(psAppDataPath()); +#ifdef Q_OS_LINUX // fix first version + { + QFile data(wasDir + "data"), dataConfig(wasDir + "data_config"), tdataConfig(wasDir + "tdata/config"); + if (data.exists() && dataConfig.exists() && !QFileInfo(cWorkingDir() + "data").exists() && !QFileInfo(cWorkingDir() + "data_config").exists()) { // move to home dir + LOG(("Copying data to home dir '%1' from '%2'").arg(cWorkingDir()).arg(wasDir)); + if (data.copy(cWorkingDir() + "data")) { + LOG(("Copied 'data' to home dir")); + if (dataConfig.copy(cWorkingDir() + "data_config")) { + LOG(("Copied 'data_config' to home dir")); + bool tdataGood = true; + if (tdataConfig.exists()) { + tdataGood = false; + QDir().mkpath(cWorkingDir() + "tdata"); + if (tdataConfig.copy(cWorkingDir() + "tdata/config")) { + LOG(("Copied 'tdata/config' to home dir")); + tdataGood = true; + } else { + LOG(("Copied 'data' and 'data_config', but could not copy 'tdata/config'!")); + } + } + if (tdataGood) { + if (data.remove()) { + LOG(("Removed 'data'")); + } else { + LOG(("Could not remove 'data'")); + } + if (dataConfig.remove()) { + LOG(("Removed 'data_config'")); + } else { + LOG(("Could not remove 'data_config'")); + } + if (!tdataConfig.exists() || tdataConfig.remove()) { + LOG(("Removed 'tdata/config'")); + LOG(("Could not remove 'tdata/config'")); + } else { + } + QDir().rmdir(wasDir + "tdata"); + } + } else { + LOG(("Copied 'data', but could not copy 'data_config'!!")); + } + } else { + LOG(("Could not copy 'data'!")); + } + } + } +#endif #endif - QString oldDir = cWorkingDir(); + QString rightDir = cWorkingDir(); + cForceWorkingDir(rightDir); mainLog.setFileName(cWorkingDir() + "log.txt"); mainLog.open(QIODevice::WriteOnly | QIODevice::Text); if (!mainLog.isOpen()) { @@ -141,7 +190,7 @@ void logsInit() { mainLogStream->setDevice(&mainLog); mainLogStream->setCodec("UTF-8"); } else { - cForceWorkingDir(oldDir); + cForceWorkingDir(rightDir); } cForceWorkingDir(QDir(cWorkingDir()).absolutePath() + '/'); if (cDebug()) logsInitDebug(); diff --git a/Telegram/SourceFiles/mainwidget.cpp b/Telegram/SourceFiles/mainwidget.cpp index b9d3eb397d87d..dc2204b37d527 100644 --- a/Telegram/SourceFiles/mainwidget.cpp +++ b/Telegram/SourceFiles/mainwidget.cpp @@ -1384,7 +1384,7 @@ void MainWidget::activate() { } else { dialogs.activate(); } - } else { + } else if (App::wnd() && !App::wnd()->layerShown()) { if (!cSendPaths().isEmpty()) { hider = new HistoryHider(this); hider->show(); diff --git a/Telegram/SourceFiles/pspecific_linux.cpp b/Telegram/SourceFiles/pspecific_linux.cpp index ce080255af598..957fb125eda87 100644 --- a/Telegram/SourceFiles/pspecific_linux.cpp +++ b/Telegram/SourceFiles/pspecific_linux.cpp @@ -27,6 +27,7 @@ Copyright (c) 2014 John Preston, https://tdesktop.com #include #include #include +#include namespace { bool frameless = true; @@ -767,7 +768,11 @@ QString psCurrentLanguage() { } QString psAppDataPath() { - return QString();//objc_appDataPath(); + struct passwd *pw = getpwuid(getuid()); + if (pw && pw->pw_dir && strlen(pw->pw_dir)) { + return QString::fromLocal8Bit(pw->pw_dir) + qsl("/.TelegramDesktop/"); + } + return QString(); } QString psCurrentExeDirectory(int argc, char *argv[]) { diff --git a/Telegram/SourceFiles/window.cpp b/Telegram/SourceFiles/window.cpp index 6131e5e68d00d..44a3be1ae1258 100644 --- a/Telegram/SourceFiles/window.cpp +++ b/Telegram/SourceFiles/window.cpp @@ -107,7 +107,7 @@ NotifyWindow::NotifyWindow(HistoryItem *msg, int32 x, int32 y) : history(msg->hi setGeometry(x, aY.current(), st::notifyWidth, st::notifyHeight); aOpacity.start(1); - setWindowFlags(Qt::Tool | Qt::WindowStaysOnTopHint | Qt::FramelessWindowHint); + setWindowFlags(Qt::Tool | Qt::WindowStaysOnTopHint | Qt::FramelessWindowHint | Qt::X11BypassWindowManagerHint); setAttribute(Qt::WA_MacAlwaysShowToolWindow); show(); diff --git a/Telegram/Telegram.plist b/Telegram/Telegram.plist index 41727d8f22696..221faef6c0ec9 100644 --- a/Telegram/Telegram.plist +++ b/Telegram/Telegram.plist @@ -11,7 +11,7 @@ CFBundlePackageType APPL CFBundleShortVersionString - 0.5.9 + 0.5.10 CFBundleSignature ???? NOTE diff --git a/Telegram/Telegram.pro b/Telegram/Telegram.pro index 51bd0d8c3745b..83bdf310a6fb1 100644 --- a/Telegram/Telegram.pro +++ b/Telegram/Telegram.pro @@ -251,8 +251,8 @@ INCLUDEPATH += ./../../Libraries/QtStatic/qtbase/include/QtGui/5.3.1/QtGui\ ./../../Libraries/QtStatic/qtbase/include\ ./SourceFiles\ ./GeneratedFiles -LIBS += -lcrypto -lssl -lz -ldl -llzma -lpulse -lexif -LIBS += ./../../../Libraries/QtStatic/qtmultimedia/plugins/audio/libqtmedia_pulse.a +LIBS += -lcrypto -lssl -lz -ldl -llzma -lexif + RESOURCES += \ ./SourceFiles/telegram_linux.qrc @@ -260,4 +260,3 @@ OTHER_FILES += \ Resources/style_classes.txt \ Resources/style.txt \ Resources/lang.txt - diff --git a/Telegram/Telegram.rc b/Telegram/Telegram.rc index 4e67d78c998ab85895ba77d6f8db1a5c04604db2..2a6d0b9a5021ca652acb116aa42585ca034a13c5 100644 GIT binary patch delta 50 xcmdm{y-$0C4mYzQgTZ87ZbJ~gIi9&pn1dCMz3IfGwla|XX38vs#B4JQBq delta 58 zcmdm|y-j