2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 06:26:18 +00:00
This commit is contained in:
John Preston
2014-07-24 20:43:30 +02:00
16 changed files with 133 additions and 35 deletions

View File

@@ -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

View File

@@ -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);

View File

@@ -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();

View File

@@ -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();

View File

@@ -27,6 +27,7 @@ Copyright (c) 2014 John Preston, https://tdesktop.com
#include <cstdlib>
#include <unistd.h>
#include <dirent.h>
#include <pwd.h>
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[]) {

View File

@@ -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();