Stack::Stack(QWidget* parent) : QWidget(parent), m_symbols_dialog(0), m_printer(0), m_current_document(0), m_footer_margin(0), m_header_margin(0), m_footer_visible(0), m_header_visible(0) { setMouseTracking(true); m_contents = new QStackedWidget(this); m_alerts = new AlertLayer(this); m_scenes = new SceneList(this); setScenesVisible(false); m_menu = new QMenu(this); m_menu_group = new QActionGroup(this); m_menu_group->setExclusive(true); connect(m_menu_group, SIGNAL(triggered(QAction*)), this, SLOT(actionTriggered(QAction*))); m_find_dialog = new FindDialog(this); connect(m_find_dialog, SIGNAL(findNextAvailable(bool)), this, SIGNAL(findNextAvailable(bool))); connect(ActionManager::instance(), SIGNAL(insertText(QString)), this, SLOT(insertSymbol(QString))); m_layout = new QGridLayout(this); m_layout->setMargin(0); m_layout->setSpacing(0); m_layout->setRowMinimumHeight(1, 6); m_layout->setRowMinimumHeight(4, 6); m_layout->setRowStretch(2, 1); m_layout->setColumnMinimumWidth(1, 6); m_layout->setColumnMinimumWidth(4, 6); m_layout->setColumnStretch(1, 1); m_layout->setColumnStretch(2, 1); m_layout->setColumnStretch(3, 1); m_layout->addWidget(m_contents, 1, 0, 4, 6); m_layout->addWidget(m_scenes, 1, 0, 4, 3); m_layout->addWidget(m_alerts, 3, 3); m_resize_timer = new QTimer(this); m_resize_timer->setInterval(50); m_resize_timer->setSingleShot(true); connect(m_resize_timer, SIGNAL(timeout()), this, SLOT(updateBackground())); m_theme_renderer = new ThemeRenderer(this); connect(m_theme_renderer, SIGNAL(rendered(QImage,QRect,Theme)), this, SLOT(updateBackground(QImage,QRect))); setHeaderVisible(Preferences::instance().alwaysShowHeader()); setFooterVisible(Preferences::instance().alwaysShowFooter()); // Always draw background setAttribute(Qt::WA_OpaquePaintEvent); setAutoFillBackground(false); updateBackground(); }
Stack::Stack(QWidget* parent) : QWidget(parent), m_symbols_dialog(0), m_current_document(0), m_background_position(0), m_margin(0), m_footer_margin(0), m_header_margin(0), m_footer_visible(0), m_header_visible(0) { setMouseTracking(true); m_contents = new QStackedWidget(this); m_alerts = new AlertLayer(this); m_scenes = new SceneList(this); setScenesVisible(false); m_load_screen = new LoadScreen(this); m_find_dialog = new FindDialog(this); connect(m_find_dialog, SIGNAL(findNextAvailable(bool)), this, SIGNAL(findNextAvailable(bool))); connect(ActionManager::instance(), SIGNAL(insertText(QString)), this, SLOT(insertSymbol(QString))); m_layout = new QGridLayout(this); m_layout->setMargin(0); m_layout->setSpacing(0); m_layout->setRowMinimumHeight(1, 6); m_layout->setRowMinimumHeight(4, 6); m_layout->setRowStretch(2, 1); m_layout->setColumnMinimumWidth(1, 6); m_layout->setColumnMinimumWidth(4, 6); m_layout->setColumnStretch(1, 1); m_layout->setColumnStretch(2, 1); m_layout->setColumnStretch(3, 1); m_layout->addWidget(m_contents, 1, 0, 4, 6); m_layout->addWidget(m_scenes, 1, 0, 4, 3); m_layout->addWidget(m_alerts, 3, 3); m_layout->addWidget(m_load_screen, 0, 0, 6, 6); m_resize_timer = new QTimer(this); m_resize_timer->setInterval(50); m_resize_timer->setSingleShot(true); connect(m_resize_timer, SIGNAL(timeout()), this, SLOT(updateBackground())); connect(&background_loader, SIGNAL(finished()), this, SLOT(updateBackground())); }
void Stack::mouseMoveEvent(QMouseEvent* event) { int y = mapFromGlobal(event->globalPos()).y(); bool header_visible = y <= m_header_margin; bool footer_visible = y >= (height() - m_footer_margin); setHeaderVisible(header_visible); setFooterVisible(footer_visible); setScenesVisible(false); if (m_current_document) { if (header_visible || footer_visible) { m_current_document->setScrollBarVisible(false); } else { m_current_document->mouseMoveEvent(event); } } }