예제 #1
0
//moved from KFormDesigner::FormManager
void KexiFormManager::createActions(KActionCollection* collection)
{
    d->collection = collection;
//    KXMLGUIClient* client = (KXMLGUIClient*)d->collection->parentGUIClient();

    d->lib->createWidgetActions(d->widgetActionGroup);
//! @todo insertWidget() slot?
//2.0    d->lib->createWidgetActions(client, d->collection,
//2.0                                this, SLOT(insertWidget(const QByteArray &)));

#ifdef KFD_SIGSLOTS
    if (d->features & KFormDesigner::Form::EnableConnections) {
        // nothing
    }
    else {
        d->dragConnectionAction = new KToggleAction(
            KIcon("signalslot"), i18n("Connect Signals/Slots"), d->collection);
        d->dragConnectionAction->setObjectName("drag_connection");
//        d->widgetActionGroup->addAction(d->dragConnectionAction);
        connect(d->dragConnectionAction, SIGNAL(triggered()),
                this, SLOT(startCreatingConnection()));
        d->dragConnectionAction->setChecked(false);
    }
#endif

    d->pointerAction = new KToggleAction(
        KIcon("mouse_pointer"), i18n("Pointer"), d->collection);
    d->pointerAction->setObjectName("edit_pointer");
    d->widgetActionGroup->addAction(d->pointerAction);
    connect(d->pointerAction, SIGNAL(triggered()),
            this, SLOT(slotPointerClicked()));
    d->pointerAction->setChecked(true);

    d->snapToGridAction = new KToggleAction(
        i18n("Snap to Grid"), d->collection);
    d->snapToGridAction->setObjectName("snap_to_grid");
//    d->widgetActionGroup->addAction(d->snapToGridAction);
//    d->snapToGridAction->setChecked(true);

#if 0 // 2.0: todo
    // Create the Style selection action (with a combo box in toolbar and submenu items)
    KSelectAction *styleAction = new KSelectAction(
        i18n("Style"), d->collection);
    styleAction->setObjectName("change_style");
    connect(styleAction, SIGNAL(triggered()),
            this, SLOT(slotStyle()));
    styleAction->setEditable(false);

//js: unused? KGlobalGroup cg = KGlobal::config()->group("General");
    QString currentStyle(kapp->style()->objectName().toLower());
    const QStringList styles = QStyleFactory::keys();
    styleAction->setItems(styles);
    styleAction->setCurrentItem(0);

    QStringList::ConstIterator endIt = styles.constEnd();
    int idx = 0;
    for (QStringList::ConstIterator it = styles.constBegin(); it != endIt; ++it, ++idx) {
        if ((*it).toLower() == currentStyle) {
            styleAction->setCurrentItem(idx);
            break;
        }
    }
    styleAction->setToolTip(i18n("Set the current view style."));
    styleAction->setMenuAccelsEnabled(true);
#endif

    d->lib->addCustomWidgetActions(d->collection);

#ifdef KEXI_DEBUG_GUI
    KConfigGroup generalGroup(KGlobal::config()->group("General"));
    if (generalGroup.readEntry("ShowInternalDebugger", false)) {
        KAction *a = new KAction(KIcon("run-build-file"), i18n("Show Form UI Code"), this);
        d->collection->addAction("show_form_ui", a);
        a->setShortcut(Qt::CTRL + Qt::Key_U);
        connect(a, SIGNAL(triggered()), this, SLOT(showFormUICode()));
    }
#endif

//! @todo move elsewhere
    {
        // (from obsolete kexiformpartinstui.rc)
        QStringList formActions;
        formActions
            << "edit_pointer"
            << QString() //sep
#ifndef KEXI_NO_AUTOFIELD_WIDGET
            << ":library_widget_KexiDBAutoField"
#endif
            << ":library_widget_KexiDBLabel"
            << ":library_widget_KexiDBImageBox"
            << ":library_widget_KexiDBLineEdit"
            << ":library_widget_KexiDBTextEdit"
            << ":library_widget_KPushButton"
            << ":library_widget_KexiDBComboBox"
            << ":library_widget_KexiDBCheckBox"
#ifndef KEXI_NO_FORM_LAYOUTS
            << ":library_widget_Spacer"
#endif
            << ":library_widget_Line"
            << ":library_widget_KexiFrame"
            << ":library_widget_QGroupBox"
            << ":library_widget_KFDTabWidget"
#ifndef KEXI_NO_FORM_SPRING_ELEMENT
            << ":library_widget_Spring"
#endif
            << QString() //sep
            ;
        KexiMainWindowIface *win = KexiMainWindowIface::global();
        foreach( const QString& actionName_, formActions ) {
            QAction *a;
            const QString actionName(actionName_.startsWith(':') ? actionName_.mid(1) : actionName_);
            if (actionName.isEmpty()) {
                a = new QAction(this);
                a->setSeparator(true);
            }
            else {
                a = d->widgetActionGroup->action(actionName);
            }
            if (actionName_.startsWith(':')) {  // icon only
                KexiSmallToolButton *btn = new KexiSmallToolButton(a, win->toolBar("form"));
                btn->setToolButtonStyle(Qt::ToolButtonIconOnly);
                win->appendWidgetToToolbar("form", btn);
            }
            else {
                win->addToolBarAction("form", a);
            }
        }

        QSet<QString> iconOnlyActions;
        iconOnlyActions << "widget_assign_action" << "show_form_ui";
        const QList<QAction*> actions( d->collection->actions() );
        foreach( QAction *a, actions ) {
            if (iconOnlyActions.contains(a->objectName())) { // icon only
                KexiSmallToolButton *btn = new KexiSmallToolButton(a, win->toolBar("form"));
                btn->setToolButtonStyle(Qt::ToolButtonIconOnly);
                win->appendWidgetToToolbar("form", btn);
            }
            else {
                win->addToolBarAction("form", a);
            }
        }
    }
예제 #2
0
파일: mainwindow.cpp 프로젝트: KDE/lskat
// Setup the GUI
void Mainwindow::initGUI()
{
    QAction *action;

    // Start a new game
    action = KStandardGameAction::gameNew(this, SLOT(menuNewLSkatGame()), actionCollection());
    if (global_demo_mode) action->setEnabled(false);

    // Clear all time statistics
    action = KStandardGameAction::clearStatistics(this, SLOT(menuClearStatistics()), actionCollection());
    action->setWhatsThis(i18n("Clears the all time statistics which is kept in all sessions."));
    if (global_demo_mode) action->setEnabled(false);

    // End a game
    action = KStandardGameAction::end(this, SLOT(menuEndGame()), actionCollection());
    action->setWhatsThis(i18n("Ends a currently played game. No winner will be declared."));
    action->setEnabled(false);

    // Quit the program
    action = KStandardGameAction::quit(this, SLOT(close()), actionCollection());
    action->setWhatsThis(i18n("Quits the program."));

    // Determine start player
    KSelectAction *startPlayerAct = new KSelectAction(i18n("Starting Player"), this);
    actionCollection()->addAction(QLatin1String("startplayer"), startPlayerAct);
    connect(startPlayerAct, SIGNAL(triggered(int)), this, SLOT(menuStartplayer()));
    startPlayerAct->setToolTip(i18n("Changing starting player..."));
    startPlayerAct->setWhatsThis(i18n("Chooses which player begins the next game."));
    QStringList list;
    list.clear();
    list.append(i18n("Player &1"));
    list.append(i18n("Player &2"));
    startPlayerAct->setItems(list);
    if (global_demo_mode) startPlayerAct->setEnabled(false);

    // Determine who player player 1
    KSelectAction *player1Act = new KSelectAction(i18n("Player &1 Played By"), this);
    actionCollection()->addAction(QLatin1String("player1"), player1Act);
    connect(player1Act, SIGNAL(triggered(int)), this, SLOT(menuPlayer1By()));
    player1Act->setToolTip(i18n("Changing who plays player 1..."));
    player1Act->setWhatsThis(i18n("Changing who plays player 1."));
    list.clear();
    list.append(i18n("&Mouse"));
    list.append(i18n("&Computer"));
    player1Act->setItems(list);
    if (global_demo_mode) player1Act->setEnabled(false);

    // Determine who player player 2
    KSelectAction *player2Act = new KSelectAction(i18n("Player &2 Played By"), this);
    actionCollection()->addAction(QLatin1String("player2"), player2Act);
    connect(player2Act, SIGNAL(triggered(int)), this, SLOT(menuPlayer2By()));
    player2Act->setToolTip(i18n("Changing who plays player 2..."));
    player2Act->setWhatsThis(i18n("Changing who plays player 2."));
    player2Act->setItems(list);
    if (global_demo_mode) player2Act->setEnabled(false);

    // Add all theme files to the menu
    QStringList themes(mThemeFiles.keys());
    themes.sort();

    KSelectAction *themeAct = new KSelectAction(i18n("&Theme"), this);
    actionCollection()->addAction(QLatin1String("theme"), themeAct);
    themeAct->setItems(themes);
    connect(themeAct, SIGNAL(triggered(int)), SLOT(changeTheme(int)));
    if (global_debug > 0) kDebug() << "Setting current theme item to" << mThemeIndexNo;
    themeAct->setCurrentItem(mThemeIndexNo);
    themeAct->setToolTip(i18n("Changing theme..."));
    themeAct->setWhatsThis(i18n("Changing theme."));

    // Choose card deck
    KAction *action1 = actionCollection()->addAction(QLatin1String("select_carddeck"));
    action1->setText(i18n("Select &Card Deck..."));
    action1->setShortcuts(KShortcut(Qt::Key_F10));
    connect(action1, SIGNAL(triggered(bool)), this, SLOT(menuCardDeck()));
    action1->setToolTip(i18n("Configure card decks..."));
    action1->setWhatsThis(i18n("Choose how the cards should look."));

    // Change player names
    action = actionCollection()->addAction(QLatin1String("change_names"));
    action->setText(i18n("&Change Player Names..."));
    connect(action, SIGNAL(triggered(bool)), this, SLOT(menuPlayerNames()));
    if (global_demo_mode) action->setEnabled(false);
}