Fix bug, about application collapse by
db can't connect
This commit is contained in:
@@ -31,18 +31,17 @@ MainWindow::MainWindow(QWidget* aParent)
|
||||
: QMainWindow(aParent)
|
||||
, mUI(new Ui::MainWindow)
|
||||
, mDebugConsoleWidget(nullptr)
|
||||
, mDebugMessageConsole(nullptr)
|
||||
, mTabWidget(new QTabWidget(this))
|
||||
, mInitializWidget(new InitializeWidget(this))
|
||||
, mShutdownWidget(new ShutdownWidget(nullptr))
|
||||
, mAdminTabIndex(-1)
|
||||
, mThread(nullptr)
|
||||
, mIsDebugMode(false)
|
||||
, mTabInited(false)
|
||||
{
|
||||
mUI->setupUi(this);
|
||||
this->setWindowFlags(Qt::Window);
|
||||
|
||||
initializeTabWidget();
|
||||
|
||||
initializeLayout();
|
||||
|
||||
connect(EventCenter::Default(), &EventCenter::PatientSelected, this,&MainWindow::switchToScanTab);
|
||||
@@ -59,8 +58,18 @@ MainWindow::MainWindow(QWidget* aParent)
|
||||
connect(DialogManager::Default(), &DialogManager::loginDialogShown, this, [this]()
|
||||
{
|
||||
mInitializWidget->setVisible(false);
|
||||
|
||||
});
|
||||
connect(EventCenter::Default(), &EventCenter::LoginSuccess, this, [this]()
|
||||
{
|
||||
if(!mTabInited){
|
||||
mTabInited = true;
|
||||
initializeTabWidget();
|
||||
mTabWidget->setCurrentIndex(0);
|
||||
}
|
||||
mTabWidget->setVisible(true);
|
||||
});
|
||||
|
||||
GUIErrorHandle::Default()->init();
|
||||
QApplication::setActiveWindow(centralWidget());
|
||||
}
|
||||
@@ -105,13 +114,14 @@ void MainWindow::initializeTabWidget()
|
||||
{
|
||||
mTabWidget->setTabPosition(QTabWidget::South);
|
||||
mTabWidget->setContentsMargins(0, 0, 0, 0);
|
||||
|
||||
auto selectForm = new SelectFormWidget(this);
|
||||
mTabWidget->addTab(selectForm, tr("Select"));
|
||||
auto scanForm = new ScanFormWidget(this);
|
||||
mTabWidget->addTab(scanForm, tr("Scan"));
|
||||
auto verifyForm = new ReconFormWidget(this);
|
||||
mTabWidget->addTab(verifyForm, tr("Recon"));
|
||||
mTabWidget->insertTab(0,verifyForm, tr("Recon"));
|
||||
auto scanForm = new ScanFormWidget(this);
|
||||
mTabWidget->insertTab(0,scanForm, tr("Scan"));
|
||||
auto selectForm = new SelectFormWidget(this);
|
||||
mTabWidget->insertTab(0,selectForm, tr("Select"));
|
||||
|
||||
|
||||
mTabWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||
}
|
||||
|
||||
@@ -251,36 +261,6 @@ void MainWindow::swipeTriggered(QSwipeGesture* aSwipeGesture)
|
||||
{
|
||||
if (aSwipeGesture->state() == Qt::GestureFinished)
|
||||
{
|
||||
//if (gesture->horizontalDirection() == QSwipeGesture::Right) {
|
||||
// int index = tab->currentIndex();
|
||||
// index--;
|
||||
// if (index >= 0) {
|
||||
// tab->setCurrentIndex(index);
|
||||
// }
|
||||
|
||||
//}
|
||||
//if (gesture->horizontalDirection() == QSwipeGesture::Left) {
|
||||
// int index = tab->currentIndex();
|
||||
// index++;
|
||||
// if (index < tab->count()) {
|
||||
// tab->setCurrentIndex(index);
|
||||
// }
|
||||
//}
|
||||
if (aSwipeGesture->verticalDirection() == QSwipeGesture::Down)
|
||||
{
|
||||
if (mIsDebugMode)
|
||||
{
|
||||
mDebugConsoleWidget->show();
|
||||
}
|
||||
}
|
||||
if (aSwipeGesture->verticalDirection() == QSwipeGesture::Up)
|
||||
{
|
||||
if (mIsDebugMode)
|
||||
{
|
||||
mDebugConsoleWidget->hide();
|
||||
}
|
||||
}
|
||||
//update();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -316,55 +296,3 @@ void MainWindow::resetRoleLayout() {
|
||||
}
|
||||
qApp->processEvents();
|
||||
}
|
||||
|
||||
//------log out about----------------------------------------------------------
|
||||
|
||||
QTextEdit* MainWindow::getEdit()
|
||||
{
|
||||
return mDebugMessageConsole;
|
||||
}
|
||||
|
||||
void MainWindow::debugConsoleOn()
|
||||
{
|
||||
mIsDebugMode = true;
|
||||
mDebugConsoleWidget = new QDockWidget(this);
|
||||
mDebugConsoleWidget->setObjectName(QString::fromUtf8("dockWidget"));
|
||||
mDebugConsoleWidget->setAllowedAreas(Qt::RightDockWidgetArea);
|
||||
this->addDockWidget(static_cast<Qt::DockWidgetArea>(2), mDebugConsoleWidget);
|
||||
|
||||
mDebugMessageConsole = new UTextEdit(this);
|
||||
mDebugMessageConsole->setFocusPolicy(Qt::NoFocus);
|
||||
mDebugConsoleWidget->setWidget(mDebugMessageConsole);
|
||||
|
||||
const QString edit_style =
|
||||
"QScrollBar:vertical{border: 0px solid grey; background:#2d2d2d; width: 15px; margin: 0px 0 0px 0; }"
|
||||
"QScrollBar::handle:vertical{background:#5a5a5a;min-height: 25px;}"
|
||||
"QScrollBar::add-page:vertical, QScrollBar::sub-page:vertical{background:#2d2d2d;}";
|
||||
mDebugMessageConsole->verticalScrollBar()->setStyleSheet(edit_style);
|
||||
//clear buffer before redirect;
|
||||
}
|
||||
|
||||
void MainWindow::QMessageOutput(QtMsgType aType, const QMessageLogContext& aContext, const QString& msg)
|
||||
{
|
||||
|
||||
std::cout << msg.toStdString().c_str() << std::endl;
|
||||
|
||||
//QByteArray localMsg = msg.toLocal8Bit();
|
||||
//switch (type) {
|
||||
//case QtDebugMsg:
|
||||
// fprintf(stderr, "Debug: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function);
|
||||
// break;
|
||||
//case QtInfoMsg:
|
||||
// fprintf(stderr, "Info: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function);
|
||||
// break;
|
||||
//case QtWarningMsg:
|
||||
// fprintf(stderr, "Warning: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function);
|
||||
// break;
|
||||
//case QtCriticalMsg:
|
||||
// fprintf(stderr, "Critical: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function);
|
||||
// break;
|
||||
//case QtFatalMsg:
|
||||
// fprintf(stderr, "Fatal: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function);
|
||||
// abort();
|
||||
//}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user