QStringList TToolbarEditor::saveActions() {
    logger()->debug("saveActions");

	QStringList list;

	for (int row = 0; row < active_actions_table->rowCount(); row++) {
		QTableWidgetItem* item = active_actions_table->item(row, COL_NAME);
		if (item) {
			QString action_name = item->text();
			if (action_name.startsWith("separator")) {
				action_name = "separator";
			}
			QString s = action_name;

			bool ns = getVis(row, COL_NS);
			bool fs = getVis(row, COL_FS);
			if (ns) {
				if (!fs) {
					s += "|1|0";
				}
			} else if (fs) {
				s += "|0|1";
			} else {
				s += "|0|0";
			}
			list << s;

			if (action_name != "separator") {
				// Update icon text
				QAction* action = findAction(action_name, *all_actions);
				if (action) {
					item = active_actions_table->item(row, COL_DESC);
					if (item) {
						QString action_icon_text = TActionsEditor::actionTextToDescription(
													   item->text(), action_name).trimmed();
						if (!action_icon_text.isEmpty()) {
							QString action_text = TActionsEditor::actionTextToDescription(action->text(), action_name);
							if (action_text != action_icon_text) {
								action->setIconText(action_icon_text);
                                action->setProperty("modified", true);
                                logger()->debug("saveActions: updated icon text '"
                                    + action_name + "' to '" + action_icon_text
                                    + "'");
							} else {
								action_icon_text = TActionsEditor::actionTextToDescription(action->iconText(), action_name);
								if (action_icon_text != action_text) {
                                    action->setIconText(action_text);
                                    logger()->debug("saveActions: cleared icon text "
                                                    + action_name);
								}
							}
						}
					}
				}
			}
		}
	}

	return list;
}
Exemple #2
0
void
Viewer::treeContextMenu(const QPoint& pos)
{
    QPoint globalPos = this->ui.repoView->viewport()->mapToGlobal(pos);

    QAction* selectedItem = treeMenu.exec(globalPos);
    if (selectedItem) {
        if (selectedItem->iconText() == EXPAND_ACTION)
        {
            expand(true);
            selectedItem->setText(COLLAPSE_ACTION);
            selectedItem->setIconText(COLLAPSE_ACTION);

        }
        else if (selectedItem->iconText() == COLLAPSE_ACTION)
        {
            expand(false);
            selectedItem->setText(EXPAND_ACTION);
            selectedItem->setIconText(EXPAND_ACTION);
        }
        else if (selectedItem->iconText() == SELECTION_TO_NODE_VIEW ||
                 selectedItem->iconText() == SELECTION_TO_GRAPH_VIEW)
        {
            // reset all the display flags
            this->dataSource_->modelRoot()->resetDisplays();

            QModelIndexList q = this->ui.repoView->selectionModel()->selectedRows();
            for (int c = 0; c < q.size(); ++c) {
                // get the node and set the display flag
                TreeNode *t = model_->getNode(q[c]);
                t->setDisplay(true);
            }

            if (selectedItem->iconText() == SELECTION_TO_NODE_VIEW)
            {
                updateNodeView(true);
            }
            else {
                updateGraphView(true);
            }
        }
        else if (selectedItem->iconText() == NODE_VIEW_OPTIONS_ACTION)
        {
            showNodeOptions();
        }
        else if (selectedItem->iconText() == GRAPH_OPTIONS_ACTION)
        {
            showGraphOptions();
        }
    }
}
void tst_QToolBar::accel()
{
#ifdef Q_WS_MAC
    extern void qt_set_sequence_auto_mnemonic(bool b);
    qt_set_sequence_auto_mnemonic(true);
#endif
    QMainWindow mw;
    QToolBar *toolBar = mw.addToolBar("test");
    QAction *action = toolBar->addAction("&test");
    action->setIconText(action->text()); // we really want that mnemonic in the button!

    QSignalSpy spy(action, SIGNAL(triggered(bool)));

    mw.show();
    QApplication::setActiveWindow(&mw);
    QTest::qWait(100);
    QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(&mw));

    QTest::keyClick(&mw, Qt::Key_T, Qt::AltModifier);
    QTest::qWait(300);

    QTRY_COMPARE(spy.count(), 1);
#ifdef Q_WS_MAC
    qt_set_sequence_auto_mnemonic(false);
#endif
}
Exemple #4
0
NoteDialog::NoteDialog(Note *note) : QWidget()
{
    setWindowTitle(note == 0 ? "Nouvelle note" : note->title());

    // Récupération des options
    m_settings = new QSettings("yellownote.ini", QSettings::IniFormat);

    // Création des champs title et content
    m_noteEdit = new NoteEdit(m_settings, this);

    m_note = note;

    // Assignation du dialog à la note
    attachToNote();

    // Si on est en modification, on remplit les champs
    if (note != 0)
    {
        m_noteEdit->update(note->title(), note->content());
    }

    QAction *actionInfos = new QAction("&Infos", this);
    actionInfos->setIcon(QIcon(":/note/infos"));
    actionInfos->setIconText("Infos");
    connect(actionInfos, SIGNAL(triggered()), this, SLOT(infos()));

    m_actionDelete = new QAction("&Supprimer", this);
    m_actionDelete->setIcon(QIcon(":/note/delete"));
    m_actionDelete->setIconText("Supprimer");
    connect(m_actionDelete, SIGNAL(triggered()), this, SLOT(deleteMe()));

    QWidget *spacerWidget = new QWidget(this);
    spacerWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
    spacerWidget->setVisible(true);

    QToolBar *toolBar = new QToolBar;
    toolBar->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
    toolBar->addWidget(spacerWidget);
    toolBar->addAction(actionInfos);
    toolBar->addAction(m_actionDelete);

    QVBoxLayout *mainLayout = new QVBoxLayout;
    mainLayout->setMargin(0);
    mainLayout->setSpacing(0);
    mainLayout->addWidget(toolBar);
    mainLayout->addWidget(m_noteEdit);
    setLayout(mainLayout);

    // Réassignation de la taille de la fenêtre
    if (m_settings->contains("note/size"))
    {
        resize(m_settings->value("note/size").toSize());
    }

    // Donne le focus à la fenêtre (quand elle est créée
    // depuis un raccouri clavier global)
    setFocus();
}
Exemple #5
0
TableTool::TableTool(KoCanvasBase* canvas)
        : CellToolBase(canvas)
        , d(new Private)
{
    setObjectName(QLatin1String("TableTool"));

    d->selection = new Selection(canvas);
    d->tableShape = 0;

    QAction* importAction = new QAction(koIcon("document-import"), i18n("Import OpenDocument Spreadsheet File"), this);
    importAction->setIconText(i18n("Import"));
    addAction("import", importAction);
    connect(importAction, SIGNAL(triggered()), this, SLOT(importDocument()));

    QAction* exportAction = new QAction(koIcon("document-export"), i18n("Export OpenDocument Spreadsheet File"), this);
    exportAction->setIconText(i18n("Export"));
    addAction("export", exportAction);
    connect(exportAction, SIGNAL(triggered()), this, SLOT(exportDocument()));
}
void MainWindow::buildToolBar()
{
    m_fileToolBar = addToolBar("File Tool Bar");
    m_fileToolBar->setMovable(true);
    QAction * newSystemAction = new QAction(QIcon("Icons/New.png"), "New", this);
    connect(newSystemAction, SIGNAL(triggered()), m_system, SLOT(newSystem()));
    QAction * openSystemAction = new QAction(QIcon("Icons/Open.png"), "Open", this);
    connect(openSystemAction, SIGNAL(triggered()), m_system, SLOT(openSystem()));
    QAction * saveSystemAction = new QAction(QIcon("Icons/Save.png"), "Save", this);
    connect(saveSystemAction, SIGNAL(triggered()), m_system, SLOT(saveSystem()));
    QAction * saveSystemAsAction = new QAction(QIcon("Icons/SaveAs.png"), QString::fromUtf8("Save As\u2026"), this);
    saveSystemAsAction->setIconText("AA");
    connect(saveSystemAsAction, SIGNAL(triggered()), m_system, SLOT(saveSystemAs()));
    m_fileToolBar->addAction(newSystemAction);
    m_fileToolBar->addAction(openSystemAction);
    m_fileToolBar->addAction(saveSystemAction);
    m_fileToolBar->addAction(saveSystemAsAction);

    m_deviceToolBar = addToolBar("Device Tool Bar");
    m_deviceToolBar->setMovable(true);
    QAction * addPlaneMirrorAction = new QAction(QIcon("Icons/PlaneMirror.png"), "Add Plane Mirror", this);
    connect(addPlaneMirrorAction, SIGNAL(triggered()), m_system, SLOT(addPlaneMirror()));
    QAction * addConcaveMirrorAction = new QAction(QIcon("Icons/ConcaveMirror.png"), "Add Concave Mirror", this);
    connect(addConcaveMirrorAction, SIGNAL(triggered()), m_system, SLOT(addConcaveMirror()));
    QAction * addDiffractionGratingAction = new QAction(QIcon("Icons/DiffractionGrating.png"), "Add Diffraction Grating", this);
    connect(addDiffractionGratingAction, SIGNAL(triggered()), m_system, SLOT(addDiffractionGrating()));
    QAction * addSlitAction = new QAction(QIcon("Icons/Slit.png"), "Add Slit", this);
    connect(addSlitAction, SIGNAL(triggered()), m_system, SLOT(addSlit()));
    QAction * addPointSourceAction = new QAction(QIcon("Icons/PointSource.png"), "Add Point Source", this);
    connect(addPointSourceAction, SIGNAL(triggered()), m_system, SLOT(addPointSource()));
    QAction * removeReflectorAction = new QAction(QIcon("Icons/RemoveReflector.png"), "Remove Reflector", this);
    connect(removeReflectorAction, SIGNAL(triggered()), m_system, SLOT(removeReflector()));
    QAction * removeLightSourceAction = new QAction(QIcon("Icons/RemoveLightSource.png"), "Remove Light Source", this);
    connect(removeLightSourceAction, SIGNAL(triggered()), m_system, SLOT(removeLightSource()));
    m_deviceToolBar->addAction(addPlaneMirrorAction);
    m_deviceToolBar->addAction(addConcaveMirrorAction);
    m_deviceToolBar->addAction(addDiffractionGratingAction);
    m_deviceToolBar->addAction(addSlitAction);
    m_deviceToolBar->addSeparator();
    m_deviceToolBar->addAction(addPointSourceAction);
    m_deviceToolBar->addSeparator();
    m_deviceToolBar->addAction(removeReflectorAction);
    m_deviceToolBar->addAction(removeLightSourceAction);

    m_zoomToolBar = addToolBar("Zoom Tool Bar");
    m_zoomToolBar->setMovable(true);
    ZoomWidget * zoomWidget = new ZoomWidget(this);
    connect(zoomWidget, SIGNAL(valueChanged(int)), m_system, SLOT(zoom(int)));
    m_zoomToolBar->addAction(QIcon("Icons/ZoomIn.png"), "Zoom In", zoomWidget, SLOT(stepUp()));
    m_zoomToolBar->addWidget(zoomWidget);
    m_zoomToolBar->addAction(QIcon("Icons/ZoomOut.png"), "Zoom Out", zoomWidget, SLOT(stepDown()));
}
    ExplorerServerTreeItem::ExplorerServerTreeItem(QTreeWidget *view,MongoServer *const server) : BaseClass(view),
        _server(server),
        _bus(AppRegistry::instance().bus())
    { 
        QAction *openShellAction = new QAction("Open Shell", this);
        openShellAction->setIcon(GuiRegistry::instance().mongodbIcon());
        VERIFY(connect(openShellAction, SIGNAL(triggered()), SLOT(ui_openShell())));

        QAction *refreshServer = new QAction("Refresh", this);
        VERIFY(connect(refreshServer, SIGNAL(triggered()), SLOT(ui_refreshServer())));

        QAction *createDatabase = new QAction("Create Database", this);
        VERIFY(connect(createDatabase, SIGNAL(triggered()), SLOT(ui_createDatabase())));

        QAction *serverStatus = new QAction("Server Status", this);
        VERIFY(connect(serverStatus, SIGNAL(triggered()), SLOT(ui_serverStatus())));

        QAction *serverVersion = new QAction("MongoDB Version", this);
        VERIFY(connect(serverVersion, SIGNAL(triggered()), SLOT(ui_serverVersion())));

        QAction *serverHostInfo = new QAction("Host Info", this);
        VERIFY(connect(serverHostInfo, SIGNAL(triggered()), SLOT(ui_serverHostInfo())));        

        QAction *showLog = new QAction("Show Log", this);
        VERIFY(connect(showLog, SIGNAL(triggered()), SLOT(ui_showLog()))); 

        QAction *disconnectAction = new QAction("Disconnect", this);
        disconnectAction->setIconText("Disconnect");
        VERIFY(connect(disconnectAction, SIGNAL(triggered()), SLOT(ui_disconnectServer())));

        BaseClass::_contextMenu->addAction(openShellAction);
        BaseClass::_contextMenu->addAction(refreshServer);
        BaseClass::_contextMenu->addSeparator();
        BaseClass::_contextMenu->addAction(createDatabase);
        BaseClass::_contextMenu->addAction(serverStatus);
        BaseClass::_contextMenu->addAction(serverHostInfo);
        BaseClass::_contextMenu->addAction(serverVersion);
        BaseClass::_contextMenu->addSeparator();
        BaseClass::_contextMenu->addAction(showLog);
        BaseClass::_contextMenu->addAction(disconnectAction);

        _bus->subscribe(this, DatabaseListLoadedEvent::Type, _server);
        _bus->subscribe(this, MongoServerLoadingDatabasesEvent::Type, _server);

        setText(0, buildServerName());
        setIcon(0, GuiRegistry::instance().serverIcon());
        setExpanded(false);
        setChildIndicatorPolicy(QTreeWidgetItem::ShowIndicator);
    }
Exemple #8
0
void TasksViewer::add(const QString &iconName, QString text, QToolBar *toolBar,
                      const char *slot, QString iconText) {
#if QT_VERSION >= 0x050500
  QAction *action = new QAction(
      createQIconOnOffPNG(iconName.toLatin1().constData(), false), text, this);
#else
  QAction *action = new QAction(
      createQIconOnOffPNG(iconName.toAscii().constData(), false), text, this);
#endif
  action->setIconText(iconText);
  bool ret = connect(action, SIGNAL(triggered(bool)),
                     (TaskTreeModel *)m_treeView->model(), slot);
  assert(ret);
  toolBar->addAction(action);
  m_actions.push_back(action);
}
Exemple #9
0
QAction *KUndoActions::createUndoAction(QUndoStack *undoStack, KActionCollection *actionCollection, const QString &actionName)
{
    QAction *action = undoStack->createUndoAction(actionCollection);

    if (actionName.isEmpty()) {
        action->setObjectName(QLatin1String(KStandardAction::name(KStandardAction::Undo)));
    } else {
        action->setObjectName(actionName);
    }

    action->setIcon(KisIconUtils::loadIcon(QStringLiteral("edit-undo")));
    action->setIconText(i18n("Undo"));
    action->setShortcuts(KStandardShortcut::undo());

    actionCollection->addAction(action->objectName(), action);

    return action;
}
Exemple #10
0
QAction* KUndo2Stack::createUndoAction(KActionCollection* actionCollection, const QString& actionName)
{
    QAction* action = KUndo2QStack::createUndoAction(actionCollection);

    if (actionName.isEmpty()) {
        action->setObjectName(KStandardAction::name(KStandardAction::Undo));
    } else {
        action->setObjectName(actionName);
    }

    action->setIcon(koIcon("edit-undo"));
    action->setIconText(i18n("Undo"));
    action->setShortcuts(KStandardShortcut::undo());

    actionCollection->addAction(action->objectName(), action);

    return action;
}
Exemple #11
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;
}
Exemple #12
0
void pdp::MainWindow::setupUi() {
	// Add back button
	QPushButton* back = new QPushButton(QIcon(":/common/res/common/back.png"), QApplication::translate("MainWindow", "Zur\303\274ck", 0, QApplication::UnicodeUTF8));
    ui_main.tabWidget->setCornerWidget(back, Qt::TopRightCorner);
    QObject::connect(back, SIGNAL(clicked()), this, SLOT(onBack()));
	
    // Add the "start" tab.
    new pdp::Home(this->ui_main.tabWidget, this);

	// Creates progressDialog
	m_progressDialog = new QProgressDialog("", QString(), 0, 100, this);
	m_progressDialog->setMinimumDuration(0);
	//m_progressDialog->setWindowModality(Qt::WindowModal);

	// Correction of automatic segmentation via 3d interactive segmentation	
	m_NumberOfInstancesOfThreeDEditing = 0;
	QMenu *menuWerkzeug;
	menuWerkzeug = new QMenu(ui_main.menubar);
    menuWerkzeug->setObjectName(QString::fromUtf8("menuWerkzeug"));
	menuWerkzeug->setTitle(QApplication::translate("MainWindow", "Werkzeug", 0, QApplication::UnicodeUTF8));
	ui_main.menubar->addMenu(menuWerkzeug);
    
	QAction *actionThreeDEditing = new QAction(this);
	actionThreeDEditing->setObjectName(QString::fromUtf8("actionThreeDEditing"));
	actionThreeDEditing->setIconText("3DEditing");
	QIcon icn_menu;
	icn_menu.addFile(":/threeDEditing/res/threeDEditing/Rubber-32.png");
	actionThreeDEditing->setIcon(icn_menu);
	menuWerkzeug->addAction(actionThreeDEditing);

	QObject::connect(actionThreeDEditing, SIGNAL(triggered()), this, SLOT(CreateThreeDEditing()));
	
	// AutoRun
	if(AUTO_IMPORT == 1)
		CreateThreeDEditing();
}
Exemple #13
0
ListView::ListView( QObject* parent, QWidget* parentWidget ) : View( parent ),
    m_model( NULL ),
    m_selectedIssueId( 0 ),
    m_isRead( false ),
    m_isSubscribed( false ),
    m_isAdmin( false ),
    m_hasIssues( false ),
    m_currentViewId( 0 ),
    m_searchColumn( Column_Name )
{
    QAction* action;

    action = new QAction( IconLoader::icon( "file-reload" ), tr( "&Update Folder" ), this );
    action->setShortcut( QKeySequence::Refresh );
    connect( action, SIGNAL( triggered() ), this, SLOT( updateFolder() ), Qt::QueuedConnection );
    setAction( "updateFolder", action );

    action = new QAction( IconLoader::icon( "issue-open" ), tr( "&Open Issue" ), this );
    action->setShortcut( QKeySequence::Open );
    connect( action, SIGNAL( triggered() ), this, SLOT( openIssue() ), Qt::QueuedConnection );
    setAction( "openIssue", action );

    action = new QAction( IconLoader::icon( "issue-new" ), tr( "&Add Issue..." ), this );
    action->setShortcut( QKeySequence::New );
    connect( action, SIGNAL( triggered() ), this, SLOT( addIssue() ), Qt::QueuedConnection );
    setAction( "addIssue", action );

    action = new QAction( IconLoader::icon( "edit-modify" ), tr( "&Edit Attributes..." ), this );
    action->setShortcut( tr( "F2" ) );
    connect( action, SIGNAL( triggered() ), this, SLOT( editIssue() ), Qt::QueuedConnection );
    setAction( "editIssue", action );

    action = new QAction( IconLoader::icon( "issue-clone" ), tr( "Clone Issue..." ), this );
    connect( action, SIGNAL( triggered() ), this, SLOT( cloneIssue() ), Qt::QueuedConnection );
    setAction( "cloneIssue", action );

    action = new QAction( IconLoader::icon( "issue-move" ), tr( "&Move Issue..." ), this );
    action->setIconText( tr( "Move" ) );
    connect( action, SIGNAL( triggered() ), this, SLOT( moveIssue() ), Qt::QueuedConnection );
    setAction( "moveIssue", action );

    action = new QAction( IconLoader::icon( "edit-delete" ), tr( "&Delete Issue" ), this );
    action->setIconText( tr( "Delete" ) );
    action->setShortcut( QKeySequence::Delete );
    connect( action, SIGNAL( triggered() ), this, SLOT( deleteIssue() ), Qt::QueuedConnection );
    setAction( "deleteIssue", action );

    action = new QAction( IconLoader::icon( "issue" ), tr( "Mark As Read" ), this );
    connect( action, SIGNAL( triggered() ), this, SLOT( markAsRead() ), Qt::QueuedConnection );
    setAction( "markAsRead", action );

    action = new QAction( IconLoader::icon( "folder-read" ), tr( "Mark All As Read" ), this );
    action->setIconText( tr( "Mark All As Read", "icon text" ) );
    setAction( "popupMarkAll", action );

    action = new QAction( IconLoader::icon( "folder-read" ), tr( "Mark All As Read" ), this );
    connect( action, SIGNAL( triggered() ), this, SLOT( markAllAsRead() ), Qt::QueuedConnection );
    setAction( "markAllAsRead", action );

    action = new QAction( IconLoader::icon( "folder-unread" ), tr( "Mark All As Unread" ), this );
    connect( action, SIGNAL( triggered() ), this, SLOT( markAllAsUnread() ), Qt::QueuedConnection );
    setAction( "markAllAsUnread", action );

    action = new QAction( IconLoader::icon( "issue-subscribe" ), tr( "Subscribe" ), this );
    connect( action, SIGNAL( triggered() ), this, SLOT( subscribe() ), Qt::QueuedConnection );
    setAction( "subscribe", action );

    action = new QAction( IconLoader::icon( "file-print" ), tr( "Print List" ), this );
    action->setIconText( tr( "Print" ) );
    action->setShortcut( QKeySequence::Print );
    connect( action, SIGNAL( triggered() ), this, SLOT( printReport() ), Qt::QueuedConnection );
    setAction( "printReport", action );

    action = new QAction( IconLoader::icon( "export-pdf" ), tr( "Export List" ), this );
    action->setIconText( tr( "Export" ) );
    setAction( "popupExport", action );

    action = new QAction( IconLoader::icon( "export-csv" ), tr( "Export To CSV" ), this );
    connect( action, SIGNAL( triggered() ), this, SLOT( exportCsv() ), Qt::QueuedConnection );
    setAction( "exportCsv", action );

    action = new QAction( IconLoader::icon( "export-html" ), tr( "Export To HTML" ), this );
    connect( action, SIGNAL( triggered() ), this, SLOT( exportHtml() ), Qt::QueuedConnection );
    setAction( "exportHtml", action );

    action = new QAction( IconLoader::icon( "export-pdf" ), tr( "Export To PDF" ), this );
    connect( action, SIGNAL( triggered() ), this, SLOT( exportPdf() ), Qt::QueuedConnection );
    setAction( "exportPdf", action );

    action = new QAction( IconLoader::icon( "configure-views" ), tr( "&Manage Views..." ), this );
    connect( action, SIGNAL( triggered() ), this, SLOT( manageViews() ), Qt::QueuedConnection );
    setAction( "manageViews", action );

    action = new QAction( IconLoader::icon( "view-new" ), tr( "Add View" ), this );
    setAction( "popupAddView", action );

    action = new QAction( IconLoader::icon( "view-new" ), tr( "&Add View" ), this );
    connect( action, SIGNAL( triggered() ), this, SLOT( addView() ), Qt::QueuedConnection );
    setAction( "addView", action );

    action = new QAction( IconLoader::icon( "view-clone" ), tr( "&Clone View" ), this );
    connect( action, SIGNAL( triggered() ), this, SLOT( cloneView() ), Qt::QueuedConnection );
    setAction( "cloneView", action );

    action = new QAction( IconLoader::icon( "edit-modify" ), tr( "M&odify View" ), this );
    connect( action, SIGNAL( triggered() ), this, SLOT( modifyView() ), Qt::QueuedConnection );
    setAction( "modifyView", action );

    setTitle( "sectionAdd", tr( "Add" ) );
    setTitle( "sectionFolder", tr( "Folder" ) );
    setTitle( "sectionIssue", tr( "Issue" ) );
    setTitle( "sectionViews", tr( "Views" ) );
    setTitle( "sectionReport", tr( "Report" ) );

    setPopupMenu( "popupExport", "menuExport", "exportPdf" );
    setPopupMenu( "popupMarkAll", "menuMarkAll", "markAllAsRead" );
    setPopupMenu( "popupAddView", "menuAddView", "addView" );

    setDefaultMenuAction( "menuIssue", "openIssue" );

    loadXmlUiFile( ":/resources/folderview.xml" );

    QWidget* main = new QWidget( parentWidget );

    QVBoxLayout* mainLayout = new QVBoxLayout( main );
    mainLayout->setMargin( 0 );
    mainLayout->setSpacing( 0 );

    QHBoxLayout* viewLayout = new QHBoxLayout();
    viewLayout->setMargin( 3 );
    viewLayout->setSpacing( 5 );

    mainLayout->addLayout( viewLayout );

    QLabel* viewLabel = new QLabel( tr( "&View:" ), main );
    viewLayout->addWidget( viewLabel );

    m_viewCombo = new SeparatorComboBox( main );
    m_viewCombo->setMaxVisibleItems( 15 );
    m_viewCombo->setMaximumWidth( 200 );
    m_viewCombo->setMinimumWidth( 100 );

    connect( m_viewCombo, SIGNAL( activated( int ) ), this, SLOT( viewActivated( int ) ) );

    viewLayout->addWidget( m_viewCombo, 1 );

    viewLabel->setBuddy( m_viewCombo );

    viewLayout->addStretch( 0 );

    QLabel* searchLabel = new QLabel( tr( "&Search:" ), main );
    viewLayout->addWidget( searchLabel );

    m_searchBox = new SearchEditBox( main );
    m_searchBox->setMaximumWidth( 200 );
    m_searchBox->setMinimumWidth( 100 );

    connect( m_searchBox, SIGNAL( textChanged( const QString& ) ), this, SLOT( quickSearchChanged( const QString& ) ) );

    m_searchMenu = new QMenu( m_searchBox );
    m_searchBox->setOptionsMenu( m_searchMenu );

    m_searchActionGroup = new QActionGroup( this );

    connect( m_searchActionGroup, SIGNAL( triggered( QAction* ) ), this, SLOT( searchActionTriggered( QAction* ) ) );

    viewLayout->addWidget( m_searchBox, 1 );

    searchLabel->setBuddy( m_searchBox );

    m_list = new QTreeView( main );
    mainLayout->addWidget( m_list );

    TreeViewHelper helper( m_list );
    helper.initializeView();

    connect( m_list, SIGNAL( customContextMenuRequested( const QPoint& ) ),
        this, SLOT( listContextMenu( const QPoint& ) ) );
    connect( m_list->header(), SIGNAL( customContextMenuRequested( const QPoint& ) ),
        this, SLOT( headerContextMenu( const QPoint& ) ) );
    connect( m_list, SIGNAL( doubleClicked( const QModelIndex& ) ),
        this, SLOT( doubleClicked( const QModelIndex& ) ) );

    connect( m_searchBox, SIGNAL( deactivate() ), m_list, SLOT( setFocus() ) );

    main->installEventFilter( this );
    m_list->installEventFilter( this );
    m_list->viewport()->installEventFilter( this );

    setMainWidget( main );

    setViewerSizeHint( QSize( 700, 500 ) );
    setViewerSizeKey( "FolderView" );

    m_list->setFocus();
}
Exemple #14
0
void KJumpingCube::initKAction() {
  QAction * action;

  QSignalMapper * gameMapper = new QSignalMapper (this);
  connect (gameMapper, SIGNAL (mapped(int)), m_game, SLOT (gameActions(int)));

  action = KStandardGameAction::gameNew (gameMapper, SLOT (map()), this);
  actionCollection()->addAction (action->objectName(), action);
  gameMapper->setMapping (action, NEW);

  action = KStandardGameAction::load    (gameMapper, SLOT (map()), this);
  actionCollection()->addAction (action->objectName(), action);
  gameMapper->setMapping (action, LOAD);

  action = KStandardGameAction::save    (gameMapper, SLOT (map()), this);
  actionCollection()->addAction (action->objectName(), action);
  gameMapper->setMapping (action, SAVE);

  action = KStandardGameAction::saveAs  (gameMapper, SLOT (map()), this);
  actionCollection()->addAction (action->objectName(), action);
  gameMapper->setMapping (action, SAVE_AS);

  action = KStandardGameAction::hint    (gameMapper, SLOT(map()), this);
  actionCollection()->addAction (action->objectName(), action);
  gameMapper->setMapping (action, HINT);

  action = KStandardGameAction::undo    (gameMapper, SLOT (map()), this);
  actionCollection()->addAction (action->objectName(), action);
  gameMapper->setMapping (action, UNDO);
  action->setEnabled (false);

  action = KStandardGameAction::redo    (gameMapper, SLOT (map()), this);
  actionCollection()->addAction (action->objectName(), action);
  gameMapper->setMapping (action, REDO);
  action->setEnabled (false);

  actionButton = new QPushButton (this);
  actionButton->setObjectName ("ActionButton");
  // Action button's style sheet: parameters for red, green and clicked colors.
  buttonLook =
       "QPushButton#ActionButton { color: white; background-color: %1; "
           "border-style: outset; border-width: 2px; border-radius: 10px; "
           "border-color: beige; font: bold 14px; min-width: 10em; "
           "padding: 6px; margin: 5px; margin-left: 10px; } "
       "QPushButton#ActionButton:pressed { background-color: %2; "
           "border-style: inset; } "
       "QPushButton#ActionButton:disabled { color: white;"
            "border-color: beige; background-color: steelblue; }";
  gameMapper->setMapping (actionButton, BUTTON);
  connect (actionButton, SIGNAL(clicked()), gameMapper, SLOT(map()));

  QWidgetAction *widgetAction = new QWidgetAction(this);
  widgetAction->setDefaultWidget(actionButton);
  actionCollection()->addAction (QLatin1String ("action_button"), widgetAction);

  changeButton (true, true);		// Load the button's style sheet.
  changeButton (false);			// Set the button to be inactive.

  action = KStandardAction::preferences (m_game, SLOT(showSettingsDialog()),
                                         actionCollection());
  qDebug() << "PREFERENCES ACTION is" << action->objectName();
  action->setIconText (i18n("Settings"));

  action = KStandardGameAction::quit (this, SLOT (close()), this);
  actionCollection()->addAction (action->objectName(), action);

  setupGUI();
}
PostWindow::PostWindow(QWidget* parent):
    QPlainTextEdit(parent)
{
    setReadOnly(true);
    setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);

    QRect availableScreenRect = qApp->desktop()->availableGeometry(this);
    mSizeHint = QSize( availableScreenRect.width() / 2.7, 300 );

    QAction * action;

    QAction *copyAction = new QAction(tr("Copy"), this);
    connect(copyAction, SIGNAL(triggered()), this, SLOT(copy()));
    copyAction->setShortcut( Main::settings()->shortcut("IDE/shortcuts/copy") );
    copyAction->setShortcutContext( Qt::WidgetShortcut );
    addAction(copyAction);

    mClearAction = new QAction(tr("Clear"), this);
    connect(mClearAction, SIGNAL(triggered()), this, SLOT(clear()));
    addAction(mClearAction);

    action = new QAction(this);
    action->setSeparator(true);
    addAction(action);

    action = new QAction(tr("Enlarge Post Font"), this);
    action->setIconText("+");
    action->setShortcut(tr("Ctrl++", "Enlarge Font"));
    action->setShortcutContext( Qt::WidgetShortcut );
    action->setToolTip(tr("Enlarge font"));
    connect(action, SIGNAL(triggered()), this, SLOT(zoomIn()));
    addAction(action);

    action = new QAction(tr("Shrink Post Font"), this);
    action->setIconText("-");
    action->setShortcut(tr("Ctrl+-", "Shrink Font"));
    action->setShortcutContext( Qt::WidgetShortcut );
    action->setToolTip(tr("Shrink font"));
    connect(action, SIGNAL(triggered()), this, SLOT(zoomOut()));
    addAction(action);

    action = new QAction(this);
    action->setSeparator(true);
    addAction(action);

    mLineWrapAction = action = new QAction(tr("Wrap Text"), this);
    action->setCheckable(true);
    addAction(action);
    connect( action, SIGNAL(triggered(bool)), this, SLOT(setLineWrap(bool)) );

    mAutoScrollAction = new QAction(tr("Auto Scroll"), this);
    mAutoScrollAction->setToolTip(tr("Scroll to bottom on new posts"));
    mAutoScrollAction->setCheckable(true);
    mAutoScrollAction->setChecked(true);
    addAction(mAutoScrollAction);

    setContextMenuPolicy(Qt::ActionsContextMenu);

    connect(this, SIGNAL(scrollToBottomRequest()),
            this, SLOT(scrollToBottom()), Qt::QueuedConnection);
    connect(mAutoScrollAction, SIGNAL(triggered(bool)),
            this, SLOT(onAutoScrollTriggered(bool)));

    applySettings( Main::settings() );
}
void QActionProto::setIconText(const QString &text)
{
  QAction *item = qscriptvalue_cast<QAction*>(thisObject());
  if (item)
    item->setIconText(text);
}
Exemple #17
0
MainWindow::MainWindow(QWidget *parent, Qt::WFlags flags)
    : QMainWindow(parent, flags)
    , mUi(new Ui::MainWindow)
    , mMapDocument(0)
    , mActionHandler(new MapDocumentActionHandler(this))
    , mLayerDock(new LayerDock(this))
    , mTilesetDock(new TilesetDock(this))
    , mZoomLabel(new QLabel)
    , mStatusInfoLabel(new QLabel)
    , mClipboardManager(new ClipboardManager(this))
    , mDocumentManager(DocumentManager::instance())
{
    mUi->setupUi(this);
    setCentralWidget(mDocumentManager->widget());

    PluginManager::instance()->loadPlugins();

#ifdef Q_WS_MAC
    MacSupport::addFullscreen(this);
#endif

    Preferences *preferences = Preferences::instance();

    QIcon redoIcon(QLatin1String(":images/16x16/edit-redo.png"));
    QIcon undoIcon(QLatin1String(":images/16x16/edit-undo.png"));

    QIcon tiledIcon(QLatin1String(":images/tiled-icon-16.png"));
    tiledIcon.addFile(QLatin1String(":images/tiled-icon-32.png"));
    setWindowIcon(tiledIcon);

    // Add larger icon versions for actions used in the tool bar
    QIcon newIcon = mUi->actionNew->icon();
    QIcon openIcon = mUi->actionOpen->icon();
    QIcon saveIcon = mUi->actionSave->icon();
    newIcon.addFile(QLatin1String(":images/24x24/document-new.png"));
    openIcon.addFile(QLatin1String(":images/24x24/document-open.png"));
    saveIcon.addFile(QLatin1String(":images/24x24/document-save.png"));
    redoIcon.addFile(QLatin1String(":images/24x24/edit-redo.png"));
    undoIcon.addFile(QLatin1String(":images/24x24/edit-undo.png"));
    mUi->actionNew->setIcon(newIcon);
    mUi->actionOpen->setIcon(openIcon);
    mUi->actionSave->setIcon(saveIcon);

    QUndoGroup *undoGroup = mDocumentManager->undoGroup();
    QAction *undoAction = undoGroup->createUndoAction(this, tr("Undo"));
    QAction *redoAction = undoGroup->createRedoAction(this, tr("Redo"));
    mUi->mainToolBar->setToolButtonStyle(Qt::ToolButtonFollowStyle);
    mUi->actionNew->setPriority(QAction::LowPriority);
    redoAction->setPriority(QAction::LowPriority);
    redoAction->setIcon(redoIcon);
    undoAction->setIcon(undoIcon);
    redoAction->setIconText(tr("Redo"));
    undoAction->setIconText(tr("Undo"));
    connect(undoGroup, SIGNAL(cleanChanged(bool)), SLOT(updateWindowTitle()));

    UndoDock *undoDock = new UndoDock(undoGroup, this);

    addDockWidget(Qt::RightDockWidgetArea, mLayerDock);
    addDockWidget(Qt::RightDockWidgetArea, undoDock);
    tabifyDockWidget(undoDock, mLayerDock);
    addDockWidget(Qt::RightDockWidgetArea, mTilesetDock);

    statusBar()->addPermanentWidget(mZoomLabel);

    mUi->actionNew->setShortcuts(QKeySequence::New);
    mUi->actionOpen->setShortcuts(QKeySequence::Open);
    mUi->actionSave->setShortcuts(QKeySequence::Save);
    mUi->actionSaveAs->setShortcuts(QKeySequence::SaveAs);
    mUi->actionClose->setShortcuts(QKeySequence::Close);
    mUi->actionQuit->setShortcuts(QKeySequence::Quit);
    mUi->actionCut->setShortcuts(QKeySequence::Cut);
    mUi->actionCopy->setShortcuts(QKeySequence::Copy);
    mUi->actionPaste->setShortcuts(QKeySequence::Paste);
    mUi->actionDelete->setShortcuts(QKeySequence::Delete);
    undoAction->setShortcuts(QKeySequence::Undo);
    redoAction->setShortcuts(QKeySequence::Redo);

    mUi->actionShowGrid->setChecked(preferences->showGrid());
    mUi->actionSnapToGrid->setChecked(preferences->snapToGrid());
    mUi->actionHighlightCurrentLayer->setChecked(preferences->highlightCurrentLayer());

    // Make sure Ctrl+= also works for zooming in
    QList<QKeySequence> keys = QKeySequence::keyBindings(QKeySequence::ZoomIn);
    keys += QKeySequence(tr("Ctrl+="));
    keys += QKeySequence(tr("+"));
    mUi->actionZoomIn->setShortcuts(keys);
    keys = QKeySequence::keyBindings(QKeySequence::ZoomOut);
    keys += QKeySequence(tr("-"));
    mUi->actionZoomOut->setShortcuts(keys);

    mUi->menuEdit->insertAction(mUi->actionCut, undoAction);
    mUi->menuEdit->insertAction(mUi->actionCut, redoAction);
    mUi->menuEdit->insertSeparator(mUi->actionCut);
    mUi->menuEdit->insertAction(mUi->actionPreferences,
                                mActionHandler->actionSelectAll());
    mUi->menuEdit->insertAction(mUi->actionPreferences,
                                mActionHandler->actionSelectNone());
    mUi->menuEdit->insertSeparator(mUi->actionPreferences);
    mUi->mainToolBar->addAction(undoAction);
    mUi->mainToolBar->addAction(redoAction);

    mUi->mainToolBar->addSeparator();

    mCommandButton = new CommandButton(this);
    mUi->mainToolBar->addWidget(mCommandButton);

    mUi->menuMap->insertAction(mUi->actionOffsetMap,
                               mActionHandler->actionCropToSelection());

    mRandomButton = new QToolButton(this);
    mRandomButton->setToolTip(tr("Random Mode"));
    mRandomButton->setIcon(QIcon(QLatin1String(":images/24x24/dice.png")));
    mRandomButton->setCheckable(true);
    mUi->mainToolBar->addWidget(mRandomButton);

    mLayerMenu = new QMenu(tr("&Layer"), this);
    mLayerMenu->addAction(mActionHandler->actionAddTileLayer());
    mLayerMenu->addAction(mActionHandler->actionAddObjectGroup());
    mLayerMenu->addAction(mActionHandler->actionDuplicateLayer());
    mLayerMenu->addAction(mActionHandler->actionMergeLayerDown());
    mLayerMenu->addAction(mActionHandler->actionRemoveLayer());
    mLayerMenu->addAction(mActionHandler->actionRenameLayer());
    mLayerMenu->addSeparator();
    mLayerMenu->addAction(mActionHandler->actionSelectPreviousLayer());
    mLayerMenu->addAction(mActionHandler->actionSelectNextLayer());
    mLayerMenu->addAction(mActionHandler->actionMoveLayerUp());
    mLayerMenu->addAction(mActionHandler->actionMoveLayerDown());
    mLayerMenu->addSeparator();
    mLayerMenu->addAction(mActionHandler->actionToggleOtherLayers());
    mLayerMenu->addSeparator();
    mLayerMenu->addAction(mActionHandler->actionLayerProperties());

    menuBar()->insertMenu(mUi->menuHelp->menuAction(), mLayerMenu);

    connect(mUi->actionNew, SIGNAL(triggered()), SLOT(newMap()));
    connect(mUi->actionOpen, SIGNAL(triggered()), SLOT(openFile()));
    connect(mUi->actionClearRecentFiles, SIGNAL(triggered()),
            SLOT(clearRecentFiles()));
    connect(mUi->actionSave, SIGNAL(triggered()), SLOT(saveFile()));
    connect(mUi->actionSaveAs, SIGNAL(triggered()), SLOT(saveFileAs()));
    connect(mUi->actionSaveAsImage, SIGNAL(triggered()), SLOT(saveAsImage()));
    connect(mUi->actionExport, SIGNAL(triggered()), SLOT(exportAs()));
    connect(mUi->actionClose, SIGNAL(triggered()), SLOT(closeFile()));
    connect(mUi->actionCloseAll, SIGNAL(triggered()), SLOT(closeAllFiles()));
    connect(mUi->actionQuit, SIGNAL(triggered()), SLOT(close()));

    connect(mUi->actionCut, SIGNAL(triggered()), SLOT(cut()));
    connect(mUi->actionCopy, SIGNAL(triggered()), SLOT(copy()));
    connect(mUi->actionPaste, SIGNAL(triggered()), SLOT(paste()));
    connect(mUi->actionDelete, SIGNAL(triggered()), SLOT(delete_()));
    connect(mUi->actionPreferences, SIGNAL(triggered()),
            SLOT(openPreferences()));

    connect(mUi->actionShowGrid, SIGNAL(toggled(bool)),
            preferences, SLOT(setShowGrid(bool)));
    connect(mUi->actionSnapToGrid, SIGNAL(toggled(bool)),
            preferences, SLOT(setSnapToGrid(bool)));
    connect(mUi->actionHighlightCurrentLayer, SIGNAL(toggled(bool)),
            preferences, SLOT(setHighlightCurrentLayer(bool)));
    connect(mUi->actionZoomIn, SIGNAL(triggered()), SLOT(zoomIn()));
    connect(mUi->actionZoomOut, SIGNAL(triggered()), SLOT(zoomOut()));
    connect(mUi->actionZoomNormal, SIGNAL(triggered()), SLOT(zoomNormal()));

    connect(mUi->actionNewTileset, SIGNAL(triggered()), SLOT(newTileset()));
    connect(mUi->actionAddExternalTileset, SIGNAL(triggered()),
            SLOT(addExternalTileset()));
    connect(mUi->actionResizeMap, SIGNAL(triggered()), SLOT(resizeMap()));
    connect(mUi->actionOffsetMap, SIGNAL(triggered()), SLOT(offsetMap()));
    connect(mUi->actionMapProperties, SIGNAL(triggered()),
            SLOT(editMapProperties()));
    connect(mUi->actionAutoMap, SIGNAL(triggered()), SLOT(autoMap()));

    connect(mActionHandler->actionLayerProperties(), SIGNAL(triggered()),
            SLOT(editLayerProperties()));

    connect(mUi->actionAbout, SIGNAL(triggered()), SLOT(aboutTiled()));
    connect(mUi->actionAboutQt, SIGNAL(triggered()), qApp, SLOT(aboutQt()));

    connect(mTilesetDock, SIGNAL(tilesetsDropped(QStringList)),
            SLOT(newTilesets(QStringList)));

    // Add recent file actions to the recent files menu
    for (int i = 0; i < MaxRecentFiles; ++i)
    {
         mRecentFiles[i] = new QAction(this);
         mUi->menuRecentFiles->insertAction(mUi->actionClearRecentFiles,
                                            mRecentFiles[i]);
         mRecentFiles[i]->setVisible(false);
         connect(mRecentFiles[i], SIGNAL(triggered()),
                 this, SLOT(openRecentFile()));
    }
    mUi->menuRecentFiles->insertSeparator(mUi->actionClearRecentFiles);

    setThemeIcon(mUi->actionNew, "document-new");
    setThemeIcon(mUi->actionOpen, "document-open");
    setThemeIcon(mUi->menuRecentFiles, "document-open-recent");
    setThemeIcon(mUi->actionClearRecentFiles, "edit-clear");
    setThemeIcon(mUi->actionSave, "document-save");
    setThemeIcon(mUi->actionSaveAs, "document-save-as");
    setThemeIcon(mUi->actionClose, "window-close");
    setThemeIcon(mUi->actionQuit, "application-exit");
    setThemeIcon(mUi->actionCut, "edit-cut");
    setThemeIcon(mUi->actionCopy, "edit-copy");
    setThemeIcon(mUi->actionPaste, "edit-paste");
    setThemeIcon(mUi->actionDelete, "edit-delete");
    setThemeIcon(redoAction, "edit-redo");
    setThemeIcon(undoAction, "edit-undo");
    setThemeIcon(mUi->actionZoomIn, "zoom-in");
    setThemeIcon(mUi->actionZoomOut, "zoom-out");
    setThemeIcon(mUi->actionZoomNormal, "zoom-original");
    setThemeIcon(mUi->actionNewTileset, "document-new");
    setThemeIcon(mUi->actionResizeMap, "document-page-setup");
    setThemeIcon(mUi->actionMapProperties, "document-properties");
    setThemeIcon(mUi->actionAbout, "help-about");

    mStampBrush = new StampBrush(this);
    mBucketFillTool = new BucketFillTool(this);
    CreateObjectTool *tileObjectsTool = new CreateObjectTool(
            CreateObjectTool::CreateTile, this);
    CreateObjectTool *areaObjectsTool = new CreateObjectTool(
            CreateObjectTool::CreateArea, this);
    CreateObjectTool *polygonObjectsTool = new CreateObjectTool(
            CreateObjectTool::CreatePolygon, this);
    CreateObjectTool *polylineObjectsTool = new CreateObjectTool(
            CreateObjectTool::CreatePolyline, this);

    connect(mTilesetDock, SIGNAL(currentTilesChanged(const TileLayer*)),
            this, SLOT(setStampBrush(const TileLayer*)));
    connect(mStampBrush, SIGNAL(currentTilesChanged(const TileLayer*)),
            this, SLOT(setStampBrush(const TileLayer*)));
    connect(mTilesetDock, SIGNAL(currentTileChanged(Tile*)),
            tileObjectsTool, SLOT(setTile(Tile*)));

    connect(mRandomButton, SIGNAL(toggled(bool)),
            mStampBrush, SLOT(setRandom(bool)));

    ToolManager *toolManager = ToolManager::instance();
    toolManager->registerTool(mStampBrush);
    toolManager->registerTool(mBucketFillTool);
    toolManager->registerTool(new Eraser(this));
    toolManager->registerTool(new TileSelectionTool(this));
    toolManager->addSeparator();
    toolManager->registerTool(new ObjectSelectionTool(this));
    toolManager->registerTool(new EditPolygonTool(this));
    toolManager->registerTool(areaObjectsTool);
    toolManager->registerTool(tileObjectsTool);
    toolManager->registerTool(polygonObjectsTool);
    toolManager->registerTool(polylineObjectsTool);

    addToolBar(toolManager->toolBar());

    statusBar()->addWidget(mStatusInfoLabel);
    connect(toolManager, SIGNAL(statusInfoChanged(QString)),
            this, SLOT(updateStatusInfoLabel(QString)));

    mUi->menuView->addSeparator();
    mUi->menuView->addAction(mTilesetDock->toggleViewAction());
    mUi->menuView->addAction(mLayerDock->toggleViewAction());
    mUi->menuView->addAction(undoDock->toggleViewAction());

    connect(mClipboardManager, SIGNAL(hasMapChanged()), SLOT(updateActions()));

    connect(mDocumentManager, SIGNAL(currentDocumentChanged(MapDocument*)),
            SLOT(mapDocumentChanged(MapDocument*)));
    connect(mDocumentManager, SIGNAL(documentCloseRequested(int)),
            this, SLOT(closeMapDocument(int)));

    QShortcut *switchToLeftDocument = new QShortcut(tr("Ctrl+PgUp"), this);
    connect(switchToLeftDocument, SIGNAL(activated()),
            mDocumentManager, SLOT(switchToLeftDocument()));
    QShortcut *switchToLeftDocument1 = new QShortcut(tr("Ctrl+Shift+Tab"), this);
    connect(switchToLeftDocument1, SIGNAL(activated()),
            mDocumentManager, SLOT(switchToLeftDocument()));

    QShortcut *switchToRightDocument = new QShortcut(tr("Ctrl+PgDown"), this);
    connect(switchToRightDocument, SIGNAL(activated()),
            mDocumentManager, SLOT(switchToRightDocument()));
    QShortcut *switchToRightDocument1 = new QShortcut(tr("Ctrl+Tab"), this);
    connect(switchToRightDocument1, SIGNAL(activated()),
            mDocumentManager, SLOT(switchToRightDocument()));

    new QShortcut(tr("X"), this, SLOT(flipStampHorizontally()));
    new QShortcut(tr("Y"), this, SLOT(flipStampVertically()));
    new QShortcut(tr("Z"), this, SLOT(rotateStampRight()));
    new QShortcut(tr("Shift+Z"), this, SLOT(rotateStampLeft()));

    QShortcut *copyPositionShortcut = new QShortcut(tr("Alt+C"), this);
    connect(copyPositionShortcut, SIGNAL(activated()),
            mActionHandler, SLOT(copyPosition()));

    updateActions();
    readSettings();
    setupQuickStamps();

    connect(AutomappingManager::instance(), SIGNAL(warningsOccurred()),
            this, SLOT(autoMappingWarning()));
    connect(AutomappingManager::instance(), SIGNAL(errorsOccurred()),
            this, SLOT(autoMappingError()));
}
ProjectsView::ProjectsView( QObject* parent, QWidget* parentWidget ) : View( parent ),
    m_folderUpdateCounter( 0 ),
    m_updateCounter( 0 ),
    m_sessionExpired( false )
{
    m_systemAdmin = dataManager->currentUserAccess() == AdminAccess;

    QAction* action;

    action = new QAction( IconLoader::icon( "file-reload" ), tr( "&Update Projects" ), this );
    action->setShortcut( QKeySequence::Refresh );
    connect( action, SIGNAL( triggered() ), this, SLOT( updateProjects() ), Qt::QueuedConnection );
    setAction( "updateProjects", action );

    action = new QAction( IconLoader::icon( "edit-access" ), tr( "&Manage Permissions..." ), this );
    action->setIconText( tr( "Permissions" ) );
    connect( action, SIGNAL( triggered() ), this, SLOT( managePermissions() ), Qt::QueuedConnection );
    setAction( "managePermissions", action );

    if ( m_systemAdmin ) {
        action = new QAction( IconLoader::icon( "project-new" ), tr( "Add &Project..." ), this );
        connect( action, SIGNAL( triggered() ), this, SLOT( addProject() ), Qt::QueuedConnection );
        setAction( "addProject", action );
    }

    action = new QAction( IconLoader::icon( "folder-new" ), tr( "Add &Folder..." ), this );
    action->setShortcut( QKeySequence::New );
    connect( action, SIGNAL( triggered() ), this, SLOT( addFolder() ), Qt::QueuedConnection );
    setAction( "addFolder", action );

    action = new QAction( IconLoader::icon( "edit-rename" ), tr( "&Rename Folder..." ), this );
    action->setIconText( tr( "Rename" ) );
    action->setShortcut( tr( "F2" ) );
    connect( action, SIGNAL( triggered() ), this, SLOT( editRename() ), Qt::QueuedConnection );
    setAction( "editRename", action );

    action = new QAction( IconLoader::icon( "edit-delete" ), tr( "&Delete Folder" ), this );
    action->setIconText( tr( "Delete" ) );
    action->setShortcut( QKeySequence::Delete );
    connect( action, SIGNAL( triggered() ), this, SLOT( editDelete() ), Qt::QueuedConnection );
    setAction( "editDelete", action );

    action = new QAction( IconLoader::icon( "folder-move" ), tr( "&Move Folder..." ), this );
    action->setIconText( tr( "Move" ) );
    connect( action, SIGNAL( triggered() ), this, SLOT( moveFolder() ), Qt::QueuedConnection );
    setAction( "moveFolder", action );

    action = new QAction( IconLoader::icon( "project" ), tr( "&Open Project" ), this );
    action->setShortcut( QKeySequence::Open );
    connect( action, SIGNAL( triggered() ), this, SLOT( openProject() ), Qt::QueuedConnection );
    setAction( "openProject", action );

    action = new QAction( IconLoader::icon( "folder-open" ), tr( "&Open Folder" ), this );
    action->setShortcut( QKeySequence::Open );
    connect( action, SIGNAL( triggered() ), this, SLOT( openFolder() ), Qt::QueuedConnection );
    setAction( "openFolder", action );

    action = new QAction( IconLoader::icon( "folder-open" ), tr( "&Open List" ), this );
    action->setShortcut( QKeySequence::Open );
    connect( action, SIGNAL( triggered() ), this, SLOT( openGlobalList() ), Qt::QueuedConnection );
    setAction( "openGlobalList", action );

    action = new QAction( IconLoader::icon( "configure-alerts" ), tr( "&Manage Alerts..." ), this );
    connect( action, SIGNAL( triggered() ), this, SLOT( manageAlerts() ), Qt::QueuedConnection );
    setAction( "manageAlerts", action );

    setTitle( "sectionAdd", tr( "Add" ) );
    setTitle( "sectionProjects", tr( "Projects" ) );

    setDefaultMenuAction( "menuProject", "openProject" );
    setDefaultMenuAction( "menuProjectAdmin", "openProject" );
    setDefaultMenuAction( "menuFolder", "openFolder" );
    setDefaultMenuAction( "menuGlobalList", "openGlobalList" );

    loadXmlUiFile( ":/resources/projectsview.xml" );

    m_list = new QTreeView( parentWidget );

    TreeViewHelper helper( m_list );
    helper.initializeView( TreeViewHelper::TreeStyle );

    connect( m_list, SIGNAL( customContextMenuRequested( const QPoint& ) ),
        this, SLOT( contextMenu( const QPoint& ) ) );
    connect( m_list, SIGNAL( doubleClicked( const QModelIndex& ) ),
        this, SLOT( doubleClicked( const QModelIndex& ) ) );

    setMainWidget( m_list );
}
Exemple #19
0
MainWindow::MainWindow(QWidget *parent, Qt::WindowFlags flags)
    : QMainWindow(parent, flags)
    , mUi(new Ui::MainWindow)
    , mMapDocument(0)
    , mActionHandler(new MapDocumentActionHandler(this))
    , mMapsDock(new MapsDock(this))
    , mTilesetDock(new TilesetDock(this))
    , mMiniMapDock(new MiniMapDock(this))
    , mZoomable(0)
    , mZoomComboBox(new QComboBox)
    , mStatusInfoLabel(new QLabel)
    , mValidationErrorWidget(new QWidget)
    , mValidationErrorLabel(new QLabel)
    , mDocumentManager(DocumentManager::instance())
    , mQuickStampManager(new QuickStampManager(this))
    , mToolManager(new ToolManager(this))
    , mKodableMapValidator(new KodableMapValidator(this))
{
    mUi->setupUi(this);
    setCentralWidget(mDocumentManager->widget());

#ifdef Q_OS_MAC
    MacSupport::addFullscreen(this);
#endif

    Preferences *preferences = Preferences::instance();

    QIcon redoIcon(QLatin1String(":images/16x16/edit-redo.png"));
    QIcon undoIcon(QLatin1String(":images/16x16/edit-undo.png"));

    QIcon windowIcon(QLatin1String(":images/kodable-editor-icon.png"));
    setWindowIcon(windowIcon);

    // Add larger icon versions for actions used in the tool bar
    QIcon newIcon = mUi->actionNew->icon();
    QIcon openIcon = mUi->actionOpen->icon();
    QIcon saveIcon = mUi->actionSave->icon();
    newIcon.addFile(QLatin1String(":images/24x24/document-new.png"));
    openIcon.addFile(QLatin1String(":images/24x24/document-open.png"));
    saveIcon.addFile(QLatin1String(":images/24x24/document-save.png"));
    redoIcon.addFile(QLatin1String(":images/24x24/edit-redo.png"));
    undoIcon.addFile(QLatin1String(":images/24x24/edit-undo.png"));
    mUi->actionNew->setIcon(newIcon);
    mUi->actionOpen->setIcon(openIcon);
    mUi->actionSave->setIcon(saveIcon);

    QUndoGroup *undoGroup = mDocumentManager->undoGroup();
    QAction *undoAction = undoGroup->createUndoAction(this, tr("Undo"));
    QAction *redoAction = undoGroup->createRedoAction(this, tr("Redo"));
    mUi->mainToolBar->setToolButtonStyle(Qt::ToolButtonFollowStyle);
    mUi->actionNew->setPriority(QAction::LowPriority);
    redoAction->setPriority(QAction::LowPriority);
    redoAction->setIcon(redoIcon);
    undoAction->setIcon(undoIcon);
    redoAction->setIconText(tr("Redo"));
    undoAction->setIconText(tr("Undo"));
    connect(undoGroup, SIGNAL(cleanChanged(bool)), SLOT(updateWindowTitle()));

    UndoDock *undoDock = new UndoDock(undoGroup, this);
    PropertiesDock *propertiesDock = new PropertiesDock(this);

    addDockWidget(Qt::LeftDockWidgetArea, undoDock);
    addDockWidget(Qt::LeftDockWidgetArea, mMapsDock);
    addDockWidget(Qt::RightDockWidgetArea, mMiniMapDock);
    addDockWidget(Qt::RightDockWidgetArea, mTilesetDock);
    addDockWidget(Qt::RightDockWidgetArea, propertiesDock);

    tabifyDockWidget(undoDock, mMapsDock);

    // These dock widgets may not be immediately useful to many people, so
    // they are hidden by default.
    undoDock->setVisible(false);
    mMapsDock->setVisible(false);
    mMiniMapDock->setVisible(false);

    QHBoxLayout *errorBoxLayout = new QHBoxLayout;
    QLabel *iconLabel = new QLabel;
    iconLabel->setPixmap(QPixmap(QLatin1String(":images/16x16/dialog-warning.png")));
    errorBoxLayout->addWidget(iconLabel);
    errorBoxLayout->addWidget(mValidationErrorLabel);
    mValidationErrorWidget->setLayout(errorBoxLayout);

    mValidationErrorWidget->setVisible(false);
    statusBar()->addPermanentWidget(mValidationErrorWidget);
    statusBar()->addPermanentWidget(mZoomComboBox);

    mUi->actionNew->setShortcuts(QKeySequence::New);
    mUi->actionOpen->setShortcuts(QKeySequence::Open);
    mUi->actionSave->setShortcuts(QKeySequence::Save);
    mUi->actionSaveAs->setShortcuts(QKeySequence::SaveAs);
    mUi->actionClose->setShortcuts(QKeySequence::Close);
    mUi->actionQuit->setShortcuts(QKeySequence::Quit);
    mUi->actionCut->setShortcuts(QKeySequence::Cut);
    mUi->actionCopy->setShortcuts(QKeySequence::Copy);
    mUi->actionPaste->setShortcuts(QKeySequence::Paste);
    mUi->actionDelete->setShortcuts(QKeySequence::Delete);
    undoAction->setShortcuts(QKeySequence::Undo);
    redoAction->setShortcuts(QKeySequence::Redo);

    mUi->actionShowGrid->setChecked(preferences->showGrid());
    mUi->actionShowTileObjectOutlines->setChecked(preferences->showTileObjectOutlines());
    mUi->actionShowTileAnimations->setChecked(preferences->showTileAnimations());
    mUi->actionSnapToGrid->setChecked(preferences->snapToGrid());
    mUi->actionSnapToFineGrid->setChecked(preferences->snapToFineGrid());
    mUi->actionHighlightCurrentLayer->setChecked(preferences->highlightCurrentLayer());

    QShortcut *reloadTilesetsShortcut = new QShortcut(QKeySequence(tr("Ctrl+T")), this);
    connect(reloadTilesetsShortcut, SIGNAL(activated()),
            this, SLOT(reloadTilesets()));

    // Make sure Ctrl+= also works for zooming in
    QList<QKeySequence> keys = QKeySequence::keyBindings(QKeySequence::ZoomIn);
    keys += QKeySequence(tr("Ctrl+="));
    keys += QKeySequence(tr("+"));
    mUi->actionZoomIn->setShortcuts(keys);
    keys = QKeySequence::keyBindings(QKeySequence::ZoomOut);
    keys += QKeySequence(tr("-"));
    mUi->actionZoomOut->setShortcuts(keys);

    mUi->menuEdit->insertAction(mUi->actionCut, undoAction);
    mUi->menuEdit->insertAction(mUi->actionCut, redoAction);
    mUi->menuEdit->insertSeparator(mUi->actionCut);
    mUi->menuEdit->insertAction(mUi->actionPreferences,
                                mActionHandler->actionSelectAll());
    mUi->menuEdit->insertAction(mUi->actionPreferences,
                                mActionHandler->actionSelectNone());
    mUi->menuEdit->insertSeparator(mUi->actionPreferences);
    mUi->mainToolBar->addAction(undoAction);
    mUi->mainToolBar->addAction(redoAction);

    mUi->mainToolBar->addSeparator();

    mLayerMenu = new QMenu(tr("&Layer"), this);
    mLayerMenu->addAction(mActionHandler->actionLayerProperties());

    menuBar()->insertMenu(mUi->menuHelp->menuAction(), mLayerMenu);

    connect(mUi->actionNew, SIGNAL(triggered()), SLOT(newMap()));
    connect(mUi->actionOpen, SIGNAL(triggered()), SLOT(openFile()));
    connect(mUi->actionClearRecentFiles, SIGNAL(triggered()),
            SLOT(clearRecentFiles()));
    connect(mUi->actionSave, SIGNAL(triggered()), SLOT(saveFile()));
    connect(mUi->actionSaveAs, SIGNAL(triggered()), SLOT(saveFileAs()));
    connect(mUi->actionSaveAsImage, SIGNAL(triggered()), SLOT(saveAsImage()));
    connect(mUi->actionExport, SIGNAL(triggered()), SLOT(exportAs()));
    connect(mUi->actionClose, SIGNAL(triggered()), SLOT(closeFile()));
    connect(mUi->actionCloseAll, SIGNAL(triggered()), SLOT(closeAllFiles()));
    connect(mUi->actionQuit, SIGNAL(triggered()), SLOT(close()));

    connect(mUi->actionCut, SIGNAL(triggered()), SLOT(cut()));
    connect(mUi->actionCopy, SIGNAL(triggered()), SLOT(copy()));
    connect(mUi->actionPaste, SIGNAL(triggered()), SLOT(paste()));
    connect(mUi->actionDelete, SIGNAL(triggered()), SLOT(delete_()));
    connect(mUi->actionPreferences, SIGNAL(triggered()),
            SLOT(openPreferences()));

    connect(mUi->actionShowGrid, SIGNAL(toggled(bool)),
            preferences, SLOT(setShowGrid(bool)));
    connect(mUi->actionShowTileObjectOutlines, SIGNAL(toggled(bool)),
            preferences, SLOT(setShowTileObjectOutlines(bool)));
    connect(mUi->actionShowTileAnimations, SIGNAL(toggled(bool)),
            preferences, SLOT(setShowTileAnimations(bool)));
    connect(mUi->actionSnapToGrid, SIGNAL(toggled(bool)),
            preferences, SLOT(setSnapToGrid(bool)));
    connect(mUi->actionSnapToFineGrid, SIGNAL(toggled(bool)),
            preferences, SLOT(setSnapToFineGrid(bool)));
    connect(mUi->actionHighlightCurrentLayer, SIGNAL(toggled(bool)),
            preferences, SLOT(setHighlightCurrentLayer(bool)));
    connect(mUi->actionZoomIn, SIGNAL(triggered()), SLOT(zoomIn()));
    connect(mUi->actionZoomOut, SIGNAL(triggered()), SLOT(zoomOut()));
    connect(mUi->actionZoomNormal, SIGNAL(triggered()), SLOT(zoomNormal()));

    connect(mUi->actionNewTileset, SIGNAL(triggered()), SLOT(newTileset()));
    connect(mUi->actionAddExternalTileset, SIGNAL(triggered()),
            SLOT(addExternalTileset()));
    connect(mUi->actionOffsetMap, SIGNAL(triggered()), SLOT(offsetMap()));
    connect(mUi->actionMapProperties, SIGNAL(triggered()),
            SLOT(editMapProperties()));

    connect(mUi->actionAbout, SIGNAL(triggered()), SLOT(aboutTiled()));
    connect(mUi->actionAboutQt, SIGNAL(triggered()), qApp, SLOT(aboutQt()));

    connect(mTilesetDock, SIGNAL(tilesetsDropped(QStringList)),
            SLOT(newTilesets(QStringList)));

    // Add recent file actions to the recent files menu
    for (int i = 0; i < MaxRecentFiles; ++i)
    {
         mRecentFiles[i] = new QAction(this);
         mUi->menuRecentFiles->insertAction(mUi->actionClearRecentFiles,
                                            mRecentFiles[i]);
         mRecentFiles[i]->setVisible(false);
         connect(mRecentFiles[i], SIGNAL(triggered()),
                 this, SLOT(openRecentFile()));
    }
    mUi->menuRecentFiles->insertSeparator(mUi->actionClearRecentFiles);

    setThemeIcon(mUi->actionNew, "document-new");
    setThemeIcon(mUi->actionOpen, "document-open");
    setThemeIcon(mUi->menuRecentFiles, "document-open-recent");
    setThemeIcon(mUi->actionClearRecentFiles, "edit-clear");
    setThemeIcon(mUi->actionSave, "document-save");
    setThemeIcon(mUi->actionSaveAs, "document-save-as");
    setThemeIcon(mUi->actionClose, "window-close");
    setThemeIcon(mUi->actionQuit, "application-exit");
    setThemeIcon(mUi->actionCut, "edit-cut");
    setThemeIcon(mUi->actionCopy, "edit-copy");
    setThemeIcon(mUi->actionPaste, "edit-paste");
    setThemeIcon(mUi->actionDelete, "edit-delete");
    setThemeIcon(redoAction, "edit-redo");
    setThemeIcon(undoAction, "edit-undo");
    setThemeIcon(mUi->actionZoomIn, "zoom-in");
    setThemeIcon(mUi->actionZoomOut, "zoom-out");
    setThemeIcon(mUi->actionZoomNormal, "zoom-original");
    setThemeIcon(mUi->actionNewTileset, "document-new");
    setThemeIcon(mUi->actionMapProperties, "document-properties");
    setThemeIcon(mUi->actionAbout, "help-about");

    mStampBrush = new StampBrush(this);
    mBucketFillTool = new BucketFillTool(this);

    connect(mTilesetDock, SIGNAL(currentTilesChanged(const TileLayer*)),
            this, SLOT(setStampBrush(const TileLayer*)));
    connect(mStampBrush, SIGNAL(currentTilesChanged(const TileLayer*)),
            this, SLOT(setStampBrush(const TileLayer*)));

    QToolBar *toolBar = mUi->toolsToolBar;
    toolBar->addAction(mToolManager->registerTool(mStampBrush));
    toolBar->addAction(mToolManager->registerTool(mBucketFillTool));
    toolBar->addAction(mToolManager->registerTool(new Eraser(this)));
    toolBar->addAction(mToolManager->registerTool(new TileSelectionTool(this)));

    mDocumentManager->setSelectedTool(mToolManager->selectedTool());
    connect(mToolManager, SIGNAL(selectedToolChanged(AbstractTool*)),
            mDocumentManager, SLOT(setSelectedTool(AbstractTool*)));

    statusBar()->addWidget(mStatusInfoLabel);
    connect(mToolManager, SIGNAL(statusInfoChanged(QString)),
            this, SLOT(updateStatusInfoLabel(QString)));

    // Add the 'Views and Toolbars' submenu. This needs to happen after all
    // the dock widgets and toolbars have been added to the main window.
    mViewsAndToolbarsMenu = new QAction(tr("Views and Toolbars"), this);
    QMenu *popupMenu = createPopupMenu();
    popupMenu->setParent(this);
    mViewsAndToolbarsMenu->setMenu(popupMenu);
    mUi->menuView->insertAction(mUi->actionShowGrid, mViewsAndToolbarsMenu);
    mUi->menuView->insertSeparator(mUi->actionShowGrid);

    connect(ClipboardManager::instance(), SIGNAL(hasMapChanged()), SLOT(updateActions()));

    connect(mDocumentManager, SIGNAL(currentDocumentChanged(MapDocument*)),
            SLOT(mapDocumentChanged(MapDocument*)));
    connect(mDocumentManager, SIGNAL(documentCloseRequested(int)),
            this, SLOT(closeMapDocument(int)));

    QShortcut *switchToLeftDocument = new QShortcut(tr("Alt+Left"), this);
    connect(switchToLeftDocument, SIGNAL(activated()),
            mDocumentManager, SLOT(switchToLeftDocument()));
    QShortcut *switchToLeftDocument1 = new QShortcut(tr("Ctrl+Shift+Tab"), this);
    connect(switchToLeftDocument1, SIGNAL(activated()),
            mDocumentManager, SLOT(switchToLeftDocument()));

    QShortcut *switchToRightDocument = new QShortcut(tr("Alt+Right"), this);
    connect(switchToRightDocument, SIGNAL(activated()),
            mDocumentManager, SLOT(switchToRightDocument()));
    QShortcut *switchToRightDocument1 = new QShortcut(tr("Ctrl+Tab"), this);
    connect(switchToRightDocument1, SIGNAL(activated()),
            mDocumentManager, SLOT(switchToRightDocument()));


    new QShortcut(tr("X"), this, SLOT(flipHorizontally()));
    new QShortcut(tr("Y"), this, SLOT(flipVertically()));
    new QShortcut(tr("Z"), this, SLOT(rotateRight()));
    new QShortcut(tr("Shift+Z"), this, SLOT(rotateLeft()));

    QShortcut *copyPositionShortcut = new QShortcut(tr("Alt+C"), this);
    connect(copyPositionShortcut, SIGNAL(activated()),
            mActionHandler, SLOT(copyPosition()));

    updateActions();
    readSettings();
    setupQuickStamps();

    connect(undoGroup, SIGNAL(indexChanged(int)),
            mKodableMapValidator, SLOT(validateCurrentMap()));
    connect(mKodableMapValidator, SIGNAL(errorChanged(QString)),
            this, SLOT(setValidationError(QString)));
}
Exemple #20
0
void ActionManager::setupActions()
{
    QAction *action;

    action = new QAction(m_ui);
    action->setText(tr("Scan"));
    action->setIcon(QIcon(QString::fromUtf8(":/images/images/viewmag.png")));
    m_collectionsScanSection.insert("scan-action", action);
    connect(action, &QAction::triggered, m_ui, &MainWindow::startScan);
    action->setEnabled(false);

    // clear action
    action = new QAction(m_ui);
    action->setText(tr("Clear History"));
    action->setIcon(QIcon::fromTheme("edit-clear-list", QIcon(":/images/images/edit-clear-list.png")));
    m_collectionsScanSection.insert("clearHistory-action", action);
    connect(action, &QAction::triggered, m_ui, &MainWindow::clearAll);
    action->setEnabled(false);

    action = new QAction(m_ui);
    action->setText(tr("S&ave Scan"));
    action->setIcon(QIcon::fromTheme("document-save", QIcon(":/images/images/save_all.png")));
    m_collectionsScanSection.insert("save-action", action);
    connect(action, &QAction::triggered, m_ui->m_parser, &ParserManager::callSaveSingleLogWriter);
    action->setEnabled(false);

    action = new QAction(m_ui);
    action->setText(tr("Save all scans to &Directory"));
    action->setIcon(QIcon::fromTheme("document-save-as", QIcon(":/images/images/document-save-as.png")));
    m_collectionsScanSection.insert("saveAll-action", action);
    connect(action, &QAction::triggered, m_ui->m_parser, &ParserManager::callSaveAllLogWriter);
    action->setEnabled(false);

    m_menuBookmark = new QMenu(m_ui);
    action = new QAction(m_ui);
    action->setText(tr("&Add host to bookmark"));
    action->setIcon(QIcon::fromTheme("address-book-new", QIcon(":/images/images/bookmark_add.png")));
    m_collectionsScanSection.insert("bookmarkAddHost-action", action);
    connect(action, &QAction::triggered, m_ui->m_bookmark, &BookmarkManager::saveHostnameItemToBookmark);

    action = new QAction(m_ui);
    action->setText(tr("Add service to &bookmark"));
    action->setIcon(QIcon::fromTheme("address-book-new", QIcon(":/images/images/bookmark_add.png")));
    m_collectionsScanSection.insert("bookmarkAddService-action", action);
    connect(action, &QAction::triggered, m_ui->m_bookmark, &BookmarkManager::saveServiceItemToBookmark);

    action = new QAction(m_ui);
    action->setText(tr("Add &parameters to bookmark"));
    action->setIcon(QIcon::fromTheme("address-book-new", QIcon(":/images/images/bookmark_add.png")));
    m_collectionsScanSection.insert("bookmarkAddParameters-action", action);
    connect(action, &QAction::triggered, m_ui->m_bookmark, &BookmarkManager::startParametersToBookmarksDialog);

    action = new QAction(m_ui);
    action->setText(tr("Add vulnerability search url"));
    action->setIcon(QIcon::fromTheme("address-book-new", QIcon(":/images/images/bookmark_add.png")));
    m_collectionsScanSection.insert("bookmarkAddVulnUrl-action", action);
    connect(action, &QAction::triggered, m_ui->m_vulnerability, &Vulnerability::showAddUrlUi);

    // Profiler QActions
    action = new QAction(m_ui);
    action->setText(tr("New Profile"));
    action->setIcon(QIcon::fromTheme("document-new", QIcon(":/images/images/document-new.png")));
    m_collectionsScanSection.insert("newProfile-action", action);
    connect(action, &QAction::triggered, m_ui, &MainWindow::newProfile);

    action = new QAction(m_ui);
    action->setText(tr("Edit Profile"));
    action->setIcon(QIcon::fromTheme("document-properties", QIcon(":/images/images/document-properties.png")));
    m_collectionsScanSection.insert("editProfile-action", action);
    connect(action, &QAction::triggered, m_ui, &MainWindow::editProfile);

    // discover Actions
    action = new QAction(m_ui);
    action->setText(tr("Scan selected IP/s"));
    action->setIcon(QIcon(QString::fromUtf8(":/images/images/viewmag.png")));
    m_collectionsDiscover.insert("scan-single", action);
    connect(action, &QAction::triggered, m_ui->m_discoverManager, &DiscoverManager::scanSingleDiscoveredIp);
    action->setEnabled(false);

    action = new QAction(m_ui);
    action->setText(tr("Scan all discovered IP/s"));
    action->setIcon(QIcon(QString::fromUtf8(":/images/images/viewmag.png")));
    m_collectionsDiscover.insert("scan-all", action);
    connect(action, &QAction::triggered, m_ui->m_discoverManager, &DiscoverManager::scanAllDiscoveredIps);
    action->setEnabled(false);

    action = new QAction(m_ui);
    action->setText(tr("Save IP list"));
    action->setIcon(QIcon::fromTheme("document-save", QIcon(":/images/images/save_all.png")));
    m_collectionsDiscover.insert("save-ips", action);
    connect(action, &QAction::triggered, m_ui->m_discoverManager, &DiscoverManager::saveXmlIpsList);
    action->setEnabled(false);

    action = new QAction(m_ui);
    action->setText(tr("Load IP list"));
    action->setIcon(QIcon::fromTheme("folder-open", QIcon(":/images/images/folder_open.png")));
    m_collectionsDiscover.insert("load-ips", action);
    connect(action, &QAction::triggered, m_ui->m_discoverManager, &DiscoverManager::loadXmlIpsList);
    action->setEnabled(true);

    // Vulnerability Actions
    action = new QAction(m_ui);
    action->setIcon(QIcon::fromTheme("system-search", QIcon(":/images/images/viewmag.png")));
    action->setIconText(tr("Search"));
    action->setEnabled(false);
    m_collectionsVulnerability.insert("search-act", action);
    connect(action, &QAction::triggered, m_ui->m_vulnerability, &Vulnerability::searchVulnerabilityFromCombo);

    action = new QAction(m_ui);
    action->setIcon(QIcon::fromTheme("go-previous", QIcon(":/images/images/go-previous.png")));
    action->setIconText(tr("Back"));
    action->setEnabled(false);
    m_collectionsVulnerability.insert("back-act", action);
    connect(action, &QAction::triggered, m_ui->m_vulnerability, &Vulnerability::tabWebBack);

    action = new QAction(m_ui);
    action->setIcon(QIcon::fromTheme("go-next", QIcon(":/images/images/go-next.png")));
    action->setIconText(tr("Forward"));
    action->setEnabled(false);
    m_collectionsVulnerability.insert("forward-act", action);
    connect(action, &QAction::triggered, m_ui->m_vulnerability, &Vulnerability::tabWebForward);

    action = new QAction(m_ui);
    action->setIcon(QIcon::fromTheme("process-stop", QIcon(":/images/images/button_cancel.png")));
    action->setIconText(tr("Stop"));
    action->setEnabled(false);
    m_collectionsVulnerability.insert("stop-act", action);
    connect(action, &QAction::triggered, m_ui->m_vulnerability, &Vulnerability::tabWebStop);

    // global QActions
    action = new QAction(m_ui);
    action->setText(tr("&Quit"));
    action->setIcon(QIcon::fromTheme("application-exit", QIcon(":/images/images/window-close.png")));
    action->setShortcut(Qt::CTRL + Qt::Key_Q);
    m_collectionsScanSection.insert("quit-action", action);
    connect(action, &QAction::triggered, m_ui, &MainWindow::close);

    action = new QAction(m_ui);
    action->setText(tr("&Preferences"));
    action->setIcon(QIcon::fromTheme("preferences-other", QIcon(":/images/images/tool.png")));
    m_collectionsScanSection.insert("preferences-action", action);
    connect(action, &QAction::triggered, m_ui, &MainWindow::startPreferencesDialog);

    action = new QAction(m_ui);
    action->setText(tr("F&ull Screen Mode"));
    action->setCheckable(true);
    action->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_F11);
    action->setIcon(QIcon::fromTheme("view-fullscreen", QIcon(":/images/images/view-fullscreen.png")));
    m_collectionsScanSection.insert("fullscreen-action", action);
    connect(action, &QAction::triggered, m_ui, &MainWindow::setFullScreen);

    action = new QAction(m_ui);
    action->setText(tr("Show &Menu Bar"));
    action->setCheckable(true);
    action->setShortcut(Qt::CTRL + Qt::Key_M);
    action->setIcon(QIcon(QString::fromUtf8(":/images/images/show-menu.png")));
    m_collectionsScanSection.insert("showmenubar-action", action);
    connect(action, &QAction::triggered, m_ui, &MainWindow::updateMenuBar);

    action = new QAction(m_ui);
    action->setText(tr("Section Scan"));
    action->setIcon(QIcon(QString::fromUtf8(":/images/images/network_local.png")));
    m_collectionsScanSection.insert("sectionScan-action", action);
    connect(action, &QAction::triggered, m_ui, &MainWindow::updateScanSection);

    action = new QAction(m_ui);
    action->setText(tr("Section Vulnerabilities"));
    action->setIcon(QIcon(QString::fromUtf8(":/images/images/viewmag+.png")));
    m_collectionsScanSection.insert("sectionVuln-action", action);
    connect(action, &QAction::triggered, m_ui, &MainWindow::updateVulnerabilitySection);

    action = new QAction(m_ui);
    action->setText(tr("Section Discover"));
    action->setIcon(QIcon(QString::fromUtf8(":/images/images/document-preview-archive.png")));
    m_collectionsScanSection.insert("sectionDiscover-action", action);
    connect(action, &QAction::triggered, m_ui, &MainWindow::updateDiscoverSection);

    // Help menu actions
    action = new QAction(m_ui);
    action->setText(tr("Report a bug"));
    action->setIcon(QIcon(QString::fromUtf8(":/images/images/tools-report-bug.png")));
    m_collectionsScanSection.insert("bug-action", action);
    connect(action, &QAction::triggered, m_ui->m_utilities, &Utilities::showBugUrl);

    action = new QAction(m_ui);
    action->setText(tr("Visit Website"));
    action->setIcon(QIcon(QString::fromUtf8(":/images/images/messagebox_info.png")));
    m_collectionsScanSection.insert("home-action", action);
    connect(action, &QAction::triggered, m_ui->m_utilities, &Utilities::showHomepageUrl);

    action = new QAction(m_ui);
    action->setText(tr("Documentation"));
    action->setIcon(QIcon(QString::fromUtf8(":/images/images/book2.png")));
    m_collectionsScanSection.insert("documentation-action", action);
    connect(action, &QAction::triggered, m_ui->m_utilities, &Utilities::showDocumentationUrl);

    action = new QAction(m_ui);
    action->setText(tr("Donate Money"));
    action->setIcon(QIcon(QString::fromUtf8(":/images/images/kwalletmanager.png")));
    m_collectionsScanSection.insert("donate-action", action);
    connect(action, &QAction::triggered, m_ui->m_utilities, &Utilities::showDonateUrl);

    action = new QAction(m_ui);
    action->setText(tr("&About nmapsi4"));
    action->setIcon(QIcon(QString::fromUtf8(":/images/icons/64x64/nmapsi4.png")));
    m_collectionsScanSection.insert("aboutui-action", action);
    connect(action, &QAction::triggered, m_ui->m_utilities, &Utilities::about);

    action = new QAction(m_ui);
    action->setText(tr("About &Qt"));
    action->setIcon(QIcon(QString::fromUtf8(":/images/images/messagebox_info.png")));
    m_collectionsScanSection.insert("aboutqt-action", action);
    connect(action, &QAction::triggered, m_ui->m_utilities, &Utilities::aboutQt);
}
ExplorerTreeWidget::ExplorerTreeWidget(QWidget *parent) : QTreeWidget(parent)
{
    setContextMenuPolicy(Qt::DefaultContextMenu);
    setObjectName("explorerTree");

    QAction *disconnectAction = new QAction("Disconnect", this);
    disconnectAction->setIconText("Disconnect");
    connect(disconnectAction, SIGNAL(triggered()), SLOT(ui_disconnectServer()));

    QAction *refreshAction = new QAction("Refresh", this);
    refreshAction->setIcon(qApp->style()->standardIcon(QStyle::SP_BrowserReload));
    connect(refreshAction, SIGNAL(triggered()), SLOT(ui_refreshServer()));

    QAction *openShellAction = new QAction("Open Shell", this);
    openShellAction->setIcon(GuiRegistry::instance().mongodbIcon());
    connect(openShellAction, SIGNAL(triggered()), SLOT(ui_openShell()));

    QAction *serverHostInfo = new QAction("Host Info", this);
    connect(serverHostInfo, SIGNAL(triggered()), SLOT(ui_serverHostInfo()));

    QAction *serverStatus = new QAction("Server Status", this);
    connect(serverStatus, SIGNAL(triggered()), SLOT(ui_serverStatus()));

    QAction *serverVersion = new QAction("MongoDB Version", this);
    connect(serverVersion, SIGNAL(triggered()), SLOT(ui_serverVersion()));

    QAction *showLog = new QAction("Show Log", this);
    connect(showLog, SIGNAL(triggered()), SLOT(ui_showLog()));

    QAction *refreshServer = new QAction("Refresh", this);
    connect(refreshServer, SIGNAL(triggered()), SLOT(ui_refreshServer()));

    QAction *createDatabase = new QAction("Create Database", this);
    connect(createDatabase, SIGNAL(triggered()), SLOT(ui_createDatabase()));

    _serverContextMenu = new QMenu(this);
    _serverContextMenu->addAction(openShellAction);
    _serverContextMenu->addAction(refreshServer);
    _serverContextMenu->addSeparator();
    _serverContextMenu->addAction(createDatabase);
    _serverContextMenu->addAction(serverStatus);
    _serverContextMenu->addAction(serverHostInfo);
    _serverContextMenu->addAction(serverVersion);
    _serverContextMenu->addSeparator();
    _serverContextMenu->addAction(showLog);
    _serverContextMenu->addAction(disconnectAction);

    QAction *openDbShellAction = new QAction("Open Shell", this);
    openDbShellAction->setIcon(GuiRegistry::instance().mongodbIcon());
    connect(openDbShellAction, SIGNAL(triggered()), SLOT(ui_dbOpenShell()));

    QAction *dbStats = new QAction("Database Statistics", this);
    connect(dbStats, SIGNAL(triggered()), SLOT(ui_dbStatistics()));

    QAction *dbDrop = new QAction("Drop Database", this);
    connect(dbDrop, SIGNAL(triggered()), SLOT(ui_dbDrop()));

    QAction *dbRepair = new QAction("Repair Database", this);
    connect(dbRepair, SIGNAL(triggered()), SLOT(ui_dbRepair()));

    QAction *refreshDatabase = new QAction("Refresh", this);
    connect(refreshDatabase, SIGNAL(triggered()), SLOT(ui_refreshDatabase()));

    _databaseContextMenu = new QMenu(this);
    _databaseContextMenu->addAction(openDbShellAction);
    _databaseContextMenu->addAction(refreshDatabase);
    _databaseContextMenu->addSeparator();
    _databaseContextMenu->addAction(dbStats);
    _databaseContextMenu->addSeparator();
    _databaseContextMenu->addAction(dbRepair);
    _databaseContextMenu->addAction(dbDrop);

    QAction *addDocument = new QAction("Insert Document", this);
    connect(addDocument, SIGNAL(triggered()), SLOT(ui_addDocument()));

    QAction *updateDocument = new QAction("Update Documents", this);
    connect(updateDocument, SIGNAL(triggered()), SLOT(ui_updateDocument()));

    QAction *removeDocument = new QAction("Remove Documents", this);
    connect(removeDocument, SIGNAL(triggered()), SLOT(ui_removeDocument()));

    QAction *removeAllDocuments = new QAction("Remove All Documents", this);
    connect(removeAllDocuments, SIGNAL(triggered()), SLOT(ui_removeAllDocuments()));

    QAction *addIndex = new QAction("Add Index", this);
    connect(addIndex, SIGNAL(triggered()), SLOT(ui_addIndex()));

    QAction *dropIndex = new QAction("Drop Index", this);
    connect(dropIndex, SIGNAL(triggered()), SLOT(ui_dropIndex()));

    QAction *reIndex = new QAction("Rebuild Indexes", this);
    connect(reIndex, SIGNAL(triggered()), SLOT(ui_reIndex()));

    QAction *collectionStats = new QAction("Statistics", this);
    connect(collectionStats, SIGNAL(triggered()), SLOT(ui_collectionStatistics()));

    QAction *storageSize = new QAction("Storage Size", this);
    connect(storageSize, SIGNAL(triggered()), SLOT(ui_storageSize()));

    QAction *totalIndexSize = new QAction("Total Index Size", this);
    connect(totalIndexSize, SIGNAL(triggered()), SLOT(ui_totalIndexSize()));

    QAction *totalSize = new QAction("Total Size", this);
    connect(totalSize, SIGNAL(triggered()), SLOT(ui_totalSize()));

    QAction *shardVersion = new QAction("Shard Version", this);
    connect(shardVersion, SIGNAL(triggered()), SLOT(ui_shardVersion()));

    QAction *shardDistribution = new QAction("Shard Distribution", this);
    connect(shardDistribution, SIGNAL(triggered()), SLOT(ui_shardDistribution()));

    QAction *dropCollection = new QAction("Drop Collection", this);
    connect(dropCollection, SIGNAL(triggered()), SLOT(ui_dropCollection()));

    QAction *renameCollection = new QAction("Rename Collection", this);
    connect(renameCollection, SIGNAL(triggered()), SLOT(ui_renameCollection()));

    QAction *viewCollection = new QAction("View Documents", this);
    connect(viewCollection, SIGNAL(triggered()), SLOT(ui_viewCollection()));

    _collectionContextMenu = new QMenu(this);
    _collectionContextMenu->addAction(viewCollection);
    _collectionContextMenu->addSeparator();
    _collectionContextMenu->addAction(addDocument);
    _collectionContextMenu->addAction(updateDocument);
    _collectionContextMenu->addAction(removeDocument);
    _collectionContextMenu->addAction(removeAllDocuments);
    _collectionContextMenu->addSeparator();
    _collectionContextMenu->addAction(renameCollection);
    _collectionContextMenu->addAction(dropCollection);
    _collectionContextMenu->addSeparator();
    _collectionContextMenu->addAction(addIndex);
    _collectionContextMenu->addAction(dropIndex);
    _collectionContextMenu->addAction(reIndex);
    _collectionContextMenu->addSeparator();
    _collectionContextMenu->addAction(collectionStats);
    _collectionContextMenu->addSeparator();
    _collectionContextMenu->addAction(shardVersion);
    _collectionContextMenu->addAction(shardDistribution);


    QAction *dropUser = new QAction("Remove User", this);
    connect(dropUser, SIGNAL(triggered()), SLOT(ui_dropUser()));

    QAction *editUser = new QAction("Edit User", this);
    connect(editUser, SIGNAL(triggered()), SLOT(ui_editUser()));

    _userContextMenu = new QMenu(this);
    _userContextMenu->addAction(editUser);
    _userContextMenu->addAction(dropUser);


    QAction *createCollection = new QAction("Create Collection", this);
    connect(createCollection, SIGNAL(triggered()), SLOT(ui_createCollection()));

    QAction *dbCollectionsStats = new QAction("Collections Statistics", this);
    connect(dbCollectionsStats, SIGNAL(triggered()), SLOT(ui_dbCollectionsStatistics()));

    QAction *refreshCollections = new QAction("Refresh", this);
    connect(refreshCollections, SIGNAL(triggered()), SLOT(ui_refreshCollections()));

    _collectionCategoryContextMenu = new QMenu(this);
    _collectionCategoryContextMenu->addAction(dbCollectionsStats);
    _collectionCategoryContextMenu->addAction(createCollection);
    _collectionCategoryContextMenu->addSeparator();
    _collectionCategoryContextMenu->addAction(refreshCollections);


    QAction *refreshUsers = new QAction("Refresh", this);
    connect(refreshUsers, SIGNAL(triggered()), SLOT(ui_refreshUsers()));

    QAction *viewUsers = new QAction("View Users", this);
    connect(viewUsers, SIGNAL(triggered()), SLOT(ui_viewUsers()));

    QAction *addUser = new QAction("Add User", this);
    connect(addUser, SIGNAL(triggered()), SLOT(ui_addUser()));

    _usersCategoryContextMenu = new QMenu(this);
    _usersCategoryContextMenu->addAction(viewUsers);
    _usersCategoryContextMenu->addAction(addUser);
    _usersCategoryContextMenu->addSeparator();
    _usersCategoryContextMenu->addAction(refreshUsers);


    QAction *dropFunction = new QAction("Remove Function", this);
    connect(dropFunction, SIGNAL(triggered()), SLOT(ui_dropFunction()));

    QAction *editFunction = new QAction("Edit Function", this);
    connect(editFunction, SIGNAL(triggered()), SLOT(ui_editFunction()));

    _functionContextMenu = new QMenu(this);
    _functionContextMenu->addAction(editFunction);
    _functionContextMenu->addAction(dropFunction);


    QAction *refreshFunctions = new QAction("Refresh", this);
    connect(refreshFunctions, SIGNAL(triggered()), SLOT(ui_refreshFunctions()));

    QAction *viewFunctions = new QAction("View Functions", this);
    connect(viewFunctions, SIGNAL(triggered()), SLOT(ui_viewFunctions()));

    QAction *addFunction = new QAction("Add Function", this);
    connect(addFunction, SIGNAL(triggered()), SLOT(ui_addFunction()));

    _functionsCategoryContextMenu = new QMenu(this);
    _functionsCategoryContextMenu->addAction(viewFunctions);
    _functionsCategoryContextMenu->addAction(addFunction);
    _functionsCategoryContextMenu->addSeparator();
    _functionsCategoryContextMenu->addAction(refreshFunctions);
}