Changeset View
Changeset View
Standalone View
Standalone View
src/mainwindow.cpp
Show All 38 Lines | 36 | MainWindow::MainWindow(QWidget *parent) : | |||
---|---|---|---|---|---|
39 | m_instances(new QTabWidget(this)) | 39 | m_instances(new QTabWidget(this)) | ||
40 | { | 40 | { | ||
41 | initWidgets(); | 41 | initWidgets(); | ||
42 | setupActions(); | 42 | setupActions(); | ||
43 | connect(m_instances, &QTabWidget::tabCloseRequested, [this] (int index){ | 43 | connect(m_instances, &QTabWidget::tabCloseRequested, [this] (int index){ | ||
44 | QWidget *tempWidget= m_instances->widget(index); | 44 | QWidget *tempWidget= m_instances->widget(index); | ||
45 | delete tempWidget; | 45 | delete tempWidget; | ||
46 | 46 | | |||
47 | if(m_instances->count() == 1) { | 47 | if(m_instances->count() == 2) { | ||
48 | m_instances->setTabsClosable(false); | 48 | m_instances->setTabsClosable(false); | ||
49 | m_instances->setMovable(false); | 49 | m_instances->setMovable(false); | ||
50 | | ||||
50 | } | 51 | } | ||
51 | }); | 52 | }); | ||
52 | 53 | | |||
53 | } | 54 | } | ||
54 | 55 | | |||
55 | void MainWindow::initWidgets() | 56 | void MainWindow::initWidgets() | ||
56 | { | 57 | { | ||
57 | 58 | | |||
Show All 11 Lines | |||||
69 | centralLayout->addWidget(splitter); | 70 | centralLayout->addWidget(splitter); | ||
70 | auto *centralWidget = new QWidget(); | 71 | auto *centralWidget = new QWidget(); | ||
71 | centralWidget->setLayout(centralLayout); | 72 | centralWidget->setLayout(centralLayout); | ||
72 | setCentralWidget(centralWidget); | 73 | setCentralWidget(centralWidget); | ||
73 | } | 74 | } | ||
74 | void MainWindow::newAtCoreInstance() | 75 | void MainWindow::newAtCoreInstance() | ||
75 | { | 76 | { | ||
76 | auto newInstanceWidget = new AtCoreInstanceWidget(); | 77 | auto newInstanceWidget = new AtCoreInstanceWidget(); | ||
77 | QString name = QString::number(m_instances->addTab(newInstanceWidget, i18n("Connect a printer"))); | 78 | QString name = QString::number(m_instances->insertTab(m_instances->count() -1, newInstanceWidget, i18n("Connect a printer"))); | ||
78 | newInstanceWidget->setObjectName(name); | 79 | newInstanceWidget->setObjectName(name); | ||
79 | connect(this, &MainWindow::profilesChanged, newInstanceWidget, &AtCoreInstanceWidget::updateProfileData); | 80 | connect(this, &MainWindow::profilesChanged, newInstanceWidget, &AtCoreInstanceWidget::updateProfileData); | ||
80 | connect(newInstanceWidget, &AtCoreInstanceWidget::requestProfileDialog, [ this ] { | 81 | connect(newInstanceWidget, &AtCoreInstanceWidget::requestProfileDialog, [ this ] { | ||
81 | std::unique_ptr<ProfilesDialog> pd(new ProfilesDialog); | 82 | std::unique_ptr<ProfilesDialog> pd(new ProfilesDialog); | ||
82 | pd->exec(); | 83 | pd->exec(); | ||
83 | emit(profilesChanged()); | 84 | emit(profilesChanged()); | ||
84 | }); | 85 | }); | ||
85 | connect(newInstanceWidget, &AtCoreInstanceWidget::connectionChanged, this, &MainWindow::atCoreInstanceNameChange); | 86 | connect(newInstanceWidget, &AtCoreInstanceWidget::connectionChanged, this, &MainWindow::atCoreInstanceNameChange); | ||
86 | 87 | | |||
87 | if(m_instances->count() > 1) { | 88 | if(m_instances->count() >= 2) { | ||
88 | m_instances->setTabsClosable(true); | 89 | m_instances->setTabsClosable(true); | ||
89 | m_instances->setMovable(true); | 90 | m_instances->setMovable(true); | ||
90 | } | 91 | } | ||
91 | } | 92 | } | ||
92 | // Move to LateralArea. | 93 | // Move to LateralArea. | ||
93 | void MainWindow::setupLateralArea() | 94 | void MainWindow::setupLateralArea() | ||
94 | { | 95 | { | ||
95 | m_lateral.m_toolBar = new QWidget(); | 96 | m_lateral.m_toolBar = new QWidget(); | ||
▲ Show 20 Lines • Show All 92 Lines • Show Last 20 Lines |