Changeset View
Changeset View
Standalone View
Standalone View
src/mainwindow.cpp
Show All 40 Lines | 40 | { | |||
---|---|---|---|---|---|
41 | m_theme = palette().text().color().value() >= QColor(Qt::lightGray).value() ? QString("dark") : QString("light"); | 41 | m_theme = palette().text().color().value() >= QColor(Qt::lightGray).value() ? QString("dark") : QString("light"); | ||
42 | 42 | | |||
43 | initWidgets(); | 43 | initWidgets(); | ||
44 | setupActions(); | 44 | setupActions(); | ||
45 | connect(m_instances, &QTabWidget::tabCloseRequested, [this] (int index){ | 45 | connect(m_instances, &QTabWidget::tabCloseRequested, [this] (int index){ | ||
46 | QWidget *tempWidget= m_instances->widget(index); | 46 | QWidget *tempWidget= m_instances->widget(index); | ||
47 | delete tempWidget; | 47 | delete tempWidget; | ||
48 | 48 | | |||
49 | if(m_instances->count() == 1) { | 49 | if(m_instances->count() == 2) { | ||
50 | m_instances->setTabsClosable(false); | 50 | m_instances->setTabsClosable(false); | ||
51 | m_instances->setMovable(false); | 51 | m_instances->setMovable(false); | ||
52 | | ||||
52 | } | 53 | } | ||
53 | }); | 54 | }); | ||
54 | } | 55 | } | ||
55 | 56 | | |||
56 | void MainWindow::initWidgets() | 57 | void MainWindow::initWidgets() | ||
57 | { | 58 | { | ||
58 | 59 | | |||
59 | setupLateralArea(); | 60 | setupLateralArea(); | ||
Show All 19 Lines | |||||
79 | auto *centralWidget = new QWidget(); | 80 | auto *centralWidget = new QWidget(); | ||
80 | centralWidget->setLayout(centralLayout); | 81 | centralWidget->setLayout(centralLayout); | ||
81 | setCentralWidget(centralWidget); | 82 | setCentralWidget(centralWidget); | ||
82 | } | 83 | } | ||
83 | 84 | | |||
84 | void MainWindow::newAtCoreInstance() | 85 | void MainWindow::newAtCoreInstance() | ||
85 | { | 86 | { | ||
86 | auto newInstanceWidget = new AtCoreInstanceWidget(); | 87 | auto newInstanceWidget = new AtCoreInstanceWidget(); | ||
87 | QString name = QString::number(m_instances->addTab(newInstanceWidget, i18n("Connect a printer"))); | 88 | QString name = QString::number(m_instances->insertTab(m_instances->count() -1, newInstanceWidget, i18n("Connect a printer"))); | ||
88 | newInstanceWidget->setObjectName(name); | 89 | newInstanceWidget->setObjectName(name); | ||
89 | connect(this, &MainWindow::profilesChanged, newInstanceWidget, &AtCoreInstanceWidget::updateProfileData); | 90 | connect(this, &MainWindow::profilesChanged, newInstanceWidget, &AtCoreInstanceWidget::updateProfileData); | ||
90 | connect(newInstanceWidget, &AtCoreInstanceWidget::requestProfileDialog, [ this ] { | 91 | connect(newInstanceWidget, &AtCoreInstanceWidget::requestProfileDialog, [ this ] { | ||
91 | std::unique_ptr<ProfilesDialog> pd(new ProfilesDialog); | 92 | std::unique_ptr<ProfilesDialog> pd(new ProfilesDialog); | ||
92 | pd->exec(); | 93 | pd->exec(); | ||
93 | emit(profilesChanged()); | 94 | emit(profilesChanged()); | ||
94 | }); | 95 | }); | ||
95 | connect(newInstanceWidget, &AtCoreInstanceWidget::connectionChanged, this, &MainWindow::atCoreInstanceNameChange); | 96 | connect(newInstanceWidget, &AtCoreInstanceWidget::connectionChanged, this, &MainWindow::atCoreInstanceNameChange); | ||
96 | 97 | | |||
97 | if(m_instances->count() > 1) { | 98 | if(m_instances->count() >= 2) { | ||
98 | m_instances->setTabsClosable(true); | 99 | m_instances->setTabsClosable(true); | ||
99 | m_instances->setMovable(true); | 100 | m_instances->setMovable(true); | ||
100 | m_instances->setCurrentIndex(m_instances->count()-1); | 101 | m_instances->setCurrentIndex(m_instances->count()-1); | ||
101 | } | 102 | } | ||
102 | } | 103 | } | ||
103 | // Move to LateralArea. | 104 | // Move to LateralArea. | ||
104 | void MainWindow::setupLateralArea() | 105 | void MainWindow::setupLateralArea() | ||
105 | { | 106 | { | ||
▲ Show 20 Lines • Show All 100 Lines • Show Last 20 Lines |