Example #1
0
LuaEditor::LuaEditor(QWidget* pa) : QTextEdit(pa), parent(pa)
{
	highlighter = new Highlighter(document());

	QStringList names = QFontDatabase().families();
	QStringList prefs;
	prefs << "DejaVu Sans Mono" << "Bitstream Vera Sans Mono" << "Terminus"
			<< "Fixed";
	foreach (QString p, prefs)
		if (names.contains(p, Qt::CaseInsensitive))
		{
			logInfo(QString("LuaEditor::LuaEditor : found font %1").arg(p));
			setFontFamily(p);
			break;
		}

	QAction* a = new QAction(tr("Open a file"), this);
	a->setShortcut(tr("Ctrl+1"));
	a->setShortcutContext(Qt::WidgetShortcut);
	addAction(a);
	connect(a, SIGNAL(triggered()), this, SLOT(load()));

	a = new QAction(tr("Save file"), this);
	a->setShortcut(tr("Ctrl+2"));
	a->setShortcutContext(Qt::WidgetShortcut);
	addAction(a);
	connect(a, SIGNAL(triggered()), this, SLOT(save()));

	a = new QAction(tr("Save to file"), this);
	a->setShortcut(tr("Ctrl+3"));
	a->setShortcutContext(Qt::WidgetShortcut);
	addAction(a);
	connect(a, SIGNAL(triggered()), this, SLOT(saveAs()));
}
Example #2
0
void SCgMainWindow::initializeActions()
{
    QUndoStack* undoStack = mScene->undoStack();

    QAction* actionRedo = undoStack->createRedoAction(mScene);
    actionRedo->setShortcut(QKeySequence::Redo);
//    actionRedo->setShortcutContext(Qt::WidgetShortcut);

    QAction* actionUndo = undoStack->createUndoAction(mScene);
    actionUndo->setShortcut(QKeySequence::Undo);
//    actionUndo->setShortcutContext(Qt::WidgetShortcut);

    QAction* actionDelete = new QAction("Delete", mScene);
    actionDelete->setShortcut(QKeySequence::Delete);
    connect(actionDelete, SIGNAL(triggered()), mInputHandler, SLOT(deleteSelected()));
    actionDelete->setShortcutContext(Qt::WidgetShortcut);

    QAction* actionDeleteJustContour = new QAction("Delete just contour", mScene);
    actionDeleteJustContour->setShortcut( QKeySequence(tr("Backspace")) );
    connect(actionDeleteJustContour, SIGNAL(triggered()), mInputHandler, SLOT(deleteJustContour()));
    actionDeleteJustContour->setShortcutContext(Qt::WidgetShortcut);

    mView->addAction(actionDeleteJustContour);
    mView->addAction(actionDelete);
    mView->addAction(actionRedo);
    mView->addAction(actionUndo);
}
Example #3
0
Editor::Editor(QWidget *parent)
  :  QWidget(parent)
  , _view(NULL)
  , _buttonBar(NULL)
  , _xmlPreview(NULL)
  , _assembly(NULL)
  , _viewController(NULL)
  , _editorController(NULL)
  , _buttonBarController(NULL)
{
  qRegisterMetaType<ItemMove>("ItemMove");
  qRegisterMetaType<ItemsMove>("ItemsMove");

  // Widgets
  _view = new GraphicsView;

  _buttonBar = new ButtonBar;
  _buttonBar->setEnabled(false);

  _xmlPreview = new QTextEdit;
  _xmlPreview->setReadOnly(true);

  QVBoxLayout* vLyt = new QVBoxLayout(this);
  vLyt->setMargin(0);
  vLyt->setSpacing(1);
  vLyt->addWidget(_view, 4);
  vLyt->addWidget(_buttonBar);
  vLyt->addWidget(_xmlPreview, 1);

  // Controllers
  _viewController = new ViewController(_view, this);

  _buttonBarController = new ButtonBarController(_buttonBar, this);
  connect(_viewController, SIGNAL(selectionChanged(int)),
          _buttonBarController, SLOT(onSelectionChanged(int)));

  _editorController = new EditorController(this);
  connect(_viewController, SIGNAL(elementsMoved(ItemsMove)),
          _editorController, SLOT(onElementsMoved(ItemsMove)));
  connect(_buttonBarController, SIGNAL(actionTriggered(int,Action)),
          _editorController, SLOT(onAction(int,Action)));
  connect(_buttonBarController, SIGNAL(actionValueTriggered(int,Action,qreal)),
          _editorController, SLOT(onActionValue(int,Action,qreal)));
  connect(_buttonBarController, SIGNAL(nameChanged(QString)),
          _editorController, SLOT(onNameEdited(QString)));

  QAction* redoAction = _editorController->undoStack()->createRedoAction(this);
  redoAction->setShortcut(QKeySequence::Redo);
  redoAction->setShortcutContext(Qt::WidgetWithChildrenShortcut);
  this->addAction(redoAction);

  QAction* undoAction = _editorController->undoStack()->createUndoAction(this);
  undoAction->setShortcut(QKeySequence::Undo);
  undoAction->setShortcutContext(Qt::WidgetWithChildrenShortcut);
  this->addAction(undoAction);
}
Example #4
0
UserManual::UserManual(QWidget *parent) : QMainWindow(parent),
	ui(new Ui::UserManual)
{
	ui->setupUi(this);

	QShortcut *closeKey = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_W), this);
	connect(closeKey, SIGNAL(activated()), this, SLOT(close()));
	QShortcut *quitKey = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_Q), this);
	connect(quitKey, SIGNAL(activated()), parent, SLOT(close()));

	QAction *actionShowSearch = new QAction(this);
	actionShowSearch->setShortcut(Qt::CTRL + Qt::Key_F);
	actionShowSearch->setShortcutContext(Qt::WindowShortcut);
	addAction(actionShowSearch);

	QAction *actionHideSearch = new QAction(this);
	actionHideSearch->setShortcut(Qt::Key_Escape);
	actionHideSearch->setShortcutContext(Qt::WindowShortcut);
	addAction(actionHideSearch);

	setWindowTitle(tr("User Manual"));

	ui->webView->page()->setLinkDelegationPolicy(QWebPage::DelegateExternalLinks);
	QString searchPath = getSubsurfaceDataPath("Documentation");
	if (searchPath.size()) {
		// look for localized versions of the manual first
		QString lang = uiLanguage(NULL);
		QString prefix = searchPath.append("/user-manual");
		QFile manual(prefix + "_" + lang + ".html");
		if (!manual.exists())
			manual.setFileName(prefix + "_" + lang.left(2) + ".html");
		if (!manual.exists())
			manual.setFileName(prefix + ".html");
		if (!manual.exists()) {
			ui->webView->setHtml(tr("Cannot find the Subsurface manual"));
		} else {
			QString urlString = QString("file:///") + manual.fileName();
			QUrl url(urlString, QUrl::TolerantMode);
			ui->webView->setUrl(url);
		}
	} else {
		ui->webView->setHtml(tr("Cannot find the Subsurface manual"));
	}
	ui->searchPanel->setParent(this);
	ui->searchPanel->hide();

	connect(actionShowSearch, SIGNAL(triggered(bool)), this, SLOT(showSearchPanel()));
	connect(actionHideSearch, SIGNAL(triggered(bool)), this, SLOT(hideSearchPanel()));
	connect(ui->webView, SIGNAL(linkClicked(QUrl)), this, SLOT(linkClickedSlot(QUrl)));
	connect(ui->searchEdit, SIGNAL(textChanged(QString)), this, SLOT(searchTextChanged(QString)));
	connect(ui->findNext, SIGNAL(clicked()), this, SLOT(searchNext()));
	connect(ui->findPrev, SIGNAL(clicked()), this, SLOT(searchPrev()));
}
Example #5
0
URLListWidget::URLListWidget(URLListController *_ctrl)
    : QWidget(), ctrl(_ctrl), connectToDbDialog(new SharedConnectionsDialog(this)), waitingForDbToConnect(false)
{
    setupUi(this);
    popup = new OptionsPopup(this);

    reset();
    QIcon fileIcon = QIcon(QString(":U2Designer/images/add_file.png"));
    QIcon dirIcon = QIcon(QString(":U2Designer/images/add_directory.png"));
    QIcon dbIcon = QIcon(QString(":U2Designer/images/database_add.png"));
    QIcon deleteIcon = QIcon(QString(":U2Designer/images/exit.png"));
    QIcon upIcon = QIcon(QString(":U2Designer/images/up.png"));
    QIcon downIcon = QIcon(QString(":U2Designer/images/down.png"));

    addFileButton->setIcon(fileIcon);
    addDirButton->setIcon(dirIcon);
    addFromDbButton->setIcon(dbIcon);
    deleteButton->setIcon(deleteIcon);
    upButton->setIcon(upIcon);
    downButton->setIcon(downIcon);

    connect(addFileButton, SIGNAL(clicked()), SLOT(sl_addFileButton()));
    connect(addDirButton, SIGNAL(clicked()), SLOT(sl_addDirButton()));
    connect(addFromDbButton, SIGNAL(clicked()), SLOT(sl_addFromDbButton()));
    connect(downButton, SIGNAL(clicked()), SLOT(sl_downButton()));
    connect(upButton, SIGNAL(clicked()), SLOT(sl_upButton()));
    connect(deleteButton, SIGNAL(clicked()), SLOT(sl_deleteButton()));
    connect(connectToDbDialog.data(), SIGNAL(si_connectionCompleted()), SLOT(sl_sharedDbConnected()));

    connect(itemsArea, SIGNAL(itemSelectionChanged()), SLOT(sl_itemChecked()));

    if (!readingFromDbIsSupported()) {
        addFromDbButton->hide();
    }

    QAction *deleteAction = new QAction(itemsArea);
    deleteAction->setShortcut(QKeySequence::Delete);
    deleteAction->setShortcutContext(Qt::WidgetShortcut);
    connect(deleteAction, SIGNAL(triggered()), SLOT(sl_deleteButton()));
    itemsArea->addAction(deleteAction);

    QAction *selectAction = new QAction(itemsArea);
    selectAction->setShortcut(QKeySequence::SelectAll);
    selectAction->setShortcutContext(Qt::WidgetShortcut);
    connect(selectAction, SIGNAL(triggered()), SLOT(sl_selectAll()));
    itemsArea->addAction(selectAction);

    itemsArea->installEventFilter(this);
}
Example #6
0
void RepoWindow::setupMainMenu()
{
    QMenu * m = ui->menuBar->addMenu("Repository");
    QAction * a = m->addAction("Open ...", this, SLOT(openRepository()));
    a->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_O));
    a->setShortcutContext(Qt::ApplicationShortcut);
}
Example #7
0
void MainWindow::scanWorlds() {
  ui->menuOpen_World->clear();
  bool enabled = false;
  int key = 0;
  for (const QString &worldDir : settings->getWorlds()) {
    QDir dir(worldDir);
  
    QDirIterator it(dir);
    QList<QAction *> actions;
    while (it.hasNext()) {
      it.next();
      if (it.fileName().endsWith(".wld")) {
        QString name = worldName(it.filePath());
        if (!name.isNull()) {
          QAction *w = new QAction(this);
          w->setText(name);
          w->setData(it.filePath());
          if (key < 9) {
            w->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_1 + key++));
            w->setShortcutContext(Qt::ApplicationShortcut);
          }
          connect(w, SIGNAL(triggered()),
                  this, SLOT(openWorld()));
          actions.append(w);
        }
      }
    }
    if (!actions.isEmpty()) {
      ui->menuOpen_World->addSection(worldDir);
      ui->menuOpen_World->addActions(actions);
      enabled = true;
    }
  }
  ui->menuOpen_World->setDisabled(!enabled);
}
Example #8
0
DiveListView::DiveListView(QWidget *parent) : QTreeView(parent), mouseClickSelection(false),
	currentHeaderClicked(-1), searchBox(new QLineEdit(this))
{
	setUniformRowHeights(true);
	setItemDelegateForColumn(TreeItemDT::RATING, new StarWidgetsDelegate());
	QSortFilterProxyModel *model = new QSortFilterProxyModel(this);
	model->setSortRole(TreeItemDT::SORT_ROLE);
	model->setFilterKeyColumn(-1); // filter all columns
	setModel(model);
	connect(model, SIGNAL(layoutChanged()), this, SLOT(fixMessyQtModelBehaviour()));

	setSortingEnabled(false);
	setContextMenuPolicy(Qt::DefaultContextMenu);
	header()->setContextMenuPolicy(Qt::ActionsContextMenu);
	QAction *showSearchBox = new QAction(tr("Show Search Box"), this);
	showSearchBox->setShortcut( Qt::CTRL + Qt::Key_F);
	showSearchBox->setShortcutContext(Qt::ApplicationShortcut);
	addAction(showSearchBox);

	searchBox->installEventFilter(this);
	searchBox->hide();
	connect(showSearchBox, SIGNAL(triggered(bool)), this, SLOT(showSearchEdit()));
	connect(searchBox, SIGNAL(textChanged(QString)), model, SLOT(setFilterFixedString(QString)));
	selectedTrips.clear();
}
Example #9
0
QAction* ActionResource::toQAction() const {
    Log log( Log::LT_TRACE, Log::MOD_MAIN, "QAction* ActionResource::toQAction() const" );

    if( !( m_Type == AT_ITEM || m_Type == AT_SEPARATOR ) ) {
        return NULL;
    };

    log.write( Log::LT_TRACE, "Produce item %s", getText() );
    QAction* act = new QAction( getText(), NULL );
    act->setAutoRepeat( getAutoRepeat() );
    act->setCheckable( getCheckable() );
    act->setChecked( getChecked() );
    act->setData( getData() );
    act->setFont( getFont() );
    act->setIcon( getIcon() );
    act->setIconVisibleInMenu( getIconVisibleInMenu() );
    act->setMenuRole( getMenuRole() );
    act->setSeparator( m_Type == AT_SEPARATOR );
    act->setShortcut( getShortcut() );
    act->setShortcutContext( getShortcutContext() );
    act->setStatusTip( getStatusTip() );
    act->setToolTip( getTooltip() );
    act->setVisible( getVisible() );
    act->setWhatsThis( getWhatsThis() );

    return act;
};
Example #10
0
QAction *KeySequence::widget(QWidget *widget, Qt::ShortcutContext context,
    const QObject *receiver, const char *member)
{
    QAction *act = KeySequence::action(widget, receiver, member);
    act->setShortcutContext(context);
    return act;
}
Example #11
0
// ------------ ObjectInspector
ObjectInspector::ObjectInspector(QDesignerFormEditorInterface *core, QWidget *parent) :
    QDesignerObjectInspector(parent),
    m_impl(new ObjectInspectorPrivate(core))
{
    QVBoxLayout *vbox = new QVBoxLayout(this);
    vbox->setMargin(0);

    QTreeView *treeView = m_impl->treeView();
    vbox->addWidget(treeView);

    connect(treeView, SIGNAL(customContextMenuRequested(QPoint)),
            this, SLOT(slotPopupContextMenu(QPoint)));

    connect(treeView->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
            this, SLOT(slotSelectionChanged(QItemSelection,QItemSelection)));

    connect(treeView->header(), SIGNAL(sectionDoubleClicked(int)), this, SLOT(slotHeaderDoubleClicked(int)));
    setAcceptDrops(true);

    ItemViewFindWidget *findWidget = m_impl->findWidget();
    vbox->addWidget(findWidget);

    findWidget->setItemView(treeView);
    QAction *findAction = new QAction(
            ItemViewFindWidget::findIconSet(),
            tr("&Find in Text..."),
            this);
    findAction->setShortcut(QKeySequence::Find);
    findAction->setShortcutContext(Qt::WidgetWithChildrenShortcut);
    addAction(findAction);
    connect(findAction, SIGNAL(triggered(bool)), findWidget, SLOT(activate()));
}
FormEditorMainWidget::FormEditorMainWidget(FormEditorMainView *mainView)
  : QWidget(),
    m_formEditorMainView(mainView),
    m_stackedWidget(new QStackedWidget(this))
{
    QFile file(":/qmldesigner/formeditorstylesheet.css");
    file.open(QFile::ReadOnly);
    QString styleSheet = QLatin1String(file.readAll());
    setStyleSheet(styleSheet);

    QVBoxLayout *fillLayout = new QVBoxLayout(this);
    fillLayout->setMargin(0);
    fillLayout->setSpacing(0);
    setLayout(fillLayout);

    QActionGroup *toolActionGroup = new QActionGroup(this);

    QAction *transformToolAction = toolActionGroup->addAction("Transform Tool (Press Key Q)");
    transformToolAction->setShortcut(Qt::Key_Q);
    transformToolAction->setShortcutContext(Qt::WidgetWithChildrenShortcut);
    transformToolAction->setCheckable(true);
    transformToolAction->setChecked(true);
    transformToolAction->setIcon(QPixmap(":/icon/tool/transform.png"));
    connect(transformToolAction, SIGNAL(triggered(bool)), SLOT(changeTransformTool(bool)));

    QAction *anchorToolAction = toolActionGroup->addAction("Anchor Tool (Press Key W)");
    anchorToolAction->setShortcut(Qt::Key_W);
    anchorToolAction->setShortcutContext(Qt::WidgetWithChildrenShortcut);
    anchorToolAction->setCheckable(true);
    anchorToolAction->setIcon(QPixmap(":/icon/tool/anchor.png"));
    connect(anchorToolAction, SIGNAL(triggered(bool)), SLOT(changeAnchorTool(bool)));

    addActions(toolActionGroup->actions());


    m_componentAction = new ComponentAction(toolActionGroup);
    addAction(m_componentAction.data());

    m_zoomAction = new ZoomAction(toolActionGroup);
    addAction(m_zoomAction.data());

    ToolBox *toolBox = new ToolBox(this);
    toolBox->setActions(actions());
    fillLayout->addWidget(toolBox);

    fillLayout->addWidget(m_stackedWidget.data());
}
Example #13
0
void ActionsManager::registerAction(const QLatin1String &name, const QString &text, const QIcon &icon)
{
	QAction *action = new QAction(icon, text, m_instance);
	action->setObjectName(name);
	action->setShortcutContext(Qt::ApplicationShortcut);

	m_applicationActions[name] = action;
}
QAction *RemoveTaskHandler::createAction(QObject *parent) const
{
    QAction *removeAction = new QAction(tr("Remove", "Name of the action triggering the removetaskhandler"), parent);
    removeAction->setToolTip(tr("Remove task from the task list."));
    removeAction->setShortcut(QKeySequence(QKeySequence::Delete));
    removeAction->setShortcutContext(Qt::WidgetWithChildrenShortcut);
    return removeAction;
}
Example #15
0
QAction *ShowInEditorTaskHandler::createAction(QObject *parent) const
{
    QAction *showAction = new QAction(tr("Show in Editor"), parent);
    showAction->setToolTip(tr("Show task location in an editor."));
    showAction->setShortcut(QKeySequence(Qt::Key_Return));
    showAction->setShortcutContext(Qt::WidgetWithChildrenShortcut);
    return showAction;
}
Example #16
0
void MainWindow::initialize(TraceModelPtr& model)
{
    model = restoreModel(model);//? trying to take settings from QSettings, but this is sooo bad
    initCanvas(model);
    // Restore window geometry
    QRect r = restoreGeometry();
    if (r.isValid())
    {
        setGeometry(r);
    }
    else
    {
        r = QApplication::desktop()->screenGeometry();
        resize(r.width(), r.height());
    }

    initToolbar();
    initSidebar();

    xinitialize(sidebarContents, canvas);

    toolbar->addActions(modeActions->actions());

    Q_ASSERT(browser);
    browser->addToolbarActions(toolbar);

    QAction* resetView = new QAction(this);
    resetView->setShortcut(Qt::Key_Escape);
    resetView->setShortcutContext(Qt::WindowShortcut);
    addAction(resetView);

    connect(resetView, SIGNAL(triggered(bool)), this,
                       SLOT(resetView()));

    toolbar->addSeparator();

    // Restore time unit and format
    QSettings settings;
    QString time_unit = settings.value("time_unit", Time::unit_name(0)).toString();
    for(int i = 0; i < Time::units().size(); ++i)
    {
        if (Time::unit_name(i) == time_unit)
        {
            Time::setUnit(i);
            break;
        }
    }
    if (settings.value("time_format", "separated") == "separated")
    {
        Time::setFormat(Time::Advanced);
    }

    // Adding freestanding tools
    foreach (QAction * action, freestandingTools)
    {
        toolbar->addAction(action);
    }
Example #17
0
Radio::Radio(Module &module) :
	once(false), net(NULL),
	qmp2Icon(QMPlay2Core.getQMPlay2Pixmap()),
	wlasneStacje(tr("Own radio stations"))
{
	SetModule(module);

	setContextMenuPolicy(Qt::CustomContextMenu);
	popupMenu.addAction(tr("Remove the radio station"), this, SLOT(removeStation()));

	dw = new DockWidget;
	dw->setWindowTitle(tr("Internet radios"));
	dw->setObjectName(RadioName);
	dw->setWidget(this);

	lW = new QListWidget;
	connect(lW, SIGNAL(itemDoubleClicked(QListWidgetItem *)), this, SLOT(openLink()));
	lW->setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel);
	lW->setResizeMode(QListView::Adjust);
	lW->setWrapping(true);
	lW->setIconSize(QSize(32, 32));

	QAction *act = new QAction(lW);
	act->setShortcuts(QList<QKeySequence>() << QKeySequence("Return") << QKeySequence("Enter"));
	connect(act, SIGNAL(triggered()), this, SLOT(openLink()));
	act->setShortcutContext(Qt::WidgetWithChildrenShortcut);
	lW->addAction(act);

	infoL = new QLabel;

	progressB = new QProgressBar;

	QVBoxLayout *layout = new QVBoxLayout(this);
	layout->addWidget(lW);
	layout->addWidget(infoL);
	layout->addWidget(progressB);

	progressB->hide();

	connect(dw, SIGNAL(visibilityChanged(bool)), this, SLOT(visibilityChanged(bool)));
	connect(this, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(popup(const QPoint &)));

	addGroup(wlasneStacje);
	nowaStacjaLWI = new QListWidgetItem("-- " + tr("Add new radio station") + " --", lW);
	nowaStacjaLWI->setData(Qt::TextAlignmentRole, Qt::AlignCenter);

	Settings sets("Radio");
	foreach (const QString &entry, sets.get("Radia").toStringList())
	{
		const QStringList nazwa_i_adres = entry.split('\n');
		if (nazwa_i_adres.count() == 2)
			addStation(nazwa_i_adres[0], nazwa_i_adres[1], wlasneStacje);
	}
}
Example #18
0
TabBar::TabBar(QWidget *parent) :
    QTabBar(parent)
{    
    setTabsClosable(true);    
    connect(this, SIGNAL(currentChanged(int)), this, SLOT(handleChanged(int)));

    v_activeIcons = QVector<QIcon>(10);
    v_normalIcons = QVector<QIcon>(10);
    v_actions = QVector<QAction*>(10);

#ifndef Q_OS_MAC
    for (int i=0; i<10; i++) {
        const QString text = i>0? QString::number(i) : "~";
        QFont f(font());
        f.setPixelSize(10);
        f.setBold(true);
        int w = QFontMetrics(f).width(text);
        QImage numberImageActive(16,16,QImage::Format_ARGB32);
        numberImageActive.fill(0);
        QPainter p(&numberImageActive);
        p.setPen(palette().brush(QPalette::HighlightedText).color());
        p.setBrush(palette().brush(QPalette::Highlight));
        p.drawRect(2,2,12,12);
        p.setFont(f);
        p.drawText(3+(12-w)/2, 12, text);
        p.end();
        QImage numberImage(16,16,QImage::Format_ARGB32);
        numberImage.fill(0);
        QPainter pp(&numberImage);
        pp.setPen(palette().brush(QPalette::WindowText).color());
        pp.setBrush(Qt::NoBrush);
        pp.drawRect(2,2,12,12);
        pp.setFont(f);
        pp.drawText(3+(12-w)/2, 12, text);
        pp.end();
        v_normalIcons[i] = QIcon(QPixmap::fromImage(numberImage));
        v_activeIcons[i] = v_normalIcons[i];
        QAction * toggleView = new QAction(this);

        if (i==0) {
            toggleView->setShortcut(QKeySequence("Ctrl+`"));
        }
        else {
            toggleView->setShortcut(QKeySequence(QString("Ctrl+%1").arg(i)));
        }
        toggleView->setShortcutContext(Qt::ApplicationShortcut);
        toggleView->setProperty("tabIndex", i);
        connect(toggleView, SIGNAL(triggered()), this, SLOT(switchToTab()));
        addAction(toggleView);
        v_actions[i] = toggleView;
    }
#endif
    setIconSize(QSize(16,16));
}
Example #19
0
void MainWindow::setupActions()
{
    KStandardAction::quit(this, SLOT(quit()), actionCollection());
    KStandardAction::preferences(this, SLOT(showConfigurationDialog()), actionCollection());

    // setup graph visual editor actions and add them to mainwindow action collection
//     m_graphEditor->setupActions(actionCollection()); //FIXME add editor actions to main action collection

    // Menu actions
    QAction *newProjectAction = new QAction(QIcon::fromTheme("document-new"), i18nc("@action:inmenu", "New Project"), this);
    newProjectAction->setShortcutContext(Qt::ApplicationShortcut);
    actionCollection()->addAction("new-project", newProjectAction);
    actionCollection()->setDefaultShortcut(newProjectAction, QKeySequence::New);
    connect(newProjectAction, &QAction::triggered, this, &MainWindow::createProject);

    QAction *projectSaveAction = new QAction(QIcon::fromTheme("document-save"), i18nc("@action:inmenu", "Save Project"), this);
    projectSaveAction->setShortcutContext(Qt::ApplicationShortcut);
    actionCollection()->addAction("save-project", projectSaveAction);
    actionCollection()->setDefaultShortcut(projectSaveAction, QKeySequence::Save);
    connect(projectSaveAction, &QAction::triggered, this, &MainWindow::saveProject);

    QAction *projectOpenAction = new QAction(QIcon::fromTheme("document-open"), i18nc("@action:inmenu", "Open Project"), this);
    projectOpenAction->setShortcutContext(Qt::ApplicationShortcut);
    actionCollection()->addAction("open-project", projectOpenAction);
    actionCollection()->setDefaultShortcut(projectOpenAction, QKeySequence::Open);
    connect(projectOpenAction, &QAction::triggered, this, [=] () { openProject(); });

    m_recentProjects = new KRecentFilesAction(QIcon ("document-open"), i18nc("@action:inmenu","Recent Projects"), this);
    connect(m_recentProjects, &KRecentFilesAction::urlSelected,
        this, &MainWindow::openProject);
    actionCollection()->addAction("recent-project", m_recentProjects);
    m_recentProjects->loadEntries(Settings::self()->config()->group("RecentFiles"));

    createAction("document-save-as",     i18nc("@action:inmenu", "Save Project as"),   "save-project-as",    SLOT(saveProjectAs()), this);
    createAction("document-new",        i18nc("@action:inmenu", "New Graph Document"), "new-graph",         SLOT(createGraphDocument()), this);
    createAction("document-new",        i18nc("@action:inmenu", "New Script File"),    "new-script",        SLOT(createCodeDocument()),    this);
    createAction("document-import",     i18nc("@action:inmenu", "Import Graph"),       "import-graph",      SLOT(importGraphDocument()),   this);
    createAction("document-export",     i18nc("@action:inmenu", "Export Graph as"),    "export-graph-as",      SLOT(exportGraphDocument()), this);
    createAction("document-import",  i18nc("@action:inmenu", "Import Script"),       "add-script",          SLOT(importCodeDocument()),   this);
    createAction("document-export", i18nc("@action:inmenu", "Export Script"),      "export-script",      SLOT(exportCodeDocument()), this);
}
Example #20
0
CodeEditor::CodeEditor(QSettings *s, QWidget *parent) : QPlainTextEdit(parent) {

    QString family = s->value("editor/fontfamily", "Courier").toString();
    uint size = s->value("editor/fontsize", 10).toUInt();

    setFont(family, size);

    highlighter = new LuaHighlighter(document());

    lineNumberArea = new LineNumberArea(this);

    connect(this, SIGNAL(blockCountChanged(int)),
            this, SLOT(updateLineNumberAreaWidth(int)));
    connect(this, SIGNAL(updateRequest(QRect,int)),
            this, SLOT(updateLineNumberArea(QRect,int)));
    connect(this, SIGNAL(cursorPositionChanged()),
            this, SLOT(highlightCurrentLine()));

    updateLineNumberAreaWidth(0);
    highlightCurrentLine();

    QAction* a = new QAction(tr("Open a file"), this);
    a->setShortcut(tr("Ctrl+1"));
    a->setShortcutContext(Qt::WidgetShortcut);
    addAction(a);
    connect(a, SIGNAL(triggered()), this, SLOT(load()));

    a = new QAction(tr("Save file"), this);
    a->setShortcut(tr("Ctrl+2"));
    a->setShortcutContext(Qt::WidgetShortcut);
    addAction(a);
    connect(a, SIGNAL(triggered()), this, SLOT(save()));

    a = new QAction(tr("Save to file"), this);
    a->setShortcut(tr("Ctrl+3"));
    a->setShortcutContext(Qt::WidgetShortcut);
    addAction(a);
    connect(a, SIGNAL(triggered()), this, SLOT(saveAs()));
}
Example #21
0
QMenu* TreeWidget::createContextMenu(TreeItem* item)
{
    QMenu* menu = new QMenu(this);
    menu->addAction(item->text(0))->setEnabled(false);
    menu->addSeparator();

    connect(item, SIGNAL(destroyed(TreeItem*)), menu, SLOT(deleteLater()));

    const bool child = item->parentItem();
    const bool connected = item->connection()->isActive();
    const bool waiting = item->connection()->status() == IrcConnection::Waiting;
    const bool active = item->buffer()->isActive();
    const bool channel = item->buffer()->isChannel();

    if (!child) {
        QAction* editAction = menu->addAction(tr("Edit"), this, SLOT(onEditTriggered()));
        editAction->setData(QVariant::fromValue(item));
        menu->addSeparator();

        if (waiting) {
            QAction* stopAction = menu->addAction(tr("Stop"));
            connect(stopAction, SIGNAL(triggered()), item->connection(), SLOT(setDisabled()));
            connect(stopAction, SIGNAL(triggered()), item->connection(), SLOT(close()));
        } else if (connected) {
            QAction* disconnectAction = menu->addAction(tr("Disconnect"));
            connect(disconnectAction, SIGNAL(triggered()), item->connection(), SLOT(setDisabled()));
            connect(disconnectAction, SIGNAL(triggered()), item->connection(), SLOT(quit()));
        } else {
            QAction* reconnectAction = menu->addAction(tr("Reconnect"));
            connect(reconnectAction, SIGNAL(triggered()), item->connection(), SLOT(setEnabled()));
            connect(reconnectAction, SIGNAL(triggered()), item->connection(), SLOT(open()));
        }
    }

    if (connected && child) {
        QAction* action = 0;
        if (!channel)
            action = menu->addAction(tr("Whois"), this, SLOT(onWhoisTriggered()));
        else if (!active)
            action = menu->addAction(tr("Join"), this, SLOT(onJoinTriggered()));
        else
            action = menu->addAction(tr("Part"), this, SLOT(onPartTriggered()));
        action->setData(QVariant::fromValue(item));
    }

    QAction* closeAction = menu->addAction(tr("Close"), this, SLOT(onCloseTriggered()), QKeySequence::Close);
    closeAction->setShortcutContext(Qt::WidgetShortcut);
    closeAction->setData(QVariant::fromValue(item));

    return menu;
}
Example #22
0
DkPreferenceWidget::DkPreferenceWidget(QWidget* parent) : DkWidget(parent) {

	createLayout();

	QAction* nextAction = new QAction(tr("next"), this);
	nextAction->setShortcut(Qt::Key_Down);
	connect(nextAction, SIGNAL(triggered()), this, SLOT(nextTab()));
	addAction(nextAction);

	QAction* previousAction = new QAction(tr("previous"), this);
	previousAction->setShortcut(Qt::Key_Up);
	previousAction->setShortcutContext(Qt::WidgetWithChildrenShortcut);
	connect(previousAction, SIGNAL(triggered()), this, SLOT(previousTab()));
	addAction(previousAction);
}
Example #23
0
UserManual::UserManual(QWidget *parent) :
	QMainWindow(parent),
	ui(new Ui::UserManual)
{
	ui->setupUi(this);

	QAction *actionShowSearch = new QAction(this);
	actionShowSearch->setShortcut(Qt::CTRL + Qt::Key_F);
	actionShowSearch->setShortcutContext(Qt::WindowShortcut);
	addAction(actionShowSearch);

	QAction *actionHideSearch = new QAction(this);
	actionHideSearch->setShortcut(Qt::Key_Escape);
	actionHideSearch->setShortcutContext(Qt::WindowShortcut);
	addAction(actionHideSearch);

	setWindowTitle(tr("User Manual"));

	ui->webView->page()->setLinkDelegationPolicy(QWebPage::DelegateExternalLinks);
	QString searchPath = getSubsurfaceDataPath("Documentation");
	if (searchPath != "") {
		QUrl url(searchPath.append("/user-manual.html"));
		ui->webView->setUrl(url);
	} else {
		ui->webView->setHtml(tr("Cannot find the Subsurface manual"));
	}
	ui->searchPanel->setParent(this);
	ui->searchPanel->hide();

	connect(actionShowSearch, SIGNAL(triggered(bool)), this, SLOT(showSearchPanel()));
	connect(actionHideSearch, SIGNAL(triggered(bool)), this, SLOT(hideSearchPanel()));
	connect(ui->webView, SIGNAL(linkClicked(QUrl)), this, SLOT(linkClickedSlot(QUrl)));
	connect(ui->searchEdit, SIGNAL(textChanged(QString)), this, SLOT(searchTextChanged(QString)));
	connect(ui->findNext, SIGNAL(clicked()), this, SLOT(searchNext()));
	connect(ui->findPrev, SIGNAL(clicked()), this, SLOT(searchPrev()));
}
AppSettingsGUIImpl::AppSettingsGUIImpl(QObject* p) : AppSettingsGUI(p)
{
    registerBuiltinPages();
    QMenu* m = AppContext::getMainWindow()->getTopLevelMenu(MWMENU_SETTINGS);
    
    QAction* settingsDialogAction = new QAction(QIcon(":ugene/images/preferences.png"), tr("Preferences..."), this);
    connect(settingsDialogAction, SIGNAL(triggered()), SLOT(sl_showSettingsDialog()));
    settingsDialogAction->setObjectName("action__settings");
#ifdef Q_OS_MAC
    settingsDialogAction->setMenuRole(QAction::ApplicationSpecificRole);
    settingsDialogAction->setShortcut(QKeySequence("Ctrl+,"));
    settingsDialogAction->setShortcutContext(Qt::ApplicationShortcut);
#endif
    m->addAction(settingsDialogAction);
    AppContext::getMainWindow()->registerAction(settingsDialogAction);
}
Example #25
0
QAction* getAction(Shortcut* s)
      {
      if (s == 0)
            return 0;
      if (s->action == 0) {
            QAction* a = new QAction(s->xml, 0); // mscore);
            s->action  = a;
            a->setData(s->xml);
            if(!s->key.isEmpty())
                a->setShortcut(s->key);
            else
                a->setShortcuts(s->standardKey);
            a->setShortcutContext(s->context);
            if (!s->help.isEmpty()) {
                  a->setToolTip(s->help);
                  a->setWhatsThis(s->help);
                  }
            else {
                  a->setToolTip(s->descr);
                  a->setWhatsThis(s->descr);
                  }
            if (s->standardKey != QKeySequence::UnknownKey) {
                  QList<QKeySequence> kl = a->shortcuts();
                  if (!kl.isEmpty()) {
                        QString s(a->toolTip());
                        s += " (";
                        for (int i = 0; i < kl.size(); ++i) {
                              if (i)
                                    s += ",";
                              s += kl[i].toString(QKeySequence::NativeText);
                              }
                        s += ")";
                        a->setToolTip(s);
                        }
                  }
            else if (!s->key.isEmpty()) {
                  a->setToolTip(a->toolTip() +
                        " (" + s->key.toString(QKeySequence::NativeText) + ")" );
                  }
            if (!s->text.isEmpty())
                  a->setText(s->text);
            if (s->icon != -1)
                  a->setIcon(*icons[s->icon]);
            }
      return s->action;
      }
Example #26
0
LoadSaveState::LoadSaveState(std::shared_ptr<CoreController> controller, QWidget* parent)
	: QWidget(parent)
	, m_controller(controller)
	, m_mode(LoadSave::LOAD)
	, m_currentFocus(controller->stateSlot() - 1)
{
	m_ui.setupUi(this);
	m_ui.lsLabel->setFocusProxy(this);
	setFocusPolicy(Qt::ClickFocus);

	m_slots[0] = m_ui.state1;
	m_slots[1] = m_ui.state2;
	m_slots[2] = m_ui.state3;
	m_slots[3] = m_ui.state4;
	m_slots[4] = m_ui.state5;
	m_slots[5] = m_ui.state6;
	m_slots[6] = m_ui.state7;
	m_slots[7] = m_ui.state8;
	m_slots[8] = m_ui.state9;

	unsigned width, height;
	controller->thread()->core->desiredVideoDimensions(controller->thread()->core, &width, &height);
	int i;
	for (i = 0; i < NUM_SLOTS; ++i) {
		loadState(i + 1);
		m_slots[i]->installEventFilter(this);
		m_slots[i]->setMaximumSize(width + 2, height + 2);
		connect(m_slots[i], &QAbstractButton::clicked, this, [this, i]() { triggerState(i + 1); });
	}

	if (m_currentFocus >= 9) {
		m_currentFocus = 0;
	}
	if (m_currentFocus < 0) {
		m_currentFocus = 0;
	}
	m_slots[m_currentFocus]->setFocus();

	QAction* escape = new QAction(this);
	connect(escape, &QAction::triggered, this, &QWidget::close);
	escape->setShortcut(QKeySequence("Esc"));
	escape->setShortcutContext(Qt::WidgetWithChildrenShortcut);
	addAction(escape);

	connect(m_controller.get(), &CoreController::stopping, this, &QWidget::close);
}
Example #27
0
ConditionWidget::ConditionWidget(ComplexCondition* condition, QWidget *parent) :
    QListView(parent)
{
    mModel = new QStandardItemModel(this);
    setModel(mModel);
    setEditTriggers(QAbstractItemView::NoEditTriggers);
    setItemDelegate(new ConditionWidgetDelegate(this));
    setCondition(condition);
    setContextMenuPolicy(Qt::ActionsContextMenu);
    mSelectedCondition = 0;

    QAction* deleteAction = new QAction(QIcon(":/media/delete.png"), tr("Delete"), this);
    deleteAction->setShortcut(QKeySequence::Delete);
    deleteAction->setShortcutContext(Qt::WidgetShortcut);
    addAction(deleteAction);
    connect(deleteAction, SIGNAL(triggered()), this, SLOT(onDeleteTriggered()));
}
Example #28
0
	CodeEditorDialog::CodeEditorDialog(QAbstractItemModel *completionModel, QWidget *parent)
		: QDialog(parent),
		ui(new Ui::CodeEditorDialog)
	{
		ui->setupUi(this);
		
		ui->editor->setCompletionModel(completionModel);

		QSettings settings;

		QAction *swapCodeAction = new QAction(this);
		swapCodeAction->setShortcut(QKeySequence(settings.value("actions/switchTextCode", QKeySequence("Ctrl+Shift+C")).toString()));
		swapCodeAction->setShortcutContext(Qt::WindowShortcut);
		addAction(swapCodeAction);

		connect(swapCodeAction, SIGNAL(triggered()), this, SLOT(swapCode()));
		connect(ui->editor, SIGNAL(acceptDialog()), this, SLOT(accept()));
	}
int main(int argv, char **args)
{
    QApplication app(argv, args);

    mainWindowExample();
    //addingSubWindowsExample();

   QAction *act = new QAction(qApp);
   act->setShortcut(Qt::ALT + Qt::Key_S);
   act->setShortcutContext( Qt::ApplicationShortcut );
   QObject::connect(act, SIGNAL(triggered()), qApp, SLOT(aboutQt()));

    QWidget widget5;
    widget5.show();
    widget5.addAction(act);

    return app.exec();
}
Example #30
0
Command *ActionManagerPrivate::registerOverridableAction(QAction *action, const QString &id, bool checkUnique)
{
    OverrideableAction *a = 0;
    const int uid = UniqueIDManager::instance()->uniqueIdentifier(id);

    if (CommandPrivate * c = m_idCmdMap.value(uid, 0)) {
        a = qobject_cast<OverrideableAction *>(c);
        if (!a) {
            qWarning() << "registerAction: id" << id << "is registered with a different command type.";
            return c;
        }
    } else {
        a = new OverrideableAction(uid);
        m_idCmdMap.insert(uid, a);
    }

    if (!a->action()) {
        QAction *baseAction = new QAction(m_mainWnd);
        baseAction->setObjectName(id);
        baseAction->setCheckable(action->isCheckable());
        baseAction->setIcon(action->icon());
        baseAction->setIconText(action->iconText());
        baseAction->setText(action->text());
        baseAction->setToolTip(action->toolTip());
        baseAction->setStatusTip(action->statusTip());
        baseAction->setWhatsThis(action->whatsThis());
        baseAction->setChecked(action->isChecked());
        baseAction->setSeparator(action->isSeparator());
        baseAction->setShortcutContext(Qt::ApplicationShortcut);
        baseAction->setEnabled(false);
        baseAction->setParent(m_mainWnd);
#ifdef Q_WS_MAC
        baseAction->setIconVisibleInMenu(false);
#endif
        a->setAction(baseAction);
        m_mainWnd->addAction(baseAction);
        a->setKeySequence(a->keySequence());
        a->setDefaultKeySequence(QKeySequence());
    } else if (checkUnique) {
        qWarning() << "registerOverridableAction: id" << id << "is already registered.";
    }

    return a;
}