SessionManager::SessionManager(Window* parent) : QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint), m_session(0), m_window(parent) { setWindowTitle(tr("Manage Sessions")); // Create session lists m_sessions_menu = new QMenu(this); m_sessions_menu->setTitle(tr("S&essions")); m_sessions_actions = new QActionGroup(this); connect(m_sessions_actions, SIGNAL(triggered(QAction*)), this, SLOT(switchSession(QAction*))); m_sessions_list = new QListWidget(this); m_sessions_list->setIconSize(QSize(16,16)); m_sessions_list->setMovement(QListWidget::Static); m_sessions_list->setResizeMode(QListWidget::Adjust); m_sessions_list->setSelectionMode(QListWidget::SingleSelection); connect(m_sessions_list, SIGNAL(currentItemChanged(QListWidgetItem*, QListWidgetItem*)), this, SLOT(selectedSessionChanged(QListWidgetItem*))); connect(m_sessions_list, SIGNAL(itemActivated(QListWidgetItem*)), this, SLOT(switchSession())); // Create buttons QPushButton* new_button = new QPushButton(tr("New"), this); connect(new_button, SIGNAL(clicked()), this, SLOT(newSession())); m_rename_button = new QPushButton(tr("Rename"), this); connect(m_rename_button, SIGNAL(clicked()), this, SLOT(renameSession())); QPushButton* clone_button = new QPushButton(tr("Clone"), this); connect(clone_button, SIGNAL(clicked()), this, SLOT(cloneSession())); m_delete_button = new QPushButton(tr("Delete"), this); connect(m_delete_button, SIGNAL(clicked()), this, SLOT(deleteSession())); m_switch_button = new QPushButton(tr("Switch To"), this); connect(m_switch_button, SIGNAL(clicked()), this, SLOT(switchSession())); QDialogButtonBox* buttons = new QDialogButtonBox(QDialogButtonBox::Close, Qt::Horizontal, this); connect(buttons, SIGNAL(rejected()), this, SLOT(reject())); // Lay out window QGridLayout* layout = new QGridLayout(this); layout->setColumnStretch(0, 1); layout->setRowStretch(5, 1); layout->addWidget(m_sessions_list, 0, 0, 6, 1); layout->addWidget(new_button, 0, 1); layout->addWidget(m_rename_button, 1, 1); layout->addWidget(clone_button, 2, 1); layout->addWidget(m_delete_button, 3, 1); layout->addWidget(m_switch_button, 4, 1); layout->addWidget(buttons, 7, 1); // Restore size resize(QSettings().value("SessionManager/Size", sizeHint()).toSize()); }
void MainWindow::initMenuFile() { //connect menu "File" Action connect(actionNew, SIGNAL(triggered()), _documentManager, SLOT(newDocument())); connect(actionOpen, SIGNAL(triggered()), _documentManager, SLOT(open())); connect(actionSave, SIGNAL(triggered()), _documentManager, SLOT(save())); connect(actionSaveAs, SIGNAL(triggered()), _documentManager, SLOT(saveAs())); connect(actionSaveACopyAs, SIGNAL(triggered()), _documentManager, SLOT(saveACopyAs())); connect(actionSaveAll, SIGNAL(triggered()), _documentManager, SLOT(saveAll())); connect(actionClose, SIGNAL(triggered()), _documentManager, SLOT(close())); connect(actionCloseAll, SIGNAL(triggered()), _documentManager, SLOT(closeAll())); connect(actionCloseAllExceptCurrentDocument, SIGNAL(triggered()), _documentManager, SLOT(closeAllExceptCurrentDocument())); connect(actionReload, SIGNAL(triggered()), _documentManager, SLOT(reload())); connect(actionPrint, SIGNAL(triggered()), _documentManager, SLOT(print())); connect(actionExit, SIGNAL(triggered()), qApp, SLOT(closeAllWindows())); connect(actionExportAsHTML, SIGNAL(triggered()), this, SLOT(exportDocument())); connect(actionNewSession, SIGNAL(triggered()), _sessionManager, SLOT(newSession())); connect(actionOpenSession, SIGNAL(triggered()), _sessionManager, SLOT(openSession())); connect(actionSwitchSession, SIGNAL(triggered()), _sessionManager, SLOT(switchSession())); connect(actionSaveSession, SIGNAL(triggered()), _sessionManager, SLOT(saveSession())); connect(actionSaveSessionAs, SIGNAL(triggered()), _sessionManager, SLOT(saveSessionAs())); connect(actionManageSessions, SIGNAL(triggered()), _sessionManager, SLOT(manageSessions())); //recent file actions connect(actionEmptyRecentFilesList, SIGNAL(triggered()), this, SLOT(clearRecentFile())); connect(actionOpenAllRecentFiles, SIGNAL(triggered()), this, SLOT(openAllRecentFile())); _recentFileSeparator = menuRecentFiles->addSeparator(); for (int i = 0; i < MaxRecentFiles; ++i) { _recentFileActions[i] = new QAction(this); _recentFileActions[i]->setVisible(false); connect(_recentFileActions[i], SIGNAL(triggered()),this, SLOT(openRecentFile())); menuRecentFiles->addAction(_recentFileActions[i]); } updateRecentFileActions(); }