Exemplo n.º 1
0
void PMShell::setupActions( )
{
//   m_helpMenu = new KHelpMenu( this, PMFactory::aboutData( ), true,
//                               actionCollection( ) );

   KStdAction::openNew( this, SLOT( slotFileNew( ) ), actionCollection( ) );
   KStdAction::open( this, SLOT( slotFileOpen( ) ), actionCollection( ) );
   m_pRecent = KStdAction::openRecent( this, SLOT( slotOpenRecent( const KURL& ) ),
                                       actionCollection( ) );
   KStdAction::save( this, SLOT( slotFileSave( ) ), actionCollection( ) );
   KStdAction::saveAs( this, SLOT( slotFileSaveAs( ) ), actionCollection( ) );

   KStdAction::revert( this, SLOT( slotFileRevert( ) ), actionCollection( ) );
   KStdAction::print( this, SLOT( slotFilePrint( ) ), actionCollection( ) );

   KStdAction::close( this, SLOT( slotFileClose( ) ), actionCollection( ) );
   KStdAction::quit( this, SLOT( close( ) ), actionCollection( ) );

   m_pPathAction = new KToggleAction( i18n( "Show &Path" ), 0, this,
                               SLOT( slotShowPath( ) ), actionCollection( ),
                               "options_show_path" );
   m_pPathAction->setCheckedState(i18n("Hide &Path"));

   m_pStatusbarAction = KStdAction::showStatusbar( this, SLOT( slotShowStatusbar( ) ),
                                                   actionCollection( ) );

   KStdAction::saveOptions( this, SLOT( saveOptions( ) ), actionCollection( ) );

   KStdAction::keyBindings( this, SLOT( slotConfigureKeys( ) ),
                            actionCollection( ) );
   KStdAction::configureToolbars( this, SLOT( slotConfigureToolbars( ) ),
                                  actionCollection( ) );
   KStdAction::preferences( this, SLOT( slotSettings( ) ), actionCollection( ) );

   m_pNewTopViewAction = new KAction( i18n( "New Top View" ), 0, this,
                                      SLOT( slotNewTopView( ) ),
                                      actionCollection( ), "view_new_topview" );
   m_pNewBottomViewAction = new KAction( i18n( "New Bottom View" ), 0, this,
                                         SLOT( slotNewBottomView( ) ),
                                         actionCollection( ), "view_new_bottomview" );
   m_pNewLeftViewAction = new KAction( i18n( "New Left View" ), 0, this,
                                       SLOT( slotNewLeftView( ) ),
                                       actionCollection( ), "view_new_leftview" );
   m_pNewRightViewAction = new KAction( i18n( "New Right View" ), 0, this,
                                        SLOT( slotNewRightView( ) ),
                                        actionCollection( ), "view_new_rightview" );
   m_pNewFrontViewAction = new KAction( i18n( "New Front View" ), 0, this,
                                        SLOT( slotNewFrontView( ) ),
                                        actionCollection( ), "view_new_frontview" );
   m_pNewBackViewAction = new KAction( i18n( "New Back View" ), 0, this,
                                       SLOT( slotNewBackView( ) ),
                                       actionCollection( ), "view_new_back_view" );
   m_pNewCameraViewAction = new KAction( i18n( "New Camera View" ), 0, this,
                                         SLOT( slotNewCameraView( ) ),
                                         actionCollection( ), "view_new_cameraview" );

   m_pNewTreeViewAction = new KAction( i18n( "New Object Tree" ), 0, this,
                              SLOT( slotNewTreeView( ) ), actionCollection( ),
                              "view_new_treeview" );
   m_pNewDialogViewAction = new KAction( i18n( "New Properties View" ), 0, this,
                             SLOT( slotNewDialogView( ) ), actionCollection( ),
                             "view_new_dialogview" );

#ifdef KPM_WITH_OBJECT_LIBRARY
   m_pNewLibraryBrowserAction = new KAction( i18n( "New Library Browser" ), 0, this,
                                    SLOT( slotNewLibraryBrowserView( ) ), actionCollection( ),
                                    "view_new_librarybrowser" );
#endif

   // Creating the view layouts menu
   m_pViewLayoutsAction = new KActionMenu( i18n( "View Layouts" ),
                                           actionCollection( ), "view_layouts_menu" );
   KPopupMenu* menu = m_pViewLayoutsAction->popupMenu( );
   connect( menu, SIGNAL( aboutToShow( ) ), SLOT( slotViewsMenuAboutToShow( ) ) );
   PMViewLayoutManager::theManager( )->fillPopupMenu( menu );
   connect( menu, SIGNAL( activated( int ) ), SLOT( slotSelectedLayout( int ) ) );

   m_pSaveViewLayoutAction = new KAction( i18n( "Save View Layout..." ), 0, this,
                                          SLOT( slotSaveViewLayout( ) ),
                                          actionCollection( ), "save_view_layout" );
}
Exemplo n.º 2
0
MainWindow::MainWindow(QWidget *parent) :
        QWidget(parent) {
    this->setWindowTitle("环境变量编辑器");
    /***************************************************
     全局布局控制
     */
    hblMain = new QHBoxLayout(this);
    vblRight = new QVBoxLayout(this);
    vblLeft = new QVBoxLayout(this);
    hblMain->addLayout(vblLeft);
    hblMain->addLayout(vblRight);
    /*******************************************************
     左侧布局
     */
    lbTableView = new QLabel("当前系统环境变量:", this);
    vblLeft->addWidget(lbTableView);
    tvValueList = new QTableView();
    vblLeft->addWidget(tvValueList);
    lbDetailTittle = new QLabel("变量信息:", this);
    vblLeft->addWidget(lbDetailTittle);
    lbPathDetail = new QLabel("变量信息:", this);
    vblLeft->addWidget(lbPathDetail);
    lbPathDetail->setGeometry(QRect(328, 240, 329, 27 * 4));  //四倍行距
    lbPathDetail->setWordWrap(true);  //自动换行
    lbPathDetail->setAlignment(Qt::AlignTop);
    /*******************************************************
     右侧布局
     */
    lbPathDescribe = new QLabel("Path设置:", this);
    vblRight->addWidget(lbPathDescribe);
    pbShowPath = new QPushButton("显示Path信息");  //显示path
    vblRight->addWidget(pbShowPath);
    pbEiditPath = new QPushButton("编辑Path路径");  //修改path
    vblRight->addWidget(pbEiditPath);

    //*****************************************************************

    lbBackDescribe = new QLabel("环境适配:");
    vblRight->addWidget(lbBackDescribe);
    pbSetBack = new QPushButton("备份当前环境");  //备份环境
    vblRight->addWidget(pbSetBack);
    pbUseBack = new QPushButton("还原到指定环境");  //还原环境
    vblRight->addWidget(pbUseBack);
    pbCheckIN = new QPushButton("导入特定环境变量");  //导入环境
    vblRight->addWidget(pbCheckIN);
    pbCheckOut = new QPushButton("导出指定环境变量"); //导出环境
    vblRight->addWidget(pbCheckOut);

    //*****************************************************************

    lbEiditDescribe = new QLabel("变量操作:");
    vblRight->addWidget(lbEiditDescribe);
    pbNewValue = new QPushButton("新建环境变量");  //新建变量
    vblRight->addWidget(pbNewValue);
    pbEiditValue = new QPushButton("编辑选中变量");  //编辑变量
    vblRight->addWidget(pbEiditValue);
    pbDelValue = new QPushButton("删除选中变量");  //删除变量
    vblRight->addWidget(pbDelValue);

    //*****************************************************************
    lbEiditFunction = new QLabel(" ");
    vblRight->addWidget(lbEiditFunction);
    pbAbout = new QPushButton("关于…");//关于
    vblRight->addWidget(pbAbout);
    pbExit = new QPushButton("退出"); //退出
    vblRight->addWidget(pbExit);

    /******************************************
     //        环境变量池
     */
    //显示变量
    slotRefrehValue();

    //通过是否可以新建环境变量判断是否以管理员身份启动
    reg->setValue("testAdminPermissions", "test");
    if (reg->value("testAdminPermissions", false).toBool()) {

        reg->remove("testAdminPermissions");
        isAdimin = true;
        //判断back目录是否存在,若没有提示用户备份!
        QDir dir;
        if (!dir.exists("./back/")) {
            switch (QMessageBox::information(this, "备份提醒",
                    "程序当前目录下找不到back文件夹,您可能从未对环境变量进行备份,为了保证操作安全,强烈建议您备份当前环境变量以减少误操作所带来的困扰!",
                    "立即备份!", "暂不需要!", 0, 1)) {
            case 0:
                slotSetBack();
                break;
            case 1:
                break;

            }

        }
    } else {
        QMessageBox::information(NULL, "未获得UAC管理员权限",
                "未使用UAC管理员权限开启本程序,由于Windows系统的限制,你可能只能查看变量内容而无法对其编辑");
        isAdimin = false;

    }

    //显示选中变量概要
    connect(tvValueList, SIGNAL(clicked(QModelIndex)), this,
            SLOT(slotGetClickedLine()));

    //槽
    //显示Path信息
    connect(pbShowPath, SIGNAL(clicked()), this, SLOT(slotShowPath()));
    //添加按钮槽
    connect(pbNewValue, SIGNAL(clicked()), this, SLOT(slotCreateWindow()));
    connect(pbEiditValue, SIGNAL(clicked()), this, SLOT(slotEiditWindow()));
    connect(pbEiditPath, SIGNAL(clicked()), this, SLOT(slotPathWindow()));

    //删除按钮槽
    connect(pbDelValue, SIGNAL(clicked()), this, SLOT(slotRemoveValue()));
    //备份
    connect(pbSetBack, SIGNAL(clicked()), this, SLOT(slotSetBack()));
    //还原
    connect(pbUseBack, SIGNAL(clicked()), this, SLOT(SlotGetBackWindow()));
    //导出
    connect(pbCheckOut, SIGNAL(clicked()), this, SLOT(slotExportWindow()));
    //导入
    connect(pbCheckIN, SIGNAL(clicked()), this, SLOT(slotImportWindow()));
    //退出
    connect(pbExit, SIGNAL(clicked()), this, SLOT(close()));
    //关于
    connect(pbAbout, SIGNAL(clicked()), this, SLOT(slotAboutWindow()));
}