mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
ChatLog::selectAll, refactoring of actions (issue #808)
This commit is contained in:
parent
ecf15a6ca3
commit
a558733507
|
@ -61,13 +61,20 @@ ChatLog::ChatLog(QWidget* parent)
|
|||
selGraphItem->setZValue(-10.0); //behind all items
|
||||
|
||||
// copy action (ie. Ctrl+C)
|
||||
copyAction = new QAction(this);
|
||||
QAction* copyAction = new QAction(this);
|
||||
copyAction->setIcon(QIcon::fromTheme("edit-copy"));
|
||||
copyAction->setText(tr("Copy"));
|
||||
copyAction->setShortcut(QKeySequence::Copy);
|
||||
connect(copyAction, &QAction::triggered, this, [this](bool) { copySelectedText(); });
|
||||
addAction(copyAction);
|
||||
connect(copyAction, &QAction::triggered, this, [this](bool)
|
||||
{
|
||||
copySelectedText();
|
||||
});
|
||||
|
||||
// select all action (ie. Ctrl+A)
|
||||
QAction* selectAllAction = new QAction(this);
|
||||
selectAllAction->setIcon(QIcon::fromTheme("edit-select-all"));
|
||||
selectAllAction->setText(tr("Select all"));
|
||||
selectAllAction->setShortcut(QKeySequence::SelectAll);
|
||||
connect(selectAllAction, &QAction::triggered, this, [this](bool) { selectAll(); });
|
||||
addAction(selectAllAction);
|
||||
|
||||
// This timer is used to scroll the view while the user is
|
||||
// moving the mouse past the top/bottom edge of the widget while selecting.
|
||||
|
@ -544,6 +551,20 @@ void ChatLog::scrollToLine(ChatLine::Ptr line)
|
|||
verticalScrollBar()->setValue(line->boundingSceneRect().top());
|
||||
}
|
||||
|
||||
void ChatLog::selectAll()
|
||||
{
|
||||
if(lines.empty())
|
||||
return;
|
||||
|
||||
clearSelection();
|
||||
|
||||
selectionMode = Multi;
|
||||
selFirstRow = 0;
|
||||
selLastRow = lines.size()-1;
|
||||
|
||||
updateMultiSelectionRect();
|
||||
}
|
||||
|
||||
void ChatLog::checkVisibility()
|
||||
{
|
||||
if(lines.empty())
|
||||
|
|
|
@ -47,6 +47,8 @@ public:
|
|||
void setTypingNotification(ChatLine::Ptr notification);
|
||||
void setTypingNotificationVisible(bool visible);
|
||||
void scrollToLine(ChatLine::Ptr line);
|
||||
void selectAll();
|
||||
|
||||
QString getSelectedText() const;
|
||||
|
||||
bool isEmpty() const;
|
||||
|
@ -126,9 +128,6 @@ private:
|
|||
bool workerStb = false;
|
||||
ChatLine::Ptr workerAnchorLine;
|
||||
|
||||
// actions
|
||||
QAction* copyAction = nullptr;
|
||||
|
||||
// layout
|
||||
QMarginsF margins = QMarginsF(10.0,10.0,10.0,10.0);
|
||||
qreal lineSpacing = 5.0f;
|
||||
|
|
|
@ -146,7 +146,7 @@ GenericChatForm::GenericChatForm(QWidget *parent)
|
|||
fileButton->setAttribute(Qt::WA_LayoutUsesWidgetRect);
|
||||
emoteButton->setAttribute(Qt::WA_LayoutUsesWidgetRect);
|
||||
|
||||
menu.addAction(QIcon::fromTheme("edit-copy"), tr("Copy"), this, SLOT(onCopyLogClicked()));
|
||||
menu.addActions(chatWidget->actions());
|
||||
menu.addSeparator();
|
||||
menu.addAction(QIcon::fromTheme("document-save"), tr("Save chat log"), this, SLOT(onSaveLogClicked()));
|
||||
menu.addAction(QIcon::fromTheme("edit-clear"), tr("Clear displayed messages"), this, SLOT(clearChatArea(bool)));
|
||||
|
@ -323,6 +323,11 @@ void GenericChatForm::clearChatArea(bool notinform)
|
|||
emit chatAreaCleared();
|
||||
}
|
||||
|
||||
void GenericChatForm::onSelectAllClicked()
|
||||
{
|
||||
chatWidget->selectAll();
|
||||
}
|
||||
|
||||
QString GenericChatForm::resolveToxID(const ToxID &id)
|
||||
{
|
||||
Friend *f = FriendList::findFriend(id);
|
||||
|
|
|
@ -73,6 +73,7 @@ protected slots:
|
|||
void onSaveLogClicked();
|
||||
void onCopyLogClicked();
|
||||
void clearChatArea(bool);
|
||||
void onSelectAllClicked();
|
||||
|
||||
protected:
|
||||
QString resolveToxID(const ToxID &id);
|
||||
|
|
Loading…
Reference in New Issue
Block a user