Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change table view font on Ctrl + Wheel combination #578

Merged
merged 1 commit into from
Nov 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/dlttableview.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#include "dlttableview.h"

#include <QDebug>
#include <QWheelEvent>

DltTableView::DltTableView(QWidget *parent) :
QTableView(parent)
{
Expand All @@ -17,6 +20,15 @@ void DltTableView::paintEvent(QPaintEvent *event)
}
}

void DltTableView::wheelEvent(QWheelEvent *event)
{
if (event->modifiers().testFlag(Qt::ControlModifier)) {
auto val = event->angleDelta().y();
emit changeFontSize((0 < val) - (val < 0));
event->accept();
}
}

void DltTableView::lock()
{
paintMutex.lock();
Expand Down
6 changes: 5 additions & 1 deletion src/dlttableview.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,15 @@ class DltTableView : public QTableView
explicit DltTableView(QWidget *parent = 0);
void lock();
void unlock();

signals:
void changeFontSize(int delta);
private:
QMutex paintMutex;

protected:
void paintEvent(QPaintEvent *e);
void paintEvent(QPaintEvent *e) override;
void wheelEvent(QWheelEvent *event) override;

signals:

Expand Down
11 changes: 10 additions & 1 deletion src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -608,6 +608,15 @@ void MainWindow::initSignalConnections()
ui->exploreView->scrollTo(
proxyModel->mapFromSource(fsModel->index(recentFiles[0])));
});

connect(ui->tableView, &DltTableView::changeFontSize, this, [this](int direction){
QFont font;
font.fromString(settings->fontName);
int fontSize = font.pointSize() + direction;
font.setPointSize(fontSize);
settings->fontName = font.toString();
ui->tableView->setFont(font);
});
}

void MainWindow::initSearchTable()
Expand Down Expand Up @@ -2066,6 +2075,7 @@ void MainWindow::reloadLogFileFinishFilter()
QList<int> list = dltIndexer->getGetLogInfoList();
QDltMsg msg;

// FIXME: this is slow operation running in the main loop
for(int num=0;num<list.size();num++)
{
if(qfile.getMsg(list[num],msg))
Expand All @@ -2082,7 +2092,6 @@ void MainWindow::reloadLogFileFinishFilter()
// hide progress bar when finished
statusProgressBar->reset();
statusProgressBar->hide();

}

void MainWindow::reloadLogFileFinishDefaultFilter()
Expand Down
8 changes: 4 additions & 4 deletions src/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -382,10 +382,10 @@ class MainWindow : public QMainWindow
void writeDLTMessageToFile(QByteArray &bufferHeader,char*bufferPayload,quint32 bufferPayloadSize,EcuItem* ecuitem,quint32 sec=0,quint32 use=0);

protected:
void keyPressEvent ( QKeyEvent * event );
void dragEnterEvent(QDragEnterEvent *event);
void dropEvent(QDropEvent *event);
void closeEvent(QCloseEvent *event);
void keyPressEvent ( QKeyEvent * event ) override;
void dragEnterEvent(QDragEnterEvent *event) override;
void dropEvent(QDropEvent *event) override;
void closeEvent(QCloseEvent *event) override;

private slots:
void reloadLogFileProgressMax(int num);
Expand Down
Loading