|
|
|
@ -65,7 +65,9 @@ Widget *Widget::instance{nullptr};
@@ -65,7 +65,9 @@ Widget *Widget::instance{nullptr};
|
|
|
|
|
Widget::Widget(QWidget *parent) |
|
|
|
|
: QMainWindow(parent), |
|
|
|
|
ui(new Ui::MainWindow), |
|
|
|
|
activeChatroomWidget{nullptr} |
|
|
|
|
activeChatroomWidget{nullptr}, |
|
|
|
|
eventFlag(false), |
|
|
|
|
eventIcon(false) |
|
|
|
|
{ |
|
|
|
|
translator = new QTranslator; |
|
|
|
|
setTranslation(); |
|
|
|
@ -75,8 +77,8 @@ void Widget::init()
@@ -75,8 +77,8 @@ void Widget::init()
|
|
|
|
|
{ |
|
|
|
|
ui->setupUi(this); |
|
|
|
|
|
|
|
|
|
idleTimer = new QTimer(); |
|
|
|
|
idleTimer->start(1000); |
|
|
|
|
timer = new QTimer(); |
|
|
|
|
timer->start(1000); |
|
|
|
|
|
|
|
|
|
//restore window state
|
|
|
|
|
restoreGeometry(Settings::getInstance().getWindowGeometry()); |
|
|
|
@ -265,7 +267,8 @@ void Widget::init()
@@ -265,7 +267,8 @@ void Widget::init()
|
|
|
|
|
connect(setStatusAway, SIGNAL(triggered()), this, SLOT(setStatusAway())); |
|
|
|
|
connect(setStatusBusy, SIGNAL(triggered()), this, SLOT(setStatusBusy())); |
|
|
|
|
connect(addFriendForm, SIGNAL(friendRequested(QString, QString)), this, SIGNAL(friendRequested(QString, QString))); |
|
|
|
|
connect(idleTimer, &QTimer::timeout, this, &Widget::onUserAwayCheck); |
|
|
|
|
connect(timer, &QTimer::timeout, this, &Widget::onUserAwayCheck); |
|
|
|
|
connect(timer, &QTimer::timeout, this, &Widget::onEventIconTick); |
|
|
|
|
|
|
|
|
|
coreThread->start(); |
|
|
|
|
|
|
|
|
@ -297,11 +300,15 @@ void Widget::setTranslation()
@@ -297,11 +300,15 @@ void Widget::setTranslation()
|
|
|
|
|
|
|
|
|
|
void Widget::updateTrayIcon() |
|
|
|
|
{ |
|
|
|
|
if (!icon) |
|
|
|
|
return; |
|
|
|
|
QString status = ui->statusButton->property("status").toString(); |
|
|
|
|
QString status; |
|
|
|
|
if (eventIcon) |
|
|
|
|
status = "event"; |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
status = ui->statusButton->property("status").toString(); |
|
|
|
|
if (!status.length()) |
|
|
|
|
status = "offline"; |
|
|
|
|
} |
|
|
|
|
QString color = Settings::getInstance().getLightTrayIcon() ? "light" : "dark"; |
|
|
|
|
QString pic = ":img/taskbar/" + color + "/taskbar_" + status + ".svg"; |
|
|
|
|
icon->setIcon(QIcon(pic)); |
|
|
|
@ -318,7 +325,7 @@ Widget::~Widget()
@@ -318,7 +325,7 @@ Widget::~Widget()
|
|
|
|
|
delete settingsWidget; |
|
|
|
|
delete addFriendForm; |
|
|
|
|
delete filesForm; |
|
|
|
|
delete idleTimer; |
|
|
|
|
delete timer; |
|
|
|
|
|
|
|
|
|
FriendList::clear(); |
|
|
|
|
GroupList::clear(); |
|
|
|
@ -858,6 +865,9 @@ void Widget::newMessageAlert(GenericChatroomWidget* chat)
@@ -858,6 +865,9 @@ void Widget::newMessageAlert(GenericChatroomWidget* chat)
|
|
|
|
|
|
|
|
|
|
QApplication::alert(this); |
|
|
|
|
|
|
|
|
|
if (inactiveWindow) |
|
|
|
|
eventFlag = true; |
|
|
|
|
|
|
|
|
|
if (Settings::getInstance().getShowWindow()) |
|
|
|
|
{ |
|
|
|
|
show(); |
|
|
|
@ -1097,20 +1107,20 @@ bool Widget::isFriendWidgetCurActiveWidget(Friend* f)
@@ -1097,20 +1107,20 @@ bool Widget::isFriendWidgetCurActiveWidget(Friend* f)
|
|
|
|
|
|
|
|
|
|
bool Widget::event(QEvent * e) |
|
|
|
|
{ |
|
|
|
|
switch(e->type()) { |
|
|
|
|
switch(e->type()) |
|
|
|
|
{ |
|
|
|
|
case QEvent::WindowActivate: |
|
|
|
|
if (activeChatroomWidget != nullptr) |
|
|
|
|
{ |
|
|
|
|
activeChatroomWidget->resetEventFlags(); |
|
|
|
|
activeChatroomWidget->updateStatusLight(); |
|
|
|
|
} |
|
|
|
|
case QEvent::MouseButtonPress: |
|
|
|
|
case QEvent::MouseButtonRelease: |
|
|
|
|
case QEvent::Wheel: |
|
|
|
|
case QEvent::KeyPress: |
|
|
|
|
case QEvent::KeyRelease: |
|
|
|
|
if (autoAwayActive) |
|
|
|
|
onUserAwayCheck(); // Just so we get back from away faster when interacting with app
|
|
|
|
|
if (eventFlag) |
|
|
|
|
{ |
|
|
|
|
eventFlag = false; |
|
|
|
|
eventIcon = false; |
|
|
|
|
updateTrayIcon(); |
|
|
|
|
} |
|
|
|
|
default: |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
@ -1146,6 +1156,15 @@ void Widget::onUserAwayCheck()
@@ -1146,6 +1156,15 @@ void Widget::onUserAwayCheck()
|
|
|
|
|
#endif |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void Widget::onEventIconTick() |
|
|
|
|
{ |
|
|
|
|
if (eventFlag) |
|
|
|
|
{ |
|
|
|
|
eventIcon ^= true; |
|
|
|
|
updateTrayIcon(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void Widget::setStatusOnline() |
|
|
|
|
{ |
|
|
|
|
core->setStatus(Status::Online); |
|
|
|
|