Example #1
0
/** GUI setup
 */
spqrMainWindow::spqrMainWindow(int argc, char *argv[], QWidget *parent)
    : QMainWindow(parent), MruHelper("spqr")
{
    statusBar()->showMessage(tr("spqr Setup"));

    lqPreferences p;
    p.loadGeometry(this);

    con = new ConsoleEdit(argc, argv);
    connect(con, SIGNAL(engine_ready()), this, SLOT(engineReady()));

    make_tabs();

    QMenu *m = menuBar()->addMenu(tr("&File"));
    m->setStatusTip(tr("Show File operations"));
    m->addAction(tr("&New..."), this, SLOT(newFile()), QKeySequence::New)->setStatusTip(tr("Create a new file"));
    m->addAction(tr("&Open..."), this, SLOT(openFile()), QKeySequence::Open)->setStatusTip(tr("Open an existing file"));
    m->addMenu(mruMenu = new QMenu(tr("Recent &Files...")))->setStatusTip(tr("List recently opened files"));
    loadMru(p, this);
    m->addSeparator();
    m->addAction(tr("&Save"), this, SLOT(saveFile()), QKeySequence::Save)->setStatusTip(tr("Save the document to disk"));
    m->addAction(tr("Save &As..."), this, SLOT(saveFileAs()), QKeySequence::SaveAs)->setStatusTip(tr("Save the document under a new name"));

    m->addSeparator();
    m->addAction(tr("&Quit"), qApp, SLOT(quit()), QKeySequence::Quit)->setStatusTip(tr("Exit the application"));

    // detach the background processor to avoid a random GPF exiting the program
    connect(qApp, &QApplication::aboutToQuit, []() { SwiPrologEngine::quit_request(); });

    menuBar()->addSeparator();
    menuBar()->addAction("&Exec", this, SLOT(execSource()))->setStatusTip(tr("Run Prolog Source code"));
    menuBar()->addAction("&Source", this, SLOT(viewSource()))->setStatusTip(tr("Show the Prolog source window"));
    menuBar()->addAction("&Console", this, SLOT(viewConsole()))->setStatusTip(tr("Show the SWI-Prolog console"));
    menuBar()->addAction("&Help", this, SLOT(viewHelp()))->setStatusTip(tr("Show SWI-Prolog helpDoc"));

    lastDir = p.value("lastDir").toString();
    QString currFile = p.value("fileSource").toString();
    if (argc >= 2)
        currFile = argv[1];
    if (currFile.length())
        openSourceFile(currFile);
}
MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent),
      lineEdit(new QLineEdit)
{
    QWidget *widget = new QWidget();        /* TO DO */
                                            /* Add layouts, buttuns, etc to widget */
    setCentralWidget(widget);

    QMenu *fileMenu = menuBar()->addMenu(tr("&File"));
    QAction *openAct = new QAction(tr("&Open"), this);

    openAct->setShortcuts(QKeySequence::Open);
    openAct->setStatusTip(tr("Open File"));

    fileMenu->addAction(openAct);
    fileMenu->setStatusTip(tr("File"));        /* it doesn'twork :( */

    connect(openAct, SIGNAL(triggered()), this, SLOT(openFile()));

    lineEdit->setReadOnly(true);
    statusBar()->addWidget(lineEdit);
    statusBar()->setToolTip("");
}
Example #3
0
QMenu *BtMenuView::newMenu(QMenu *parentMenu, const QModelIndex &itemIndex) {
    QVariant displayData(m_model->data(itemIndex, Qt::DisplayRole));
    QVariant iconData(m_model->data(itemIndex, Qt::DecorationRole));
    QVariant toolTipData(m_model->data(itemIndex, Qt::ToolTipRole));
    QVariant statusTipData(m_model->data(itemIndex, Qt::StatusTipRole));
    QVariant whatsThisData(m_model->data(itemIndex, Qt::WhatsThisRole));

    QMenu *childMenu = new QMenu(parentMenu);

    // Set text:
    if (displayData.canConvert(QVariant::String)) {
        childMenu->setTitle(displayData.toString());
    }

    // Set icon:
    if (iconData.canConvert(QVariant::Icon)) {
        childMenu->setIcon(iconData.value<QIcon>());
    }

    // Set tooltip:
    if (toolTipData.canConvert(QVariant::String)) {
        childMenu->setToolTip(toolTipData.toString());
    }

    // Set status tip:
    if (statusTipData.canConvert(QVariant::String)) {
        childMenu->setStatusTip(statusTipData.toString());
    }

    // Set whatsthis:
    if (whatsThisData.canConvert(QVariant::String)) {
        childMenu->setWhatsThis(whatsThisData.toString());
    }

    return childMenu;
}