{
}
-bool BufferSettings::hasFilter() {
- return localValue("hasMessageTypeFilter", false).toBool();
-}
-
-int BufferSettings::messageFilter() {
- return localValue("MessageTypeFilter", 0).toInt();
-}
-
void BufferSettings::filterMessage(Message::Type msgType, bool filter) {
if(!hasFilter())
setLocalValue("hasMessageTypeFilter", true);
inline void setValue(const QString &key, const QVariant &data) { setLocalValue(key, data); }
inline QVariant value(const QString &key, const QVariant &def = QVariant()) { return localValue(key, def); }
- bool hasFilter();
- int messageFilter();
+ inline bool hasFilter() { return localValue("hasMessageTypeFilter", false).toBool(); }
+ inline int messageFilter() { return localValue("MessageTypeFilter", 0).toInt(); }
void filterMessage(Message::Type msgType, bool filter);
+
+ inline bool showUserStateIcons() { return localValue("ShowUserStateIcons", true).toBool(); }
+ inline void enableUserStateIcons(bool enabled) { setLocalValue("ShowUserStateIcons", enabled); }
};
webPreview.deleteTimer.setInterval(10000);
connect(&webPreview.deleteTimer, SIGNAL(timeout()), this, SLOT(deleteWebPreviewEvent()));
#endif
+ _showWebPreview = defaultSettings.showWebPreview();
+ defaultSettings.notify("ShowWebPreview", this, SLOT(showWebPreviewChanged()));
setItemIndexMethod(QGraphicsScene::NoIndex);
}
Q_UNUSED(url)
Q_UNUSED(urlRect)
#else
+ if(!_showWebPreview)
+ return;
+
if(webPreview.parentItem != parentItem)
webPreview.parentItem = parentItem;
webPreview.urlRect = QRectF();
#endif
}
+
+void ChatScene::showWebPreviewChanged() {
+ ChatViewSettings settings;
+ _showWebPreview = settings.showWebPreview();
+}
void secondHandlePositionChanged(qreal xpos);
void showWebPreviewEvent();
void deleteWebPreviewEvent();
+ void showWebPreviewChanged();
private:
void setHandleXLimits();
int _firstSelectionRow;
bool _isSelecting;
+ bool _showWebPreview;
+
struct WebPreview {
ChatItem *parentItem;
QGraphicsItem *previewItem;
: QtUiSettings(QString("ChatView/%1").arg(view->scene()->idString()))
{
}
+
ChatViewSettings(const QString &id = "__default__");
ChatViewSettings(ChatScene *scene);
ChatViewSettings(ChatView *view);
+
+ inline bool showWebPreview() { return localValue("ShowWebPreview", true).toBool(); }
+ inline void enableWebPreview(bool enabled) { setLocalValue("ShowWebPreview", enabled); }
};
#endif //CHATVIEWSETTINGS_H
}
void MainWin::showSettingsDlg() {
- SettingsDlg *dlg = new SettingsDlg();
+ SettingsDlg *dlg = new SettingsDlg(this);
//Category: Appearance
dlg->registerSettingsPage(new ColorSettingsPage(dlg));
_currentPage(0)
{
setModal(true);
+ setWindowFlags(Qt::Sheet);
+ setAttribute(Qt::WA_DeleteOnClose, true);
ui.setupUi(this);
updateGeometry();
#include "appearancesettingspage.h"
+#include "buffersettings.h"
+#include "chatviewsettings.h"
#include "qtui.h"
#include "qtuisettings.h"
#include "util.h"
initStyleComboBox();
initLanguageComboBox();
- connect(ui.styleComboBox, SIGNAL(currentIndexChanged(QString)), this, SLOT(widgetHasChanged()));
- connect(ui.languageComboBox, SIGNAL(currentIndexChanged(QString)), this, SLOT(widgetHasChanged()));
+ foreach(QComboBox *comboBox, findChildren<QComboBox *>()) {
+ connect(comboBox, SIGNAL(currentIndexChanged(QString)), this, SLOT(widgetHasChanged()));
+ }
+ foreach(QCheckBox *checkBox, findChildren<QCheckBox *>()) {
+ connect(checkBox, SIGNAL(clicked()), this, SLOT(widgetHasChanged()));
+ }
}
void AppearanceSettingsPage::initStyleComboBox() {
void AppearanceSettingsPage::load() {
QtUiSettings uiSettings;
+ // Gui Style
settings["Style"] = uiSettings.value("Style", QString(""));
if(settings["Style"].toString() == "") {
ui.styleComboBox->setCurrentIndex(0);
QApplication::setStyle(settings["Style"].toString());
}
+ // Language
QLocale locale = uiSettings.value("Locale", QLocale::system()).value<QLocale>();
if(locale == QLocale::system())
ui.languageComboBox->setCurrentIndex(0);
ui.languageComboBox->setCurrentIndex(ui.languageComboBox->findText(QLocale::languageToString(locale.language()), Qt::MatchExactly));
loadTranslation(selectedLocale());
+ ChatViewSettings chatViewSettings;
+ SettingsPage::load(ui.showWebPreview, chatViewSettings.showWebPreview());
+
+ BufferSettings bufferSettings;
+ SettingsPage::load(ui.showUserStateIcons, bufferSettings.showUserStateIcons());
+
setChangedState(false);
}
uiSettings.setValue("Locale", selectedLocale());
}
+ ChatViewSettings chatViewSettings;
+ chatViewSettings.enableWebPreview(ui.showWebPreview->isChecked());
+
+ BufferSettings bufferSettings;
+ bufferSettings.enableUserStateIcons(ui.showUserStateIcons->isChecked());
+
load();
setChangedState(false);
}
if(settings["Style"].toString() != ui.styleComboBox->currentText()) return true;
if(selectedLocale() != QLocale()) return true; // QLocale() returns the default locale (manipulated via loadTranslation())
+ if(SettingsPage::hasChanged(ui.showWebPreview)) return true;
+ if(SettingsPage::hasChanged(ui.showUserStateIcons)) return true;
+
return false;
}
<rect>
<x>0</x>
<y>0</y>
- <width>331</width>
- <height>269</height>
+ <width>396</width>
+ <height>324</height>
</rect>
</property>
<property name="windowTitle" >
</widget>
</item>
<item>
- <spacer>
+ <widget class="QGroupBox" name="groupBox_3" >
+ <property name="title" >
+ <string>Misc:</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout_3" >
+ <item>
+ <widget class="QCheckBox" name="showWebPreview" >
+ <property name="text" >
+ <string>Show Web Previews</string>
+ </property>
+ <property name="checked" >
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="showUserStateIcons" >
+ <property name="text" >
+ <string>Use Icons to represent away state of Users</string>
+ </property>
+ <property name="checked" >
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <spacer name="verticalSpacer" >
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
#include "bufferinfo.h"
#include "buffermodel.h"
+#include "buffersettings.h"
#include "client.h"
#include "iconloader.h"
#include "networkmodel.h"
connect(this, SIGNAL(_dataChanged(const QModelIndex &, const QModelIndex &)),
this, SLOT(_q_sourceDataChanged(QModelIndex,QModelIndex)));
+
+ BufferSettings bufferSettings;
+ _showUserStateIcons = bufferSettings.showUserStateIcons();
+ bufferSettings.notify("ShowUserStateIcons", this, SLOT(showUserStateIconsChanged()));
}
void BufferViewFilter::loadColors() {
_FgColorOtherActivity = s.value("otherActivityFG", QVariant(QColor(Qt::darkGreen))).value<QColor>();
}
+void BufferViewFilter::showUserStateIconsChanged() {
+ BufferSettings bufferSettings;
+ _showUserStateIcons = bufferSettings.showUserStateIcons();
+}
+
void BufferViewFilter::setConfig(BufferViewConfig *config) {
if(_config == config)
return;
}
QVariant BufferViewFilter::icon(const QModelIndex &index) const {
+ if(!_showUserStateIcons)
+ return QVariant();
+
if(index.column() != 0)
return QVariant();
*****************************************/
class BufferViewFilter : public QSortFilterProxyModel {
Q_OBJECT
-
+
public:
enum Mode {
NoActive = 0x01,
Q_DECLARE_FLAGS(Modes, Mode)
BufferViewFilter(QAbstractItemModel *model, BufferViewConfig *config = 0);
-
+
virtual Qt::ItemFlags flags(const QModelIndex &index) const;
virtual bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent);
inline BufferViewConfig *config() const { return _config; }
virtual void sort(int column, Qt::SortOrder order = Qt::AscendingOrder);
-
+
public slots:
void checkPreviousCurrentForRemoval(const QModelIndex ¤t, const QModelIndex &previous);
void checkItemForRemoval(const QModelIndex &index) { checkItemsForRemoval(index, index); }
void checkItemsForRemoval(const QModelIndex &topLeft, const QModelIndex &bottomRight);
-
+
protected:
bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const;
bool lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const;
private slots:
void configInitialized();
-
+ void showUserStateIconsChanged();
+
private:
QPointer<BufferViewConfig> _config;
Qt::SortOrder _sortOrder;
-
+
QColor _FgColorInactiveActivity;
QColor _FgColorNoActivity;
QColor _FgColorHighlightActivity;
QPixmap _userOfflineIcon;
QPixmap _userAwayIcon;
QPixmap _userOnlineIcon;
+ bool _showUserStateIcons;
void loadColors();
bool filterAcceptNetwork(const QModelIndex &) const;
void addBuffer(const BufferId &) const;
};
-Q_DECLARE_OPERATORS_FOR_FLAGS(BufferViewFilter::Modes)
+Q_DECLARE_OPERATORS_FOR_FLAGS(BufferViewFilter::Modes)
bool bufferIdLessThan(const BufferId &, const BufferId &);