21 #include "ui_userinterfacesettings.h"
24 #include <QDesktopWidget>
25 #include <QFileDialog>
27 #include <QMessageBox>
28 #include <QRegularExpressionValidator>
29 #include <QStyleFactory>
58 :
GenericForm(QPixmap(
":/img/settings/general.png"))
62 bodyUI =
new Ui::UserInterfaceSettings;
70 bodyUI->txtChatFontSize->setValue(QFontInfo(chatBaseFont).pixelSize());
71 bodyUI->txtChatFont->setCurrentFont(chatBaseFont);
73 bodyUI->textStyleComboBox->setCurrentIndex(index);
85 #if DESKTOP_NOTIFICATIONS
89 bodyUI->desktopNotify->hide();
95 bodyUI->cbCompactLayout->setChecked(s.getCompactLayout());
103 bodyUI->smileyPackBrowser->addItem(entry.first, entry.second);
108 bodyUI->smileyPackBrowser->setCurrentIndex(currentPack);
110 bodyUI->smileyPackBrowser->setEnabled(
bodyUI->useEmoticons->isChecked());
112 bodyUI->styleBrowser->addItem(tr(
"None"));
113 bodyUI->styleBrowser->addItems(QStyleFactory::keys());
116 if (QStyleFactory::keys().contains(s.
getStyle()))
121 bodyUI->styleBrowser->setCurrentText(style);
124 bodyUI->themeColorCBox->addItem(color);
130 QStringList timeFormats;
131 timeFormats << ql.timeFormat(QLocale::ShortFormat) << ql.timeFormat(QLocale::LongFormat)
135 timeFormats.removeDuplicates();
136 bodyUI->timestamp->addItems(timeFormats);
139 QRegularExpressionValidator* validator =
new QRegularExpressionValidator(re,
this);
142 if (!re.match(timeFormat).hasMatch())
143 timeFormat = timeFormats[0];
145 bodyUI->timestamp->setCurrentText(timeFormat);
146 bodyUI->timestamp->setValidator(validator);
149 QStringList dateFormats;
150 dateFormats << QStringLiteral(
"yyyy-MM-dd")
152 << ql.dateFormat(QLocale::LongFormat) << ql.dateFormat(QLocale::ShortFormat)
153 << ql.dateFormat(QLocale::NarrowFormat) <<
"dd-MM-yyyy"
158 dateFormats.removeDuplicates();
159 bodyUI->dateFormats->addItems(dateFormats);
162 if (!re.match(dateFormat).hasMatch())
163 dateFormat = dateFormats[0];
165 bodyUI->dateFormats->setCurrentText(dateFormat);
166 bodyUI->dateFormats->setValidator(validator);
181 if (
bodyUI->styleBrowser->currentIndex() == 0)
186 this->setStyle(QStyleFactory::create(style));
197 QString timeExample = QTime::currentTime().toString(format);
198 bodyUI->timeExample->setText(timeExample);
207 QString dateExample = QDate::currentDate().toString(format);
208 bodyUI->dateExample->setText(dateExample);
218 bodyUI->smileyPackBrowser->setEnabled(
bodyUI->useEmoticons->isChecked());
230 QString filename =
bodyUI->smileyPackBrowser->itemData(index).toString();
243 if (emoticons.isEmpty()) {
244 qDebug() <<
"reloadSmilies: No emoticons found";
249 for (
int i = 0; i < emoticons.size(); ++i)
250 smileys.push_front(emoticons.at(i).first());
253 const QSize size(18, 18);
262 QDesktopWidget desktop;
264 const int sideSize = 8;
265 int maxSide = qMin(desktop.geometry().height() / sideSize, desktop.geometry().width() / sideSize);
266 QSize maxSize(maxSide, maxSide);
269 bodyUI->emoticonSize->setMaximum(actualSize.width());
274 const bool notify =
bodyUI->notify->isChecked();
276 bodyUI->groupOnlyNotfiyWhenMentioned->setEnabled(notify);
277 bodyUI->notifySound->setEnabled(notify);
278 bodyUI->busySound->setEnabled(notify &&
bodyUI->notifySound->isChecked());
279 bodyUI->desktopNotify->setEnabled(notify);
284 const bool notify =
bodyUI->notifySound->isChecked();
286 bodyUI->busySound->setEnabled(notify);
291 const bool notify =
bodyUI->desktopNotify->isChecked();
318 bool checked =
bodyUI->cbSeparateWindow->isChecked();
319 bodyUI->cbDontGroupWindows->setEnabled(checked);
340 int index =
bodyUI->themeColorCBox->currentIndex();
354 bodyUI->retranslateUi(
this);
357 bodyUI->textStyleComboBox->setCurrentIndex(
361 for (
int i = 0; i < colorThemes.size(); ++i) {
362 bodyUI->themeColorCBox->setItemText(i, colorThemes[i]);
365 bodyUI->styleBrowser->setItemText(0, tr(
"None"));
371 const int px =
bodyUI->txtChatFontSize->value();
373 if (QFontInfo(tmpFont).pixelSize() != px)
374 tmpFont.setPixelSize(px);
383 const int fontSize = QFontInfo(tmpFont).pixelSize();
385 if (px != fontSize) {
386 tmpFont.setPixelSize(px);