app/mode: place tabs in menu corner
Signed-off-by: Kiara Navarro <sophiekovalevsky@fedoraproject.org>
This commit is contained in:
parent
7a0e6da706
commit
cb9b03e418
@ -125,7 +125,6 @@ HEADERS += \
|
|||||||
json.hpp \
|
json.hpp \
|
||||||
modehandler.h \
|
modehandler.h \
|
||||||
mode.h \
|
mode.h \
|
||||||
modetabwidget.h \
|
|
||||||
modewindow.h \
|
modewindow.h \
|
||||||
preferences.h \
|
preferences.h \
|
||||||
savable.h \
|
savable.h \
|
||||||
@ -247,7 +246,6 @@ SOURCES += \
|
|||||||
main.cpp \
|
main.cpp \
|
||||||
modehandler.cpp \
|
modehandler.cpp \
|
||||||
mode.cpp \
|
mode.cpp \
|
||||||
modetabwidget.cpp \
|
|
||||||
modewindow.cpp \
|
modewindow.cpp \
|
||||||
preferences.cpp \
|
preferences.cpp \
|
||||||
scpi.cpp \
|
scpi.cpp \
|
||||||
@ -312,7 +310,6 @@ FORMS += \
|
|||||||
VNA/s2pImportOptions.ui \
|
VNA/s2pImportOptions.ui \
|
||||||
aboutdialog.ui \
|
aboutdialog.ui \
|
||||||
main.ui \
|
main.ui \
|
||||||
modewindow.ui \
|
|
||||||
preferencesdialog.ui
|
preferencesdialog.ui
|
||||||
|
|
||||||
DISTFILES +=
|
DISTFILES +=
|
||||||
|
@ -227,12 +227,15 @@ AppWindow::AppWindow(QWidget *parent)
|
|||||||
}
|
}
|
||||||
|
|
||||||
modeHandler = new ModeHandler(this);
|
modeHandler = new ModeHandler(this);
|
||||||
auto modeWindow = new ModeWindow(modeHandler, this);
|
new ModeWindow(modeHandler, this);
|
||||||
|
|
||||||
setCentralWidget(modeWindow);
|
central = new QStackedWidget;
|
||||||
modeHandler->createMode("Vector Network Analyzer", Mode::Type::VNA);
|
setCentralWidget(central);
|
||||||
|
|
||||||
|
auto vnaIndex = modeHandler->createMode("Vector Network Analyzer", Mode::Type::VNA);
|
||||||
modeHandler->createMode("Spectrum Analyzer", Mode::Type::SA);
|
modeHandler->createMode("Spectrum Analyzer", Mode::Type::SA);
|
||||||
modeHandler->createMode("Signal Generator", Mode::Type::SG);
|
modeHandler->createMode("Signal Generator", Mode::Type::SG);
|
||||||
|
modeHandler->setCurrentIndex(vnaIndex);
|
||||||
|
|
||||||
auto setModeStatusbar = [=](const QString &msg) {
|
auto setModeStatusbar = [=](const QString &msg) {
|
||||||
lModeInfo.setText(msg);
|
lModeInfo.setText(msg);
|
||||||
@ -1128,28 +1131,29 @@ void AppWindow::LoadSetup(nlohmann::json j)
|
|||||||
|
|
||||||
modeHandler->closeModes();
|
modeHandler->closeModes();
|
||||||
|
|
||||||
// old style VNA/Generator/Spectrum Analyzer settings
|
/* old style VNA/Generator/Spectrum Analyzer settings,
|
||||||
|
* no more than one instance in each mode running */
|
||||||
if(j.contains("VNA")) {
|
if(j.contains("VNA")) {
|
||||||
modeHandler->createMode("Vector Network Analyzer", Mode::Type::VNA);
|
auto vnaIndex = modeHandler->createMode("Vector Network Analyzer", Mode::Type::VNA);
|
||||||
auto * vna = static_cast<VNA*>(modeHandler->findFirstOfType(Mode::Type::VNA));
|
auto *vna = static_cast<VNA*>(modeHandler->getMode(vnaIndex));
|
||||||
vna->fromJSON(j["VNA"]);
|
vna->fromJSON(j["VNA"]);
|
||||||
}
|
}
|
||||||
if(j.contains("Generator")) {
|
if(j.contains("Generator")) {
|
||||||
modeHandler->createMode("Generator", Mode::Type::SG);
|
auto sgIndex = modeHandler->createMode("Generator", Mode::Type::SG);
|
||||||
auto * generator = static_cast<Generator*>(modeHandler->findFirstOfType(Mode::Type::SG));
|
auto *generator = static_cast<Generator*>(modeHandler->getMode(sgIndex));
|
||||||
generator->fromJSON(j["Generator"]);
|
generator->fromJSON(j["Generator"]);
|
||||||
}
|
}
|
||||||
if(j.contains("SpectrumAnalyzer")) {
|
if(j.contains("SpectrumAnalyzer")) {
|
||||||
modeHandler->createMode("Spectrum Analyzer", Mode::Type::SA);
|
auto saIndex = modeHandler->createMode("Spectrum Analyzer", Mode::Type::SA);
|
||||||
auto * spectrumAnalyzer = static_cast<SpectrumAnalyzer*>(modeHandler->findFirstOfType(Mode::Type::SA));
|
auto *spectrumAnalyzer = static_cast<SpectrumAnalyzer*>(modeHandler->getMode(saIndex));
|
||||||
spectrumAnalyzer->fromJSON(j["SpectrumAnalyzer"]);
|
spectrumAnalyzer->fromJSON(j["SpectrumAnalyzer"]);
|
||||||
}
|
}
|
||||||
if(j.contains("Modes")) {
|
if(j.contains("Modes")) {
|
||||||
for(auto jm : j["Modes"]) {
|
for(auto jm : j["Modes"]) {
|
||||||
auto type = Mode::TypeFromName(QString::fromStdString(jm.value("type", "Invalid")));
|
auto type = Mode::TypeFromName(QString::fromStdString(jm.value("type", "Invalid")));
|
||||||
if(type != Mode::Type::Last && jm.contains("settings")) {
|
if(type != Mode::Type::Last && jm.contains("settings")) {
|
||||||
modeHandler->createMode(QString::fromStdString(jm.value("name", "")), type);
|
auto index = modeHandler->createMode(QString::fromStdString(jm.value("name", "")), type);
|
||||||
auto m = modeHandler->getMode(modeHandler->getCurrentIndex());
|
auto m = modeHandler->getMode(index);
|
||||||
m->fromJSON(jm["settings"]);
|
m->fromJSON(jm["settings"]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1159,7 +1163,8 @@ void AppWindow::LoadSetup(nlohmann::json j)
|
|||||||
QString modeName = QString::fromStdString(j.value("activeMode", ""));
|
QString modeName = QString::fromStdString(j.value("activeMode", ""));
|
||||||
for(auto m : modeHandler->getModes()) {
|
for(auto m : modeHandler->getModes()) {
|
||||||
if(m->getName() == modeName) {
|
if(m->getName() == modeName) {
|
||||||
m->activate();
|
auto index = modeHandler->findIndex(m);
|
||||||
|
modeHandler->setCurrentIndex(index);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1174,6 +1179,11 @@ Device *&AppWindow::getDevice()
|
|||||||
return device;
|
return device;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QStackedWidget *AppWindow::getCentral() const
|
||||||
|
{
|
||||||
|
return central;
|
||||||
|
}
|
||||||
|
|
||||||
Ui::MainWindow *AppWindow::getUi() const
|
Ui::MainWindow *AppWindow::getUi() const
|
||||||
{
|
{
|
||||||
return ui;
|
return ui;
|
||||||
|
@ -41,6 +41,7 @@ public:
|
|||||||
~AppWindow();
|
~AppWindow();
|
||||||
|
|
||||||
Ui::MainWindow *getUi() const;
|
Ui::MainWindow *getUi() const;
|
||||||
|
QStackedWidget *getCentral() const;
|
||||||
Device*&getDevice();
|
Device*&getDevice();
|
||||||
|
|
||||||
const QString& getAppVersion() const;
|
const QString& getAppVersion() const;
|
||||||
|
@ -32,6 +32,8 @@ Mode::~Mode()
|
|||||||
if(activeMode == this) {
|
if(activeMode == this) {
|
||||||
deactivate();
|
deactivate();
|
||||||
}
|
}
|
||||||
|
window->getCentral()->removeWidget(central);
|
||||||
|
delete central;
|
||||||
for(auto d : docks) {
|
for(auto d : docks) {
|
||||||
delete d;
|
delete d;
|
||||||
}
|
}
|
||||||
@ -64,7 +66,7 @@ void Mode::activate()
|
|||||||
}
|
}
|
||||||
|
|
||||||
QSettings settings;
|
QSettings settings;
|
||||||
|
window->getCentral()->setCurrentWidget(central);
|
||||||
// restore dock and toolbar positions
|
// restore dock and toolbar positions
|
||||||
window->restoreState(settings.value("windowState_"+name).toByteArray());
|
window->restoreState(settings.value("windowState_"+name).toByteArray());
|
||||||
|
|
||||||
@ -179,6 +181,7 @@ Mode *Mode::createNew(AppWindow *window, QString name, Mode::Type t)
|
|||||||
void Mode::finalize(QWidget *centralWidget)
|
void Mode::finalize(QWidget *centralWidget)
|
||||||
{
|
{
|
||||||
central = centralWidget;
|
central = centralWidget;
|
||||||
|
window->getCentral()->addWidget(central);
|
||||||
// Set ObjectName for toolbars and docks
|
// Set ObjectName for toolbars and docks
|
||||||
for(auto d : docks) {
|
for(auto d : docks) {
|
||||||
d->setObjectName(d->windowTitle()+name);
|
d->setObjectName(d->windowTitle()+name);
|
||||||
@ -224,8 +227,3 @@ void Mode::updateGraphColors()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QWidget *Mode::getCentral() const
|
|
||||||
{
|
|
||||||
return central;
|
|
||||||
}
|
|
||||||
|
@ -45,8 +45,6 @@ public:
|
|||||||
|
|
||||||
static Mode *createNew(AppWindow *window, QString name, Type t);
|
static Mode *createNew(AppWindow *window, QString name, Type t);
|
||||||
|
|
||||||
virtual QWidget *getCentral() const;
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void statusbarMessage(QString msg);
|
void statusbarMessage(QString msg);
|
||||||
protected:
|
protected:
|
||||||
|
@ -18,19 +18,23 @@ void ModeHandler::shutdown()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModeHandler::createMode(QString name, Mode::Type t)
|
int ModeHandler::createMode(QString name, Mode::Type t)
|
||||||
{
|
{
|
||||||
auto mode = Mode::createNew(aw, name, t);
|
auto mode = Mode::createNew(aw, name, t);
|
||||||
createMode(mode);
|
return createMode(mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModeHandler::createMode(Mode *mode)
|
int ModeHandler::createMode(Mode *mode)
|
||||||
{
|
{
|
||||||
modes.push_back(mode);
|
modes.push_back(mode);
|
||||||
currentModeIndex = int(modes.size());
|
currentModeIndex = int(modes.size()) - 1;
|
||||||
connect(mode, &Mode::statusbarMessage, this, &ModeHandler::setStatusBarMessageChanged);
|
connect(mode, &Mode::statusbarMessage, this, &ModeHandler::setStatusBarMessageChanged);
|
||||||
emit ModeCreated(currentModeIndex - 1);
|
|
||||||
|
|
||||||
|
auto * m = getMode(currentModeIndex);
|
||||||
|
m->activate();
|
||||||
|
|
||||||
|
emit ModeCreated(currentModeIndex);
|
||||||
|
return (currentModeIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
Mode* ModeHandler::getMode(int index)
|
Mode* ModeHandler::getMode(int index)
|
||||||
@ -45,10 +49,12 @@ std::vector<Mode*> ModeHandler::getModes()
|
|||||||
|
|
||||||
void ModeHandler::setCurrentIndex(int index)
|
void ModeHandler::setCurrentIndex(int index)
|
||||||
{
|
{
|
||||||
if ( (currentModeIndex != index) && (index >= 0)) {
|
// if ( (getCurrentIndex() != index) && (index >= 0)) {
|
||||||
|
if ( (getCurrentIndex() != index) && (index >= 0)) {
|
||||||
currentModeIndex = index;
|
currentModeIndex = index;
|
||||||
auto * mode = modes.at(currentModeIndex);
|
auto * m = getMode(getCurrentIndex());
|
||||||
mode->activate();
|
m->activate();
|
||||||
|
emit CurrentModeChanged(getCurrentIndex());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -62,10 +68,10 @@ void ModeHandler::closeMode(int index)
|
|||||||
disconnect(modes.at(index), &Mode::statusbarMessage, this, &ModeHandler::setStatusBarMessageChanged);
|
disconnect(modes.at(index), &Mode::statusbarMessage, this, &ModeHandler::setStatusBarMessageChanged);
|
||||||
delete modes.at(index);
|
delete modes.at(index);
|
||||||
modes.erase(modes.begin() + index);
|
modes.erase(modes.begin() + index);
|
||||||
if (currentModeIndex > int(modes.size()) ) {
|
if (int(modes.size()) > 0) {
|
||||||
setCurrentIndex(currentModeIndex - 1); // Select bar before one deleted
|
if (getCurrentIndex() == index) {
|
||||||
auto vna = modes.at(currentModeIndex);
|
setCurrentIndex(getCurrentIndex()-1); // Select bar before one deleted
|
||||||
vna->activate();
|
}
|
||||||
}
|
}
|
||||||
emit ModeClosed(index);
|
emit ModeClosed(index);
|
||||||
}
|
}
|
||||||
@ -95,6 +101,12 @@ bool ModeHandler::nameAllowed(const QString &name)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int ModeHandler::findIndex(Mode *targetMode)
|
||||||
|
{
|
||||||
|
auto it = std::find(modes.begin(), modes.end(), targetMode);
|
||||||
|
return it - modes.begin();
|
||||||
|
}
|
||||||
|
|
||||||
Mode* ModeHandler::findFirstOfType(Mode::Type t)
|
Mode* ModeHandler::findFirstOfType(Mode::Type t)
|
||||||
{
|
{
|
||||||
for(auto m : modes) {
|
for(auto m : modes) {
|
||||||
|
@ -15,7 +15,7 @@ public:
|
|||||||
~ModeHandler() = default;
|
~ModeHandler() = default;
|
||||||
|
|
||||||
void shutdown();
|
void shutdown();
|
||||||
void createMode(QString name, Mode::Type t);
|
int createMode(QString name, Mode::Type t);
|
||||||
void closeMode(int index);
|
void closeMode(int index);
|
||||||
void closeModes();
|
void closeModes();
|
||||||
int getCurrentIndex();
|
int getCurrentIndex();
|
||||||
@ -24,6 +24,7 @@ public:
|
|||||||
std::vector<Mode*> getModes();
|
std::vector<Mode*> getModes();
|
||||||
|
|
||||||
bool nameAllowed(const QString &name);
|
bool nameAllowed(const QString &name);
|
||||||
|
int findIndex(Mode *targetMode);
|
||||||
Mode* findFirstOfType(Mode::Type t);
|
Mode* findFirstOfType(Mode::Type t);
|
||||||
|
|
||||||
void setAveragingMode(Averaging::Mode m);
|
void setAveragingMode(Averaging::Mode m);
|
||||||
@ -33,6 +34,7 @@ signals:
|
|||||||
|
|
||||||
void ModeCreated(int modeIndex);
|
void ModeCreated(int modeIndex);
|
||||||
void ModeClosed(int modeIndex);
|
void ModeClosed(int modeIndex);
|
||||||
|
void CurrentModeChanged(int modeIndex);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void setCurrentIndex(int modeIndex);
|
void setCurrentIndex(int modeIndex);
|
||||||
@ -40,7 +42,7 @@ public slots:
|
|||||||
private:
|
private:
|
||||||
std::vector<Mode*> modes;
|
std::vector<Mode*> modes;
|
||||||
int currentModeIndex;
|
int currentModeIndex;
|
||||||
void createMode(Mode *mode);
|
int createMode(Mode *mode);
|
||||||
AppWindow *aw;
|
AppWindow *aw;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
@ -1,14 +0,0 @@
|
|||||||
#include "modetabwidget.h"
|
|
||||||
|
|
||||||
#include <QBoxLayout>
|
|
||||||
#include <QPushButton>
|
|
||||||
|
|
||||||
ModeTabWidget::ModeTabWidget(QWidget* parent):
|
|
||||||
QTabWidget(parent)
|
|
||||||
{
|
|
||||||
tabBar = new QTabBar;
|
|
||||||
tabBar->setStyleSheet("QTabBar::tab { height: " + QString::number(parent->height()) + "px;}");
|
|
||||||
this->setTabBar(tabBar);
|
|
||||||
this->setTabsClosable(true);
|
|
||||||
this->setMovable(true);
|
|
||||||
}
|
|
@ -1,18 +0,0 @@
|
|||||||
#ifndef MODETABWIDGET_H
|
|
||||||
#define MODETABWIDGET_H
|
|
||||||
|
|
||||||
#include <QTabWidget>
|
|
||||||
#include <QTabBar>
|
|
||||||
|
|
||||||
class ModeTabWidget: public QTabWidget
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
public:
|
|
||||||
explicit ModeTabWidget(QWidget* parent = nullptr);
|
|
||||||
~ModeTabWidget() = default;
|
|
||||||
|
|
||||||
private:
|
|
||||||
QTabBar * tabBar = nullptr;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // MODETABWIDGET_H
|
|
@ -1,7 +1,6 @@
|
|||||||
#include "modewindow.h"
|
#include "modewindow.h"
|
||||||
|
|
||||||
#include "mode.h"
|
#include "mode.h"
|
||||||
#include "ui_modewindow.h"
|
|
||||||
#include "appwindow.h"
|
#include "appwindow.h"
|
||||||
#include "CustomWidgets/informationbox.h"
|
#include "CustomWidgets/informationbox.h"
|
||||||
|
|
||||||
@ -14,31 +13,34 @@ ModeWindow::ModeWindow(ModeHandler* handler, AppWindow* aw, QWidget* parent):
|
|||||||
handler(handler),
|
handler(handler),
|
||||||
aw(aw)
|
aw(aw)
|
||||||
{
|
{
|
||||||
ui = new Ui::ModeWindow;
|
|
||||||
ui->setupUi(this);
|
|
||||||
|
|
||||||
SetupUi();
|
SetupUi();
|
||||||
|
|
||||||
connect(handler, &ModeHandler::ModeCreated, this, &ModeWindow::ModeCreated);
|
connect(handler, &ModeHandler::ModeCreated, this, &ModeWindow::ModeCreated);
|
||||||
connect(handler, &ModeHandler::ModeClosed, this, &ModeWindow::ModeClosed);
|
connect(handler, &ModeHandler::ModeClosed, this, &ModeWindow::ModeClosed);
|
||||||
|
connect(handler, &ModeHandler::CurrentModeChanged, this, &ModeWindow::CurrentModeChanged);
|
||||||
|
|
||||||
connect(ui->tabwidgetModes, &ModeTabWidget::currentChanged, handler, &ModeHandler::setCurrentIndex);
|
connect(tabBar, &QTabBar::currentChanged, handler, &ModeHandler::setCurrentIndex);
|
||||||
connect(ui->tabwidgetModes, &ModeTabWidget::tabCloseRequested, handler, &ModeHandler::closeMode);
|
connect(tabBar, &QTabBar::tabCloseRequested, handler, &ModeHandler::closeMode);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ModeWindow::~ModeWindow()
|
ModeWindow::~ModeWindow()
|
||||||
{
|
{
|
||||||
delete ui;
|
|
||||||
ui = nullptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModeWindow::SetupUi()
|
void ModeWindow::SetupUi()
|
||||||
{
|
{
|
||||||
ui->horizontalLayout->setSpacing(0);
|
auto cornerWidget = new QWidget();
|
||||||
ui->horizontalLayout->setMargin(0);
|
cornerWidget->setLayout(new QHBoxLayout);
|
||||||
ui->horizontalLayout->setContentsMargins(0,0,0,0);
|
cornerWidget->layout()->setSpacing(0);
|
||||||
ui->tabwidgetModes->setUsesScrollButtons(true);
|
cornerWidget->layout()->setMargin(0);
|
||||||
|
cornerWidget->layout()->setContentsMargins(0,0,0,0);
|
||||||
|
cornerWidget->setMaximumHeight(aw->menuBar()->height());
|
||||||
|
|
||||||
|
tabBar = new QTabBar;
|
||||||
|
tabBar->setStyleSheet("QTabBar::tab { height: " + QString::number(aw->menuBar()->height()) + "px;}");
|
||||||
|
tabBar->setTabsClosable(true);
|
||||||
|
cornerWidget->layout()->addWidget(tabBar);
|
||||||
|
|
||||||
auto bAdd = new QPushButton();
|
auto bAdd = new QPushButton();
|
||||||
QIcon icon;
|
QIcon icon;
|
||||||
@ -50,7 +52,7 @@ void ModeWindow::SetupUi()
|
|||||||
icon.addFile(QString::fromUtf8(":/icons/add.png"), QSize(), QIcon::Normal, QIcon::Off);
|
icon.addFile(QString::fromUtf8(":/icons/add.png"), QSize(), QIcon::Normal, QIcon::Off);
|
||||||
|
|
||||||
bAdd->setIcon(icon);
|
bAdd->setIcon(icon);
|
||||||
bAdd->setMaximumHeight(450);
|
bAdd->setMaximumHeight(aw->menuBar()->height());
|
||||||
bAdd->setMaximumWidth(40);
|
bAdd->setMaximumWidth(40);
|
||||||
|
|
||||||
auto mAdd = new QMenu();
|
auto mAdd = new QMenu();
|
||||||
@ -75,7 +77,10 @@ void ModeWindow::SetupUi()
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
bAdd->setMenu(mAdd);
|
bAdd->setMenu(mAdd);
|
||||||
aw->menuBar()->setCornerWidget(bAdd);
|
|
||||||
|
cornerWidget->layout()->addWidget(bAdd);
|
||||||
|
|
||||||
|
aw->menuBar()->setCornerWidget(cornerWidget);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModeWindow::ModeCreated(int modeIndex)
|
void ModeWindow::ModeCreated(int modeIndex)
|
||||||
@ -85,15 +90,27 @@ void ModeWindow::ModeCreated(int modeIndex)
|
|||||||
if (mode)
|
if (mode)
|
||||||
{
|
{
|
||||||
const auto name = mode->getName();
|
const auto name = mode->getName();
|
||||||
auto central = mode->getCentral();
|
|
||||||
const auto tabIndex = ui->tabwidgetModes->insertTab(modeIndex, central, name);
|
tabBar->blockSignals(true);
|
||||||
ui->tabwidgetModes->setCurrentIndex(tabIndex);
|
tabBar->insertTab(modeIndex, name);
|
||||||
|
tabBar->blockSignals(false);
|
||||||
|
|
||||||
|
tabBar->setCurrentIndex(modeIndex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModeWindow::ModeClosed(int modeIndex)
|
void ModeWindow::ModeClosed(int modeIndex)
|
||||||
{
|
{
|
||||||
auto modeWidget = ui->tabwidgetModes->widget(modeIndex);
|
tabBar->blockSignals(true);
|
||||||
ui->tabwidgetModes->removeTab(modeIndex);
|
tabBar->removeTab(modeIndex);
|
||||||
delete modeWidget;
|
tabBar->blockSignals(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ModeWindow::CurrentModeChanged(int modeIndex)
|
||||||
|
{
|
||||||
|
if (modeIndex != tabBar->currentIndex())
|
||||||
|
{
|
||||||
|
tabBar->setCurrentIndex(modeIndex);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,10 +3,6 @@
|
|||||||
|
|
||||||
#include "modehandler.h"
|
#include "modehandler.h"
|
||||||
|
|
||||||
namespace Ui {
|
|
||||||
class ModeWindow;
|
|
||||||
}
|
|
||||||
|
|
||||||
class ModeWindow: public QWidget
|
class ModeWindow: public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@ -16,13 +12,14 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
ModeHandler* handler;
|
ModeHandler* handler;
|
||||||
Ui::ModeWindow *ui;
|
|
||||||
void SetupUi();
|
void SetupUi();
|
||||||
AppWindow* aw;
|
AppWindow* aw;
|
||||||
|
QTabBar* tabBar;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void ModeCreated(int modeIndex);
|
void ModeCreated(int modeIndex);
|
||||||
void ModeClosed(int modeIndex);
|
void ModeClosed(int modeIndex);
|
||||||
|
void CurrentModeChanged(int modeIndex);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MODEWINDOW_H
|
#endif // MODEWINDOW_H
|
||||||
|
@ -1,45 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<ui version="4.0">
|
|
||||||
<class>ModeWindow</class>
|
|
||||||
<widget class="QWidget" name="ModeWindow">
|
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>0</x>
|
|
||||||
<y>0</y>
|
|
||||||
<width>22</width>
|
|
||||||
<height>29</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<property name="windowTitle">
|
|
||||||
<string>Form</string>
|
|
||||||
</property>
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
|
||||||
<item>
|
|
||||||
<widget class="ModeTabWidget" name="tabwidgetModes">
|
|
||||||
<property name="layoutDirection">
|
|
||||||
<enum>Qt::LeftToRight</enum>
|
|
||||||
</property>
|
|
||||||
<property name="currentIndex">
|
|
||||||
<number>-1</number>
|
|
||||||
</property>
|
|
||||||
<property name="usesScrollButtons">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
<property name="tabsClosable">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
<customwidgets>
|
|
||||||
<customwidget>
|
|
||||||
<class>ModeTabWidget</class>
|
|
||||||
<extends>QTabWidget</extends>
|
|
||||||
<header>modetabwidget.h</header>
|
|
||||||
<container>1</container>
|
|
||||||
</customwidget>
|
|
||||||
</customwidgets>
|
|
||||||
<resources/>
|
|
||||||
<connections/>
|
|
||||||
</ui>
|
|
Loading…
Reference in New Issue
Block a user