-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
77 lines (63 loc) · 2.8 KB
/
Copy pathmain.cpp
File metadata and controls
77 lines (63 loc) · 2.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#include "contentviewwidget.h"
#include "mainwindow.h"
#include "statusbarwidget.h"
#include <QApplication>
#include <QLabel>
#include <QPushButton>
#include <QSplitter>
#include <QVBoxLayout>
#include <QWebEngineView>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
w.setWindowTitle("Sidekick Viewer");
w.setWindowIcon(
QIcon(":/assets/icons/32x32.png")); // BUG: This doesn't seem to set it on Linux Mint 22.1
// Create ContentViews
ContentViewWidget *leftContentView = new ContentViewWidget(&w, "left");
ContentViewWidget *rightContentView = new ContentViewWidget(&w, "right");
// Add ContentViews to the splitter
QSplitter *splitter = new QSplitter(Qt::Horizontal);
splitter->addWidget(leftContentView);
splitter->addWidget(rightContentView);
splitter->setSizes(QList<int>({INT_MAX, INT_MAX}));
// Create status bar
StatusBarWidget *statusBar = new StatusBarWidget();
statusBar->connectContentViews(leftContentView, rightContentView);
// Create main widget
QWidget *mainWidget = new QWidget();
// Layout for main widget
QVBoxLayout *mainLayout = new QVBoxLayout(mainWidget);
mainLayout->setContentsMargins(0, 0, 0, 0);
mainLayout->addWidget(splitter);
mainLayout->addWidget(statusBar);
// Remove default statusBar
w.setStatusBar(NULL);
// Add mainWidget to window
w.setCentralWidget(mainWidget);
// Programmatically scroll right when left is scrolled by user and panes are locked
QObject::connect(leftContentView,
&ContentViewWidget::changedScrollPosition,
[leftContentView, rightContentView, statusBar](std::string id,
int deltaX,
int deltaY) {
if (statusBar->getIsLocked()) {
rightContentView->setProgScroll(true);
rightContentView->scrollBy(deltaX, deltaY);
}
});
// Programmatically scroll left when right is scrolled by user and panes are locked
QObject::connect(rightContentView,
&ContentViewWidget::changedScrollPosition,
[leftContentView, rightContentView, statusBar](std::string id,
int deltaX,
int deltaY) {
if (statusBar->getIsLocked()) {
leftContentView->setProgScroll(true);
leftContentView->scrollBy(deltaX, deltaY);
}
});
w.show();
return a.exec();
}