Skip to content

Commit

Permalink
Merge f47af14 into 9d4a859
Browse files Browse the repository at this point in the history
  • Loading branch information
crackedmind committed Dec 23, 2018
2 parents 9d4a859 + f47af14 commit 4a72fd1
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 92 deletions.
2 changes: 1 addition & 1 deletion Telegram/Resources/langs/lang.strings
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@
"lng_pinned_unpin" = "Unpin";
"lng_pinned_notify" = "Notify all members";

"lng_intro_about" = "Welcome to Kepka - the unofficial telegram app.\nIt's fast and secure.";
"lng_intro_about" = "Welcome to the {appname}, unofficial Telegram app.\nIt's fast and secure.";
"lng_start_msgs" = "START MESSAGING";

"lng_intro_next" = "NEXT";
Expand Down
91 changes: 0 additions & 91 deletions Telegram/SourceFiles/history/history_widget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@
#include "styles/style_chat_helpers.h"
#include "styles/style_dialogs.h"
#include "styles/style_history.h"
#include "styles/style_profile.h"
#include "styles/style_window.h"
#include "ui/effects/ripple_animation.h"
#include "ui/special_buttons.h"
Expand All @@ -75,96 +74,6 @@
#include "window/themes/window_theme.h"
#include "window/top_bar_widget.h"
#include "window/window_controller.h"
#include <QWindow>
// Smart pointer for QObject*, has move semantics, destroys object if it doesn't have a parent.
template <typename Object> class test_ptr {
public:
test_ptr(std::nullptr_t) {}

// No default constructor, but constructors with at least
// one argument are simply make functions.
template <typename Parent, typename... Args>
explicit test_ptr(Parent &&parent, Args &&... args)
: _object(new Object(std::forward<Parent>(parent), std::forward<Args>(args)...)) {}

test_ptr(const test_ptr &other) = delete;
test_ptr &operator=(const test_ptr &other) = delete;
test_ptr(test_ptr &&other)
: _object(base::take(other._object)) {}
test_ptr &operator=(test_ptr &&other) {
auto temp = std::move(other);
destroy();
std::swap(_object, temp._object);
return *this;
}

template <typename OtherObject, typename = std::enable_if_t<std::is_base_of<Object, OtherObject>::value>>
test_ptr(test_ptr<OtherObject> &&other)
: _object(base::take(other._object)) {}

template <typename OtherObject, typename = std::enable_if_t<std::is_base_of<Object, OtherObject>::value>>
test_ptr &operator=(test_ptr<OtherObject> &&other) {
_object = base::take(other._object);
return *this;
}

test_ptr &operator=(std::nullptr_t) {
_object = nullptr;
return *this;
}

// So we can pass this pointer to methods like connect().
Object *data() const {
return static_cast<Object *>(_object);
}
operator Object *() const {
return data();
}

explicit operator bool() const {
return _object != nullptr;
}

Object *operator->() const {
return data();
}
Object &operator*() const {
return *data();
}

// Use that instead "= new Object(parent, ...)"
template <typename Parent, typename... Args> void create(Parent &&parent, Args &&... args) {
destroy();
_object = new Object(std::forward<Parent>(parent), std::forward<Args>(args)...);
}
void destroy() {
delete base::take(_object);
}
void destroyDelayed() {
if (_object) {
if (auto widget = base::up_cast<QWidget *>(data())) {
widget->hide();
}
base::take(_object)->deleteLater();
}
}

~test_ptr() {
if (auto pointer = _object) {
if (!pointer->parent()) {
destroy();
}
}
}

private:
template <typename OtherObject> friend class test_ptr;

QPointer<QObject> _object;
};

class TestClass;
test_ptr<TestClass> tmp = {nullptr};

namespace {

Expand Down

0 comments on commit 4a72fd1

Please sign in to comment.