mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
Merge branch tux3:unsigned_clean_for_zetok into master
Dmytro Shynkevych (10): statusnotifier: fixed pointer type settings: fixed check on an uninitialized value systemtrayicon: fixed multiple gdk_pixbuf memory leaks cameradevice: fixed a major leak: avformat_context not always freed profileform: fixed leaky toxId field systemtrayicon: fixed multiple small leaks cameradevice: fixed a regression cameradevice: fixed a double free systemtrayicon: optimized QImage <-> GdkPixbuf conversion systemtrayicon: switched to manual memory management for pixmap data agilob (9): use Qt backend of KDE5 fix icon scaling on gnome3 by scaling icons down remove dependency injection from systemtrayicon core review changes - formatting add quit role to quit action in trayicon add logout action to tray menu use plaintext label for username and status in header remove unused code, better logging for systray, removed KDE5 from enum change default quit icon in tray menu tux3 (3): Merge branch 'pr2343' Fix qTox on OSX, closes #2447 Merge branch 'pr2132' into unsigned
This commit is contained in:
commit
636bb91898
|
@ -279,13 +279,13 @@ void ChatLog::mouseMoveEvent(QMouseEvent* ev)
|
|||
if (row != selClickedRow)
|
||||
{
|
||||
selectionMode = Multi;
|
||||
|
||||
lines[selClickedRow]->selectionCleared();
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (row >= selClickedRow)
|
||||
selLastRow = row;
|
||||
|
|
|
@ -70,6 +70,8 @@ void logMessageHandler(QtMsgType type, const QMessageLogContext& ctxt, const QSt
|
|||
case QtFatalMsg:
|
||||
LogMsg += "Fatal";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
LogMsg += ": " + msg + "\n";
|
||||
|
|
|
@ -858,6 +858,9 @@ QSplitter:handle{
|
|||
<property name="cursor">
|
||||
<cursorShape>PointingHandCursor</cursorShape>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Your name</string>
|
||||
</property>
|
||||
<property name="textFormat">
|
||||
<enum>Qt::PlainText</enum>
|
||||
</property>
|
||||
|
@ -940,6 +943,9 @@ QSplitter:handle{
|
|||
<pointsize>8</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Your status</string>
|
||||
</property>
|
||||
<property name="textFormat">
|
||||
<enum>Qt::PlainText</enum>
|
||||
</property>
|
||||
|
|
|
@ -370,7 +370,7 @@ void Nexus::updateWindowsArg(QWindow* closedWindow)
|
|||
dockMenu->insertAction(dockLast, action);
|
||||
}
|
||||
|
||||
if (!dockLast->isSeparator())
|
||||
if (dockLast && !dockLast->isSeparator())
|
||||
dockMenu->insertSeparator(dockLast);
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
@ -251,7 +251,7 @@ void ProfileForm::onAvatarClicked()
|
|||
return bytes;
|
||||
};
|
||||
|
||||
QString filename = QFileDialog::getOpenFileName(0,
|
||||
QString filename = QFileDialog::getOpenFileName(this,
|
||||
tr("Choose a profile picture"),
|
||||
QDir::homePath(),
|
||||
Nexus::getSupportedImageFilter());
|
||||
|
@ -291,8 +291,9 @@ void ProfileForm::onAvatarClicked()
|
|||
// If this happens, you're really doing it on purpose.
|
||||
if (bytes.size() > 65535)
|
||||
{
|
||||
QMessageBox::critical(this, tr("Error"),
|
||||
tr("The supplied image is too large.\nPlease use another image."));
|
||||
QMessageBox::critical(this,
|
||||
tr("Error"),
|
||||
tr("The supplied image is too large.\nPlease use another image."));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -327,7 +328,8 @@ void ProfileForm::onRenameClicked()
|
|||
void ProfileForm::onExportClicked()
|
||||
{
|
||||
QString current = Nexus::getProfile()->getName() + Core::TOX_EXT;
|
||||
QString path = QFileDialog::getSaveFileName(0, tr("Export profile", "save dialog title"),
|
||||
QString path = QFileDialog::getSaveFileName(this,
|
||||
tr("Export profile", "save dialog title"),
|
||||
QDir::home().filePath(current),
|
||||
tr("Tox save file (*.tox)", "save dialog filter"));
|
||||
if (!path.isEmpty())
|
||||
|
@ -344,8 +346,9 @@ void ProfileForm::onExportClicked()
|
|||
|
||||
void ProfileForm::onDeleteClicked()
|
||||
{
|
||||
if (GUI::askQuestion(tr("Really delete profile?","deletion confirmation title"),
|
||||
tr("Are you sure you want to delete this profile?","deletion confirmation text")))
|
||||
if (GUI::askQuestion(
|
||||
tr("Really delete profile?", "deletion confirmation title"),
|
||||
tr("Are you sure you want to delete this profile?", "deletion confirmation text")))
|
||||
{
|
||||
Nexus& nexus = Nexus::getInstance();
|
||||
nexus.getProfile()->remove();
|
||||
|
@ -368,7 +371,8 @@ void ProfileForm::onCopyQrClicked()
|
|||
void ProfileForm::onSaveQrClicked()
|
||||
{
|
||||
QString current = Nexus::getProfile()->getName() + ".png";
|
||||
QString path = QFileDialog::getSaveFileName(0, tr("Save", "save qr image"),
|
||||
QString path = QFileDialog::getSaveFileName(this,
|
||||
tr("Save", "save qr image"),
|
||||
QDir::home().filePath(current),
|
||||
tr("Save QrCode (*.png)", "save dialog filter"));
|
||||
if (!path.isEmpty())
|
||||
|
@ -413,7 +417,7 @@ void ProfileForm::onChangePassClicked()
|
|||
void ProfileForm::retranslateUi()
|
||||
{
|
||||
bodyUI->retranslateUi(this);
|
||||
nameLabel->setText(QObject::tr("User Profile"));
|
||||
nameLabel->setText(tr("User Profile"));
|
||||
// We have to add the toxId tooltip here and not in the .ui or Qt won't know how to translate it dynamically
|
||||
toxId->setToolTip(tr("This bunch of characters tells other Tox clients how to contact you.\nShare it with your friends to communicate."));
|
||||
}
|
||||
|
|
|
@ -43,6 +43,7 @@ public:
|
|||
|
||||
signals:
|
||||
void clicked();
|
||||
|
||||
protected:
|
||||
virtual void mouseReleaseEvent(QMouseEvent*) final override {emit clicked();}
|
||||
};
|
||||
|
@ -63,6 +64,7 @@ signals:
|
|||
|
||||
public slots:
|
||||
void onSelfAvatarLoaded(const QPixmap &pic);
|
||||
void onLogoutClicked();
|
||||
|
||||
private slots:
|
||||
void setToxId(const QString& id);
|
||||
|
@ -72,7 +74,6 @@ private slots:
|
|||
void onRenameClicked();
|
||||
void onExportClicked();
|
||||
void onDeleteClicked();
|
||||
void onLogoutClicked();
|
||||
void onCopyQrClicked();
|
||||
void onSaveQrClicked();
|
||||
void onDeletePassClicked();
|
||||
|
|
|
@ -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) =
|
||||
|
@ -94,40 +88,16 @@ SystemTrayIcon::SystemTrayIcon()
|
|||
g_signal_connect(gtkIcon, "button-release-event", G_CALLBACK(callbackButtonClick), this);
|
||||
}
|
||||
#endif
|
||||
#ifdef ENABLE_SYSTRAY_STATUSNOTIFIER_BACKEND
|
||||
else if (desktop == "kde"
|
||||
&& getenv("KDE_SESSION_VERSION") == QString("5"))
|
||||
else if (desktop == "kde" && getenv("KDE_SESSION_VERSION") == QStringLiteral("5"))
|
||||
{
|
||||
qDebug() << "Using Status Notifier backend";
|
||||
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);
|
||||
|
||||
statusNotifier = status_notifier_new_from_pixbuf("qtox",
|
||||
STATUS_NOTIFIER_CATEGORY_APPLICATION_STATUS, pixbuf);
|
||||
status_notifier_register(statusNotifier);
|
||||
}
|
||||
#endif
|
||||
else if (desktop == "kde"
|
||||
&& getenv("KDE_SESSION_VERSION") == QString("5"))
|
||||
{
|
||||
backendType = SystrayBackendType::KDE5;
|
||||
qWarning() << "Detected a KDE5 session, but we don't have Status Notifier support. Disabling the systray icon";
|
||||
qDebug() << "Using the Qt backend on KDE5";
|
||||
qtIcon = new QSystemTrayIcon;
|
||||
backendType = SystrayBackendType::Qt;
|
||||
connect(qtIcon, &QSystemTrayIcon::activated, this, &SystemTrayIcon::activated);
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug() << "Using the Qt backend";
|
||||
qDebug() << "Using the Qt backend, because nothing else matches";
|
||||
qtIcon = new QSystemTrayIcon;
|
||||
backendType = SystrayBackendType::Qt;
|
||||
connect(qtIcon, &QSystemTrayIcon::activated, this, &SystemTrayIcon::activated);
|
||||
|
@ -182,19 +152,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 +202,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 +340,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
|
||||
|
|
|
@ -48,6 +48,7 @@ private:
|
|||
private:
|
||||
SystrayBackendType backendType;
|
||||
QSystemTrayIcon* qtIcon;
|
||||
|
||||
#ifdef ENABLE_SYSTRAY_UNITY_BACKEND
|
||||
AppIndicator *unityIndicator;
|
||||
GtkWidget *unityMenu;
|
||||
|
|
|
@ -63,7 +63,6 @@ extern "C" {
|
|||
enum class SystrayBackendType
|
||||
{
|
||||
Qt,
|
||||
KDE5,
|
||||
#ifdef ENABLE_SYSTRAY_UNITY_BACKEND
|
||||
Unity,
|
||||
#endif
|
||||
|
|
|
@ -71,6 +71,7 @@
|
|||
#include <QList>
|
||||
#include <QDesktopServices>
|
||||
#include <QProcess>
|
||||
#include <QSvgRenderer>
|
||||
#include <QWindow>
|
||||
#include <tox/tox.h>
|
||||
|
||||
|
@ -118,15 +119,18 @@ void Widget::init()
|
|||
offlineMsgTimer = new QTimer();
|
||||
offlineMsgTimer->start(15000);
|
||||
|
||||
icon_size = 15;
|
||||
statusOnline = new QAction(this);
|
||||
statusOnline->setIcon(getStatusIcon(Status::Online, 10, 10));
|
||||
connect(statusOnline, SIGNAL(triggered()), this, SLOT(setStatusOnline()));
|
||||
statusOnline->setIcon(getStatusIcon(Status::Online, icon_size, icon_size));
|
||||
connect(statusOnline, &QAction::triggered, this, &Widget::setStatusOnline);
|
||||
|
||||
statusAway = new QAction(this);
|
||||
statusAway->setIcon(getStatusIcon(Status::Away, 10, 10));
|
||||
connect(statusAway, SIGNAL(triggered()), this, SLOT(setStatusAway()));
|
||||
statusAway->setIcon(getStatusIcon(Status::Away, icon_size, icon_size));
|
||||
connect(statusAway, &QAction::triggered, this, &Widget::setStatusAway);
|
||||
|
||||
statusBusy = new QAction(this);
|
||||
statusBusy->setIcon(getStatusIcon(Status::Busy, 10, 10));
|
||||
connect(statusBusy, SIGNAL(triggered()), this, SLOT(setStatusBusy()));
|
||||
statusBusy->setIcon(getStatusIcon(Status::Busy, icon_size, icon_size));
|
||||
connect(statusBusy, &QAction::triggered, this, &Widget::setStatusBusy);
|
||||
|
||||
layout()->setContentsMargins(0, 0, 0, 0);
|
||||
ui->friendList->setStyleSheet(Style::resolve(Style::getStylesheet(":ui/friendList/friendList.css")));
|
||||
|
@ -408,11 +412,19 @@ void Widget::updateIcons()
|
|||
status = "offline";
|
||||
}
|
||||
|
||||
QIcon ico = QIcon::fromTheme("qtox-" + status);
|
||||
QIcon ico;
|
||||
if (ico.isNull())
|
||||
{
|
||||
QString color = Settings::getInstance().getLightTrayIcon() ? "light" : "dark";
|
||||
ico = QIcon(":img/taskbar/" + color + "/taskbar_" + status + ".svg");
|
||||
QString path = ":img/taskbar/" + color + "/taskbar_" + status + ".svg";
|
||||
QSvgRenderer renderer(path);
|
||||
|
||||
// Prepare a QImage with desired characteritisc
|
||||
QImage image = QImage(250, 250, QImage::Format_ARGB32);
|
||||
image.fill(Qt::transparent);
|
||||
QPainter painter(&image);
|
||||
renderer.render(&painter);
|
||||
ico = QIcon(QPixmap::fromImage(image));
|
||||
}
|
||||
|
||||
setWindowIcon(ico);
|
||||
|
@ -550,7 +562,7 @@ void Widget::onBadProxyCore()
|
|||
void Widget::onStatusSet(Status status)
|
||||
{
|
||||
ui->statusButton->setProperty("status", getStatusTitle(status));
|
||||
ui->statusButton->setIcon(getStatusIcon(status, 10, 10));
|
||||
ui->statusButton->setIcon(getStatusIcon(status, icon_size, icon_size));
|
||||
updateIcons();
|
||||
}
|
||||
|
||||
|
@ -1682,22 +1694,30 @@ void Widget::onTryCreateTrayIcon()
|
|||
{
|
||||
if (QSystemTrayIcon::isSystemTrayAvailable())
|
||||
{
|
||||
icon = new SystemTrayIcon;
|
||||
icon = new SystemTrayIcon();
|
||||
updateIcons();
|
||||
trayMenu = new QMenu;
|
||||
trayMenu = new QMenu(this);
|
||||
|
||||
actionQuit = new QAction(tr("&Quit"), this);
|
||||
connect(actionQuit, SIGNAL(triggered()), qApp, SLOT(quit()));
|
||||
QStyle *style = qApp->style();
|
||||
|
||||
actionLogout = new QAction(tr("&Logout"), this);
|
||||
actionLogout->setIcon(style->standardIcon(QStyle::SP_BrowserStop));
|
||||
connect(actionLogout, &QAction::triggered, profileForm, &ProfileForm::onLogoutClicked);
|
||||
|
||||
actionQuit = new QAction(tr("&Exit"), this);
|
||||
actionQuit->setMenuRole(QAction::QuitRole);
|
||||
actionQuit->setIcon(style->standardIcon(QStyle::SP_DialogDiscardButton));
|
||||
connect(actionQuit, &QAction::triggered, qApp, &QApplication::quit);
|
||||
|
||||
trayMenu->addAction(statusOnline);
|
||||
trayMenu->addAction(statusAway);
|
||||
trayMenu->addAction(statusBusy);
|
||||
trayMenu->addSeparator();
|
||||
trayMenu->addAction(actionLogout);
|
||||
trayMenu->addAction(actionQuit);
|
||||
icon->setContextMenu(trayMenu);
|
||||
|
||||
connect(icon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)),
|
||||
this, SLOT(onIconClick(QSystemTrayIcon::ActivationReason)));
|
||||
connect(icon, &SystemTrayIcon::activated, this, &Widget::onIconClick);
|
||||
|
||||
if (Settings::getInstance().getShowSystemTray())
|
||||
{
|
||||
|
@ -1909,12 +1929,26 @@ QString Widget::getStatusIconPath(Status status)
|
|||
}
|
||||
}
|
||||
|
||||
inline QIcon Widget::getStatusIcon(Status status, uint32_t w/*=0*/, uint32_t h/*=0*/)
|
||||
inline QIcon Widget::getStatusIcon(Status status, uint32_t w, uint32_t h)
|
||||
{
|
||||
if (w > 0 && h > 0)
|
||||
return getStatusIconPixmap(status, w, h);
|
||||
else
|
||||
return QIcon(getStatusIconPath(status));
|
||||
#ifdef Q_OS_LINUX
|
||||
|
||||
QString desktop = getenv("XDG_CURRENT_DESKTOP");
|
||||
if (desktop.isEmpty())
|
||||
{
|
||||
desktop = getenv("DESKTOP_SESSION");
|
||||
}
|
||||
desktop = desktop.toLower();
|
||||
|
||||
if (desktop == "xfce" || desktop.contains("gnome") || desktop == "mate")
|
||||
{
|
||||
if (w > 0 && h > 0)
|
||||
{
|
||||
return getStatusIconPixmap(status, w, h);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return QIcon(getStatusIconPath(status));
|
||||
}
|
||||
|
||||
QPixmap Widget::getStatusIconPixmap(Status status, uint32_t w, uint32_t h)
|
||||
|
|
|
@ -182,6 +182,9 @@ private slots:
|
|||
void processOfflineMsgs();
|
||||
void friendListContextMenu(const QPoint &pos);
|
||||
|
||||
private:
|
||||
int icon_size;
|
||||
|
||||
private:
|
||||
enum ActiveToolMenuButton {
|
||||
AddButton,
|
||||
|
@ -225,6 +228,7 @@ private:
|
|||
QAction *statusOnline;
|
||||
QAction *statusAway;
|
||||
QAction *statusBusy;
|
||||
QAction *actionLogout;
|
||||
QAction *actionQuit;
|
||||
|
||||
QMenu* filterMenu;
|
||||
|
|
Loading…
Reference in New Issue
Block a user