ContainerWidget * MultiViewWidget::createContainer(QWidget *widget)
{
  ContainerWidget *container = new ContainerWidget;
  connect(container, SIGNAL(splitHorizontal()), SLOT(splitHorizontal()));
  connect(container, SIGNAL(splitVertical()), SLOT(splitVertical()));
  connect(container, SIGNAL(closeView()), SLOT(removeView()));

  if (widget) {
    container->setViewWidget(widget);
  }
  // If we have a factory, then create the options widget too!
  else if (m_factory) {
    QWidget *optionsWidget = new QWidget;
    QVBoxLayout *v = new QVBoxLayout;
    optionsWidget->setLayout(v);
    v->addStretch();
    foreach (const QString &name, m_factory->views()) {
      QPushButton *button = new QPushButton(name);
      button->setToolTip(tr("Create a new view"));
      connect(button, SIGNAL(clicked()), SLOT(createView()));
      QHBoxLayout *h = new QHBoxLayout;
      h->addStretch();
      h->addWidget(button);
      h->addStretch();
      v->addLayout(h);
    }
    v->addStretch();
    container->layout()->addWidget(optionsWidget);
  }

  return container;
}
Esempio n. 2
0
void ViewportsSplitter::setViewportsLayout(ViewportPanel * vp, int index)
{
	switch (index)
	{
	case 0:
		splitSingle(vp);
		break;
	case 1:
		splitVertical(vp);
		break;
	case 2: 
		splitHorizontal(vp);
		break;
	case 3:
		split2Up1Down(vp);
		break;
	case 4:
		split1Up2Down(vp);
		break;
	case 5:
		splitQuad();
		break;
	}
	if (index<=5 && index>=0 && index != currentLayoutIndex)
	{
		currentLayoutIndex = index;
		emit indexLayoutChanged(index);
	}
}
Esempio n. 3
0
Example2Main::Example2Main(Sublime::Controller *controller, Qt::WindowFlags flags)
    :Sublime::MainWindow(controller, flags)
{
    QMenu *windowMenu = new QMenu("Window", this);
    windowMenu->addAction("Split Top/Bottom", this, SLOT(splitVertical()), Qt::CTRL + Qt::Key_T);
    windowMenu->addAction("Split Left/Right", this, SLOT(splitHorizontal()), Qt::CTRL + Qt::Key_L);
    windowMenu->addSeparator();
    windowMenu->addAction("Close", this, SLOT(close()), Qt::CTRL + Qt::Key_W);
    menuBar()->addMenu(windowMenu);
}
ContainerWidget::ContainerWidget(QWidget *p, Qt::WindowFlags f)
  : QWidget(p, f), m_viewWidget(NULL), m_label(new QLabel("   ", this)),
    m_active(false)
{
  QHBoxLayout *h = new QHBoxLayout;
  h->setContentsMargins(0, 0, 0, 0);
  QVBoxLayout *v = new QVBoxLayout;
  v->setContentsMargins(0, 0, 0, 0);
  v->setSpacing(0);

  h->addWidget(m_label);
  h->addStretch();
  QPushButton *button = new QPushButton(tr("Split Horizontal"), this);
  connect(button, SIGNAL(clicked()), SIGNAL(splitHorizontal()));
  h->addWidget(button);
  button = new QPushButton(tr("Split Vertical"), this);
  connect(button, SIGNAL(clicked()), SIGNAL(splitVertical()));
  h->addWidget(button);
  button = new QPushButton(tr("Close"), this);
  connect(button, SIGNAL(clicked()), SIGNAL(closeView()));
  h->addWidget(button);
  v->addLayout(h);
  setLayout(v);
}
Esempio n. 5
0
TermWidget::TermWidget(const QString & wdir, const QString & shell, QWidget * parent)
    : QWidget(parent)
{
    m_border = palette().color(QPalette::Window);
    m_term = new TermWidgetImpl(wdir, shell, this);
    setFocusProxy(m_term);

    m_layout = new QVBoxLayout;
    setLayout(m_layout);

    m_layout->addWidget(m_term);

    propertiesChanged();

    connect(m_term, SIGNAL(finished()), this, SIGNAL(finished()));
    connect(m_term, SIGNAL(splitHorizontal()),
            this, SLOT(term_splitHorizontal()));
    connect(m_term, SIGNAL(splitVertical()),
            this, SLOT(term_splitVertical()));
    connect(m_term, SIGNAL(splitCollapse()),
            this, SLOT(term_splitCollapse()));
    connect(m_term, SIGNAL(termGetFocus()), this, SLOT(term_termGetFocus()));
    connect(m_term, SIGNAL(termLostFocus()), this, SLOT(term_termLostFocus()));
}
Esempio n. 6
0
void MainWindow::createActions()
{
    m_newAct = new QAction(QIcon(":/images/new.png"), tr("&New"), this);
    m_newAct->setShortcut(tr("Ctrl+N"));
    m_newAct->setStatusTip(tr("Create a new file"));
    connect(m_newAct, SIGNAL(triggered()), this, SLOT(newFile()));

    m_openAct = new QAction(QIcon(":/images/open.png"), tr("&Open..."), this);
    m_openAct->setShortcut(tr("Ctrl+O"));
    m_openAct->setStatusTip(tr("Open a file from disk"));
    connect(m_openAct, SIGNAL(triggered()), this, SLOT(open()));

    m_saveAct = new QAction(QIcon(":/images/save.png"), tr("&Save"), this);
    m_saveAct->setShortcut(tr("Ctrl+S"));
    m_saveAct->setStatusTip(tr("Save the document to disk"));
    connect(m_saveAct, SIGNAL(triggered()), this, SLOT(save()));

    m_saveAsAct = new QAction(tr("Save &As..."), this);
    m_saveAsAct->setStatusTip(tr("Save the document under a new name"));
    connect(m_saveAsAct, SIGNAL(triggered()), this, SLOT(saveAs()));

    m_closeAct = new QAction(tr("&Close..."), this);
    m_closeAct->setShortcut(tr("Ctrl+W"));
    m_closeAct->setStatusTip(tr("Close the document"));
    connect(m_closeAct, SIGNAL(triggered()), this, SLOT(close()));

    m_openSourceFile = new QAction(tr("&Open Source File"), this);
    m_openSourceFile->setShortcut(tr("Ctrl+Alt+J"));
    m_openSourceFile->setStatusTip(tr("Open a file from the source directory"));
    connect(m_openSourceFile, SIGNAL(triggered()), this, SLOT(openSourceFile()));

    m_openBuildFile = new QAction(tr("&Open Build File"), this);
    m_openBuildFile->setShortcut(tr("Ctrl+Alt+K"));
    m_openBuildFile->setStatusTip(tr("Open a file from the build directory"));
    connect(m_openBuildFile, SIGNAL(triggered()), this, SLOT(openBuildFile()));

    m_selectOpenedFile = new QAction(tr("&Select Opened File"), this);
    m_selectOpenedFile->setShortcut(tr("Ctrl+Space"));
    m_selectOpenedFile->setStatusTip(tr("Select an already opened file"));
    connect(m_selectOpenedFile, SIGNAL(triggered()), this, SLOT(selectOpenedFile()));

    m_exitAct = new QAction(tr("E&xit"), this);
    m_exitAct->setShortcut(tr("Ctrl+Q"));
    m_exitAct->setStatusTip(tr("Exit the application"));
    connect(m_exitAct, SIGNAL(triggered()), this, SLOT(close()));

    m_cutAct = new QAction(QIcon(":/images/cut.png"), tr("Cu&t"), this);
    m_cutAct->setShortcut(tr("Ctrl+X"));
    m_cutAct->setStatusTip(tr("Cut the current selection's contents to the "
                            "clipboard"));
    connect(m_cutAct, SIGNAL(triggered()), m_fileStack, SLOT(cut()));

    m_copyAct = new QAction(QIcon(":/images/copy.png"), tr("&Copy"), this);
    m_copyAct->setShortcut(tr("Ctrl+C"));
    m_copyAct->setStatusTip(tr("Copy the current selection's contents to the "
                             "clipboard"));
    connect(m_copyAct, SIGNAL(triggered()), m_fileStack, SLOT(copy()));

    m_pasteAct = new QAction(QIcon(":/images/paste.png"), tr("&Paste"), this);
    m_pasteAct->setShortcut(tr("Ctrl+V"));
    m_pasteAct->setStatusTip(tr("Paste the clipboard's contents into the current "
                              "selection"));
    connect(m_pasteAct, SIGNAL(triggered()), m_fileStack, SLOT(paste()));

    m_splitVertical = new QAction(tr("Split &Vertical"), this);
    m_splitVertical->setShortcut(tr("Ctrl+Alt+V"));
    m_splitVertical->setStatusTip(tr("Split the focused file view vertically"));
    connect(m_splitVertical, SIGNAL(triggered()), this, SLOT(splitVertical()));

    m_splitHorizontal = new QAction(tr("Split &Horizontal"), this);
    m_splitHorizontal->setShortcut(tr("Ctrl+Alt+H"));
    m_splitHorizontal->setStatusTip(tr("Split the focused file view horizontally"));
    connect(m_splitHorizontal, SIGNAL(triggered()), this, SLOT(splitHorizontal()));

    m_newProjectAct = new QAction(QIcon(":/images/new.png"), tr("&New Project"), this);
    m_newProjectAct->setStatusTip(tr("Create a new project"));
    connect(m_newProjectAct, SIGNAL(triggered()), this, SLOT(newProject()));

    m_openProjectAct = new QAction(QIcon(":/images/open.png"), tr("&Open Project..."), this);
    m_openProjectAct->setStatusTip(tr("Open an existing project"));
    connect(m_openProjectAct, SIGNAL(triggered()), this, SLOT(openProject()));

    m_importProjectAct = new QAction(tr("&Import Project"), this);
    m_importProjectAct->setStatusTip(tr("Import an existing project"));
    connect(m_importProjectAct, SIGNAL(triggered()), this, SLOT(importProject()));

    m_closeProjectAct = new QAction(tr("&Close Project..."), this);
    m_closeProjectAct->setStatusTip(tr("Close the project"));
    connect(m_closeProjectAct, SIGNAL(triggered()), this, SLOT(closeProject()));

    m_openSettingsAct = new QAction(tr("&Configure..."), this);
    m_openSettingsAct->setStatusTip(tr("Configure settings"));
    connect(m_openSettingsAct, SIGNAL(triggered()), this, SLOT(openSettings()));

    m_aboutAct = new QAction(tr("&About"), this);
    m_aboutAct->setStatusTip(tr("Show the application's About box"));
    connect(m_aboutAct, SIGNAL(triggered()), this, SLOT(about()));

    m_aboutQtAct = new QAction(tr("About &Qt"), this);
    m_aboutQtAct->setStatusTip(tr("Show the Qt library's About box"));
    connect(m_aboutQtAct, SIGNAL(triggered()), qApp, SLOT(aboutQt()));

    m_cutAct->setEnabled(false);
    m_copyAct->setEnabled(false);
    connect(m_fileStack, SIGNAL(copyAvailable(bool)),
            m_cutAct, SLOT(setEnabled(bool)));
    connect(m_fileStack, SIGNAL(copyAvailable(bool)),
            m_copyAct, SLOT(setEnabled(bool)));
}
Esempio n. 7
0
void TermWidget::term_splitHorizontal()
{
    emit splitHorizontal(this);
}
Esempio n. 8
0
void TermWidgetImpl::act_splitHorizontal()
{
    emit splitHorizontal();
}