Commit 39812321 authored by scuq's avatar scuq

cosmetics

parent 5a65686a
Pipeline #405 passed with stage
in 1 minute and 20 seconds
......@@ -162,10 +162,12 @@ set(CPACK_PACKAGE_VERSION_PATCH ${AIC_PATCH_VERSION})
set(CPACK_PACKAGE_CONTACT "scuq")
SET(CPACK_NSIS_EXECUTABLES_DIRECTORY ".")
set(CPACK_PACKAGE_INSTALL_DIRECTORY "aic")
SET(CPACK_PACKAGE_INSTALL_DIRECTORY "aic")
SET(CPACK_NSIS_MUI_ICON "${CMAKE_CURRENT_SOURCE_DIR}/aic.ico")
SET(CPACK_NSIS_MUI_UNIICON ${CPACK_NSIS_MUI_ICON})
set(CPACK_NSIS_EXTRA_INSTALL_COMMANDS " CreateShortCut '$DESKTOP\\\\aic.lnk' '$INSTDIR\\\\bin\\\\aic.exe' ")
SET(CPACK_NSIS_URL_INFO_ABOUT "https://git.abyle.org/scuq/aic")
SET(CPACK_NSIS_EXTRA_INSTALL_COMMANDS " CreateShortCut '$DESKTOP\\\\aic.lnk' '$INSTDIR\\\\bin\\\\aic.exe' ")
SET(CPACK_NSIS_EXTRA_PREINSTALL_COMMANDS "ExecWait 'taskkill /F /IM aic.exe'")
if(APPLE)
set_target_properties(aic PROPERTIES MACOSX_BUNDLE_INFO_PLIST MyBundleInfo.plist.in)
......
......@@ -40,7 +40,7 @@ dialogChat::dialogChat(QWidget *parent, ImSession *session, manipulator *manipul
this->ui->wAttachment->setVisible(false);
this->shine();
}
......@@ -50,6 +50,15 @@ dialogChat::~dialogChat()
delete ui;
}
void dialogChat::shine()
{
this->show();
this->raise();
this->ui->plainTextEditChatInput->setFocus();
this->ui->plainTextEditChatInput->setTextCursor(this->ui->plainTextEditChatInput->textCursor());
}
void dialogChat::setChatDetails()
{
this->setWindowTitle( QString("aicChat - %1").arg(this->contact->getUsername()) );
......@@ -429,7 +438,12 @@ void dialogChat::slChannelPosted(const QJsonDocument &replyJson, const QString &
QString dialogChat::formatChannelUser(const QString &username)
{
QString style = QString("color=\"%1\"").arg( this->getColorChatNick().name() );
QString style;
if (this->session->getAccount()->getNickname() == username) {
style = QString("color=\"%1\"").arg( this->getColorChatNickSelf().name() );
} else {
style = QString("color=\"%1\"").arg( this->getColorChatNick().name() );
}
QString formatedUsername;
......@@ -508,6 +522,8 @@ void dialogChat::slOnMessageReceived(QDateTime timestamp, QString message, bool
if (channelid == this->contact->getDirectChannelId()) {
......@@ -563,9 +579,6 @@ void dialogChat::slGlobalSettingsChanged(QMap<QString, QVariant> globalSettings)
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]*))?)");
......@@ -580,8 +593,8 @@ void dialogChat::insertText(QString datetime, QString text, QString usernamestr)
textout = QString("<table cellspacing=\"0\" cellpadding=\"5\" border=\"0\" width=\"100%\">" \
" <tr>" \
" <td width=\"%5\">[%1]</td>" \
" <td align=\"right\" width=\"%4\">%3</td>" \
" <td width=\"%5\"><p style=\"color: %6;\">[%1]</p></td>" \
" <td align=\"right\" width=\"%4\"><b>%3</b></td>" \
" <td width=\"*\">%2</td>" \
" </tr>" \
"</table>" \
......@@ -590,15 +603,11 @@ void dialogChat::insertText(QString datetime, QString text, QString usernamestr)
text.toHtmlEscaped().replace("\n","<br>").replace(regExp, "<a href='\\1'>\\1</a>"),
usernamestr,
QString::number(this->longestUsernameLen),
QString::number(datewidth)
QString::number(datewidth),
this->getColorChatTimestamp().name()
);
qDebug() << longestUsernameLen;
// textout.toHtmlEscaped();
qDebug() << "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAa" << this->getColorChatTimestamp().name();
// <p style="color: #000000;"></p>
QTextCursor cursor = this->ui->textBrowserChatOutput->textCursor();
......@@ -607,21 +616,13 @@ void dialogChat::insertText(QString datetime, QString text, QString usernamestr)
cursor.setCharFormat(format);
this->ui->textBrowserChatOutput->setCurrentCharFormat(format);
//cursor.beginEditBlock();
//cursor.insertText("\n"+text);
//cursor.insertText("<br>"+text.replace(regExp, "<a href='\\1'>\\1</a>"));
cursor.movePosition(QTextCursor::End);
this->ui->textBrowserChatOutput->setTextCursor(cursor);
cursor.insertHtml(textout);
cursor.insertHtml(textout);
this->ui->textBrowserChatOutput->verticalScrollBar()->setValue(this->ui->textBrowserChatOutput->verticalScrollBar()->maximum());
//cursor.insertHtml("<a href=http://www.google.at>link text</a>");
//cursor.endEditBlock();
}
void dialogChat::insertHline()
......@@ -769,6 +770,8 @@ void dialogChat::slChatSettingsChanged(QMap<QString, QVariant> chatsettings)
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()));
this->setColorChatNickSelf(QColor::fromRgba((unsigned)chatsettings.value("chat_color_nickself").toInt()));
this->setColorChatTimestamp(QColor::fromRgba((unsigned)chatsettings.value("chat_color_timestamp").toInt()));
}
......@@ -895,6 +898,26 @@ void dialogChat::slAttachmentIdsReceived(const QStringList &fileids, const QStri
}
QColor dialogChat::getColorChatNickSelf() const
{
return m_colorchatnickself;
}
void dialogChat::setColorChatNickSelf(const QColor &colorchatnickself)
{
m_colorchatnickself = colorchatnickself;
}
QColor dialogChat::getColorChatTimestamp() const
{
return m_colorchattimestamp;
}
void dialogChat::setColorChatTimestamp(const QColor &colorchattimestamp)
{
m_colorchattimestamp = colorchattimestamp;
}
QStringList dialogChat::getAttachmentIds() const
{
return m_attachmentIds;
......
......@@ -32,6 +32,7 @@ public:
~dialogChat();
void shine();
QColor getColorUnread() const;
void setColorUnread(const QColor &value);
......@@ -66,6 +67,12 @@ public:
void setAttachmentIds(const QStringList &attachmentIds);
void resetAttachmentIds();
QColor getColorChatTimestamp() const;
void setColorChatTimestamp(const QColor &colorchattimestamp);
QColor getColorChatNickSelf() const;
void setColorChatNickSelf(const QColor &colorchatnickself);
private slots:
void on_plainTextEditChatInput_textChanged();
//void slChannelPostsReceived(const QJsonDocument &replyJson, const QString &channelid);
......@@ -98,6 +105,8 @@ private:
account *m_account;
QColor m_colorchatlink;
QColor m_colorchatnick;
QColor m_colorchatnickself;
QColor m_colorchattimestamp;
int historicMsgPrintCount;
QFont chatFont;
QMap<QString, ImContact*> m_contacts;
......
......@@ -11,8 +11,7 @@ DialogPreferences::DialogPreferences(QWidget *parent, manipulator *mp) :
ui->setupUi(this);
this->setupSignals();
this->loadThemes();
this->refreshAvailableThemes();
}
......@@ -73,7 +72,58 @@ void DialogPreferences::saveSettings()
this->m_mp->saveSettings();
}
void DialogPreferences::refreshAvailableThemes()
{
foreach (QString fileName, this->m_mp->getAvailableThemes()) {
this->ui->comboBoxTheme->addItem(fileName);
}
}
QColor DialogPreferences::getColorChatNickSelf() const
{
return colorChatNickSelf;
}
void DialogPreferences::setColorChatNickSelf(const QColor &value)
{
colorChatNickSelf = value;
QString style = "background: rgb(%1, %2, %3);";
style = style.arg(colorChatNickSelf.red()).arg(colorChatNickSelf.green()).arg(colorChatNickSelf.blue());
this->ui->labelColorChatNickSelfSample->setStyleSheet(style);
}
QColor DialogPreferences::getColorRosterHighlight() const
{
return colorRosterHighlight;
}
void DialogPreferences::setColorRosterHighlight(const QColor &value)
{
colorRosterHighlight = value;
QString style = "background: rgb(%1, %2, %3);";
style = style.arg(colorRosterHighlight.red()).arg(colorRosterHighlight.green()).arg(colorRosterHighlight.blue());
this->ui->labelColorRosterHighlightSample->setStyleSheet(style);
}
QColor DialogPreferences::getColorChatTimestamp() const
{
return colorChatTimestamp;
}
void DialogPreferences::setColorChatTimestamp(const QColor &value)
{
colorChatTimestamp = value;
QString style = "background: rgb(%1, %2, %3);";
style = style.arg(colorChatTimestamp.red()).arg(colorChatTimestamp.green()).arg(colorChatTimestamp.blue());
this->ui->labelColorChatTimestampSample->setStyleSheet(style);
}
/*
void DialogPreferences::loadThemes()
{
QString _themedir = QStandardPaths::writableLocation(QStandardPaths::HomeLocation) + QDir::separator() + appname;
......@@ -99,6 +149,7 @@ void DialogPreferences::loadThemes()
}
}
*/
QColor DialogPreferences::getColorChatNick() const
{
......@@ -471,6 +522,7 @@ void DialogPreferences::slRosterSettingsChanged(QMap<QString, QVariant> rosterSe
QFont _rosterfont = qvariant_cast<QFont>(rosterSettings["roster_font"]);
this->setRosterFont(_rosterfont);
this->setColorRosterHighlight( QColor::fromRgba((unsigned)rosterSettings.value("roster_color_highlight").toInt()) );
}
......@@ -485,6 +537,9 @@ void DialogPreferences::slChatSettingsChanged(QMap<QString, QVariant> chatSettin
this->setColorChatNick( QColor::fromRgba((unsigned)chatSettings.value("chat_color_nick").toInt()) );
this->setColorChatNickSelf( QColor::fromRgba((unsigned)chatSettings.value("chat_color_nickself").toInt()) );
this->setColorChatTimestamp( QColor::fromRgba((unsigned)chatSettings.value("chat_color_timestamp").toInt()) );
}
......@@ -605,3 +660,33 @@ void DialogPreferences::on_checkBoxHideMuc_stateChanged(int arg1)
{
this->m_mp->setRosterHideMuc(arg1);
}
void DialogPreferences::on_pushButtonChooseChatTimestampColor_clicked()
{
QColor color = QColorDialog::getColor(this->getColorChatTimestamp(), this );
if ( color.isValid() )
{
this->setColorChatTimestamp(color);
this->m_mp->setChatColorTimestamp(unsigned(color.rgba()));
}
}
void DialogPreferences::on_pushButtonChooseRosterHighlightColor_clicked()
{
QColor color = QColorDialog::getColor(this->getColorRosterHighlight(), this );
if ( color.isValid() )
{
this->setColorRosterHighlight(color);
this->m_mp->setRosterColorHighlight(unsigned(color.rgba()));
}
}
void DialogPreferences::on_pushButtonChooseChatnickselfcolor_clicked()
{
QColor color = QColorDialog::getColor(this->getColorChatNickSelf(), this );
if ( color.isValid() )
{
this->setColorChatNickSelf(color);
this->m_mp->setChatColorNickSelf(unsigned(color.rgba()));
}
}
......@@ -55,8 +55,6 @@ public:
QColor getColorUnread() const;
void setColorUnread(const QColor &value);
QFont getChatFont() const;
void setChatFont(const QFont &value);
......@@ -87,6 +85,15 @@ public:
QColor getColorChatNick() const;
void setColorChatNick(const QColor &value);
QColor getColorChatTimestamp() const;
void setColorChatTimestamp(const QColor &value);
QColor getColorRosterHighlight() const;
void setColorRosterHighlight(const QColor &value);
QColor getColorChatNickSelf() const;
void setColorChatNickSelf(const QColor &value);
private slots:
......@@ -132,8 +139,6 @@ private slots:
void on_pushButtonChooseChannelcolor_clicked();
void on_comboBoxChannelShape_currentTextChanged(const QString &arg1);
void on_pushButtonRosterFont_clicked();
......@@ -150,19 +155,23 @@ private slots:
void on_pushButtonChooseChatnickcolor_clicked();
void on_checkBoxCloseToTray_stateChanged(int arg1);
void on_checkBoxHideMuc_stateChanged(int arg1);
void on_pushButtonChooseChatTimestampColor_clicked();
void on_pushButtonChooseRosterHighlightColor_clicked();
void on_pushButtonChooseChatnickselfcolor_clicked();
private:
Ui::DialogPreferences *ui;
manipulator *m_mp;
bool dialogShown;
void setupSignals();
void saveSettings();
void loadThemes();
void refreshAvailableThemes();
QColor colorOnline;
QColor colorAway;
QColor colorOffline;
......@@ -171,6 +180,9 @@ private:
QColor colorChannel;
QColor colorChatLink;
QColor colorChatNick;
QColor colorChatNickSelf;
QColor colorChatTimestamp;
QColor colorRosterHighlight;
QFont chatFont;
QString chatDateTimeFormat;
QFont rosterFont;
......
This diff is collapsed.
......@@ -2,7 +2,15 @@
manipulator::manipulator(QObject *parent) : QObject(parent)
{
this->setWantedMigrationLevel(1);
this->loadEmbeddedFonts();
if ( this->migrationNeeded() )
{
this->migrate(this->getWantedMigrationLevel());
}
this->loadSettings();
this->createDefaultThemes();
}
int manipulator::numberOfChanges() const
......@@ -61,13 +69,69 @@ void manipulator::loadSettings()
this->setRosterHideStatusText(settings.value("roster_hide_statustext", 2));
this->setRosterLocalHide(settings.value("roster_local_hidelist", ""));
this->setRosterFont(settings.value("roster_font", ""));
this->setRosterColorHighlight(settings.value("roster_color_highlight", "4282533453"));
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"));
this->setChatColorNickSelf(settings.value("chat_color_nickself", "4285367245"));
this->setChatColorTimestamp(settings.value("chat_color_timestamp", "4283914847"));
}
void manipulator::loadEmbeddedFonts()
{
QFontDatabase::addApplicationFont(":/fonts/pt_mono.ttf");
}
bool manipulator::migrationNeeded()
{
QSettings settings(company, appname);
this->setMigrationLevel(settings.value("migration_level", 0).toInt());
if (this->getMigrationLevel() < this->getWantedMigrationLevel()) {
return true;
}
return false;
}
void manipulator::migrate(int level)
{
if (level == 1) {
qWarning() << QString("applying config migration to migration level %1").arg(QString::number(level));
QSettings settings(company, appname);
settings.setValue( "color_online", unsigned(QColor("#ff00ff00").rgba()) );
settings.setValue( "color_away", unsigned(QColor("#fffda814").rgba()) );
settings.setValue( "color_offline", unsigned(QColor("#ffdbdec8").rgba()) );
settings.setValue( "color_channel", unsigned(QColor("#ff6663a3").rgba()) );
settings.setValue( "chat_color_link", unsigned(QColor("#ff0f7ca7").rgba()) );
settings.setValue( "chat_color_nick", unsigned(QColor("#ffefeff0").rgba()) );
settings.setValue( "chat_color_nickself", unsigned(QColor("#ff6d83cd").rgba()) );
settings.setValue( "roster_color_highlight", unsigned(QColor("#ff42464d").rgba()) );
QFont font = QFont("PT Mono", 10, 1);
settings.setValue( "chat_font", font );
settings.setValue( "roster_font", font );
settings.remove("roster_hide_statustext");
settings.remove("hide_status_text");
settings.setValue( "log_level", 2 );
settings.setValue( "channel_shape_basesize", 7 );
settings.setValue( "status_shape_basesize", 7 );
settings.setValue( "status_shape", "Ellipse" );
settings.setValue( "channel_shape", "Rectangle" );
settings.setValue( "chat_datetimeformat", "HH:mm:ss" );
settings.setValue( "theme", "aic1.qss" );
settings.setValue("migration_level", 1);
}
}
void manipulator::saveSettings()
......@@ -97,16 +161,65 @@ void manipulator::saveSettings()
settings.setValue( "roster_hide_statustext", this->m_rosterSettings["roster_hide_statustext"] );
settings.setValue( "roster_local_hidelist", this->m_rosterSettings["roster_local_hidelist"] );
settings.setValue( "roster_font", this->m_rosterSettings["roster_font"] );
settings.setValue( "roster_color_highlight", this->m_rosterSettings["roster_color_highlight"] );
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"] );
settings.setValue( "chat_color_nickself", this->m_chatSettings["chat_color_nickself"] );
settings.setValue( "chat_color_timestamp", this->m_chatSettings["chat_color_timestamp"] );
}
void manipulator::createDefaultThemes()
{
QString _themedir = QStandardPaths::writableLocation(QStandardPaths::HomeLocation) + QDir::separator() + appname;
QDir _qthemedir(_themedir);
if ( ! _qthemedir.exists() ) {
_qthemedir.mkpath(".");
}
QFile source;
QFile destination;
QString themename;
themename = "dark";
source.setFileName(QString(":/themes/%1.qss").arg(themename));
destination.setFileName(QDir::cleanPath(_themedir+QDir::separator()+QString("%1.qss").arg(themename)));
if (destination.exists()) {
destination.setPermissions(QFile::ReadOther | QFile::WriteOther);
destination.remove();
}
source.copy(_themedir+QDir::separator()+QString("%1.qss").arg(themename));
themename = "aic1";
source.setFileName(QString(":/themes/%1.qss").arg(themename));
destination.setFileName(QDir::cleanPath(_themedir+QDir::separator()+QString("%1.qss").arg(themename)));
if (destination.exists()) {
destination.setPermissions(QFile::ReadOther | QFile::WriteOther);
destination.remove();
}
source.copy(_themedir+QDir::separator()+QString("%1.qss").arg(themename));
themename = "console";
source.setFileName(QString(":/themes/%1.qss").arg(themename));
destination.setFileName(QDir::cleanPath(_themedir+QDir::separator()+QString("%1.qss").arg(themename)));
if (destination.exists()) {
destination.setPermissions(QFile::ReadOther | QFile::WriteOther);
destination.remove();
}
source.copy(_themedir+QDir::separator()+QString("%1.qss").arg(themename));
}
void manipulator::updateSettingMap(QMap<QString, QVariant> &map, QString key, QVariant value)
{
if (map.keys().contains(key)) {
......@@ -250,6 +363,11 @@ void manipulator::setRosterFont(const QVariant &font)
this->updateSettingMap(this->m_rosterSettings, "roster_font", font);
}
void manipulator::setRosterColorHighlight(const QVariant &color)
{
this->updateSettingMap(this->m_rosterSettings, "roster_color_highlight", color);
}
void manipulator::setChatFont(const QVariant &font)
{
this->updateSettingMap(this->m_chatSettings, "chat_font", font);
......@@ -270,6 +388,16 @@ void manipulator::setChatColorNick(const QVariant &color)
this->updateSettingMap(this->m_chatSettings, "chat_color_nick", color);
}
void manipulator::setChatColorNickSelf(const QVariant &color)
{
this->updateSettingMap(this->m_chatSettings, "chat_color_nickself", color);
}
void manipulator::setChatColorTimestamp(const QVariant &color)
{
this->updateSettingMap(this->m_chatSettings, "chat_color_timestamp", color);
}
void manipulator::setSaveWindowStatePosition(const QString windowtitle, const QByteArray geometry, const QByteArray state)
{
QSettings settings(company, appname);
......@@ -292,6 +420,49 @@ QByteArray manipulator::getLoadWindowState(const QString windowtitle)
return settings.value("window_state_"+windowtitle).toByteArray();
}
QStringList manipulator::getAvailableThemes()
{
QStringList _availThemes;
QString _themedir = QStandardPaths::writableLocation(QStandardPaths::HomeLocation) + QDir::separator() + appname;
QDir _qthemedir(_themedir);
_qthemedir.setFilter(QDir::Files | QDir::Hidden | QDir::NoSymLinks);
_qthemedir.setSorting(QDir::Size | QDir::Reversed);
_qthemedir.setNameFilters( QStringList() << "*.qss" );
QFileInfoList filelist = _qthemedir.entryInfoList();
for (int i = 0; i < filelist.size(); ++i) {
QFileInfo fileInfo = filelist.at(i);
qInfo() << "found theme file: " << fileInfo.fileName();
_availThemes << fileInfo.fileName();
//this->ui->comboBoxTheme->addItem(fileInfo.fileName());
}
return _availThemes;
}
int manipulator::getMigrationLevel() const
{
return m_migrationLevel;
}
void manipulator::setMigrationLevel(int migrationLevel)
{
m_migrationLevel = migrationLevel;
}
int manipulator::getWantedMigrationLevel() const
{
return m_wantedMigrationLevel;
}
void manipulator::setWantedMigrationLevel(int wantedMigrationLevel)