Commit 107a0f7e authored by scuq's avatar scuq

local release tests

parents 81fe1c4d 02d313ad
#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
......@@ -100,7 +100,9 @@ void dialogChat::setUnread()
this->m_unreadBlinkTimer->start((int)this->m_unreadBlinkInterval);
qApp->alert(this);
}
void dialogChat::setRead()
......@@ -339,16 +341,18 @@ void dialogChat::slChannelPosted(const QJsonDocument &replyJson, const QString &
QString dialogChat::formatChannelUser(const QString &username)
{
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("<font color=\"DeepPink\">");
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;
}
......@@ -475,7 +479,8 @@ void dialogChat::insertText(QString datetime, QString text, QString usernamestr)
QRegExp regExp("((([A-Za-z]{3,9}:(?:\\/\\/)?)(?:[\\-;:&=\\+\\$,\\w]+@)?[A-Za-z0-9\\.\\-]+|(?:www\\.|[\\-;:&=\\+\\$,\\w]+@)[A-Za-z0-9\\.\\-]+)((?:\\/[\\+~%\\/\\.\\w\\-]*)?\\??(?:[\\-\\+=&;%@\\.\\w]*)#?(?:[\\.\\!\\/\\\\\\w]*))?)");
QRegExp regExp("((([A-Za-z]{3,9}:(?:\\/\\/)?)(?:[\\-;:&=\\+\\$,\\w]+@)?[A-Za-z0-9\\.\\-]+|(?:www\\.|[\\-;:&=\\+\\$,\\w]+@)[A-Za-z0-9\\.\\-]+)((?:\\/[\\+~%\\/\\.\\w\\-]*)?\\??(?:[\\-\\+=&;%@()\\.\\w]*)#?(?:[\\.\\!\\/\\\\\\w]*))?)");
QString textout;
......@@ -484,7 +489,7 @@ void dialogChat::insertText(QString datetime, QString text, QString usernamestr)
int datewidth = fm.averageCharWidth() *1.4 * datetime.length() ;
text.replace(regExp, "<a href='\\1'>\\1</a>");
textout = QString("<table cellspacing=\"0\" cellpadding=\"5\" border=\"0\" width=\"100%\">" \
" <tr>" \
......@@ -495,7 +500,7 @@ void dialogChat::insertText(QString datetime, QString text, QString usernamestr)
"</table>" \
).arg(
datetime,
text,
text.toHtmlEscaped().replace("\n","<br>").replace(regExp, "<a href='\\1'>\\1</a>"),
usernamestr,
QString::number(this->longestUsernameLen),
QString::number(datewidth)
......@@ -668,6 +673,7 @@ void dialogChat::slChatSettingsChanged(QMap<QString, QVariant> chatsettings)
this->setChatFont( qvariant_cast<QFont>(chatsettings.value("chat_font")) );
this->setChatDateTimeFormat(chatsettings.value("chat_datetimeformat").toString());
this->setColorChatLink(QColor::fromRgba((unsigned)chatsettings.value("chat_color_link").toInt()));
this->setColorChatNick(QColor::fromRgba((unsigned)chatsettings.value("chat_color_nick").toInt()));
}
......@@ -753,6 +759,16 @@ void dialogChat::slOnBlinkTimerRefresh()
}
QColor dialogChat::getColorChatNick() const
{
return m_colorchatnick;
}
void dialogChat::setColorChatNick(const QColor &colorchatnick)
{
m_colorchatnick = colorchatnick;
}
QFont dialogChat::getChatFontInternal() const
{
return chatFont;
......@@ -770,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);
......
......@@ -54,6 +54,9 @@ public:
QFont getChatFontInternal() const;
void setChatFontInternal(QFont font);
QColor getColorChatNick() const;
void setColorChatNick(const QColor &colorchatnick);
private slots:
void on_plainTextEditChatInput_textChanged();
//void slChannelPostsReceived(const QJsonDocument &replyJson, const QString &channelid);
......@@ -73,6 +76,7 @@ private slots:
signals:
void siOnRead(QString channelid);
private:
Ui::dialogChat *ui;
ImSession *session;
......@@ -81,6 +85,7 @@ private:
manipulator *m_mp;
account *m_account;
QColor m_colorchatlink;
QColor m_colorchatnick;
int historicMsgPrintCount;
QFont chatFont;
QMap<QString, ImContact*> m_contacts;
......
......@@ -6,13 +6,17 @@
<rect>
<x>0</x>
<y>0</y>
<width>1020</width>
<height>524</height>
<width>649</width>
<height>521</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<property name="windowIcon">
<iconset resource="res.qrc">
<normaloff>:/images/aic.png</normaloff>:/images/aic.png</iconset>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing">
<number>1</number>
......@@ -34,8 +38,17 @@
<property name="spacing">
<number>1</number>
</property>
<property name="sizeConstraint">
<enum>QLayout::SetDefaultConstraint</enum>
</property>
<item>
<widget class="QTextBrowser" name="textBrowserChatOutput">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="autoFillBackground">
<bool>true</bool>
</property>
......@@ -56,7 +69,7 @@
<item>
<widget class="QPlainTextEdit" name="plainTextEditChatInput">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Minimum">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
......@@ -70,7 +83,7 @@
<property name="maximumSize">
<size>
<width>16777215</width>
<height>100</height>
<height>40</height>
</size>
</property>
<property name="verticalScrollBarPolicy">
......@@ -88,6 +101,8 @@
</item>
</layout>
</widget>
<resources/>
<resources>
<include location="res.qrc"/>
</resources>
<connections/>
</ui>
......@@ -100,6 +100,20 @@ void DialogPreferences::loadThemes()
}
QColor DialogPreferences::getColorChatNick() const
{
return colorChatNick;
}
void DialogPreferences::setColorChatNick(const QColor &value)
{
colorChatNick = value;
QString style = "background: rgb(%1, %2, %3);";
style = style.arg(colorChatNick.red()).arg(colorChatNick.green()).arg(colorChatNick.blue());
this->ui->labelColorChatNickSample->setStyleSheet(style);
}
QColor DialogPreferences::getColorUnread2() const
{
return colorUnread2;
......@@ -424,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)
......@@ -457,6 +477,8 @@ void DialogPreferences::slChatSettingsChanged(QMap<QString, QVariant> chatSettin
this->setColorChatLink( QColor::fromRgba((unsigned)chatSettings.value("chat_color_link").toInt()) );
this->setColorChatNick( QColor::fromRgba((unsigned)chatSettings.value("chat_color_nick").toInt()) );
}
......@@ -557,3 +579,18 @@ void DialogPreferences::on_pushButtonChooseUnreadcolor2_clicked()
this->m_mp->setGlobalColorUnread2(unsigned(color.rgba()));
}
}
void DialogPreferences::on_pushButtonChooseChatnickcolor_clicked()
{
QColor color = QColorDialog::getColor(this->getColorChatNick(), this );
if ( color.isValid() )
{
this->setColorChatNick(color);
this->m_mp->setChatColorNick(unsigned(color.rgba()));
}
}
void DialogPreferences::on_checkBoxCloseToTray_stateChanged(int arg1)
{
this->m_mp->setGlobalCloseToTray(arg1);
}
......@@ -84,6 +84,9 @@ public:
QColor getColorUnread2() const;
void setColorUnread2(const QColor &value);
QColor getColorChatNick() const;
void setColorChatNick(const QColor &value);
private slots:
......@@ -145,6 +148,12 @@ private slots:
void on_pushButtonChooseUnreadcolor2_clicked();
void on_pushButtonChooseChatnickcolor_clicked();
void on_checkBoxCloseToTray_stateChanged(int arg1);
private:
Ui::DialogPreferences *ui;
manipulator *m_mp;
......@@ -159,6 +168,7 @@ private:
QColor colorUnread2;
QColor colorChannel;
QColor colorChatLink;
QColor colorChatNick;
QFont chatFont;
QString chatDateTimeFormat;
QFont rosterFont;
......
This diff is collapsed.
......@@ -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));
......@@ -63,6 +64,7 @@ void manipulator::loadSettings()
this->setChatFont(settings.value("chat_font"));
this->setChatDateTimeFormat(settings.value("chat_datetimeformat","yyyy-MM-dd HH:mm:ss"));
this->setChatColorLink(settings.value("chat_color_link", "4278255487"));
this->setChatColorNick(settings.value("chat_color_nick", "4294907222"));
}
......@@ -87,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"] );
......@@ -96,6 +99,7 @@ void manipulator::saveSettings()
settings.setValue( "chat_font", this->m_chatSettings["chat_font"] );
settings.setValue( "chat_datetimeformat", this->m_chatSettings["chat_datetimeformat"] );
settings.setValue( "chat_color_link", this->m_chatSettings["chat_color_link"] );
settings.setValue( "chat_color_nick", this->m_chatSettings["chat_color_nick"] );
......@@ -202,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);
......@@ -246,7 +255,12 @@ void manipulator::setChatDateTimeFormat(const QVariant &format)
void manipulator::setChatColorLink(const QVariant &color)
{
this->updateSettingMap(this->m_chatSettings, "chat_color_link", color);
this->updateSettingMap(this->m_chatSettings, "chat_color_link", color);
}
void manipulator::setChatColorNick(const QVariant &color)
{
this->updateSettingMap(this->m_chatSettings, "chat_color_nick", color);
}
void manipulator::setSaveWindowStatePosition(const QString windowtitle, const QByteArray geometry, const QByteArray state)
......
......@@ -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);
......@@ -58,6 +59,7 @@ public:
void setChatFont(const QVariant &font);
void setChatDateTimeFormat(const QVariant &format);
void setChatColorLink(const QVariant &color);
void setChatColorNick(const QVariant &color);
void setSaveWindowStatePosition(const QString windowtitle, const QByteArray geometry, const QByteArray state);
QByteArray getLoadWindowPosition(const QString windowtitle);
......
......@@ -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 \
......
......@@ -29,6 +29,8 @@ qmMainWindow::qmMainWindow(QWidget *parent) :
this->createActions();
this->loadConfig();
this->setupDialogs();
this->setupTableViews();
......@@ -36,6 +38,8 @@ qmMainWindow::qmMainWindow(QWidget *parent) :
this->printDebugSslLib();
this->setupTrayIcon();
......@@ -72,6 +76,9 @@ void qmMainWindow::createActions()
{
actionAddIgnore = new QAction(tr("Add to local ignore list"), this);
connect(actionAddIgnore, SIGNAL(triggered()), this, SLOT(slActionAddIgnore()));
}
void qmMainWindow::loadConfig()
......@@ -192,6 +199,7 @@ void qmMainWindow::setupTableViews()
connect(rostermodel, SIGNAL(siRosterLoaded()), this, SLOT(slRosterLoaded()));
connect( this->m_mp, SIGNAL(siGlobalSettingsChanged(QMap<QString, QVariant>)), rostermodel, SLOT(slGlobalSettingsChanged(QMap<QString, QVariant>)) );
connect( this->m_mp, SIGNAL(siRosterSettingsChanged(QMap<QString, QVariant>)), rostermodel, SLOT(slRosterSettingsChanged(QMap<QString, QVariant>)) );
connect(rostermodel, SIGNAL(siUnreadsPending()), this, SLOT(slUnreadsPending()));
this->m_mp->apply();
......@@ -272,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()
......@@ -281,6 +295,34 @@ void qmMainWindow::restoreWindowPositionState()
restoreState(this->m_mp->getLoadWindowState("main"));
}
void qmMainWindow::createTrayIcon()
{
trayIcon = new AicTrayIcon(this);
connect(trayIcon,SIGNAL(activated(QSystemTrayIcon::ActivationReason)),this,SLOT(trayIconActivated(QSystemTrayIcon::ActivationReason)));
}
bool qmMainWindow::getCloseToTray() const
{
return closeToTray;
}
void qmMainWindow::setCloseToTray(bool value)
{
closeToTray = value;
}
void qmMainWindow::setupTrayIcon()
{
createTrayIcon();
trayIcon->show();
}
void qmMainWindow::on_action_Manage_Accounts_triggered()
......@@ -414,15 +456,23 @@ void qmMainWindow::slOnRosterClicked(const QModelIndex &index)
if ( !( chatDialogs.keys().contains(_contact->getId()) ) ) {
dialogChat *diaChat = new dialogChat(this,rm->getSession(), this->m_mp, _contact, rm->getSession()->getAccount(), this->m_chatSettings);
dialogChat *diaChat = new dialogChat(0,rm->getSession(), this->m_mp, _contact, rm->getSession()->getAccount(), this->m_chatSettings);
connect( this->m_mp, SIGNAL(siChatSettingsChanged(QMap<QString, QVariant>)), diaChat, SLOT(slChatSettingsChanged(QMap<QString, QVariant>)) );
connect( this->m_mp, SIGNAL(siGlobalSettingsChanged(QMap<QString, QVariant>)), diaChat, SLOT(slGlobalSettingsChanged(QMap<QString, QVariant>)) );
this->m_mp->apply();
connect(diaChat, SIGNAL(siOnRead(QString)), rm, SLOT(slOnRead(QString)));
Qt::WindowFlags flags = Qt::Dialog | Qt::WindowSystemMenuHint
| Qt::WindowMinimizeButtonHint
| Qt::WindowCloseButtonHint;
diaChat->setWindowFlags(flags);
diaChat->show();
chatDialogs.insert(_contact->getId(), diaChat);
......@@ -457,6 +507,33 @@ void qmMainWindow::slRosterLoaded()
}
}
void qmMainWindow::slExit()
{
qApp->quit();
}
void qmMainWindow::slShow()
{
this->show();
this->setWindowState(Qt::WindowNoState);
}
void qmMainWindow::slUnreadsPending()
{
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)
{
......@@ -492,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)
......
......@@ -12,6 +12,7 @@
#include <QComboBox>
#include <QSignalMapper>
#include <QCloseEvent>
#include <QSystemTrayIcon>
#include "manipulator.h"
#include "dialogaccounts.h"
#include "dialogpreferences.h"
......@@ -22,6 +23,7 @@
#include "rostersortfilterproxymodel.h"
#include "updatecheck.h"
#include "dialogchat.h"
#include "aictrayicon.h"
namespace Ui {
class qmMainWindow;
......@@ -35,6 +37,7 @@ public:
explicit qmMainWindow(QWidget *parent = nullptr);
~qmMainWindow();