Ejemplo n.º 1
0
NamedAreaDialog::NamedAreaDialog(QWidget* parent, Selection* selection)
        : KDialog(parent)
        , m_selection(selection)
{
    setButtons(KDialog::Ok | KDialog::Close | KDialog::User1 | KDialog::User2 | KDialog::User3);
    setButtonsOrientation(Qt::Vertical);
    setButtonText(KDialog::Ok, i18n("&Select"));
    setButtonText(KDialog::User1, i18n("&Remove"));
    setButtonText(KDialog::User2, i18n("&Edit..."));
    setButtonText(KDialog::User3, i18n("&New..."));
    setCaption(i18n("Named Areas"));
    setModal(true);
    setObjectName("NamedAreaDialog");

    QWidget* widget = new QWidget(this);
    setMainWidget(widget);

    QVBoxLayout *vboxLayout = new QVBoxLayout(widget);
    vboxLayout->setMargin(0);
    vboxLayout->setSpacing(KDialog::spacingHint());

    m_list = new KListWidget(this);
    m_list->setSortingEnabled(true);
    vboxLayout->addWidget(m_list);

    m_rangeName = new QLabel(this);
    m_rangeName->setText(i18n("Area: %1", QString()));
    vboxLayout->addWidget(m_rangeName);

    const QList<QString> namedAreas = m_selection->activeSheet()->map()->namedAreaManager()->areaNames();
    for (int i = 0; i < namedAreas.count(); ++i)
        m_list->addItem(namedAreas[i]);

    if (m_list->count() == 0) {
        enableButtonOk(false);
        enableButton(KDialog::User1, false);
        enableButton(KDialog::User2, false);
        m_list->setCurrentRow(0);
    }

    connect(this, SIGNAL(okClicked()), this, SLOT(slotOk()));
    connect(this, SIGNAL(cancelClicked()), this, SLOT(slotClose()));
    connect(this, SIGNAL(user1Clicked()), this, SLOT(slotRemove()));
    connect(this, SIGNAL(user2Clicked()), this, SLOT(slotEdit()));
    connect(this, SIGNAL(user3Clicked()), this, SLOT(slotNew()));
    connect(m_list, SIGNAL(itemActivated(QListWidgetItem*)), this, SLOT(slotOk()));
    connect(m_list, SIGNAL(currentTextChanged(const QString&)),
            this, SLOT(displayAreaValues(const QString&)));

    if (m_list->count() > 0)
        m_list->setCurrentItem(m_list->item(0));

    m_list->setFocus();
}
Ejemplo n.º 2
0
void KMInstancePage::initActions()
{
    addButton(i18n("New..."), "filenew", SLOT(slotNew()));
    addButton(i18n("Copy..."), "editcopy", SLOT(slotCopy()));
    addButton(i18n("Remove"), "edittrash", SLOT(slotRemove()));
    m_buttons.append(0);
    addButton(i18n("Set as Default"), "exec", SLOT(slotDefault()));
    addButton(i18n("Settings"), "configure", SLOT(slotSettings()));
    m_buttons.append(0);
    addButton(i18n("Test..."), "fileprint", SLOT(slotTest()));
}
Ejemplo n.º 3
0
KonqSessionDlg::KonqSessionDlg( KonqViewManager *manager, QWidget *parent )
    : KDialog( parent )
    , d( new KonqSessionDlgPrivate( manager, this ) )
{
    d->layout()->setMargin( 0 );
    setMainWidget( d );
    
    setObjectName( QLatin1String( "konq_session_dialog" ) );
    setModal( true );
    setCaption( i18nc( "@title:window", "Manage Sessions" ) );
    setButtons( BTN_OPEN | Close );
    setDefaultButton( Close );
    
    setButtonGuiItem( BTN_OPEN, KGuiItem( i18n( "&Open" ), "document-open" ) );
    d->m_pSaveCurrentButton->setIcon(KIcon("document-save"));
    d->m_pRenameButton->setIcon(KIcon("edit-rename"));
    d->m_pDeleteButton->setIcon(KIcon("edit-delete"));
    d->m_pNewButton->setIcon(KIcon("document-new"));
    
    QString dir = KStandardDirs::locateLocal("appdata", "sessions/");
    
    d->m_pModel = new KDirModel(d->m_pListView);
    d->m_pModel->sort(QDir::Name);
    d->m_pModel->dirLister()->setDirOnlyMode(true);
    d->m_pModel->dirLister()->openUrl(dir);
    d->m_pListView->setModel(d->m_pModel);
    
    d->m_pListView->setMinimumSize( d->m_pListView->sizeHint() );
    
    connect( d->m_pListView->selectionModel(), SIGNAL( selectionChanged(
        const QItemSelection  &, const QItemSelection &) ), this, SLOT(
        slotSelectionChanged() ) );
    
    enableButton( BTN_OPEN, d->m_pListView->currentIndex().isValid() );
    slotSelectionChanged();

    d->m_pOpenTabsInsideCurrentWindow->setChecked(
	KonqSettings::openTabsInsideCurrentWindow());

    connect( this,SIGNAL(user1Clicked()),SLOT(slotOpen()));
    connect( d->m_pNewButton, SIGNAL(clicked()),SLOT(slotNew()));
    connect( d->m_pSaveCurrentButton, SIGNAL(clicked()),SLOT(slotSave()));
    connect( d->m_pRenameButton, SIGNAL(clicked()),SLOT(slotRename()));
    connect( d->m_pDeleteButton, SIGNAL(clicked()),SLOT(slotDelete()));
    
    resize( sizeHint() );
}
Ejemplo n.º 4
0
void MainWindow::setupAction()
{
    actionCollection()->addAction( KStandardAction::Close, "file_close", this, SLOT(slotClose()) );
    actionCollection()->addAction( KStandardAction::New, "file_new", this, SLOT(slotNew()) );
    actionCollection()->addAction( KStandardAction::Open, "file_open", this, SLOT(slotOpen()) );

    QAction *previewAction = actionCollection()->addAction("file_preview", this, SLOT(slotPreview()));
    previewAction->setIcon(QIcon::fromTheme(QLatin1String("document-preview")));
    previewAction->setText(i18n("Preview"));
    previewAction->setCheckable(true);
    actionCollection()->setDefaultShortcut(previewAction, QKeySequence("F8"));
    
    QAction *splitAction = actionCollection()->addAction("window_split", this, SLOT(slotSplit()));
    splitAction->setIcon(QIcon::fromTheme(QLatin1String("view-split-left-right")));
    splitAction->setText(i18n("Split"));
    splitAction->setCheckable(true);

    m_recentFiles = KStandardAction::openRecent(this, SLOT(slotOpen(QUrl)), this);
    actionCollection()->addAction(m_recentFiles->objectName(), m_recentFiles);
    m_recentFiles->setWhatsThis(i18n("This lists files which you have opened recently, and allows you to easily open them again."));
}
Ejemplo n.º 5
0
imageViewer::imageViewer(QWidget *parent): QLabel(parent)
{
  addToLog("image creation",LOGIMAG);
  validImage=false;
  setFrameStyle(QFrame::Sunken | QFrame::Panel);
  QBrush b;
  QPalette palette;
  b.setTexture(QPixmap::fromImage(QImage(":/icons/transparency.png")));
  palette.setBrush(QPalette::Active,QPalette::Base,b);
  palette.setBrush(QPalette::Inactive,QPalette::Base,b);
  palette.setBrush(QPalette::Disabled,QPalette::Base,b);
  setPalette(palette);
  setBackgroundRole(QPalette::Base);
  setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);

  setBackgroundRole(QPalette::Dark);

  popup=new QMenu (this);
  newAct = new QAction(tr("&New"),this);
  connect(newAct, SIGNAL(triggered()), this, SLOT(slotNew()));
  loadAct = new QAction(tr("&Load"), this);
  connect(loadAct, SIGNAL(triggered()), this, SLOT(slotLoad()));
  toTXAct = new QAction(tr("&To TX"), this);
  connect(toTXAct, SIGNAL(triggered()), this, SLOT(slotToTX()));
  editAct = new QAction(tr("&Edit"), this);
  connect(editAct, SIGNAL(triggered()), this, SLOT(slotEdit()));
  printAct = new QAction(tr("&Print"), this);
  connect(printAct, SIGNAL(triggered()), this, SLOT(slotPrint()));
  deleteAct = new QAction(tr("&Delete"), this);
  connect(deleteAct, SIGNAL(triggered()), this, SLOT(slotDelete()));
  viewAct = new QAction(tr("&View"), this);
  connect(viewAct, SIGNAL(triggered()), this, SLOT(slotView()));
  propertiesAct = new QAction(tr("Propert&ies"), this);
  connect(propertiesAct, SIGNAL(triggered()), this, SLOT(slotProperties()));
  connect(configDialogPtr,SIGNAL(bgColorChanged()), SLOT(slotBGColorChanged()));

  init(RXIMG);
  activeMovie=false;
  //
}
void MainWindow::createActions()       	//创建主窗体的所有动作
{
    newAct = new QAction(tr("新建"),this);
    clearAct = new QAction(tr("清除"),this);
    exitAct = new QAction(tr("退出"),this);
    addEllipseItemAct = new QAction(tr("加入 椭圆"),this);
    addPolygonItemAct = new QAction(tr("加入 多边形"),this);
    addTextItemAct = new QAction(tr("加入 文字"),this);
    addRectItemAct = new QAction(tr("加入 长方形"),this);
    addAlphaItemAct = new QAction(tr("加入 透明图片"),this);
    addFlashItemAct = new QAction(tr("加入 闪烁圆"),this);
    addAnimItemAct = new QAction(tr("加入 星星"),this);

    connect(newAct,SIGNAL(triggered()),this,SLOT(slotNew()));
    connect(clearAct,SIGNAL(triggered()),this,SLOT(slotClear()));
    connect(exitAct,SIGNAL(triggered()),this,SLOT(close()));
    connect(addEllipseItemAct,SIGNAL(triggered()),this,SLOT (slotAddEllipseItem()));
    connect(addPolygonItemAct,SIGNAL(triggered()),this,SLOT (slotAddPolygonItem()));
    connect(addTextItemAct,SIGNAL(triggered()),this,SLOT (slotAddTextItem()));
    connect(addRectItemAct,SIGNAL(triggered()),this,SLOT (slotAddRectItem()));
    connect(addAlphaItemAct,SIGNAL(triggered()),this,SLOT (slotAddAlphaItem()));
    connect(addFlashItemAct,SIGNAL(triggered()),this,SLOT(slotAddFlashItem()));
    connect(addAnimItemAct,SIGNAL(triggered()),this,SLOT(slotAddAnimationItem()));
}
Ejemplo n.º 7
0
//-----------------------------------------------------------------------------
SplashInstaller::SplashInstaller (QWidget *aParent, const char *aName, bool aInit)
  : QWidget(aParent), mGui(!aInit)
{
  setObjectName(aName);
  KGlobal::dirs()->addResourceType("ksplashthemes", "data", "ksplash/Themes");

  if (!mGui)
    return;

  QHBoxLayout* hbox = new QHBoxLayout( this );
  hbox->setMargin( 0 );

  QVBoxLayout* leftbox = new QVBoxLayout(  );
  hbox->addLayout( leftbox );
  hbox->setStretchFactor( leftbox, 1 );

  mThemesList = new ThemeListBox(this);
  mThemesList->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Expanding );
  connect(mThemesList, SIGNAL(currentRowChanged(int)), SLOT(slotSetTheme(int)));
  connect(mThemesList, SIGNAL(filesDropped(KUrl::List)), SLOT(slotFilesDropped(KUrl::List)));
  leftbox->addWidget(mThemesList);

  mBtnNew = new KPushButton( KIcon("get-hot-new-stuff"), i18n("Get New Themes..."), this );
  mBtnNew->setToolTip(i18n("Get new themes from the Internet"));
  mBtnNew->setWhatsThis(i18n("You need to be connected to the Internet to use this action. A dialog will display a list of themes from the http://www.kde.org website. Clicking the Install button associated with a theme will install this theme locally."));
  leftbox->addWidget( mBtnNew );
  connect(mBtnNew, SIGNAL(clicked()), SLOT(slotNew()));

  mBtnAdd = new KPushButton( KIcon("document-import"), i18n("Install Theme File..."), this );
  mBtnAdd->setToolTip(i18n("Install a theme archive file you already have locally"));
  mBtnAdd->setWhatsThis(i18n("If you already have a theme archive locally, this button will unpack it and make it available for KDE applications"));
  leftbox->addWidget( mBtnAdd );
  connect(mBtnAdd, SIGNAL(clicked()), SLOT(slotAdd()));

  mBtnRemove = new KPushButton( KIcon("edit-delete"), i18n("Remove Theme"), this );
  mBtnRemove->setToolTip(i18n("Remove the selected theme from your disk"));
  mBtnRemove->setWhatsThis(i18n("This will remove the selected theme from your disk."));
  mBtnRemove->setEnabled( false );
  leftbox->addWidget( mBtnRemove );
  connect(mBtnRemove, SIGNAL(clicked()), SLOT(slotRemove()));

  mBtnTest = new KPushButton( KIcon("document-preview"), i18n("Test Theme"), this );
  mBtnTest->setToolTip(i18n("Test the selected theme"));
  mBtnTest->setWhatsThis(i18n("This will test the selected theme."));
  mBtnTest->setEnabled( false );
  leftbox->addWidget( mBtnTest );
  connect(mBtnTest, SIGNAL(clicked()), SLOT(slotTest()));

  QVBoxLayout* rightbox = new QVBoxLayout(  );
  hbox->addLayout( rightbox );
  hbox->setStretchFactor( rightbox, 3 );

  QScrollArea* scrollarea = new QScrollArea(this);
  scrollarea->setAlignment(Qt::AlignHCenter|Qt::AlignVCenter);
  mPreview = new QLabel(this);
  scrollarea->setWidget(mPreview);
  mPreview->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding );
  mPreview->setMinimumSize(QSize(320,240));
  mPreview->setAlignment(Qt::AlignHCenter|Qt::AlignVCenter);
  rightbox->addWidget(scrollarea);
  rightbox->setStretchFactor( scrollarea, 3 );

  mText = new QTextEdit(this);
  mText->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Preferred );
  mText->setMinimumSize(mText->sizeHint().width(), 7 * mText->fontMetrics().height());
  mText->setReadOnly(true);
  rightbox->addWidget(mText);
  rightbox->setStretchFactor( mText, 1 );


  readThemesList();
  load();
}
PolicyEditorClass::PolicyEditorClass(int argc, char** argv, Miro::Client& _client) :
  QMainWindow(NULL, "PolicyEditor"),
  client_(_client),
  miroRoot_(getenv("MIRO_ROOT")),
  policyFileName_("_"),
  robot_(getenv("HOST"))
{
  resize(600, 500);

  //-----------//
  // init menu //
  //-----------//

  // file menu
  QPopupMenu* MenuFile = new QPopupMenu();
  menuBar()->insertItem("&File", MenuFile);

  MenuFile->insertItem("New",         this, SLOT(slotNew()));
  MenuFile->insertItem("Open ...",    this, SLOT(slotLoad()));
  MenuFile->insertItem("Save",        this, SLOT(slotSave())); 
  MenuFile->insertItem("Save As ...", this, SLOT(slotSaveAs()));
  MenuFile->insertSeparator();
  MenuFile->insertItem("Send to ...", this, SLOT(slotSendTo()));
  MenuFile->insertSeparator();
  MenuFile->insertItem("Quit",        this, SLOT(quit()));

  // options menue
  QPopupMenu* MenuOptions = new QPopupMenu();
  menuBar()->insertItem("&Options", MenuOptions);

  //MenuOptions->insertItem("&Configuration ..",  this, SLOT(slotConfiguration()));
  //  MenuEdit->insertItem("Add Basic Behaviour ..", this, NULL);
  MenuOptions->insertItem("&Behaviour-Description-Filename..", this, SLOT(getBehaviourDescriptionFileName()));
  MenuOptions->insertItem("&Load Behaviour-Description-Filename..", this, SLOT(setBehaviourDescriptionFileName()));


  // help menu
  QPopupMenu* MenuHelp = new QPopupMenu();
  menuBar()->insertSeparator();
  menuBar()->insertItem("&Help", MenuHelp);
  
  MenuHelp->insertItem("About PolicyEditor", this, SLOT(slotAbout()));
  MenuHelp->insertItem("About Qt",           this, SLOT(slotAboutQt()));
  

  //---------------//
  // init document //
  //---------------//

  // load database file
  document_.loadDatabase("behaviours.dat");
  document_.setModified(false);

  // if given -> load policy file
  if (argc > 1) {
    document_.loadXML(argv[1]);
    policyFileName_=argv[1];
    statusBar()->message(policyFileName_+" geladen!", 1000);
  }
  else {
    document_.loadXML(miroRoot_ + "/etc/PolicyEditorNewFile.xml");
    document_.setModified(false);

    setCaption("new document");
    policyFileName_="_";
    QString message;
    message.sprintf("New document opend");
    statusBar()->message(message, 3000);
  }

  //-----------//
  // init view //
  //-----------//
  view_ = new PolicyViewClass(this, document_);
  setCentralWidget(view_);

#ifdef ASDF
  // load pattern database //
  QMessageBox::information(this, "Policy Editor", "Hallo,\n\nfirst, you have to select your\nbehaviour database ...");
  QString filename = QFileDialog::getOpenFileName(0, "*.dat", this);
  if (filename.isNull()) 
  { 
    std::cout << "database must be chosen !" << std::endl; 
    exit(0); 
  }
  document_.LoadDatabase(string(filename));
#endif
 
}
Ejemplo n.º 9
0
    QPushButton *cancelButton = new QPushButton();
    KGuiItem::assign(cancelButton, KStandardGuiItem::quit());
    connect(cancelButton, SIGNAL(clicked()), this, SLOT(slotCancel()));
    buttonBox->addButton(cancelButton, QDialogButtonBox::RejectRole);

    m_openButton = new QPushButton(QIcon::fromTheme(QStringLiteral("document-open")), i18n("Open Session"));
    m_openButton->setEnabled(m_sessions->currentIndex().isValid());
    m_openButton->setDefault(true);
    m_openButton->setFocus();
    buttonBox->addButton(m_openButton, QDialogButtonBox::ActionRole);
    connect(m_openButton, SIGNAL(clicked()), this, SLOT(slotOpen()));

    QPushButton *newButton = new QPushButton(QIcon::fromTheme(QStringLiteral("document-new")), i18n("New Session"));
    buttonBox->addButton(newButton, QDialogButtonBox::ActionRole);
    connect(newButton, SIGNAL(clicked()), this, SLOT(slotNew()));

    setResult(resultNone);
    selectionChanged(NULL, NULL);
}

KateSessionChooser::~KateSessionChooser()
{}

void KateSessionChooser::slotCopySession()
{
    m_sessions->setCurrentItem((KateSessionChooserItem *)((QAction *)sender())->data().value<void *>());
    Q_ASSERT(static_cast<KateSessionChooserItem *>(m_sessions->currentItem()));
    done(resultCopy);
}
Ejemplo n.º 10
0
OFileViewFileListView::OFileViewFileListView( QWidget* parent, const QString& startDir,
        OFileSelector* sel)
    : QWidget( parent ), m_sel( sel ) {
    m_all = false;
    QVBoxLayout* lay = new QVBoxLayout( this );
    m_currentDir = startDir;

    /*
     * now we add a special bar
     * One Button For Up
     * Home
     * Doc
     * And a dropdown menu with FileSystems
     * FUTURE: one to change dir with lineedit
     * Bookmarks
     * Create Dir
     */
    QHBox* box = new QHBox(this );
    box->setBackgroundMode( PaletteButton );
    box->setSpacing( 0 );

    QToolButton *btn = new QToolButton( box );
    btn->setIconSet( Resource::loadIconSet("up") );
    connect(btn, SIGNAL(clicked() ),
            this, SLOT( cdUP() ) );

    btn = new QToolButton( box );
    btn->setIconSet( Resource::loadIconSet("home") );
    connect(btn, SIGNAL(clicked() ),
            this, SLOT( cdHome() ) );

    btn = new QToolButton( box );
    btn->setIconSet( Resource::loadIconSet("DocsIcon") );
    connect(btn, SIGNAL(clicked() ),
            this, SLOT(cdDoc() ) );

    m_btnNew = new QToolButton( box );
    m_btnNew->setIconSet( Resource::loadIconSet("new") );
    connect(m_btnNew, SIGNAL(clicked() ),
            this, SLOT(slotNew() ) );


    m_btnClose = new QToolButton( box );
    m_btnClose->setIconSet( Resource::loadIconSet("close") );
    connect(m_btnClose, SIGNAL(clicked() ),
            selector(), SIGNAL(closeMe() ) );

    btn = new QToolButton( box );
    btn->setIconSet( Resource::loadIconSet("pcmcia") );

    /* let's fill device parts */
    QPopupMenu* pop = new QPopupMenu(this);
    connect(pop, SIGNAL( activated(int) ),
            this, SLOT(slotFSActivated(int) ) );

    StorageInfo storage;
    const QList<FileSystem> &fs = storage.fileSystems();
    QListIterator<FileSystem> it(fs);
    for ( ; it.current(); ++it ) {
        const QString disk = (*it)->name();
        const QString path = (*it)->path();
        m_dev.insert( disk, path );
        pop->insertItem( disk );
    }
    m_fsPop = pop;


    btn->setPopup( pop );

    lay->addWidget( box );

    m_view = new QListView( this );

    m_view->installEventFilter(this);

    QPEApplication::setStylusOperation( m_view->viewport(),
                                        QPEApplication::RightOnHold);
    m_view->addColumn(" " );
    m_view->addColumn(tr("Name"), 135 );
    m_view->addColumn(tr("Size"), -1 );
    m_view->addColumn(tr("Date"), 60 );
    m_view->addColumn(tr("Mime Type"), -1 );


    m_view->setSorting( 1 );
    m_view->setAllColumnsShowFocus( TRUE );

    lay->addWidget( m_view, 1000 );
    connectSlots();
}
Ejemplo n.º 11
0
void KWrite::setupActions()
{
    m_closeAction = actionCollection()->addAction(KStandardAction::Close, QStringLiteral("file_close"), this, SLOT(slotFlush()));
    m_closeAction->setWhatsThis(i18n("Use this command to close the current document"));
    m_closeAction->setDisabled(true);

    // setup File menu
    actionCollection()->addAction(KStandardAction::New, QStringLiteral("file_new"), this, SLOT(slotNew()))
    ->setWhatsThis(i18n("Use this command to create a new document"));
    actionCollection()->addAction(KStandardAction::Open, QStringLiteral("file_open"), this, SLOT(slotOpen()))
    ->setWhatsThis(i18n("Use this command to open an existing document for editing"));

    m_recentFiles = KStandardAction::openRecent(this, SLOT(slotOpen(QUrl)), this);
    actionCollection()->addAction(m_recentFiles->objectName(), m_recentFiles);
    m_recentFiles->setWhatsThis(i18n("This lists files which you have opened recently, and allows you to easily open them again."));

    QAction *a = actionCollection()->addAction(QStringLiteral("view_new_view"));
    a->setIcon(QIcon::fromTheme(QStringLiteral("window-new")));
    a->setText(i18n("&New Window"));
    connect(a, SIGNAL(triggered()), this, SLOT(newView()));
    a->setWhatsThis(i18n("Create another view containing the current document"));

    actionCollection()->addAction(KStandardAction::Quit, this, SLOT(close()))
    ->setWhatsThis(i18n("Close the current document view"));

    // setup Settings menu
    setStandardToolBarMenuEnabled(true);

    m_paShowMenuBar = KStandardAction::showMenubar(this, SLOT(toggleMenuBar()), actionCollection());

    m_paShowStatusBar = KStandardAction::showStatusbar(this, SLOT(toggleStatusBar()), this);
    actionCollection()->addAction(m_paShowStatusBar->objectName(), m_paShowStatusBar);
    m_paShowStatusBar->setWhatsThis(i18n("Use this command to show or hide the view's statusbar"));

    m_paShowPath = new KToggleAction(i18n("Sho&w Path in Titlebar"), this);
    actionCollection()->addAction(QStringLiteral("set_showPath"), m_paShowPath);
    connect(m_paShowPath, SIGNAL(triggered()), this, SLOT(documentNameChanged()));
    m_paShowPath->setWhatsThis(i18n("Show the complete document path in the window caption"));

    a = actionCollection()->addAction(KStandardAction::KeyBindings, this, SLOT(editKeys()));
    a->setWhatsThis(i18n("Configure the application's keyboard shortcut assignments."));

    a = actionCollection()->addAction(KStandardAction::ConfigureToolbars, QStringLiteral("options_configure_toolbars"),
                                      this, SLOT(editToolbars()));
    a->setWhatsThis(i18n("Configure which items should appear in the toolbar(s)."));

    a = actionCollection()->addAction(QStringLiteral("help_about_editor"));
    a->setText(i18n("&About Editor Component"));
    connect(a, SIGNAL(triggered()), this, SLOT(aboutEditor()));
}
Ejemplo n.º 12
0
registerABE::registerABE (QWidget *parent, const NV_CHAR *name, NV_INT32 key, const NV_CHAR *file, QSharedMemory **abeRegister,
			  ABE_REGISTER **abe_register):
  QDialog (parent, (Qt::WindowFlags) Qt::WA_DeleteOnClose)
{
  member_id = key;
  strcpy (member_name, name);
  if (file == NULL)
    {
      strcpy (member_file, "N/A");
    }
  else
    {
      strcpy (member_file, file);
    }
  selected = 0;


  setModal (TRUE);


  //  Grab or create the memory block.

  QString skey;
#ifdef NVWIN3X
  skey.sprintf ("%d", windows_getuid ());
#else
  skey.sprintf ("%d", getuid ());
#endif

  *abeRegister = new QSharedMemory (skey);

  NV_BOOL attached = NVFalse;

  if (!(*abeRegister)->create (sizeof (ABE_REGISTER), QSharedMemory::ReadWrite))
    {
      (*abeRegister)->attach (QSharedMemory::ReadWrite);
      attached = NVTrue;
    }
  abeRegister_ptr = *abeRegister;


  //  Lock this while we're working with it.

  abeRegister_ptr->lock ();


  *abe_register = (ABE_REGISTER *) (*abeRegister)->data ();


  //  It's easier to deal with a pointer than (*abe_register)->

  abe_register_ptr = *abe_register;


  //  If we created the ABE_REGISTER memory block we need to clear it.

  if (!attached)
    {
      //  Clear the block.

      for (NV_INT32 i = 0 ; i < MAX_ABE_GROUPS ; i++)
	{
	  abe_register_ptr->group[i] = NVFalse;
	  abe_register_ptr->member_count[i] = 0;
	  memset (&abe_register_ptr->data[i], 0, sizeof (ABE_REGISTER_DATA));


	  //  Clear the members.

	  for (NV_INT32 j = 0 ; j < MAX_ABE_MEMBERS ; j++)
	    {
	      abe_register_ptr->member[i][j].key = 0;
	      strcpy (abe_register_ptr->member[i][j].name, "N/A");
	      strcpy (abe_register_ptr->member[i][j].file, "N/A");
	    }
	}


      //  Unlock when we're done.

      abeRegister_ptr->unlock ();
    }


  setWindowTitle (tr ("registerABE process table"));


  setSizeGripEnabled (TRUE);


  QVBoxLayout *vbox = new QVBoxLayout (this);
  vbox->setMargin (5);
  vbox->setSpacing (5);


#ifdef NVLinux

  //  On Linux we need to make sure that all processes listed in the ABE_REGISTER are actually
  //  still running.  See the check_dead_processes function for an explanation and caveats.

  check_dead_processes ();

#endif


  //  Search for available groups.

  NV_INT32 count = 0;
  NV_INT32 max_members = 0;

  for (NV_INT32 i = 0 ; i < MAX_ABE_GROUPS ; i++)
    {
      if (abe_register_ptr->group[i])
	{
	  available_group[count] = i;
	  max_members = qMax (max_members, abe_register_ptr->member_count[i]);
	  count++;
	}
    }


  processTable = new QTableWidget (count, 2 + max_members * 2, this);
  processTable->setToolTip (tr ("Connect to another group's shared memory, create a new group, or <b>Cancel</b>"));
  processTable->setWhatsThis (tr ("Use this table to select a group of ABE applications with which "
				  "to share information.  If there are no available groups or you wish to create "
				  "a new group you may use the <b>New group</b> button to do so.  If you don't "
				  "want to connect to an existing group or create a new group, use the "
				  "<b>Cancel</b> button."));
  processTable->setAlternatingRowColors (TRUE);
  QTableWidgetItem *aItem = new QTableWidgetItem (tr ("Connect"));
  processTable->setHorizontalHeaderItem (0, aItem);
  aItem->setTextAlignment (Qt::AlignHCenter);
  QTableWidgetItem *pItem = new QTableWidgetItem (tr ("Group #"));
  processTable->setHorizontalHeaderItem (1, pItem);
  pItem->setTextAlignment (Qt::AlignHCenter);


  QTableWidgetItem *hItem[max_members * 2];
  for (NV_INT32 i = 0 ; i < max_members * 2 ; i += 2)
    {
      QString tmp = QString (tr ("Application %1")).arg (i / 2);
      hItem[i] = new QTableWidgetItem (tmp);
      processTable->setHorizontalHeaderItem (i + 2, hItem[i]);
      hItem[i]->setTextAlignment (Qt::AlignHCenter);

      hItem[i + 1] = new QTableWidgetItem (tr ("File"));
      processTable->setHorizontalHeaderItem (i + 3, hItem[i + 1]);
      hItem[i + 1]->setTextAlignment (Qt::AlignHCenter);
    }


  QCheckBox *join_group[count];


  processGrp = new QButtonGroup (this);
  processGrp->setExclusive (TRUE);


  for (NV_INT32 i = 0 ; i < count ; i++)
    {
      join_group[i] = new QCheckBox (this);
      processTable->setCellWidget (i, 0, join_group[i]);
      processGrp->addButton (join_group[i], i);
      join_group[i]->setCheckState (Qt::Unchecked);


      QString tmp;

      tmp.sprintf ("%02d", available_group[i]);
      QTableWidgetItem *pI = new QTableWidgetItem (tmp);
      processTable->setItem (i, 1, pI);


      NV_INT32 memcount = 0;
      for (NV_INT32 j = 0 ; j < MAX_ABE_MEMBERS ; j++)
	{
	  if (abe_register_ptr->member[available_group[i]][j].key)
	    {
	      QTableWidgetItem *nI = new QTableWidgetItem (QString (abe_register_ptr->member[available_group[i]][j].name));
	      processTable->setItem (i, memcount + 2, nI);

	      QTableWidgetItem *fI = new QTableWidgetItem (QString (abe_register_ptr->member[available_group[i]][j].file));
	      processTable->setItem (i, memcount + 3, fI);

	      memcount += 2;
	    }
	}
      processTable->resizeColumnsToContents ();
      processTable->resizeRowsToContents ();
    }

  vbox->addWidget (processTable, 0, 0);


  //  Connect after populating table so the slot doesn't get called.

  connect (processGrp, SIGNAL (buttonClicked (int)), this, SLOT (slotValueChanged (int)));


  resize (800, 600);


  processTable->show ();


  QHBoxLayout *actions = new QHBoxLayout (0);
  vbox->addLayout (actions);

  QPushButton *bHelp = new QPushButton (this);
  bHelp->setIcon (QIcon (":/icons/contextHelp.xpm"));
  bHelp->setToolTip (tr ("Enter What's This mode for help"));
  connect (bHelp, SIGNAL (clicked ()), this, SLOT (slotHelp ()));
  actions->addWidget (bHelp);

  actions->addStretch (10);

  QPushButton *newButton = new QPushButton (tr ("New group"), this);
  newButton->setToolTip (tr ("Create a new group and close dialog"));
  connect (newButton, SIGNAL (clicked ()), this, SLOT (slotNew ()));
  actions->addWidget (newButton);

  QPushButton *applyButton = new QPushButton (tr ("Apply"), this);
  applyButton->setToolTip (tr ("Connect to selected process and close dialog"));
  connect (applyButton, SIGNAL (clicked ()), this, SLOT (slotApply ()));
  actions->addWidget (applyButton);

  QPushButton *closeButton = new QPushButton (tr ("Cancel"), this);
  closeButton->setToolTip (tr ("Discard selection and close dialog"));
  connect (closeButton, SIGNAL (clicked ()), this, SLOT (slotClose ()));
  actions->addWidget (closeButton);

  show ();
}