mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
Merge branch 'pr2343'
This commit is contained in:
commit
1f61534841
|
@ -289,6 +289,12 @@ void Settings::loadPersonnal(Profile* profile)
|
|||
SettingsSerializer ps(filePath, profile->getPassword());
|
||||
ps.load();
|
||||
friendLst.clear();
|
||||
|
||||
ps.beginGroup("Privacy");
|
||||
typingNotification = ps.value("typingNotification", true).toBool();
|
||||
enableLogging = ps.value("enableLogging", true).toBool();
|
||||
ps.endGroup();
|
||||
|
||||
ps.beginGroup("Friends");
|
||||
int size = ps.beginReadArray("Friend");
|
||||
friendLst.reserve(size);
|
||||
|
@ -327,11 +333,6 @@ void Settings::loadPersonnal(Profile* profile)
|
|||
}
|
||||
ps.endArray();
|
||||
ps.endGroup();
|
||||
|
||||
ps.beginGroup("Privacy");
|
||||
typingNotification = ps.value("typingNotification", true).toBool();
|
||||
enableLogging = ps.value("enableLogging", true).toBool();
|
||||
ps.endGroup();
|
||||
}
|
||||
|
||||
void Settings::saveGlobal()
|
||||
|
|
|
@ -1608,7 +1608,7 @@ get_prop (GDBusConnection *conn,
|
|||
else if (!g_strcmp0 (property, "ToolTip"))
|
||||
{
|
||||
GVariant *variant;
|
||||
GVariantBuilder *builder;
|
||||
GVariant *pixmap;
|
||||
|
||||
if (!priv->icon[STATUS_NOTIFIER_TOOLTIP_ICON].has_pixbuf)
|
||||
{
|
||||
|
@ -1621,13 +1621,13 @@ get_prop (GDBusConnection *conn,
|
|||
return variant;
|
||||
}
|
||||
|
||||
builder = get_icon_pixmap (sn, STATUS_NOTIFIER_TOOLTIP_ICON);
|
||||
pixmap = get_icon_pixmap (sn, STATUS_NOTIFIER_TOOLTIP_ICON);
|
||||
variant = g_variant_new ("(sa(iiay)ss)",
|
||||
"",
|
||||
builder,
|
||||
pixmap,
|
||||
(priv->tooltip_title) ? priv->tooltip_title : "",
|
||||
(priv->tooltip_body) ? priv->tooltip_body : "");
|
||||
g_variant_builder_unref (builder);
|
||||
g_variant_unref (pixmap);
|
||||
|
||||
return variant;
|
||||
}
|
||||
|
|
|
@ -226,8 +226,11 @@ QVector<QPair<QString, QString>> CameraDevice::getRawDeviceListGeneric()
|
|||
{
|
||||
av_dict_free(&tmp);
|
||||
avformat_free_context(s);
|
||||
return devices;
|
||||
}
|
||||
avdevice_list_devices(s, &devlist);
|
||||
av_dict_free(&tmp);
|
||||
avformat_free_context(s);
|
||||
if (!devlist)
|
||||
{
|
||||
qWarning() << "avdevice_list_devices failed";
|
||||
|
|
|
@ -79,7 +79,7 @@ ProfileForm::ProfileForm(QWidget *parent) :
|
|||
toxId->setToolTip(bodyUI->toxId->toolTip());
|
||||
|
||||
QVBoxLayout *toxIdGroup = qobject_cast<QVBoxLayout*>(bodyUI->toxGroup->layout());
|
||||
toxIdGroup->replaceWidget(bodyUI->toxId, toxId);
|
||||
delete toxIdGroup->replaceWidget(bodyUI->toxId, toxId); // Original toxId is in heap, delete it
|
||||
bodyUI->toxId->hide();
|
||||
|
||||
bodyUI->qrLabel->setWordWrap(true);
|
||||
|
|
|
@ -65,18 +65,12 @@ SystemTrayIcon::SystemTrayIcon()
|
|||
qDebug() << "Using GTK backend";
|
||||
backendType = SystrayBackendType::GTK;
|
||||
gtk_init(nullptr, nullptr);
|
||||
void (*callbackFreeImage)(guchar*, gpointer) =
|
||||
[](guchar*, gpointer image)
|
||||
{
|
||||
delete reinterpret_cast<QImage*>(image);
|
||||
};
|
||||
QImage* image = new QImage(":/img/icon.png");
|
||||
if (image->format() != QImage::Format_RGBA8888_Premultiplied)
|
||||
*image = image->convertToFormat(QImage::Format_RGBA8888_Premultiplied);
|
||||
GdkPixbuf* pixbuf = gdk_pixbuf_new_from_data(image->bits(), GDK_COLORSPACE_RGB, image->hasAlphaChannel(),
|
||||
8, image->width(), image->height(),
|
||||
image->bytesPerLine(), callbackFreeImage, image);
|
||||
|
||||
// No ':' needed in resource path!
|
||||
GdkPixbuf *pixbuf = gdk_pixbuf_new_from_resource("/img/icon.png", NULL);
|
||||
gtkIcon = gtk_status_icon_new_from_pixbuf(pixbuf);
|
||||
g_object_unref(pixbuf);
|
||||
|
||||
gtkMenu = gtk_menu_new();
|
||||
|
||||
void (*callbackTrigger)(GtkStatusIcon*, gpointer) =
|
||||
|
@ -102,21 +96,13 @@ SystemTrayIcon::SystemTrayIcon()
|
|||
backendType = SystrayBackendType::StatusNotifier;
|
||||
gtk_init(nullptr, nullptr);
|
||||
snMenu = gtk_menu_new();
|
||||
void (*callbackFreeImage)(guchar*, gpointer) =
|
||||
[](guchar*, gpointer image)
|
||||
{
|
||||
delete reinterpret_cast<QImage*>(image);
|
||||
};
|
||||
QImage image(":/img/icon.png");
|
||||
if (image.format() != QImage::Format_RGBA8888_Premultiplied)
|
||||
image = image.convertToFormat(QImage::Format_RGBA8888_Premultiplied);
|
||||
GdkPixbuf* pixbuf = gdk_pixbuf_new_from_data(image.bits(), GDK_COLORSPACE_RGB, image.hasAlphaChannel(),
|
||||
8, image.width(), image.height(),
|
||||
image.bytesPerLine(), callbackFreeImage, &image);
|
||||
|
||||
// No ':' needed in resource path!
|
||||
GdkPixbuf *pixbuf = gdk_pixbuf_new_from_resource("/img/icon.png", NULL);
|
||||
statusNotifier = status_notifier_new_from_pixbuf("qtox",
|
||||
STATUS_NOTIFIER_CATEGORY_APPLICATION_STATUS, pixbuf);
|
||||
status_notifier_register(statusNotifier);
|
||||
g_object_unref(pixbuf);
|
||||
}
|
||||
#endif
|
||||
else if (desktop == "kde"
|
||||
|
@ -182,19 +168,24 @@ void SystemTrayIcon::setContextMenu(QMenu* menu)
|
|||
else
|
||||
{
|
||||
void (*callbackFreeImage)(guchar*, gpointer) =
|
||||
[](guchar*, gpointer image)
|
||||
[](guchar*, gpointer image_bytes)
|
||||
{
|
||||
delete reinterpret_cast<QImage*>(image);
|
||||
free(reinterpret_cast<guchar*>(image_bytes));
|
||||
};
|
||||
QImage* image = new QImage(a->icon().pixmap(64, 64).toImage());
|
||||
if (image->format() != QImage::Format_RGBA8888_Premultiplied)
|
||||
*image = image->convertToFormat(QImage::Format_RGBA8888_Premultiplied);
|
||||
GdkPixbuf* pixbuf = gdk_pixbuf_new_from_data(image->bits(), GDK_COLORSPACE_RGB, image->hasAlphaChannel(),
|
||||
8, image->width(), image->height(),
|
||||
image->bytesPerLine(), callbackFreeImage, image);
|
||||
QImage image = a->icon().pixmap(64, 64).toImage();
|
||||
if (image.format() != QImage::Format_RGBA8888_Premultiplied)
|
||||
image = image.convertToFormat(QImage::Format_RGBA8888_Premultiplied);
|
||||
guchar* image_bytes = (guchar*)malloc(image.byteCount());
|
||||
memcpy(image_bytes, image.bits(), image.byteCount());
|
||||
|
||||
GdkPixbuf* pixbuf = gdk_pixbuf_new_from_data(image_bytes, GDK_COLORSPACE_RGB, image.hasAlphaChannel(),
|
||||
8, image.width(), image.height(), image.bytesPerLine(),
|
||||
callbackFreeImage, image_bytes);
|
||||
|
||||
item = gtk_image_menu_item_new_with_label(aText.toStdString().c_str());
|
||||
gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item), gtk_image_new_from_pixbuf(pixbuf));
|
||||
gtk_image_menu_item_set_always_show_image(GTK_IMAGE_MENU_ITEM(item),TRUE);
|
||||
g_object_unref(pixbuf);
|
||||
}
|
||||
gtk_menu_shell_append(GTK_MENU_SHELL(snMenu), item);
|
||||
void (*callback)(GtkMenu*, gpointer data) = [](GtkMenu*, gpointer a)
|
||||
|
@ -227,19 +218,24 @@ void SystemTrayIcon::setContextMenu(QMenu* menu)
|
|||
else
|
||||
{
|
||||
void (*callbackFreeImage)(guchar*, gpointer) =
|
||||
[](guchar*, gpointer image)
|
||||
[](guchar*, gpointer image_bytes)
|
||||
{
|
||||
delete reinterpret_cast<QImage*>(image);
|
||||
free(reinterpret_cast<guchar*>(image_bytes));
|
||||
};
|
||||
QImage* image = new QImage(a->icon().pixmap(64, 64).toImage());
|
||||
if (image->format() != QImage::Format_RGBA8888_Premultiplied)
|
||||
*image = image->convertToFormat(QImage::Format_RGBA8888_Premultiplied);
|
||||
GdkPixbuf* pixbuf = gdk_pixbuf_new_from_data(image->bits(), GDK_COLORSPACE_RGB, image->hasAlphaChannel(),
|
||||
8, image->width(), image->height(),
|
||||
image->bytesPerLine(), callbackFreeImage, image);
|
||||
QImage image = a->icon().pixmap(64, 64).toImage();
|
||||
if (image.format() != QImage::Format_RGBA8888_Premultiplied)
|
||||
image = image.convertToFormat(QImage::Format_RGBA8888_Premultiplied);
|
||||
guchar* image_bytes = (guchar*)malloc(image.byteCount());
|
||||
memcpy(image_bytes, image.bits(), image.byteCount());
|
||||
|
||||
GdkPixbuf* pixbuf = gdk_pixbuf_new_from_data(image_bytes, GDK_COLORSPACE_RGB, image.hasAlphaChannel(),
|
||||
8, image.width(), image.height(), image.bytesPerLine(),
|
||||
callbackFreeImage, image_bytes);
|
||||
|
||||
item = gtk_image_menu_item_new_with_label(aText.toStdString().c_str());
|
||||
gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item), gtk_image_new_from_pixbuf(pixbuf));
|
||||
gtk_image_menu_item_set_always_show_image(GTK_IMAGE_MENU_ITEM(item),TRUE);
|
||||
g_object_unref(pixbuf);
|
||||
}
|
||||
gtk_menu_shell_append(GTK_MENU_SHELL(gtkMenu), item);
|
||||
void (*callback)(GtkMenu*, gpointer data) = [](GtkMenu*, gpointer a)
|
||||
|
@ -360,34 +356,44 @@ void SystemTrayIcon::setIcon(QIcon &icon)
|
|||
else if (backendType == SystrayBackendType::StatusNotifier)
|
||||
{
|
||||
void (*callbackFreeImage)(guchar*, gpointer) =
|
||||
[](guchar*, gpointer image)
|
||||
[](guchar*, gpointer image_bytes)
|
||||
{
|
||||
delete reinterpret_cast<QImage*>(image);
|
||||
free(reinterpret_cast<guchar*>(image_bytes));
|
||||
};
|
||||
QImage* image = new QImage(icon.pixmap(64, 64).toImage());
|
||||
if (image->format() != QImage::Format_RGBA8888_Premultiplied)
|
||||
*image = image->convertToFormat(QImage::Format_RGBA8888_Premultiplied);
|
||||
GdkPixbuf* pixbuf = gdk_pixbuf_new_from_data(image->bits(), GDK_COLORSPACE_RGB, image->hasAlphaChannel(),
|
||||
8, image->width(), image->height(),
|
||||
image->bytesPerLine(), callbackFreeImage, image);
|
||||
QImage image = icon.pixmap(64, 64).toImage();
|
||||
if (image.format() != QImage::Format_RGBA8888_Premultiplied)
|
||||
image = image.convertToFormat(QImage::Format_RGBA8888_Premultiplied);
|
||||
guchar* image_bytes = (guchar*)malloc(image.byteCount());
|
||||
memcpy(image_bytes, image.bits(), image.byteCount());
|
||||
|
||||
GdkPixbuf* pixbuf = gdk_pixbuf_new_from_data(image_bytes, GDK_COLORSPACE_RGB, image.hasAlphaChannel(),
|
||||
8, image.width(), image.height(), image.bytesPerLine(),
|
||||
callbackFreeImage, image_bytes);
|
||||
|
||||
status_notifier_set_from_pixbuf(statusNotifier, STATUS_NOTIFIER_ICON, pixbuf);
|
||||
g_object_unref(pixbuf);
|
||||
}
|
||||
#endif
|
||||
#ifdef ENABLE_SYSTRAY_GTK_BACKEND
|
||||
else if (backendType == SystrayBackendType::GTK)
|
||||
{
|
||||
void (*callbackFreeImage)(guchar*, gpointer) =
|
||||
[](guchar*, gpointer image)
|
||||
[](guchar*, gpointer image_bytes)
|
||||
{
|
||||
delete reinterpret_cast<QImage*>(image);
|
||||
free(reinterpret_cast<guchar*>(image_bytes));
|
||||
};
|
||||
QImage* image = new QImage(icon.pixmap(64, 64).toImage());
|
||||
if (image->format() != QImage::Format_RGBA8888_Premultiplied)
|
||||
*image = image->convertToFormat(QImage::Format_RGBA8888_Premultiplied);
|
||||
GdkPixbuf* pixbuf = gdk_pixbuf_new_from_data(image->bits(), GDK_COLORSPACE_RGB, image->hasAlphaChannel(),
|
||||
8, image->width(), image->height(),
|
||||
image->bytesPerLine(), callbackFreeImage, image);
|
||||
QImage image = icon.pixmap(64, 64).toImage();
|
||||
if (image.format() != QImage::Format_RGBA8888_Premultiplied)
|
||||
image = image.convertToFormat(QImage::Format_RGBA8888_Premultiplied);
|
||||
guchar* image_bytes = (guchar*)malloc(image.byteCount());
|
||||
memcpy(image_bytes, image.bits(), image.byteCount());
|
||||
|
||||
GdkPixbuf* pixbuf = gdk_pixbuf_new_from_data(image_bytes, GDK_COLORSPACE_RGB, image.hasAlphaChannel(),
|
||||
8, image.width(), image.height(), image.bytesPerLine(),
|
||||
callbackFreeImage, image_bytes);
|
||||
|
||||
gtk_status_icon_set_from_pixbuf(gtkIcon, pixbuf);
|
||||
g_object_unref(pixbuf);
|
||||
}
|
||||
#endif
|
||||
#ifdef ENABLE_SYSTRAY_UNITY_BACKEND
|
||||
|
|
Loading…
Reference in New Issue
Block a user