mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
Merge branch 'pr1244'
This commit is contained in:
commit
17042c1aff
|
@ -114,46 +114,6 @@ void Widget::init()
|
||||||
statusBusy->setIcon(QIcon(":img/status/dot_busy.png"));
|
statusBusy->setIcon(QIcon(":img/status/dot_busy.png"));
|
||||||
connect(statusBusy, SIGNAL(triggered()), this, SLOT(setStatusBusy()));
|
connect(statusBusy, SIGNAL(triggered()), this, SLOT(setStatusBusy()));
|
||||||
|
|
||||||
if (QSystemTrayIcon::isSystemTrayAvailable())
|
|
||||||
{
|
|
||||||
icon = new SystemTrayIcon;
|
|
||||||
updateTrayIcon();
|
|
||||||
trayMenu = new QMenu;
|
|
||||||
|
|
||||||
actionQuit = new QAction(tr("&Quit"), this);
|
|
||||||
connect(actionQuit, SIGNAL(triggered()), qApp, SLOT(quit()));
|
|
||||||
|
|
||||||
trayMenu->addAction(statusOnline);
|
|
||||||
trayMenu->addAction(statusAway);
|
|
||||||
trayMenu->addAction(statusBusy);
|
|
||||||
trayMenu->addSeparator();
|
|
||||||
trayMenu->addAction(actionQuit);
|
|
||||||
icon->setContextMenu(trayMenu);
|
|
||||||
|
|
||||||
connect(icon,
|
|
||||||
SIGNAL(activated(QSystemTrayIcon::ActivationReason)),
|
|
||||||
this,
|
|
||||||
SLOT(onIconClick(QSystemTrayIcon::ActivationReason)));
|
|
||||||
|
|
||||||
icon->show();
|
|
||||||
icon->hide();
|
|
||||||
|
|
||||||
if (Settings::getInstance().getShowSystemTray())
|
|
||||||
{
|
|
||||||
icon->show();
|
|
||||||
if (Settings::getInstance().getAutostartInTray() == false)
|
|
||||||
this->show();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
this->show();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
qWarning() << "Widget: No system tray detected!";
|
|
||||||
icon = nullptr;
|
|
||||||
this->show();
|
|
||||||
}
|
|
||||||
|
|
||||||
ui->statusbar->hide();
|
ui->statusbar->hide();
|
||||||
ui->menubar->hide();
|
ui->menubar->hide();
|
||||||
|
|
||||||
|
@ -232,6 +192,7 @@ void Widget::init()
|
||||||
connect(addFriendForm, SIGNAL(friendRequested(QString, QString)), this, SIGNAL(friendRequested(QString, QString)));
|
connect(addFriendForm, SIGNAL(friendRequested(QString, QString)), this, SIGNAL(friendRequested(QString, QString)));
|
||||||
connect(timer, &QTimer::timeout, this, &Widget::onUserAwayCheck);
|
connect(timer, &QTimer::timeout, this, &Widget::onUserAwayCheck);
|
||||||
connect(timer, &QTimer::timeout, this, &Widget::onEventIconTick);
|
connect(timer, &QTimer::timeout, this, &Widget::onEventIconTick);
|
||||||
|
connect(timer, &QTimer::timeout, this, &Widget::onTryCreateTrayIcon);
|
||||||
connect(offlineMsgTimer, &QTimer::timeout, this, &Widget::processOfflineMsgs);
|
connect(offlineMsgTimer, &QTimer::timeout, this, &Widget::processOfflineMsgs);
|
||||||
|
|
||||||
addFriendForm->show(*ui);
|
addFriendForm->show(*ui);
|
||||||
|
@ -240,6 +201,8 @@ void Widget::init()
|
||||||
if (Settings::getInstance().getCheckUpdates())
|
if (Settings::getInstance().getCheckUpdates())
|
||||||
AutoUpdater::checkUpdatesAsyncInteractive();
|
AutoUpdater::checkUpdatesAsyncInteractive();
|
||||||
#endif
|
#endif
|
||||||
|
if (!Settings::getInstance().getShowSystemTray())
|
||||||
|
show();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Widget::setTranslation()
|
void Widget::setTranslation()
|
||||||
|
@ -281,7 +244,8 @@ Widget::~Widget()
|
||||||
{
|
{
|
||||||
qDebug() << "Widget: Deleting Widget";
|
qDebug() << "Widget: Deleting Widget";
|
||||||
AutoUpdater::abortUpdates();
|
AutoUpdater::abortUpdates();
|
||||||
icon->hide();
|
if (icon)
|
||||||
|
icon->hide();
|
||||||
hideMainForms();
|
hideMainForms();
|
||||||
delete settingsWidget;
|
delete settingsWidget;
|
||||||
delete addFriendForm;
|
delete addFriendForm;
|
||||||
|
@ -1094,6 +1058,52 @@ void Widget::onEventIconTick()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Widget::onTryCreateTrayIcon()
|
||||||
|
{
|
||||||
|
static int32_t tries = 15;
|
||||||
|
if (!icon && tries--)
|
||||||
|
{
|
||||||
|
if (QSystemTrayIcon::isSystemTrayAvailable())
|
||||||
|
{
|
||||||
|
icon = new SystemTrayIcon;
|
||||||
|
updateTrayIcon();
|
||||||
|
trayMenu = new QMenu;
|
||||||
|
|
||||||
|
actionQuit = new QAction(tr("&Quit"), this);
|
||||||
|
connect(actionQuit, SIGNAL(triggered()), qApp, SLOT(quit()));
|
||||||
|
|
||||||
|
trayMenu->addAction(statusOnline);
|
||||||
|
trayMenu->addAction(statusAway);
|
||||||
|
trayMenu->addAction(statusBusy);
|
||||||
|
trayMenu->addSeparator();
|
||||||
|
trayMenu->addAction(actionQuit);
|
||||||
|
icon->setContextMenu(trayMenu);
|
||||||
|
|
||||||
|
connect(icon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)),
|
||||||
|
this, SLOT(onIconClick(QSystemTrayIcon::ActivationReason)));
|
||||||
|
|
||||||
|
if (Settings::getInstance().getShowSystemTray())
|
||||||
|
{
|
||||||
|
icon->show();
|
||||||
|
setHidden(Settings::getInstance().getAutostartInTray());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
show();
|
||||||
|
}
|
||||||
|
else if (!isVisible())
|
||||||
|
show();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
disconnect(timer, &QTimer::timeout, this, &Widget::onTryCreateTrayIcon);
|
||||||
|
if (!icon)
|
||||||
|
{
|
||||||
|
qWarning() << "Widget: No system tray detected!";
|
||||||
|
show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Widget::setStatusOnline()
|
void Widget::setStatusOnline()
|
||||||
{
|
{
|
||||||
Nexus::getCore()->setStatus(Status::Online);
|
Nexus::getCore()->setStatus(Status::Online);
|
||||||
|
@ -1137,8 +1147,10 @@ void Widget::onFriendTypingChanged(int friendId, bool isTyping)
|
||||||
f->getChatForm()->setFriendTyping(isTyping);
|
f->getChatForm()->setFriendTyping(isTyping);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Widget::onSetShowSystemTray(bool newValue){
|
void Widget::onSetShowSystemTray(bool newValue)
|
||||||
icon->setVisible(newValue);
|
{
|
||||||
|
if (icon)
|
||||||
|
icon->setVisible(newValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Widget::saveWindowGeometry()
|
void Widget::saveWindowGeometry()
|
||||||
|
|
|
@ -134,6 +134,7 @@ private slots:
|
||||||
void onIconClick(QSystemTrayIcon::ActivationReason);
|
void onIconClick(QSystemTrayIcon::ActivationReason);
|
||||||
void onUserAwayCheck();
|
void onUserAwayCheck();
|
||||||
void onEventIconTick();
|
void onEventIconTick();
|
||||||
|
void onTryCreateTrayIcon();
|
||||||
void onSetShowSystemTray(bool newValue);
|
void onSetShowSystemTray(bool newValue);
|
||||||
void onSplitterMoved(int pos, int index);
|
void onSplitterMoved(int pos, int index);
|
||||||
void processOfflineMsgs();
|
void processOfflineMsgs();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user