forked from blue/squawk
duck taped annoying scroll problem, started with local archive
This commit is contained in:
parent
fad72d8db2
commit
e04f7db7c2
6 changed files with 2063 additions and 14 deletions
|
@ -29,7 +29,8 @@ Conversation::Conversation(Models::Contact* p_contact, QWidget* parent):
|
|||
ker(),
|
||||
activePalResource(),
|
||||
thread(),
|
||||
scroll(nothing)
|
||||
scroll(down),
|
||||
manualSliderChange(false)
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
m_ui->splitter->setSizes({300, 0});
|
||||
|
@ -54,9 +55,11 @@ Conversation::Conversation(Models::Contact* p_contact, QWidget* parent):
|
|||
line->setMyName(p_contact->getAccountName());
|
||||
connect(line, SIGNAL(resize(int)), this, SLOT(onMessagesResize(int)));
|
||||
|
||||
QScrollBar* vs = m_ui->scrollArea->verticalScrollBar();
|
||||
m_ui->scrollArea->setWidget(line);
|
||||
m_ui->scrollArea->verticalScrollBar()->setBackgroundRole(QPalette::Base);
|
||||
m_ui->scrollArea->verticalScrollBar()->setAutoFillBackground(true);;
|
||||
vs->setBackgroundRole(QPalette::Base);
|
||||
vs->setAutoFillBackground(true);
|
||||
connect(vs, SIGNAL(valueChanged(int)), this, SLOT(onSliderValueChanged(int)));
|
||||
}
|
||||
|
||||
Conversation::~Conversation()
|
||||
|
@ -118,13 +121,6 @@ void Conversation::addMessage(const Shared::Message& data)
|
|||
return;
|
||||
}
|
||||
|
||||
if (scroll == nothing) {
|
||||
if (pos == max) {
|
||||
scroll = down;
|
||||
} else if (place != MessageLine::end) { //todo make some better handling of that situation
|
||||
scroll = keep;
|
||||
}
|
||||
}
|
||||
if (!data.getOutgoing()) {
|
||||
const QString& res = data.getPenPalResource();
|
||||
if (res.size() > 0) {
|
||||
|
@ -194,16 +190,24 @@ void Conversation::onEnterPressed()
|
|||
|
||||
void Conversation::onMessagesResize(int amount)
|
||||
{
|
||||
manualSliderChange = true;
|
||||
switch (scroll) {
|
||||
case down:
|
||||
m_ui->scrollArea->verticalScrollBar()->setValue(m_ui->scrollArea->verticalScrollBar()->maximum());
|
||||
break;
|
||||
case keep:
|
||||
m_ui->scrollArea->verticalScrollBar()->setValue(m_ui->scrollArea->verticalScrollBar()->value() - amount);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
scroll = nothing;
|
||||
manualSliderChange = false;
|
||||
}
|
||||
|
||||
void Conversation::onSliderValueChanged(int value)
|
||||
{
|
||||
if (!manualSliderChange) {
|
||||
if (value == m_ui->scrollArea->verticalScrollBar()->maximum()) {
|
||||
scroll = down;
|
||||
} else {
|
||||
scroll = nothing;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -69,6 +69,7 @@ protected slots:
|
|||
void onContactChanged(Models::Item* item, int row, int col);
|
||||
void onEnterPressed();
|
||||
void onMessagesResize(int amount);
|
||||
void onSliderValueChanged(int value);
|
||||
|
||||
private:
|
||||
enum Scroll {
|
||||
|
@ -83,6 +84,7 @@ private:
|
|||
QString activePalResource;
|
||||
QString thread;
|
||||
Scroll scroll;
|
||||
bool manualSliderChange;
|
||||
};
|
||||
|
||||
#endif // CONVERSATION_H
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue