Skip to content

Commit

Permalink
Change table view font on Ctrl + Wheel combination (#578)
Browse files Browse the repository at this point in the history
#577

Signed-off-by: Viktor Kopp <vifactor@gmail.com>
  • Loading branch information
vifactor authored Nov 15, 2024
1 parent 6192e36 commit f9f45ed
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 6 deletions.
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

0 comments on commit f9f45ed

Please sign in to comment.