Skip to content

Commit

Permalink
fix most bugs of nurupo#122
Browse files Browse the repository at this point in the history
  • Loading branch information
Schlumpf committed Jun 27, 2014
1 parent d844a78 commit a7aa410
Show file tree
Hide file tree
Showing 11 changed files with 107 additions and 82 deletions.
20 changes: 20 additions & 0 deletions resources/icons/emoticons/theme
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Name = TOX Qt GUI Smileys
Author = FatCow
Description = A default smileypack for TOX Qt GUI.
Verion = 0.1

[theme]
emotion_smile.png :) :-) :o)
emotion_sad.png :( :-(
emotion_grin.png :D :-D
emotion_cool.png 8) 8-)
emotion_suprised.png :O :-O
emotion_wink.png ;) ;-)
emotion_cry.png ;( ;-(
emotion_sweat.png (:|
emotion_kiss.png :* :-*
emotion_tongue.png :P :-P
emotion_angel.png O:) O:-) o:) o:-) (angel)
emotion_doubt.png :^) :^-)
emotion_love.png (inlove)
emotion_evilgrin.png ]:) ]:-)
14 changes: 0 additions & 14 deletions resources/resources.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,6 @@
<file>icons/database.png</file>
<file>icons/icon64.png</file>
<file>icons/cog.png</file>
<file>icons/emoticons/emotion_angel.png</file>
<file>icons/emoticons/emotion_kiss.png</file>
<file>icons/emoticons/emotion_smile.png</file>
<file>icons/emoticons/emotion_wink.png</file>
<file>icons/emoticons/emotion_love.png</file>
<file>icons/emoticons/emotion_grin.png</file>
<file>icons/emoticons/emotion_cool.png</file>
<file>icons/emoticons/emotion_suprised.png</file>
<file>icons/emoticons/emotion_cry.png</file>
<file>icons/emoticons/emotion_sweat.png</file>
<file>icons/emoticons/emotion_sad.png</file>
<file>icons/emoticons/emotion_tongue.png</file>
<file>icons/emoticons/emotion_doubt.png</file>
<file>icons/emoticons/emotion_evilgrin.png</file>
<file>icons/error.png</file>
<file>icons/status_away.png</file>
<file>icons/status_busy.png</file>
Expand Down
83 changes: 40 additions & 43 deletions src/Settings/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -296,8 +296,10 @@ const QString &Settings::getTimestampFormat() const

void Settings::setTimestampFormat(const QString &format)
{
timestampFormat = format;
emit timestampFormatChanged();
if (timestampFormat != format) {
timestampFormat = format;
emit timestampFormatChanged();
}
}

bool Settings::isMinimizeOnCloseEnabled() const
Expand All @@ -311,63 +313,63 @@ void Settings::setMinimizeOnClose(bool newValue)
}

// Smileys
bool Settings::isSmileyReplacementEnabled() const
void Settings::setSmileySettings(bool replacementEnabled, int type, const QString &packPath, bool eFontOverride, const QString &eFontFamily, int eFontPointSize, bool eSendPlaintext)
{
return smileyReplacementEnabled;
bool changed = false;
if (smileyReplacementEnabled != replacementEnabled) {
smileyReplacementEnabled = replacementEnabled;
changed = true;
}
if (smileyType != type) {
smileyType = type;
changed = true;
}
if (smileyPackPath != packPath) {
smileyPackPath = packPath;
emit smileyPackChanged();
changed = true;
}
if (emojiFontOverride != eFontOverride) {
emojiFontOverride = eFontOverride;
changed = true;
}
if (emojiFontFamily != eFontFamily) {
emojiFontFamily = eFontFamily;
changed = true;
}
if (emojiFontPointSize != eFontPointSize) {
emojiFontPointSize = eFontPointSize;
changed = true;
}
if (emojiSendPlaintext != eSendPlaintext) {
emojiSendPlaintext = eSendPlaintext;
changed = true;
}

if(changed)
emit smileySettingsChanged();
}

void Settings::setSmileyReplacementEnabled(bool value)
bool Settings::isSmileyReplacementEnabled() const
{
smileyReplacementEnabled = value;
emit smileySettingsChanged();
return smileyReplacementEnabled;
}

int Settings::getSmileyType() const
{
return smileyType;
}

void Settings::setSmileyType(int value)
{
smileyType = value;
emit smileySettingsChanged();
}

QString Settings::getSmileyPackPath() const
{
return smileyPackPath;
}

void Settings::setSmileyPackPath(const QString &value)
{
smileyPackPath = value;
emit smileyPackChanged();
emit smileySettingsChanged();
}

bool Settings::isCurstomEmojiFont() const
{
return emojiFontOverride;
}

void Settings::setCurstomEmojiFont(bool value)
{
emojiFontOverride = value;
emit smileySettingsChanged();
}

void Settings::setEmojiFontFamily(const QString &value)
{
emojiFontFamily = value;
emit smileySettingsChanged();
}

void Settings::setEmojiFontPointSize(int value)
{
emojiFontPointSize = value;
emit smileySettingsChanged();
}

QFont Settings::getEmojiFont() const
{
return QFont(emojiFontFamily, emojiFontPointSize);
Expand All @@ -378,11 +380,6 @@ bool Settings::isEmojiSendPlaintext() const
return emojiSendPlaintext;
}

void Settings::setEmojiSendPlaintext(bool value)
{
emojiSendPlaintext = value;
}

// Privacy
bool Settings::isTypingNotificationEnabled() const
{
Expand Down
14 changes: 2 additions & 12 deletions src/Settings/settings.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,24 +94,14 @@ class Settings : public QObject
void setMinimizeOnClose(bool newValue);

// Smileys
bool isSmileyReplacementEnabled() const;
void setSmileyReplacementEnabled(bool value);
void setSmileySettings(bool replacementEnabled, int type, const QString &packPath, bool eFontOverride, const QString &eFontFamily, int eFontPointSize, bool eSendPlaintext);

bool isSmileyReplacementEnabled() const;
int getSmileyType() const;
void setSmileyType(int value);

QString getSmileyPackPath() const;
void setSmileyPackPath(const QString &value);

bool isCurstomEmojiFont() const;
void setCurstomEmojiFont(bool value);

void setEmojiFontFamily(const QString &value);
void setEmojiFontPointSize(int value);
QFont getEmojiFont() const;

bool isEmojiSendPlaintext() const;
void setEmojiSendPlaintext(bool value);

// Privacy
bool isTypingNotificationEnabled() const;
Expand Down
16 changes: 7 additions & 9 deletions src/Settings/smileysettingspage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,13 @@ void SmileySettingsPage::setGui()
void SmileySettingsPage::applyChanges()
{
Settings& settings = Settings::getInstance();

// Emoji font settings
settings.setSmileyReplacementEnabled(mSmileyGroup->isChecked());
settings.setSmileyType(mSmileyType->currentData().toInt());
settings.setCurstomEmojiFont(mEmojiFontGroup->isChecked());
settings.setEmojiFontFamily(mEmojiFontComboBox->itemText(mEmojiFontComboBox->currentIndex()));
settings.setEmojiFontPointSize(mEmojiFontSizeSpinBox->value());
settings.setEmojiSendPlaintext(mSendPlaintextCheckbox->isChecked());
settings.setSmileyPackPath(mSmileyPacks.at(mSmileypackCombobox->currentIndex())->getThemeFile());
settings.setSmileySettings(mSmileyGroup->isChecked(),
mSmileyType->currentData().toInt(),
mSmileyPacks.at(mSmileypackCombobox->currentIndex())->getThemeFile(),
mEmojiFontGroup->isChecked(),
mEmojiFontComboBox->itemText(mEmojiFontComboBox->currentIndex()),
mEmojiFontSizeSpinBox->value(),
mSendPlaintextCheckbox->isChecked());
}

/*void SmileySettingsPage::updateEmojiFontPreview()
Expand Down
4 changes: 1 addition & 3 deletions src/messages/chatitem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,7 @@ ChatItem::ChatItem(const QRectF &boundingRect, ChatLine *parent) :

ChatItem::~ChatItem()
{
if(mDoc)
delete mDoc;

clearCache();
qDeleteAll(mHighlights);
}

Expand Down
6 changes: 6 additions & 0 deletions src/messages/chatscene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -863,6 +863,12 @@ void ChatScene::clickTimeout()
handleClick(Qt::LeftButton, _clickPos);
}

/*! Relayouts the whole scene */
void ChatScene::updateLayout()
{
layout(0, _lines.count()-1, _sceneRect.width());
}

void ChatScene::setHandleXLimits()
{
_firstColHandle->setXLimits(0, _secondColHandle->sceneLeft() - minContentsWidth);
Expand Down
1 change: 1 addition & 0 deletions src/messages/chatscene.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ public slots:
void updateForViewport(qreal width, qreal height);
void setWidth(qreal width);
void layout(int start, int end, qreal width);
void updateLayout();

void setMarkerLineValid(bool valid = true);
void setMarkerLineVisible(bool visible = true);
Expand Down
28 changes: 27 additions & 1 deletion src/messages/chatview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ ChatView::ChatView(MessageFilter *model, QWidget *parent) :
_lastScrollbarPos = verticalScrollBar()->value();

// Update timstamps
connect(&Settings::getInstance(), &Settings::timestampFormatChanged, this, &ChatView::clearCache);
connect(&Settings::getInstance(), &Settings::timestampFormatChanged, this, &ChatView::clearTimestampCache);
connect(&Settings::getInstance(), &Settings::smileySettingsChanged, this, &ChatView::clearContentCacheAndRelayout);

// Actions
hidePlain = new QAction(tr("Text messages"), this);
Expand Down Expand Up @@ -183,6 +184,31 @@ void ChatView::clearCache()
}
}

void ChatView::clearTimestampCache()
{
QSet<ChatLine *>::iterator iter = _linesWithCache.begin();
while (iter != _linesWithCache.end()) {
ChatLine *line = *iter;
line->timestampItem()->clearCache();
iter = _linesWithCache.erase(iter);
line->update();
}
}

void ChatView::clearContentCacheAndRelayout()
{
// Clear content cache
QSet<ChatLine *>::iterator iter = _linesWithCache.begin();
while (iter != _linesWithCache.end()) {
ChatLine *line = *iter;
line->contentsItem()->clearCache();
iter = _linesWithCache.erase(iter);
line->update();
}

scene()->updateLayout();
}

void ChatView::setTypingNotificationVisible(const QString &name, bool visible)
{
scene()->setTypingNotificationVisible(name, visible);
Expand Down
2 changes: 2 additions & 0 deletions src/messages/chatview.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ class ChatView : public QGraphicsView

public slots:
void clearCache();
void clearTimestampCache();
void clearContentCacheAndRelayout();
inline virtual void clear() {}

void setTypingNotificationVisible(const QString &name, bool visible = true);
Expand Down
1 change: 1 addition & 0 deletions src/messages/chatviewsearchwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ ChatViewSearchWidget::ChatViewSearchWidget(QWidget *parent) :
mRegularMsgOnly(true)
{
setHidden(true);
mSearchEnabled = false;
setIconSize(QSize(16,16));

mSearchDelayTimer.setSingleShot(true);
Expand Down

0 comments on commit a7aa410

Please sign in to comment.