changed to 80 max column
This commit is contained in:
@@ -65,7 +65,8 @@ public:
|
||||
this->data_.insert(name, value);
|
||||
}
|
||||
|
||||
void each(std::function<void(const TKey &name, const TValue &value)> func) const
|
||||
void each(
|
||||
std::function<void(const TKey &name, const TValue &value)> func) const
|
||||
{
|
||||
QMutexLocker lock(&this->mutex_);
|
||||
|
||||
|
||||
@@ -5,7 +5,8 @@
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
void initUpdateButton(RippleEffectButton &button, std::unique_ptr<UpdateDialog> &handle,
|
||||
void initUpdateButton(RippleEffectButton &button,
|
||||
std::unique_ptr<UpdateDialog> &handle,
|
||||
pajlada::Signals::SignalHolder &signalHolder)
|
||||
{
|
||||
button.hide();
|
||||
@@ -16,7 +17,8 @@ void initUpdateButton(RippleEffectButton &button, std::unique_ptr<UpdateDialog>
|
||||
|
||||
auto dialog = new UpdateDialog();
|
||||
dialog->setActionOnFocusLoss(BaseWindow::Delete);
|
||||
dialog->move(button.mapToGlobal(QPoint(int(-100 * button.getScale()), button.height())));
|
||||
dialog->move(button.mapToGlobal(
|
||||
QPoint(int(-100 * button.getScale()), button.height())));
|
||||
dialog->show();
|
||||
dialog->raise();
|
||||
|
||||
@@ -39,15 +41,17 @@ void initUpdateButton(RippleEffectButton &button, std::unique_ptr<UpdateDialog>
|
||||
auto updateChange = [&button](auto) {
|
||||
button.setVisible(Updates::getInstance().shouldShowUpdateButton());
|
||||
|
||||
auto imageUrl = Updates::getInstance().isError() ? ":/images/download_update_error.png"
|
||||
: ":/images/download_update.png";
|
||||
auto imageUrl = Updates::getInstance().isError()
|
||||
? ":/images/download_update_error.png"
|
||||
: ":/images/download_update.png";
|
||||
button.setPixmap(QPixmap(imageUrl));
|
||||
};
|
||||
|
||||
updateChange(Updates::getInstance().getStatus());
|
||||
|
||||
signalHolder.managedConnect(Updates::getInstance().statusUpdated,
|
||||
[updateChange](auto status) { updateChange(status); });
|
||||
signalHolder.managedConnect(
|
||||
Updates::getInstance().statusUpdated,
|
||||
[updateChange](auto status) { updateChange(status); });
|
||||
}
|
||||
|
||||
} // namespace chatterino
|
||||
|
||||
@@ -13,7 +13,8 @@ namespace chatterino {
|
||||
class RippleEffectButton;
|
||||
class UpdateDialog;
|
||||
|
||||
void initUpdateButton(RippleEffectButton &button, std::unique_ptr<UpdateDialog> &handle,
|
||||
void initUpdateButton(RippleEffectButton &button,
|
||||
std::unique_ptr<UpdateDialog> &handle,
|
||||
pajlada::Signals::SignalHolder &signalHolder);
|
||||
|
||||
} // namespace chatterino
|
||||
|
||||
+22
-11
@@ -53,7 +53,8 @@ public:
|
||||
}
|
||||
|
||||
template <typename Q = T,
|
||||
typename std::enable_if<std::is_base_of<QScrollArea, Q>::value, int>::type = 0>
|
||||
typename std::enable_if<std::is_base_of<QScrollArea, Q>::value,
|
||||
int>::type = 0>
|
||||
LayoutCreator<QWidget> emplaceScrollAreaWidget()
|
||||
{
|
||||
QWidget *widget = new QWidget;
|
||||
@@ -62,8 +63,10 @@ public:
|
||||
}
|
||||
|
||||
template <typename T2, typename Q = T,
|
||||
typename std::enable_if<std::is_base_of<QWidget, Q>::value, int>::type = 0,
|
||||
typename std::enable_if<std::is_base_of<QLayout, T2>::value, int>::type = 0>
|
||||
typename std::enable_if<std::is_base_of<QWidget, Q>::value,
|
||||
int>::type = 0,
|
||||
typename std::enable_if<std::is_base_of<QLayout, T2>::value,
|
||||
int>::type = 0>
|
||||
LayoutCreator<T2> setLayoutType()
|
||||
{
|
||||
T2 *layout = new T2;
|
||||
@@ -81,7 +84,8 @@ public:
|
||||
}
|
||||
|
||||
template <typename Q = T,
|
||||
typename std::enable_if<std::is_base_of<QLayout, Q>::value, int>::type = 0>
|
||||
typename std::enable_if<std::is_base_of<QLayout, Q>::value,
|
||||
int>::type = 0>
|
||||
LayoutCreator<T> withoutMargin()
|
||||
{
|
||||
this->item_->setContentsMargins(0, 0, 0, 0);
|
||||
@@ -90,7 +94,8 @@ public:
|
||||
}
|
||||
|
||||
template <typename Q = T,
|
||||
typename std::enable_if<std::is_base_of<QWidget, Q>::value, int>::type = 0>
|
||||
typename std::enable_if<std::is_base_of<QWidget, Q>::value,
|
||||
int>::type = 0>
|
||||
LayoutCreator<T> hidden()
|
||||
{
|
||||
this->item_->setVisible(false);
|
||||
@@ -99,10 +104,12 @@ public:
|
||||
}
|
||||
|
||||
template <typename Q = T, typename T2,
|
||||
typename std::enable_if<std::is_same<QTabWidget, Q>::value, int>::type = 0>
|
||||
typename std::enable_if<std::is_same<QTabWidget, Q>::value,
|
||||
int>::type = 0>
|
||||
LayoutCreator<T2> appendTab(T2 *item, const QString &title)
|
||||
{
|
||||
static_assert(std::is_base_of<QLayout, T2>::value, "needs to be QLayout");
|
||||
static_assert(std::is_base_of<QLayout, T2>::value,
|
||||
"needs to be QLayout");
|
||||
|
||||
QWidget *widget = new QWidget;
|
||||
widget->setLayout(item);
|
||||
@@ -116,14 +123,16 @@ private:
|
||||
T *item_;
|
||||
|
||||
template <typename T2,
|
||||
typename std::enable_if<std::is_base_of<QWidget, T2>::value, int>::type = 0>
|
||||
typename std::enable_if<std::is_base_of<QWidget, T2>::value,
|
||||
int>::type = 0>
|
||||
void addItem(QLayout *layout, T2 *item)
|
||||
{
|
||||
layout->addWidget(item);
|
||||
}
|
||||
|
||||
template <typename T2,
|
||||
typename std::enable_if<std::is_base_of<QLayout, T2>::value, int>::type = 0>
|
||||
typename std::enable_if<std::is_base_of<QLayout, T2>::value,
|
||||
int>::type = 0>
|
||||
void addItem(QLayout *layout, T2 *item)
|
||||
{
|
||||
QWidget *widget = new QWidget();
|
||||
@@ -132,14 +141,16 @@ private:
|
||||
}
|
||||
|
||||
template <typename Q = T,
|
||||
typename std::enable_if<std::is_base_of<QLayout, Q>::value, int>::type = 0>
|
||||
typename std::enable_if<std::is_base_of<QLayout, Q>::value,
|
||||
int>::type = 0>
|
||||
QLayout *getOrCreateLayout()
|
||||
{
|
||||
return this->item_;
|
||||
}
|
||||
|
||||
template <typename Q = T,
|
||||
typename std::enable_if<std::is_base_of<QWidget, Q>::value, int>::type = 0>
|
||||
typename std::enable_if<std::is_base_of<QWidget, Q>::value,
|
||||
int>::type = 0>
|
||||
QLayout *getOrCreateLayout()
|
||||
{
|
||||
if (!this->item_->layout()) {
|
||||
|
||||
@@ -7,7 +7,8 @@
|
||||
|
||||
#include <functional>
|
||||
|
||||
#define async_exec(a) QThreadPool::globalInstance()->start(new LambdaRunnable(a));
|
||||
#define async_exec(a) \
|
||||
QThreadPool::globalInstance()->start(new LambdaRunnable(a));
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
|
||||
@@ -26,7 +26,8 @@ void set(rapidjson::Value &obj, const char *key, const Type &value,
|
||||
}
|
||||
|
||||
template <>
|
||||
inline void set(rapidjson::Value &obj, const char *key, const rapidjson::Value &value,
|
||||
inline void set(rapidjson::Value &obj, const char *key,
|
||||
const rapidjson::Value &value,
|
||||
rapidjson::Document::AllocatorType &a)
|
||||
{
|
||||
assert(obj.IsObject());
|
||||
@@ -45,7 +46,8 @@ void set(rapidjson::Document &obj, const char *key, const Type &value)
|
||||
}
|
||||
|
||||
template <>
|
||||
inline void set(rapidjson::Document &obj, const char *key, const rapidjson::Value &value)
|
||||
inline void set(rapidjson::Document &obj, const char *key,
|
||||
const rapidjson::Value &value)
|
||||
{
|
||||
assert(obj.IsObject());
|
||||
|
||||
@@ -55,7 +57,8 @@ inline void set(rapidjson::Document &obj, const char *key, const rapidjson::Valu
|
||||
}
|
||||
|
||||
template <typename Type>
|
||||
void add(rapidjson::Value &arr, const Type &value, rapidjson::Document::AllocatorType &a)
|
||||
void add(rapidjson::Value &arr, const Type &value,
|
||||
rapidjson::Document::AllocatorType &a)
|
||||
{
|
||||
assert(arr.IsArray());
|
||||
|
||||
|
||||
@@ -4,7 +4,8 @@
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
static void removeScrollAreaBackground(QScrollArea *scrollArea, QWidget *childWidget)
|
||||
static void removeScrollAreaBackground(QScrollArea *scrollArea,
|
||||
QWidget *childWidget)
|
||||
{
|
||||
scrollArea->setWidgetResizable(true);
|
||||
scrollArea->setFrameStyle(0);
|
||||
|
||||
@@ -6,7 +6,8 @@ namespace chatterino {
|
||||
|
||||
template <typename T>
|
||||
struct SharedPtrElementLess {
|
||||
bool operator()(const std::shared_ptr<T> &a, const std::shared_ptr<T> &b) const
|
||||
bool operator()(const std::shared_ptr<T> &a,
|
||||
const std::shared_ptr<T> &b) const
|
||||
{
|
||||
return a->operator<(*b);
|
||||
}
|
||||
|
||||
@@ -4,19 +4,21 @@
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
static void setBoolItem(QStandardItem *item, bool value, bool userCheckable = true,
|
||||
bool selectable = true)
|
||||
static void setBoolItem(QStandardItem *item, bool value,
|
||||
bool userCheckable = true, bool selectable = true)
|
||||
{
|
||||
item->setFlags((Qt::ItemFlags)(Qt::ItemIsEnabled | (selectable ? Qt::ItemIsSelectable : 0) |
|
||||
(userCheckable ? Qt::ItemIsUserCheckable : 0)));
|
||||
item->setFlags((Qt::ItemFlags)(
|
||||
Qt::ItemIsEnabled | (selectable ? Qt::ItemIsSelectable : 0) |
|
||||
(userCheckable ? Qt::ItemIsUserCheckable : 0)));
|
||||
item->setCheckState(value ? Qt::Checked : Qt::Unchecked);
|
||||
}
|
||||
|
||||
static void setStringItem(QStandardItem *item, const QString &value, bool editable = true,
|
||||
bool selectable = true)
|
||||
static void setStringItem(QStandardItem *item, const QString &value,
|
||||
bool editable = true, bool selectable = true)
|
||||
{
|
||||
item->setData(value, Qt::EditRole);
|
||||
item->setFlags((Qt::ItemFlags)(Qt::ItemIsEnabled | (selectable ? Qt::ItemIsSelectable : 0) |
|
||||
item->setFlags((Qt::ItemFlags)(Qt::ItemIsEnabled |
|
||||
(selectable ? Qt::ItemIsSelectable : 0) |
|
||||
(editable ? (Qt::ItemIsEditable) : 0)));
|
||||
}
|
||||
|
||||
|
||||
+44
-33
@@ -50,7 +50,8 @@ bool checkStreamlinkPath(const QString &path)
|
||||
|
||||
if (!fileinfo.exists()) {
|
||||
return false;
|
||||
// throw Exception(fS("Streamlink path ({}) is invalid, file does not exist", path));
|
||||
// throw Exception(fS("Streamlink path ({}) is invalid, file does not
|
||||
// exist", path));
|
||||
}
|
||||
|
||||
return fileinfo.isExecutable();
|
||||
@@ -63,11 +64,13 @@ void showStreamlinkNotFoundError()
|
||||
auto app = getApp();
|
||||
if (app->settings->streamlinkUseCustomPath) {
|
||||
msg->showMessage(
|
||||
"Unable to find Streamlink executable\nMake sure your custom path is pointing "
|
||||
"Unable to find Streamlink executable\nMake sure your custom path "
|
||||
"is pointing "
|
||||
"to the DIRECTORY where the streamlink executable is located");
|
||||
} else {
|
||||
msg->showMessage("Unable to find Streamlink executable.\nIf you have Streamlink "
|
||||
"installed, you might need to enable the custom path option");
|
||||
msg->showMessage(
|
||||
"Unable to find Streamlink executable.\nIf you have Streamlink "
|
||||
"installed, you might need to enable the custom path option");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,51 +89,58 @@ QProcess *createStreamlinkProcess()
|
||||
p->deleteLater();
|
||||
});
|
||||
|
||||
QObject::connect(p, static_cast<void (QProcess::*)(int)>(&QProcess::finished), [=](int res) {
|
||||
p->deleteLater(); //
|
||||
});
|
||||
QObject::connect(p,
|
||||
static_cast<void (QProcess::*)(int)>(&QProcess::finished),
|
||||
[=](int res) {
|
||||
p->deleteLater(); //
|
||||
});
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
void getStreamQualities(const QString &channelURL, std::function<void(QStringList)> cb)
|
||||
void getStreamQualities(const QString &channelURL,
|
||||
std::function<void(QStringList)> cb)
|
||||
{
|
||||
auto p = createStreamlinkProcess();
|
||||
|
||||
QObject::connect(p, static_cast<void (QProcess::*)(int)>(&QProcess::finished), [=](int res) {
|
||||
if (res != 0) {
|
||||
qDebug() << "Got error code" << res;
|
||||
// return;
|
||||
}
|
||||
QString lastLine = QString(p->readAllStandardOutput());
|
||||
lastLine = lastLine.trimmed().split('\n').last().trimmed();
|
||||
if (lastLine.startsWith("Available streams: ")) {
|
||||
QStringList options;
|
||||
QStringList split = lastLine.right(lastLine.length() - 19).split(", ");
|
||||
|
||||
for (int i = split.length() - 1; i >= 0; i--) {
|
||||
QString option = split.at(i);
|
||||
if (option.endsWith(" (worst)")) {
|
||||
options << option.left(option.length() - 8);
|
||||
} else if (option.endsWith(" (best)")) {
|
||||
options << option.left(option.length() - 7);
|
||||
} else {
|
||||
options << option;
|
||||
}
|
||||
QObject::connect(
|
||||
p, static_cast<void (QProcess::*)(int)>(&QProcess::finished),
|
||||
[=](int res) {
|
||||
if (res != 0) {
|
||||
qDebug() << "Got error code" << res;
|
||||
// return;
|
||||
}
|
||||
QString lastLine = QString(p->readAllStandardOutput());
|
||||
lastLine = lastLine.trimmed().split('\n').last().trimmed();
|
||||
if (lastLine.startsWith("Available streams: ")) {
|
||||
QStringList options;
|
||||
QStringList split =
|
||||
lastLine.right(lastLine.length() - 19).split(", ");
|
||||
|
||||
cb(options);
|
||||
}
|
||||
});
|
||||
for (int i = split.length() - 1; i >= 0; i--) {
|
||||
QString option = split.at(i);
|
||||
if (option.endsWith(" (worst)")) {
|
||||
options << option.left(option.length() - 8);
|
||||
} else if (option.endsWith(" (best)")) {
|
||||
options << option.left(option.length() - 7);
|
||||
} else {
|
||||
options << option;
|
||||
}
|
||||
}
|
||||
|
||||
cb(options);
|
||||
}
|
||||
});
|
||||
|
||||
p->setArguments({channelURL, "--default-stream=KKona"});
|
||||
|
||||
p->start();
|
||||
}
|
||||
|
||||
void openStreamlink(const QString &channelURL, const QString &quality, QStringList extraArguments)
|
||||
void openStreamlink(const QString &channelURL, const QString &quality,
|
||||
QStringList extraArguments)
|
||||
{
|
||||
auto app = getApp();
|
||||
|
||||
@@ -149,7 +159,8 @@ void openStreamlink(const QString &channelURL, const QString &quality, QStringLi
|
||||
arguments << quality;
|
||||
}
|
||||
|
||||
bool res = QProcess::startDetached(getStreamlinkProgram() + " " + QString(arguments.join(' ')));
|
||||
bool res = QProcess::startDetached(getStreamlinkProgram() + " " +
|
||||
QString(arguments.join(' ')));
|
||||
|
||||
if (!res) {
|
||||
showStreamlinkNotFoundError();
|
||||
|
||||
@@ -15,12 +15,13 @@ public:
|
||||
};
|
||||
|
||||
// Open streamlink for given channel, quality and extra arguments
|
||||
// the "Additional arguments" are fetched and added at the beginning of the streamlink call
|
||||
// the "Additional arguments" are fetched and added at the beginning of the
|
||||
// streamlink call
|
||||
void openStreamlink(const QString &channelURL, const QString &quality,
|
||||
QStringList extraArguments = QStringList());
|
||||
|
||||
// Start opening streamlink for the given channel, reading settings like quality from settings
|
||||
// and opening a quality dialog if the quality is "Choose"
|
||||
// Start opening streamlink for the given channel, reading settings like quality
|
||||
// from settings and opening a quality dialog if the quality is "Choose"
|
||||
void openStreamlinkForChannel(const QString &channel);
|
||||
|
||||
} // namespace chatterino
|
||||
|
||||
@@ -11,14 +11,17 @@ typedef enum MONITOR_DPI_TYPE {
|
||||
MDT_DEFAULT = MDT_EFFECTIVE_DPI
|
||||
} MONITOR_DPI_TYPE;
|
||||
|
||||
typedef HRESULT(CALLBACK *GetDpiForMonitor_)(HMONITOR, MONITOR_DPI_TYPE, UINT *, UINT *);
|
||||
typedef HRESULT(CALLBACK *GetDpiForMonitor_)(HMONITOR, MONITOR_DPI_TYPE, UINT *,
|
||||
UINT *);
|
||||
|
||||
boost::optional<UINT> getWindowDpi(HWND hwnd)
|
||||
{
|
||||
static HINSTANCE shcore = LoadLibrary(L"Shcore.dll");
|
||||
if (shcore != nullptr) {
|
||||
if (auto getDpiForMonitor = GetDpiForMonitor_(GetProcAddress(shcore, "GetDpiForMonitor"))) {
|
||||
HMONITOR monitor = MonitorFromWindow(hwnd, MONITOR_DEFAULTTONEAREST);
|
||||
if (auto getDpiForMonitor =
|
||||
GetDpiForMonitor_(GetProcAddress(shcore, "GetDpiForMonitor"))) {
|
||||
HMONITOR monitor =
|
||||
MonitorFromWindow(hwnd, MONITOR_DEFAULTTONEAREST);
|
||||
|
||||
UINT xScale, yScale;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user