Commit 02d313ad authored by scuq's avatar scuq

work in progress animated png

parent d9ea3df1
Pipeline #370 failed with stage
in 39 seconds
#include "aictrayicon.h"
AicTrayIcon::AicTrayIcon(QWidget *parent)
{
this->myParent = parent;
this->setupIcon();
}
void AicTrayIcon::setupIcon()
{
menu = new QMenu(this->myParent);
iconMovie = new QMovie((":/images/aic.png"));
iconMovie->start();
actionOpen = new QAction(tr("&Open"), this);
connect(actionOpen, SIGNAL(triggered()), this->myParent, SLOT(slShow()));
actionClose = new QAction(tr("&Exit"), this);
connect(actionClose, SIGNAL(triggered()), this->myParent, SLOT(slExit()));
menu->addAction(actionOpen);
menu->addSeparator();
menu->addAction(actionClose);
this->setContextMenu(menu);
this->updateIcon();
}
void AicTrayIcon::updateIcon()
{
QIcon _icon = QIcon();
_icon.addPixmap(this->iconMovie->currentPixmap());
this->setIcon(_icon);
}
void AicTrayIcon::slBeFlashy()
{
iconMovie-
}
#ifndef AICTRAYICON_H
#define AICTRAYICON_H
#include <QObject>
#include <QMenu>
#include <QAction>
#include <QSystemTrayIcon>
#include <QMovie>
class AicTrayIcon : public QSystemTrayIcon
{
Q_OBJECT
public:
AicTrayIcon(QWidget *parent);
private:
void setupIcon();
void updateIcon();
QMenu *menu;
QAction *actionOpen;
QAction *actionClose;
QWidget *myParent;
QMovie *iconMovie;
private slots:
void slBeFlashy();
void slBeUnFlashy();
};
#endif // AICTRAYICON_H
......@@ -342,22 +342,17 @@ void dialogChat::slChannelPosted(const QJsonDocument &replyJson, const QString &
QString dialogChat::formatChannelUser(const QString &username)
{
QString style = QString("color=\"rgb(%1, %2, %3)\"").arg( this->getColorChatNick().red(), this->getColorChatNick().green(), this->getColorChatNick().blue() );
qDebug() << this->getColorChatNick();
//QString style = "background: rgb(%1, %2, %3);";
// style = style.arg(colorChannel.red()).arg(colorChannel.green()).arg(colorChannel.blue());
QString style = QString("color=\"%1\"").arg( this->getColorChatNick().name() );
QString formatedUsername;
//formatedUsername = QString("< %1 >").arg(username);
formatedUsername = username;
formatedUsername = username;
// formatedUsername = username.rightJustified(this->longestUsernameLen+1, ' ', false);
formatedUsername.replace(" ","&nbsp;");
formatedUsername += "> ";
formatedUsername.prepend(QString("<font %1>").arg(style));
formatedUsername.append("</font>");
// formatedUsername = username.rightJustified(this->longestUsernameLen+1, ' ', false);
formatedUsername.replace(" ","&nbsp;");
formatedUsername += "> ";
formatedUsername.prepend(QString("<font %1>").arg(style));
formatedUsername.append("</font>");
return formatedUsername;
}
......@@ -791,6 +786,7 @@ void dialogChat::setColorChatLink(const QColor &colorchatlink)
style += " table { margin: 0px; padding: 0px; border-collapse: collapse; } ";
style += " * { margin: 0; padding: 0; } ";
style = style.arg(colorchatlink.red()).arg(colorchatlink.green()).arg(colorchatlink.blue());
this->ui->textBrowserChatOutput->document()->setDefaultStyleSheet(style);
......
......@@ -438,6 +438,12 @@ void DialogPreferences::slGlobalSettingsChanged(QMap<QString, QVariant> globalSe
this->ui->checkBoxUpdatecheck->setCheckState(Qt::CheckState::Unchecked);
}
if (globalSettings.value("close_to_tray").toInt() > 0) {
this->ui->checkBoxCloseToTray->setCheckState(Qt::CheckState::Checked);
} else {
this->ui->checkBoxCloseToTray->setCheckState(Qt::CheckState::Unchecked);
}
}
void DialogPreferences::slRosterSettingsChanged(QMap<QString, QVariant> rosterSettings)
......@@ -583,3 +589,8 @@ void DialogPreferences::on_pushButtonChooseChatnickcolor_clicked()
this->m_mp->setChatColorNick(unsigned(color.rgba()));
}
}
void DialogPreferences::on_checkBoxCloseToTray_stateChanged(int arg1)
{
this->m_mp->setGlobalCloseToTray(arg1);
}
......@@ -150,6 +150,10 @@ private slots:
void on_pushButtonChooseChatnickcolor_clicked();
void on_checkBoxCloseToTray_stateChanged(int arg1);
private:
Ui::DialogPreferences *ui;
manipulator *m_mp;
......
......@@ -32,7 +32,7 @@
<x>0</x>
<y>-564</y>
<width>444</width>
<height>1106</height>
<height>1125</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
......@@ -528,54 +528,28 @@ p, li { white-space: pre-wrap; }
<string>Advanced</string>
</property>
<layout class="QGridLayout" name="gridLayout_5" columnminimumwidth="0,10,100">
<item row="3" column="2">
<widget class="QSpinBox" name="spinBoxAfkTimeout">
<property name="suffix">
<string> ms</string>
</property>
<property name="minimum">
<number>30000</number>
</property>
<property name="maximum">
<number>86400000</number>
</property>
<property name="singleStep">
<number>60000</number>
</property>
<property name="value">
<number>60000</number>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="labelStatusRefreshInterval">
<property name="text">
<string>Roster Status Refresh Interval</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="labelAfkTimeout">
<widget class="QLabel" name="labelUpdateCheck">
<property name="text">
<string>AFK suppress timeout</string>
<string>Update Check</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="labelSelfStatusRefreshInterval">
<widget class="QLabel" name="labelStatusRefreshInterval">
<property name="text">
<string>Self Status Refresh/Repost Interval</string>
<string>Roster Status Refresh Interval</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="labelUpdateCheck">
<item row="5" column="0" colspan="3">
<widget class="QLabel" name="label">
<property name="text">
<string>Update Check</string>
<string>Note 300000 ms (5min) will be added by mattermost server activity detection</string>
</property>
</widget>
</item>
<item row="2" column="2">
<item row="3" column="2">
<widget class="QSpinBox" name="spinBoxSelfStatusRefreshInterval">
<property name="suffix">
<string> ms</string>
......@@ -594,21 +568,40 @@ p, li { white-space: pre-wrap; }
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QCheckBox" name="checkBoxUpdatecheck">
<item row="3" column="0">
<widget class="QLabel" name="labelSelfStatusRefreshInterval">
<property name="text">
<string/>
<string>Self Status Refresh/Repost Interval</string>
</property>
</widget>
</item>
<item row="4" column="0" colspan="3">
<widget class="QLabel" name="label">
<item row="4" column="0">
<widget class="QLabel" name="labelAfkTimeout">
<property name="text">
<string>Note 300000 ms (5min) will be added by mattermost server activity detection</string>
<string>AFK suppress timeout</string>
</property>
</widget>
</item>
<item row="1" column="2">
<item row="4" column="2">
<widget class="QSpinBox" name="spinBoxAfkTimeout">
<property name="suffix">
<string> ms</string>
</property>
<property name="minimum">
<number>30000</number>
</property>
<property name="maximum">
<number>86400000</number>
</property>
<property name="singleStep">
<number>60000</number>
</property>
<property name="value">
<number>60000</number>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QSpinBox" name="spinBoxStatusRefreshInterval">
<property name="suffix">
<string> ms</string>
......@@ -627,7 +620,7 @@ p, li { white-space: pre-wrap; }
</property>
</widget>
</item>
<item row="0" column="1">
<item row="1" column="1">
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
......@@ -640,6 +633,27 @@ p, li { white-space: pre-wrap; }
</property>
</spacer>
</item>
<item row="1" column="2">
<widget class="QCheckBox" name="checkBoxUpdatecheck">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="labelCloseToTray">
<property name="text">
<string>Close to tray</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QCheckBox" name="checkBoxCloseToTray">
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</widget>
</item>
......
......@@ -54,6 +54,7 @@ void manipulator::loadSettings()
this->setGlobalAfkTimeout(settings.value("afk_timeout", 60000));
this->setGlobalUpdateCheck(settings.value("update_check", 2));
this->setGlobalTheme((settings.value("theme")));
this->setGlobalCloseToTray(settings.value("close_to_tray", 2));
this->setRosterHideOffline(settings.value("roster_hide_offline", 2));
this->setRosterHideStatusText(settings.value("roster_hide_statustext", 2));
......@@ -88,6 +89,7 @@ void manipulator::saveSettings()
settings.setValue( "afk_timeout", this->m_globalSettings["afk_timeout"] );
settings.setValue( "update_check", this->m_globalSettings["update_check"] );
settings.setValue( "theme", this->m_globalSettings["theme"] );
settings.setValue( "close_to_tray", this->m_globalSettings["close_to_tray"] );
settings.setValue( "roster_hide_offline", this->m_rosterSettings["roster_hide_offline"] );
settings.setValue( "roster_hide_statustext", this->m_rosterSettings["roster_hide_statustext"] );
......@@ -204,6 +206,11 @@ void manipulator::setGlobalUpdateCheck(const QVariant &updatecheck)
this->updateSettingMap(this->m_globalSettings, "update_check", updatecheck);
}
void manipulator::setGlobalCloseToTray(const QVariant &closetotray)
{
this->updateSettingMap(this->m_globalSettings, "close_to_tray", closetotray);
}
void manipulator::setRosterHideOffline(const QVariant &hideoffline)
{
this->updateSettingMap(this->m_rosterSettings, "roster_hide_offline", hideoffline);
......
......@@ -50,6 +50,7 @@ public:
void setGlobalSelfStatusRefreshInterval(const QVariant &interval);
void setGlobalAfkTimeout(const QVariant &timeout);
void setGlobalUpdateCheck(const QVariant &updatecheck);
void setGlobalCloseToTray(const QVariant &closetotray);
void setRosterHideOffline(const QVariant &hideoffline);
void setRosterHideStatusText(const QVariant &hidestatustext);
void addRosterLocalHide(const QVariant &rosternickname);
......
......@@ -49,7 +49,8 @@ SOURCES += \
manipulator.cpp \
replytimeout.cpp \
dialogfileviewer.cpp \
qclicklabel.cpp
qclicklabel.cpp \
aictrayicon.cpp
HEADERS += \
qmmainwindow.h \
......@@ -73,7 +74,8 @@ HEADERS += \
manipulator.h \
replytimeout.h \
dialogfileviewer.h \
qclicklabel.h
qclicklabel.h \
aictrayicon.h
FORMS += \
qmmainwindow.ui \
......
......@@ -77,13 +77,8 @@ void qmMainWindow::createActions()
actionAddIgnore = new QAction(tr("Add to local ignore list"), this);
connect(actionAddIgnore, SIGNAL(triggered()), this, SLOT(slActionAddIgnore()));
actionTrayOpen = new QAction(tr("&Open"), this);
connect(actionTrayOpen, SIGNAL(triggered()), this, SLOT(slShow()));
actionTrayClose = new QAction(tr("&Exit"), this);
connect(actionTrayClose, SIGNAL(triggered()), this, SLOT(slExit()));
}
void qmMainWindow::loadConfig()
......@@ -285,7 +280,13 @@ accntviews.value()->setModel(fsModel);
void qmMainWindow::closeEvent(QCloseEvent *closeev)
{
this->m_mp->setSaveWindowStatePosition("main", saveGeometry(),saveState());
closeev->accept();
if (this->getCloseToTray() == true) {
this->trayIcon->showMessage(appname+" closed to tray.","");
this->hide();
closeev->ignore();
} else {
closeev->accept();
}
}
void qmMainWindow::restoreWindowPositionState()
......@@ -296,18 +297,22 @@ void qmMainWindow::restoreWindowPositionState()
void qmMainWindow::createTrayIcon()
{
trayIconMenu = new QMenu(this);
trayIconMenu->addAction(actionTrayOpen);
trayIconMenu->addSeparator();
trayIconMenu->addAction(actionTrayClose);
trayIcon = new QSystemTrayIcon(this);
trayIcon->setContextMenu(trayIconMenu);
connect(trayIcon,SIGNAL(activated(QSystemTrayIcon::ActivationReason)),this,SLOT(trayIconClicked(QSystemTrayIcon::ActivationReason)));
trayIcon = new AicTrayIcon(this);
connect(trayIcon,SIGNAL(activated(QSystemTrayIcon::ActivationReason)),this,SLOT(trayIconActivated(QSystemTrayIcon::ActivationReason)));
}
void qmMainWindow::setTrayIcon(QString iconname)
bool qmMainWindow::getCloseToTray() const
{
trayIcon->setIcon(QIcon(":/images/"+iconname+".png"));
return closeToTray;
}
void qmMainWindow::setCloseToTray(bool value)
{
closeToTray = value;
}
......@@ -315,7 +320,6 @@ void qmMainWindow::setTrayIcon(QString iconname)
void qmMainWindow::setupTrayIcon()
{
createTrayIcon();
setTrayIcon();
trayIcon->show();
}
......@@ -516,10 +520,20 @@ void qmMainWindow::slShow()
void qmMainWindow::slUnreadsPending()
{
qDebug() << "UNREEEEEEEEEEEEEEEEEEEEEEEEEEEEEe";
qApp->alert(this);
}
void qmMainWindow::trayIconActivated(QSystemTrayIcon::ActivationReason reason)
{
if(reason == QSystemTrayIcon::DoubleClick) {
this->show();
this->raise();
this->activateWindow();
if( this->isMinimized() )
this->showNormal();
}
}
void qmMainWindow::loadTheme(QString theme)
{
......@@ -555,6 +569,9 @@ void qmMainWindow::slGlobalSettingsChanged(QMap<QString, QVariant> globalSetting
//fix this
uc->checkUpdate();
this->setCloseToTray(globalSettings.value("close_to_tray").toBool());
}
void qmMainWindow::slRosterSettingsChanged(QMap<QString, QVariant> rosterSettings)
......
......@@ -23,6 +23,7 @@
#include "rostersortfilterproxymodel.h"
#include "updatecheck.h"
#include "dialogchat.h"
#include "aictrayicon.h"
namespace Ui {
class qmMainWindow;
......@@ -36,6 +37,7 @@ public:
explicit qmMainWindow(QWidget *parent = nullptr);
~qmMainWindow();
private:
void printDebugSslLib();
void setupDialogs();
......@@ -46,13 +48,13 @@ private:
void closeEvent(QCloseEvent *closeev);
void restoreWindowPositionState();
void createTrayIcon();
void setTrayIcon(QString iconname = "aic");
bool getCloseToTray() const;
void setCloseToTray(bool value);
manipulator *m_mp;
QSystemTrayIcon *trayIcon;
QMenu *trayIconMenu;
QAction *actionTrayOpen;
QAction *actionTrayClose;
AicTrayIcon *trayIcon;
QAction *actionAddIgnore;
QAction *actionRemoveIgnore;
dialogAccounts *diaAccounts;
......@@ -66,6 +68,7 @@ private:
updateCheck *uc;
QMap<QString, QVariant> m_chatSettings;
bool updateQuestionShown;
bool closeToTray;
void setupUpdateCheck();
......@@ -100,6 +103,7 @@ private slots:
void slExit();
void slShow();
void slUnreadsPending();
void trayIconActivated(QSystemTrayIcon::ActivationReason reason);
void slGlobalSettingsChanged(QMap<QString, QVariant> globalSettings);
......
......@@ -2,6 +2,7 @@
<qresource prefix="/">
<file>images/aic.png</file>
<file>themes/dark.qss</file>
<file>images/aic_alt.png</file>
</qresource>
<qresource prefix="/themes"/>
</RCC>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment