Ejemplo n.º 1
0
QucsEdit::QucsEdit(const QString& FileName_, bool readOnly)
{
  // set application icon
  setIcon (QPixmap(QucsSettings.BitmapDir + "big.qucs.xpm"));
  setCaption("Qucs Editor " PACKAGE_VERSION " - " + tr("File: "));

  QVBoxLayout *v = new QVBoxLayout(this);

  QHBox *h = new QHBox(this);
  v->addWidget(h);

  QToolButton *ButtLoad = new QToolButton(h);
  ButtLoad->setIconSet(
	    QIconSet(QImage(QucsSettings.BitmapDir + "fileopen.png")));
  connect(ButtLoad, SIGNAL(clicked()), SLOT(slotLoad()));

  QToolButton *ButtSave = new QToolButton(h);
  ButtSave->setIconSet(
            QIconSet(QImage(QucsSettings.BitmapDir + "filesave.png")));
  connect(ButtSave, SIGNAL(clicked()), SLOT(slotSave()));
  ButtSave->setDisabled(readOnly);

  h->setStretchFactor(new QWidget(h),5); // stretchable placeholder
  PosText = new QLabel(tr("Line: %1  -  Column: %2").arg(1).arg(1), h);
  h->setStretchFactor(new QWidget(h),5); // stretchable placeholder

  QPushButton *ButtAbout = new QPushButton(tr("About"),h);
  connect(ButtAbout, SIGNAL(clicked()), SLOT(slotAbout()));

  QPushButton *ButtOK = new QPushButton(tr("Quit"),h);
  connect(ButtOK, SIGNAL(clicked()), SLOT(slotQuit()));
  ButtOK->setFocus();

  // try using same-sized mono-spaced font in the textarea
  QFont fedit = QFont("Courier New");
  fedit.setPointSize(QucsSettings.font.pointSize()-1);
  fedit.setStyleHint(QFont::Courier);
  fedit.setFixedPitch(true);

  text = new QTextEdit(this);
  text->setTextFormat(Qt::PlainText);
  text->setReadOnly(readOnly);
  text->setWordWrap(QTextEdit::NoWrap);
  text->setMinimumSize(300,200);
  text->setFont(fedit);
  text->setCurrentFont(fedit);
  v->addWidget(text);
  connect(text, SIGNAL(cursorPositionChanged(int, int)),
          SLOT(slotPrintCursorPosition(int, int)));

  // .................................................
  loadFile(FileName_);
}
Ejemplo n.º 2
0
void PreferencesDialog::addFontOverride( const QString& language ) {
    // Do nothing if the font override already exists.
    int fontOverrideCount = fontOverrideLabels.count();
    for( int i = 0; i < fontOverrideCount; i++ ) {
        if( fontOverrideLabels.at( i )->text() == QObject::tr( language ) )
            return;
    }
    
    QHBox* fontOverrideBox = new QHBox( fontOverridesBox );
    fontOverrideBox->setSpacing( 2 );
    fontOverrideBox->setMargin( 2 );
    QLabel* fontOverrideLabel = new QLabel( QObject::tr( language ), fontOverrideBox );
    QComboBox* fontOverrideFamilyComboBox = new QComboBox( fontOverrideBox );
    initFontFamilyValues( fontOverrideFamilyComboBox, true );
    if( prefs->isFontOverrideFamilyDefined( language ) ) 
        selectFontFamily( fontOverrideFamilyComboBox, prefs->getFontOverrideFamily( language ) );
    QComboBox* fontOverrideSizeComboBox = new QComboBox( fontOverrideBox );
    initFontSizeValues( fontOverrideSizeComboBox, true );
    if( prefs->isFontOverrideSizeDefined( language ) ) 
        selectFontSize( fontOverrideSizeComboBox, prefs->getFontOverrideSize( language ), true );
    fontOverrideBox->setStretchFactor( fontOverrideLabel, 1 );

    fontOverrideBoxes.append( fontOverrideBox );
    fontOverrideLabels.append( fontOverrideLabel );
    fontOverrideFamilyComboBoxes.append( fontOverrideFamilyComboBox );
    fontOverrideSizeComboBoxes.append( fontOverrideSizeComboBox );

    int indexOfFiller = fontOverridesBoxLayout->findWidget( fontOverridesBoxFiller );
    fontOverridesBoxLayout->insertWidget( indexOfFiller, fontOverrideBox ); 
}
Ejemplo n.º 3
0
void PreferencesDialog::initFontOverrides() {
    QValueList<QString> lang( prefs->getStudyLanguages() );
    int i = 0;
    for( QValueList<QString>::ConstIterator it = lang.begin(); it != lang.end(); it++, i++ ) {
        QString language( *it );
        QHBox* fontOverrideBox = new QHBox( fontOverridesBox );
        fontOverrideBox->setSpacing( 2 );
        fontOverrideBox->setMargin( 2 );
        QLabel* fontOverrideLabel = new QLabel( QObject::tr( language ), fontOverrideBox );
        QComboBox* fontOverrideFamilyComboBox = new QComboBox( fontOverrideBox );
        initFontFamilyValues( fontOverrideFamilyComboBox, true );
        if( prefs->isFontOverrideFamilyDefined( language ) ) 
            selectFontFamily( fontOverrideFamilyComboBox, prefs->getFontOverrideFamily( language ) );
        QComboBox* fontOverrideSizeComboBox = new QComboBox( fontOverrideBox );
        initFontSizeValues( fontOverrideSizeComboBox, true );
        if( prefs->isFontOverrideSizeDefined( language ) ) 
            selectFontSize( fontOverrideSizeComboBox, prefs->getFontOverrideSize( language ), true );
        fontOverrideBox->setStretchFactor( fontOverrideLabel, 1 );

        fontOverrideBoxes.append( fontOverrideBox );
        fontOverrideLabels.append( fontOverrideLabel );
        fontOverrideFamilyComboBoxes.append( fontOverrideFamilyComboBox );
        fontOverrideSizeComboBoxes.append( fontOverrideSizeComboBox );

        fontOverridesBoxLayout->addWidget( fontOverrideBox, 0 );
    }
    fontOverridesBoxFiller = new QWidget( fontOverridesBox );
    fontOverridesBoxLayout->addWidget( fontOverridesBoxFiller, 1 );
}
Ejemplo n.º 4
0
HelpDialog::HelpDialog(QWidget *parent)
                     : QDialog(parent, 0, false, Qt::WDestructiveClose)
{
  setCaption(tr("Qucs Attenuator Help"));


  // --------  set help text into dialog  ------------
  QString s(tr("QucsAttenuator is an attenuator synthesis program. "
	       "To create a attenuator, simply enter all "
	       "the input parameters and press the calculation button. "
	       "Immediatly, the "
	       "schematic of the attenuator is calculated and "
	       "put into the clipboard. Now go to Qucs, "
	       "open an schematic and press "
	       "CTRL-V (paste from clipboard). The attenuator "
	       "schematic can now be inserted. "
	       "Have lots of fun!"));


  // --------  create dialog widgets  ------------
  resize(250, 230);

  vLayout = new QVBoxLayout(this);

  Text = new QTextEdit(s, QString::null, this);
  Text->setTextFormat(Qt::PlainText);
  Text->setReadOnly(true);
//  Text->setWordWrap(QTextEdit::NoWrap);
  Text->setMinimumSize(200,200);
  vLayout->addWidget(Text);

  QHBox *h = new QHBox(this);
  vLayout->addWidget(h);

  h->setStretchFactor(new QWidget(h),5); // stretchable placeholder

  QPushButton *ButtonClose = new QPushButton(tr("Close"), h);
  connect(ButtonClose, SIGNAL(clicked()), SLOT(slotClose()));
  ButtonClose->setFocus();

  h->setStretchFactor(new QWidget(h),5); // stretchable placeholder
}
Ejemplo n.º 5
0
// -------------------------------------------------------------------------------------------------
AboutDialog::AboutDialog(QWidget* parent, const char* name)
    throw ()
    : QDialog(parent, name)
{
     m_mainLayout = new QVBoxLayout(this, 10, 6);
    setCaption(tr("About The Fabulous Logic Analyzer"));
    
    // the top of the dialog
    QHBox* titleBox = new QHBox(this);
    QLabel* titleIcon = new QLabel(titleBox);
    titleIcon->setPixmap(QPixmap::fromMimeSource("tfla-01_32.png"));
    QLabel* titleText = new QLabel(tr("<p><b>The Fabulous Logic Analyzer "VERSION_STRING"</b></p>"),
            titleBox);
    titleBox->setStretchFactor(titleIcon, 0);
    titleBox->setStretchFactor(titleText, 5);
    titleBox->setSpacing(5);
    
    // the tab
    m_tabWidget = new QTabWidget(this);
    setupAboutTab();
    setupLicenseTab();
    
    // the ok Button
    QPushButton* okButton = new QPushButton(tr("&Close"), this, "Close button");
    okButton->setDefault(true);
    QWidget* filler = new QWidget(this);
    QHBoxLayout* buttonLayout = new QHBoxLayout(0, 0, 6);
    buttonLayout->addWidget(filler);
    buttonLayout->addWidget(okButton);
    buttonLayout->setStretchFactor(filler, 1);
    buttonLayout->setStretchFactor(okButton, 0);
    
    // main layout
    m_mainLayout->addWidget(titleBox);
    m_mainLayout->addWidget(m_tabWidget);
    m_mainLayout->addStretch(5);
    m_mainLayout->addLayout(buttonLayout);
    
    connect(okButton, SIGNAL(clicked()), SLOT(accept()));
}
Ejemplo n.º 6
0
CharacterSelectorView::CharacterSelectorView(KBCatalog* catalog,QWidget *parent, Project::Ptr project)
    : KBCatalogView(catalog,parent,project)
{
    QVBoxLayout* layout = new QVBoxLayout( this );
    layout->setResizeMode( QLayout::Minimum );

    layout->setSpacing( KDialog::spacingHint() );
    
    QHBox* bar = new QHBox(this);
    bar->setSpacing( KDialog::spacingHint() );
    layout->addWidget (bar);
    
    QLabel *lTable = new QLabel( i18n( "Table:" ), bar );
    _tableNum = new QSpinBox( 0, 255, 1, bar );
    lTable->setBuddy( _tableNum );
    bar->setStretchFactor( _tableNum, 1 );
    
    QScrollView* scroll = new QScrollView( this );    
    _table = new KCharSelectTable(scroll,"charselector","helvetica",' ',0);
    _table->setNumCols(16);
    _table->setNumRows(16);
    
    scroll->addChild(_table);
    layout->addWidget (scroll);
    
    connect( _table, SIGNAL( doubleClicked() ), this, SLOT( emitChar() ) );
    connect( _tableNum, SIGNAL( valueChanged(int) ), this, SLOT( setTab(int) ));
    
    connect( _catalog, SIGNAL( signalFileOpened(bool) ), this, SLOT (setDisabled (bool)));
    connect( _catalog, SIGNAL( signalFileOpened(bool) ), _table, SLOT (setDisabled (bool)));

    QWhatsThis::add(this,
       i18n("<qt><p><b>Character Selector</b></p>"
         "<p>This tool allows to insert special characters using "
         "double click.</p></qt>"));
}
Ejemplo n.º 7
0
FontColourChooser::FontColourChooser(QWidget *parent, const char *name,
                                     bool onlyFixed, const QStringList &fontList,
                                     const QString &frameLabel, bool editColours, bool fg, bool defaultFont,
                                     int visibleListSize)
    : QWidget(parent, name),
      mFgColourButton(0),
      mRemoveColourButton(0),
      mColourList(Preferences::messageColours()),
      mReadOnly(false)
{
    QVBoxLayout *topLayout = new QVBoxLayout(this, 0, KDialog::spacingHint());
    QWidget *page = this;
    if(!frameLabel.isNull())
    {
        page = new QGroupBox(frameLabel, this);
        topLayout->addWidget(page);
        topLayout = new QVBoxLayout(page, KDialog::marginHint(), KDialog::spacingHint());
        topLayout->addSpacing(fontMetrics().height() - KDialog::marginHint() + KDialog::spacingHint());
    }
    QHBoxLayout *hlayout = new QHBoxLayout(topLayout);
    QVBoxLayout *colourLayout = new QVBoxLayout(hlayout);
    if(fg)
    {
        QHBox *box = new QHBox(page);    // to group widgets for QWhatsThis text
        box->setSpacing(KDialog::spacingHint() / 2);
        colourLayout->addWidget(box);

        QLabel *label = new QLabel(i18n("&Foreground color:"), box);
        box->setStretchFactor(new QWidget(box), 0);
        mFgColourButton = new ColourCombo(box);
        connect(mFgColourButton, SIGNAL(activated(const QString &)), SLOT(setSampleColour()));
        label->setBuddy(mFgColourButton);
        QWhatsThis::add(box, i18n("Select the alarm message foreground color"));
    }

    QHBox *box = new QHBox(page);    // to group widgets for QWhatsThis text
    box->setSpacing(KDialog::spacingHint() / 2);
    colourLayout->addWidget(box);

    QLabel *label = new QLabel(i18n("&Background color:"), box);
    box->setStretchFactor(new QWidget(box), 0);
    mBgColourButton = new ColourCombo(box);
    connect(mBgColourButton, SIGNAL(activated(const QString &)), SLOT(setSampleColour()));
    label->setBuddy(mBgColourButton);
    QWhatsThis::add(box, i18n("Select the alarm message background color"));
    hlayout->addStretch();

    if(editColours)
    {
        QHBoxLayout *layout = new QHBoxLayout(topLayout);
        QPushButton *button = new QPushButton(i18n("Add Co&lor..."), page);
        button->setFixedSize(button->sizeHint());
        connect(button, SIGNAL(clicked()), SLOT(slotAddColour()));
        QWhatsThis::add(button, i18n("Choose a new color to add to the color selection list."));
        layout->addWidget(button);

        mRemoveColourButton = new QPushButton(i18n("&Remove Color"), page);
        mRemoveColourButton->setFixedSize(mRemoveColourButton->sizeHint());
        connect(mRemoveColourButton, SIGNAL(clicked()), SLOT(slotRemoveColour()));
        QWhatsThis::add(mRemoveColourButton,
                        i18n("Remove the color currently shown in the background color chooser, from the color selection list."));
        layout->addWidget(mRemoveColourButton);
    }

    if(defaultFont)
    {
        QHBoxLayout *layout = new QHBoxLayout(topLayout);
        mDefaultFont = new CheckBox(i18n("Use &default font"), page);
        mDefaultFont->setMinimumSize(mDefaultFont->sizeHint());
        connect(mDefaultFont, SIGNAL(toggled(bool)), SLOT(slotDefaultFontToggled(bool)));
        QWhatsThis::add(mDefaultFont,
                        i18n("Check to use the default font current at the time the alarm is displayed."));
        layout->addWidget(mDefaultFont);
        layout->addWidget(new QWidget(page));    // left adjust the widget
    }
    else
        mDefaultFont = 0;

    mFontChooser = new KFontChooser(page, name, onlyFixed, fontList, false, visibleListSize);
    mFontChooser->installEventFilter(this);   // for read-only mode
    const QObjectList *kids = mFontChooser->queryList();
    for(QObjectList::ConstIterator it = kids->constBegin();  it != kids->constEnd();  ++it)
        (*it)->installEventFilter(this);
    topLayout->addWidget(mFontChooser);

    slotDefaultFontToggled(false);
}
Ejemplo n.º 8
0
BatteryConfig::BatteryConfig (QWidget * parent, const char *name)
  : KCModule(parent, name),
    editPoll(0),
    iconloader(0),
    buttonNoBattery(0),
    buttonNoCharge(0),
    buttonCharge(0)
{
    KGlobal::locale()->insertCatalogue("klaptopdaemon"); // For translation of klaptopdaemon messages

    apm = laptop_portable::has_power_management();
    config =  new KConfig("kcmlaptoprc");
    instance = new KInstance("klaptopdaemon");

    QVBoxLayout *top_layout = new QVBoxLayout( this, KDialog::marginHint(),
					       KDialog::spacingHint() );

    // do we show the monitor
    runMonitor = new QCheckBox( i18n("&Show battery monitor"), this );
    top_layout->addWidget( runMonitor );
    QToolTip::add( runMonitor, i18n( "This box enables the battery state icon in the panel" ) );
    connect( runMonitor, SIGNAL(clicked()), this, SLOT(configChanged()) );
    connect( runMonitor, SIGNAL(clicked()), this, SLOT(runMonitorChanged()) );

    // show also the battery level percentage
    showLevel = new QCheckBox( i18n("Show battery level percentage"), this );
    top_layout->addWidget( showLevel );
    QToolTip::add( showLevel, i18n( "This box enables a text message near the battery state icon containing battery level percentage" ) );
    connect( showLevel, SIGNAL(clicked()), this, SLOT(configChanged()) );
    
    notifyMe = new QCheckBox( i18n("&Notify me whenever my battery becomes fully charged"), this );
    top_layout->addWidget( notifyMe );
    QToolTip::add( notifyMe, i18n( "This box enables a dialog box that pops up when your battery becomes fully charged" ) );
    connect( notifyMe, SIGNAL(clicked()), this, SLOT(configChanged()) );

    blankSaver = new QCheckBox( i18n("&Use a blank screen saver when running on battery"), this );
    top_layout->addWidget( blankSaver );
    connect( blankSaver, SIGNAL(clicked()), this, SLOT(configChanged()) );

    if (!apm) {
      top_layout->addWidget( laptop_portable::no_power_management_explanation(this) );
    } else {
      iconloader = new KIconLoader("klaptopdaemon");

      // the poll time (in seconds)
      QHBox *hb = new QHBox( this );
      hb->setSpacing( KDialog::spacingHint() );
      top_layout->addWidget( hb );

      QLabel* poll_label = new QLabel( i18n("&Check status every:"), hb );
      editPoll = new QSpinBox( 1, 3600, 1, hb ); // min,max,step
      QToolTip::add( editPoll, i18n( "Choose how responsive the laptop software will be when it checks the battery status" ) );
      editPoll->setSuffix( i18n("keep short, unit in spinbox", "sec") );
      poll_label->setBuddy( editPoll );
      connect( editPoll, SIGNAL(valueChanged(int)),
	       this, SLOT(configChanged()) );
      QWidget* spacer = new QWidget( hb );
      hb->setStretchFactor( spacer, 1 );

      // group box to hold the icons together
      QVGroupBox* icons_groupbox = new QVGroupBox( i18n("Select Battery Icons"), this );
      icons_groupbox->layout()->setSpacing( KDialog::spacingHint() );
      top_layout->addWidget( icons_groupbox, 0, Qt::AlignLeft );

      // layout to hold the icons inside the groupbox
      QGrid *icon_grid = new QGrid( 3 /*cols*/, icons_groupbox );
      icon_grid->setSpacing( KDialog::spacingHint() );

      buttonNoBattery = new KIconButton( iconloader, icon_grid );
      buttonNoCharge  = new KIconButton( iconloader, icon_grid );
      buttonCharge    = new KIconButton( iconloader, icon_grid );
      (void)new QLabel( buttonNoBattery, i18n("No &battery"), icon_grid);
      (void)new QLabel( buttonNoCharge, i18n("&Not charging"), icon_grid);
      (void)new QLabel( buttonCharge, i18n("Char&ging"), icon_grid);
      buttonNoBattery->setIconType( KIcon::NoGroup, KIcon::Any, 1);
      buttonNoCharge->setIconType( KIcon::NoGroup, KIcon::Any, 1);
      buttonCharge->setIconType( KIcon::NoGroup, KIcon::Any, 1);
      connect(buttonNoBattery, SIGNAL(iconChanged(QString)), this, SLOT(iconChanged()));
      connect(buttonNoCharge, SIGNAL(iconChanged(QString)), this, SLOT(iconChanged()));
      connect(buttonCharge, SIGNAL(iconChanged(QString)), this, SLOT(configChanged()));


      int num_batteries;
      QStringList battery_names, battery_states, battery_values;
      laptop_portable::get_battery_status(num_batteries, battery_names, battery_states, battery_values);
      if (num_batteries > 0) {
	    QHBoxLayout *hl = new QHBoxLayout();
	    top_layout->addLayout(hl);

	    QHGroupBox *hb = new QHGroupBox(i18n("Current Battery Status"), this);
	    for (int i = 0; i < num_batteries; i++) {

		QWidget *wp;
		if (num_batteries == 1) {
			wp = new QWidget(hb);
		} else {
			wp = new QVGroupBox(battery_names[i], hb);
		}
	    	QVBoxLayout *vb = new QVBoxLayout(wp);

		QLabel *l;

		l = new QLabel(wp);					// icon indicating state
		vb->addWidget(l);
		batt_label_1.append(l);

		l = new QLabel(QString(""), wp);
		vb->addWidget(l);
		batt_label_2.append(l);

		l = new QLabel(QString(""), wp);
		vb->addWidget(l);
		batt_label_3.append(l);
	    }	
	    hl->addWidget(hb);
	    hl->addStretch(1);
            (void)startTimer(30*1000);	// update 2x every minute
      }

      // TODO: remove linefeed from string, can't do it right now coz we have a string freeze
      QLabel* explain = new KRichTextLabel( i18n("This panel controls whether the battery status monitor\nappears in the system tray and what it looks like.").replace("\n"," "), this);
      top_layout->addWidget(explain, 0);
      laptop_portable::extra_config(this, config, top_layout);
    }

    top_layout->addStretch(1);
    startMonitor = new QPushButton( i18n("&Start Battery Monitor"), this);
    connect(startMonitor, SIGNAL(clicked()), this, SLOT(slotStartMonitor()));
    top_layout->addWidget( startMonitor, 0, Qt::AlignRight );

    load();
}
Ejemplo n.º 9
0
KateFileSelector::KateFileSelector( KateMainWindow *mainWindow,
                                    KateViewManager *viewManager,
                                    QWidget * parent, const char * name )
    : QVBox (parent, name),
      mainwin(mainWindow),
      viewmanager(viewManager)
{
  mActionCollection = new KActionCollection( this );

  QtMsgHandler oldHandler = qInstallMsgHandler( silenceQToolBar );

  KateFileSelectorToolBarParent *tbp=new KateFileSelectorToolBarParent(this);
  toolbar = new KateFileSelectorToolBar(tbp);
  tbp->setToolBar(toolbar);
  toolbar->setMovingEnabled(false);
  toolbar->setFlat(true);
  qInstallMsgHandler( oldHandler );

  cmbPath = new KURLComboBox( KURLComboBox::Directories, true, this, "path combo" );
  cmbPath->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ));
  KURLCompletion* cmpl = new KURLCompletion(KURLCompletion::DirCompletion);
  cmbPath->setCompletionObject( cmpl );
  cmbPath->setAutoDeleteCompletionObject( true );
  cmbPath->listBox()->installEventFilter( this );

  dir = new KDirOperator(KURL(), this, "operator");
  dir->setView(KFile::/* Simple */Detail);
  dir->view()->setSelectionMode(KFile::Extended);
  connect ( dir, SIGNAL( viewChanged(KFileView *) ),
                   this, SLOT( selectorViewChanged(KFileView *) ) );
  setStretchFactor(dir, 2);

  KActionCollection *coll = dir->actionCollection();
  // some shortcuts of diroperator that clashes with Kate
  coll->action( "delete" )->setShortcut( KShortcut( ALT + Key_Delete ) );
  coll->action( "reload" )->setShortcut( KShortcut( ALT + Key_F5 ) );
  coll->action( "back" )->setShortcut( KShortcut( ALT + SHIFT + Key_Left ) );
  coll->action( "forward" )->setShortcut( KShortcut( ALT + SHIFT + Key_Right ) );
  // some consistency - reset up for dir too
  coll->action( "up" )->setShortcut( KShortcut( ALT + SHIFT + Key_Up ) );
  coll->action( "home" )->setShortcut( KShortcut( CTRL + ALT + Key_Home ) );

  // bookmarks action!
  KActionMenu *acmBookmarks = new KActionMenu( i18n("Bookmarks"), "bookmark",
        mActionCollection, "bookmarks" );
  acmBookmarks->setDelayed( false );
  bookmarkHandler = new KBookmarkHandler( this, acmBookmarks->popupMenu() );
  QHBox* filterBox = new QHBox(this);

  btnFilter = new QToolButton( filterBox );
  btnFilter->setIconSet( SmallIconSet("filter" ) );
  btnFilter->setToggleButton( true );
  filter = new KHistoryCombo( true, filterBox, "filter");
  filter->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ));
  filterBox->setStretchFactor(filter, 2);
  connect( btnFilter, SIGNAL( clicked() ), this, SLOT( btnFilterClick() ) );

  connect( filter, SIGNAL( activated(const QString&) ),
                   SLOT( slotFilterChange(const QString&) ) );
  connect( filter, SIGNAL( returnPressed(const QString&) ),
           filter, SLOT( addToHistory(const QString&) ) );

  // kaction for the dir sync method
  acSyncDir = new KAction( i18n("Current Document Folder"), "curfiledir", 0,
        this, SLOT( setActiveDocumentDir() ), mActionCollection, "sync_dir" );
  toolbar->setIconText( KToolBar::IconOnly );
  toolbar->setIconSize( 16 );
  toolbar->setEnableContextMenu( false );

  connect( cmbPath, SIGNAL( urlActivated( const KURL&  )),
             this,  SLOT( cmbPathActivated( const KURL& ) ));
  connect( cmbPath, SIGNAL( returnPressed( const QString&  )),
             this,  SLOT( cmbPathReturnPressed( const QString& ) ));
  connect(dir, SIGNAL(urlEntered(const KURL&)),
             this, SLOT(dirUrlEntered(const KURL&)) );

  connect(dir, SIGNAL(finishedLoading()),
             this, SLOT(dirFinishedLoading()) );

  // enable dir sync button if current doc has a valid URL
  connect ( viewmanager, SIGNAL( viewChanged() ),
              this, SLOT( kateViewChanged() ) );

  // Connect the bookmark handler
  connect( bookmarkHandler, SIGNAL( openURL( const QString& )),
           this, SLOT( setDir( const QString& ) ) );

  waitingUrl = QString::null;

  // whatsthis help
  QWhatsThis::add( cmbPath,
       i18n("<p>Here you can enter a path for a folder to display."
            "<p>To go to a folder previously entered, press the arrow on "
            "the right and choose one. <p>The entry has folder "
            "completion. Right-click to choose how completion should behave.") );
  QWhatsThis::add( filter,
        i18n("<p>Here you can enter a name filter to limit which files are displayed."
             "<p>To clear the filter, toggle off the filter button to the left."
             "<p>To reapply the last filter used, toggle on the filter button." ) );
  QWhatsThis::add( btnFilter,
        i18n("<p>This button clears the name filter when toggled off, or "
             "reapplies the last filter used when toggled on.") );

}
Ejemplo n.º 10
0
CoverManager::CoverManager()
        : QSplitter( 0, "TheCoverManager" )
        , m_timer( new QTimer( this ) )    //search filter timer
        , m_fetchCounter( 0 )
        , m_fetchingCovers( 0 )
        , m_coversFetched( 0 )
        , m_coverErrors( 0 )
{
    DEBUG_BLOCK

    s_instance = this;

    // Sets caption and icon correctly (needed e.g. for GNOME)
    kapp->setTopWidget( this );
    setCaption( kapp->makeStdCaption( i18n("Cover Manager") ) );
    setWFlags( WDestructiveClose );
    setMargin( 4 );

    //artist listview
    m_artistView = new KListView( this );
    m_artistView->addColumn(i18n( "Albums By" ));
    m_artistView->setFullWidth( true );
    m_artistView->setSorting( -1 );    //no sort
    m_artistView->setMinimumWidth( 180 );
    KListViewItem *item = new KListViewItem( m_artistView, i18n( "All Albums" ) );
    item->setPixmap( 0, SmallIcon("cdrom_unmount") );

    //load artists from the collection db
    const QStringList artists = CollectionDB::instance()->artistList( false, false );
    foreach( artists )  {
        item = new KListViewItem( m_artistView, item, *it );
        item->setPixmap( 0, SmallIcon("personal") );
    }
    QueryBuilder qb;
    qb.addReturnValue( QueryBuilder::tabAlbum, QueryBuilder::valName );
    qb.setOptions( QueryBuilder::optOnlyCompilations | QueryBuilder::optRemoveDuplicates );
    qb.setLimit( 0, 1 );
    if ( qb.run().count() ) {
        item = new KListViewItem( m_artistView, item, i18n( "Various Artists" ) );
        item->setPixmap( 0, SmallIcon("personal") );
    }

    QVBox *vbox = new QVBox( this );
    QHBox *hbox = new QHBox( vbox );

    vbox->setSpacing( 4 );
    hbox->setSpacing( 4 );

    { //<Search LineEdit>
        QHBox *searchBox = new QHBox( hbox );
        KToolBar* searchToolBar = new Browser::ToolBar( searchBox );
        KToolBarButton *button = new KToolBarButton( "locationbar_erase", 0, searchToolBar );
        m_searchEdit = new ClickLineEdit( i18n( "Filter here..." ), searchToolBar );
        m_searchEdit->setFrame( QFrame::Sunken );

        searchToolBar->setStretchableWidget( m_searchEdit );
        connect( button, SIGNAL(clicked()), m_searchEdit, SLOT(clear()) );

        QToolTip::add( button, i18n( "Clear filter" ) );
        QToolTip::add( m_searchEdit, i18n( "Enter space-separated terms to filter albums" ) );

        hbox->setStretchFactor( searchBox, 1 );
    } //</Search LineEdit>

    // view menu
    m_viewMenu = new KPopupMenu( this );
    m_viewMenu->insertItem( i18n("All Albums"), AllAlbums );
    m_viewMenu->insertItem( i18n("Albums With Cover"), AlbumsWithCover );
    m_viewMenu->insertItem( i18n("Albums Without Cover"), AlbumsWithoutCover );
    m_viewMenu->setItemChecked( AllAlbums, true );
    connect( m_viewMenu, SIGNAL( activated(int) ), SLOT( changeView(int) ) );

    #ifdef AMAZON_SUPPORT
    // amazon locale menu
    m_amazonLocaleMenu = new KPopupMenu( this );
    m_amazonLocaleMenu->insertItem( i18n("International"), International );
    m_amazonLocaleMenu->insertItem( i18n("Canada"), Canada );
    m_amazonLocaleMenu->insertItem( i18n("France"), France );
    m_amazonLocaleMenu->insertItem( i18n("Germany"), Germany );
    m_amazonLocaleMenu->insertItem( i18n("Japan"), Japan);
    m_amazonLocaleMenu->insertItem( i18n("United Kingdom"), UK );
    connect( m_amazonLocaleMenu, SIGNAL( activated(int) ), SLOT( changeLocale(int) ) );
    #endif

    KToolBar* toolBar = new KToolBar( hbox );
    toolBar->setIconText( KToolBar::IconTextRight );
    toolBar->setFrameShape( QFrame::NoFrame );
    toolBar->insertButton( "view_choose", 1, m_viewMenu, true, i18n( "View" ) );
    #ifdef AMAZON_SUPPORT
    const QString babelfish = locate( "data", QString( "amarok/images/babelfish.png" ) );
    toolBar->insertButton( babelfish, 2, m_amazonLocaleMenu, true, i18n( "Amazon Locale" ) );

    QString locale = AmarokConfig::amazonLocale();

         if( locale == "fr" ) m_currentLocale = France;
    else if( locale == "de" ) m_currentLocale = Germany;
    else if( locale == "jp" ) m_currentLocale = Japan;
    else if( locale == "uk" ) m_currentLocale = UK;
    else if( locale == "ca" ) m_currentLocale = Canada;
    else {
        // make sure we handle old config files correctly
        locale = "us";
        m_currentLocale = International;
    }

    m_amazonLocaleMenu->setItemChecked( m_currentLocale, true );

    //fetch missing covers button
    m_fetchButton = new KPushButton( KGuiItem( i18n("Fetch Missing Covers"), "cdrom_unmount" ), hbox );
    connect( m_fetchButton, SIGNAL(clicked()), SLOT(fetchMissingCovers()) );
    #endif

    //cover view
    m_coverView = new CoverView( vbox );

    //status bar
    KStatusBar *m_statusBar = new KStatusBar( vbox );
    m_statusBar->addWidget( m_statusLabel = new KSqueezedTextLabel( m_statusBar ), 4 );
    m_statusLabel->setIndent( 3 );
    m_statusBar->addWidget( m_progressBox = new QHBox( m_statusBar ), 1, true );
    KPushButton *stopButton = new KPushButton( KGuiItem(i18n("Abort"), "stop"), m_progressBox );
    connect( stopButton, SIGNAL(clicked()), SLOT(stopFetching()) );
    m_progress = new KProgress( m_progressBox );
    m_progress->setCenterIndicator( true );

    const int h = m_statusLabel->height() + 3;
    m_statusLabel->setFixedHeight( h );
    m_progressBox->setFixedHeight( h );
    m_progressBox->hide();


    // signals and slots connections
    connect( m_artistView, SIGNAL(selectionChanged( QListViewItem* ) ),
                           SLOT(slotArtistSelected( QListViewItem* )) );
    connect( m_coverView,  SIGNAL(rightButtonPressed( QIconViewItem*, const QPoint& )),
                           SLOT(showCoverMenu( QIconViewItem*, const QPoint& )) );
    connect( m_coverView,  SIGNAL(executed( QIconViewItem* )),
                           SLOT(coverItemExecuted( QIconViewItem* )) );
    connect( m_timer,      SIGNAL(timeout()),
                           SLOT(slotSetFilter()) );
    connect( m_searchEdit, SIGNAL(textChanged( const QString& )),
                           SLOT(slotSetFilterTimeout()) );

    #ifdef AMAZON_SUPPORT
    connect( CollectionDB::instance(), SIGNAL(coverFetched( const QString&, const QString& )),
                                       SLOT(coverFetched( const QString&, const QString& )) );
    connect( CollectionDB::instance(), SIGNAL(coverRemoved( const QString&, const QString& )),
                                       SLOT(coverRemoved( const QString&, const QString& )) );
    connect( CollectionDB::instance(), SIGNAL(coverFetcherError( const QString& )),
                                       SLOT(coverFetcherError()) );
    #endif

    m_currentView = AllAlbums;

    QSize size = QApplication::desktop()->screenGeometry( this ).size() / 1.5;
    resize( amaroK::config( "Cover Manager" )->readSizeEntry( "Window Size", &size ) );

    show();

    QTimer::singleShot( 0, this, SLOT(init()) );
}
Ejemplo n.º 11
0
Dialog::Dialog(QCString & path, QCString & encoding, QCString & nomodel, QCString & genview, QCString & uml20, QCString & pk, QCString & vis, QCString & primitivetype, QCString & genextension, QCString & geneclipse, QCString & commentexporter, QCString & linefeed, Language & lang)
  : QDialog(0, 0, TRUE), _path(path), _encoding(encoding), _nomodel(nomodel), _genview(genview), _uml20(uml20), _pk(pk), _vis(vis), _primitivetype(primitivetype), _genextension(genextension), _geneclipse(geneclipse), _commentexporter(commentexporter), _linefeed(linefeed), _lang(lang) {
  QVBoxLayout * vbox = new QVBoxLayout(this);
  QHBox * htab;
  
  vbox->setMargin(5);
  
  // get xmi pathname
  
  htab = new QHBox(this);
  htab->setMargin(5);
  vbox->addWidget(htab);
  
  new QLabel("generated \nXMI file : ", htab);
  
  ed = new QLineEdit(htab);
  ed->setText(_path);
  
  new QLabel(" ", htab);
  
  SmallPushButton * br = new SmallPushButton("browse", htab);
  
  connect(br, SIGNAL(clicked ()), this, SLOT(browse()));

  // to choose encoding
  
  htab = new QHBox(this);
  htab->setMargin(5);
  vbox->addWidget(htab);
  
  new QLabel("Encoding : ", htab);
  
  QString charset = getenv("BOUML_CHARSET");
  int index = 0;
  
  while ((index = charset.find('_')) != -1) {
    charset[index] = '-';
    index += 1;
  }

  encoding_cb = new QComboBox(TRUE, htab);
  htab->setStretchFactor(encoding_cb, 1000);
  if (_encoding.isEmpty())
    _encoding = "UTF-8";
  encoding_cb->insertItem(QString(_encoding));
  if (!charset.isEmpty() && (_encoding != (const char *) charset))
    encoding_cb->insertItem(charset);
  if (_encoding != "UTF-8")
    encoding_cb->insertItem("UTF-8");
#ifdef WIN32
  if ((_encoding != "windows-1252") && (charset != "windows-1252"))
    encoding_cb->insertItem("windows-1252");
  if ((_encoding != "ISO-8859-1") && (charset != "ISO-8859-1"))
    encoding_cb->insertItem("ISO-8859-1");
#else
  if ((_encoding != "ISO-8859-1") && (charset != "ISO-8859-1"))
    encoding_cb->insertItem("ISO-8859-1");
  if ((_encoding != "windows-1252") && (charset != "windows-1252"))
    encoding_cb->insertItem("windows-1252");
#endif
  
  // uml 2.0 or uml2.1
    
  htab = new QHBox(this);
  htab->setMargin(5);
  vbox->addWidget(htab);
  
  QButtonGroup * bg = new QButtonGroup(2, Qt::Horizontal, "Uml", htab);
  
  uml20_rb = new QRadioButton("uml 2.0", bg);
  uml21_rb = new QRadioButton("uml 2.1", bg);

  if (uml20 == "yes")
    uml20_rb->setChecked(TRUE);
  else
    uml21_rb->setChecked(TRUE);
  
  // generate model
  
  htab = new QHBox(this);
  htab->setMargin(5);
  vbox->addWidget(htab);
  
  nomodel_cb = new QCheckBox("Don't generate model level", htab);
  if (_nomodel == "yes")
    nomodel_cb->setChecked(TRUE);
    
  // generate view checkbox
  
  htab = new QHBox(this);
  htab->setMargin(5);
  vbox->addWidget(htab);
  
  genview_cb = new QCheckBox("Generate views as package (not compatible with profile generation)", htab);
  if (_genview == "yes")
    genview_cb->setChecked(TRUE);
    
  // generate pk_ prefix
  
  htab = new QHBox(this);
  htab->setMargin(5);
  vbox->addWidget(htab);
  
  pk_cb = new QCheckBox("Generate 'pk_' prefix for parameter direction", htab);
  if (_pk == "yes")
    pk_cb->setChecked(TRUE);
    
  // generate vis_ prefix
  
  htab = new QHBox(this);
  htab->setMargin(5);
  vbox->addWidget(htab);
  
  vis_cb = new QCheckBox("Generate 'vis_' prefix for visibility", htab);
  if (_vis == "yes")
    vis_cb->setChecked(TRUE);
    
  // use PrimitiveType rather than DataType
  
  htab = new QHBox(this);
  htab->setMargin(5);
  vbox->addWidget(htab);
  
  primitivetype_cb = new QCheckBox("Use PrimitiveType rather than DataType", htab);
  if (_primitivetype == "yes")
    primitivetype_cb->setChecked(TRUE);
  
  // generate extension
  
  htab = new QHBox(this);
  htab->setMargin(5);
  vbox->addWidget(htab);
  
  genextension_cb = new QCheckBox("Generate extensions", htab);
  if (_genextension == "yes")
    genextension_cb->setChecked(TRUE);
    
  // generate for Eclipse
  
  htab = new QHBox(this);
  htab->setMargin(5);
  vbox->addWidget(htab);
  
  geneclipse_cb = new QCheckBox("Generate for Eclipse (aggregation set on other relation side)", htab);
  if (_geneclipse == "yes")
    geneclipse_cb->setChecked(TRUE);
    
  // comment exporter
  
  htab = new QHBox(this);
  htab->setMargin(5);
  vbox->addWidget(htab);
  
  commentexporter_cb = new QCheckBox("Comment exporter indication (needed to import in some tools like Rsa)", htab);
  if (_commentexporter == "yes")
    commentexporter_cb->setChecked(TRUE);
    
  // generate &#10; rather than linefeed
  
  htab = new QHBox(this);
  htab->setMargin(5);
  vbox->addWidget(htab);
  
  linefeed_cb = new QCheckBox("Generate lf and cr characters in string rather than '&&#10;' and '&&#13;'", htab);
  if (_linefeed == "yes")
    linefeed_cb->setChecked(TRUE);
    
  // uml , c++, java, cancel buttons
  
  htab = new QHBox(this);
  htab->setMargin(5);
  vbox->addWidget(htab);
  
  new QLabel(htab);
  QPushButton * uml = new QPushButton("&Uml", htab);
  new QLabel(htab);
  QPushButton * cpp = new QPushButton("&C++", htab);
  new QLabel(htab);
  QPushButton * java = new QPushButton("&Java", htab);
  new QLabel(htab);
  QPushButton * cancel = new QPushButton("&Cancel", htab);
  new QLabel(htab);
  QSize bs(cancel->sizeHint());
  
  uml->setFixedSize(bs);
  cpp->setFixedSize(bs);
  java->setFixedSize(bs);
  
  connect(uml, SIGNAL(clicked()), this, SLOT(accept_uml()));
  connect(cpp, SIGNAL(clicked()), this, SLOT(accept_cpp()));
  connect(java, SIGNAL(clicked()), this, SLOT(accept_java()));
  connect(cancel, SIGNAL(clicked()), this, SLOT(reject()));

  // help
  
  htab = new QHBox(this);
  htab->setMargin(5);
  vbox->addWidget(htab);
  
  new QLabel(htab);
  new QLabel("Remark : to help Eclipse to import the generated file,\n"
	     "choose Uml 2.1 and name the file with the extension '.xmi'", htab);
  new QLabel(htab);
}
Ejemplo n.º 12
0
kpEffectsDialog::kpEffectsDialog (bool actOnSelection,
                                  kpMainWindow *parent,
                                  const char *name)
    : kpToolPreviewDialog (kpToolPreviewDialog::Preview,
                           true/*reserve top row*/,
                           QString::null/*caption*/,
                           QString::null/*afterActionText (no Dimensions Group Box)*/,
                           actOnSelection,
                           parent,
                           name),
      m_delayedUpdateTimer (new QTimer (this)),
      m_effectsComboBox (0),
      m_settingsGroupBox (0),
      m_settingsLayout (0),
      m_colorEffectWidget (0)
{
#if DEBUG_KP_EFFECTS_DIALOG
    kdDebug () << "kpEffectsDialog::kpEffectsDialog()" << endl;
#endif

    if (actOnSelection)
        setCaption (i18n ("More Image Effects (Selection)"));
    else
        setCaption (i18n ("More Image Effects"));


    connect (m_delayedUpdateTimer, SIGNAL (timeout ()),
             this, SLOT (slotUpdateWithWaitCursor ()));


    QHBox *effectContainer = new QHBox (mainWidget ());
    effectContainer->setSpacing (spacingHint () * 4
                                 /*need more space for QGroupBox titles*/);
    effectContainer->setMargin (0);

    QLabel *label = new QLabel (i18n ("&Effect:"), effectContainer);

    m_effectsComboBox = new KComboBox (effectContainer);
    m_effectsComboBox->insertItem (i18n ("Balance"));
    m_effectsComboBox->insertItem (i18n ("Emboss"));
    m_effectsComboBox->insertItem (i18n ("Flatten"));
    m_effectsComboBox->insertItem (i18n ("Invert"));
    m_effectsComboBox->insertItem (i18n ("Reduce Colors"));
    m_effectsComboBox->insertItem (i18n ("Soften & Sharpen"));

    label->setBuddy (m_effectsComboBox);
    effectContainer->setStretchFactor (m_effectsComboBox, 1);

    addCustomWidgetToFront (effectContainer);


    m_settingsGroupBox = new QGroupBox (mainWidget ());
    m_settingsLayout = new QVBoxLayout (m_settingsGroupBox,
                                        marginHint () * 2,
                                        spacingHint ());
    addCustomWidgetToBack (m_settingsGroupBox);


    connect (m_effectsComboBox, SIGNAL (activated (int)),
             this, SLOT (selectEffect (int)));
    selectEffect (0);


    resize (s_lastWidth, s_lastHeight);


#if DEBUG_KP_EFFECTS_DIALOG
    kdDebug () << "\tabout to slotUpdate()" << endl;
#endif
    slotUpdate ();
}
Ejemplo n.º 13
0
void MyFracWindow::onFileSave()
{
	QHBox* box = new QHBox(NULL);
	box->setSpacing(10);

	new QLabel(i18n("Image Size:"), box);
	QLineEdit* editResX = new QLineEdit(box);
	editResX->setValidator(new QIntValidator(1, 32768, editResX));
	box->setStretchFactor(editResX, 0);
	new QLabel(i18n("x"), box);
	QLineEdit* editResY = new QLineEdit(box);
	editResY->setValidator(new QIntValidator(1, 32768, editResY));
	box->setStretchFactor(editResY, 0);
	box->setStretchFactor(new QWidget(box), 1);

	editResX->setText(QString::number(_imageSize.width()));
	editResY->setText(QString::number(_imageSize.height()));

	KFileDialog imageDlg(_imagePath, QString::null, this, "file_dlg", true, box);
	imageDlg.setCaption(i18n("Save Image"));
	imageDlg.setOperationMode(KFileDialog::Saving);
	imageDlg.setMimeFilter(KImageIO::mimeTypes(KImageIO::Writing), _imageMime);

	if (imageDlg.exec() == KFileDialog::Accepted) {
		QString fileName = imageDlg.selectedFile();

		_imagePath = QFileInfo(fileName).dirPath();
		_imageMime = imageDlg.currentMimeFilter();

		if (editResX->hasAcceptableInput() && editResY->hasAcceptableInput()) {
			_imageSize.setWidth(editResX->text().toInt());
			_imageSize.setHeight(editResY->text().toInt());
		} else {
			KMessageBox::sorry(this, i18n("An invalid image size was entered."));
			return;
		}

		emit previewEnabled(false);

		_progressDialog = new QProgressDialog(this, NULL, true);
		_progressDialog->setCaption(i18n("Save Image"));
		_progressDialog->setLabelText(i18n("Generating Image..."));
		_progressDialog->setTotalSteps(100);
		_progressDialog->setMinimumDuration(0);

		_generator.setSize(_imageSize);
		_generator.setPosition(_posX, _posY, _zoom, _angle);
		if (_juliaMode)
			_generator.setJuliaMode(_juliaX, _juliaY);
		_generator.setQuality(_maxIter, _threshold);
		_generator.setBackground(_backgroundColor.rgb());
		_generator.setGradient(_gradientData, _gradientScale, _gradientOffset);

		_generator.addToQueue();
		_progressDialog->exec();

		if (!_progressDialog->wasCanceled()) {
			if (!_generator.isValid()) {
				KMessageBox::sorry(this, i18n("Not enough memory to generate the fractal."));
			} else {
				_progressDialog->setLabelText(i18n("Saving Image..."));
				_progressDialog->setProgress(0);
				qApp->processEvents();
				_generator.repaintImage();
				QString format = KImageIO::typeForMime(_imageMime);
				bool result = _generator.getImage().save(fileName, format.ascii());
				_progressDialog->setProgress(100);
				if (!result) {
					KMessageBox::sorry(this, i18n("Failed to save the image file."));
				}
			}
		} else
			_generator.abort();

		delete _progressDialog;
		_progressDialog = NULL;

		_generator.freeData();

		if (!_juliaMode)
			emit previewEnabled(true);
	}
}
Ejemplo n.º 14
0
Main::Main()
{
    setIcon( (const char**)logo_xpm );
#ifdef FIXED_LAYOUT
    QHBox* horizontal = new QHBox(this);
#else
    QSplitter* horizontal = new QSplitter(this);
#endif

    lv = new QListView(horizontal);
    lv->setSorting(-1);
    lv->setRootIsDecorated(TRUE);
    lv->addColumn("ID");

    info = new Info(horizontal);
    info->setBackgroundMode(PaletteBase);
    info->setMargin(10);
    info->setFrameStyle(QFrame::WinPanel|QFrame::Sunken);
    info->setAlignment(AlignTop);

    connect(info, SIGNAL(idClicked(const QString&)),
	    this, SLOT(selectId(const QString&)));

#ifdef FIXED_LAYOUT
    horizontal->setStretchFactor(info,2);
#endif

    connect(lv, SIGNAL(pressed(QListViewItem*)),
	    this, SLOT(updateAvailability(QListViewItem*)));
    connect(lv, SIGNAL(selectionChanged(QListViewItem*)),
	    this, SLOT(showInfo(QListViewItem*)));

    setCentralWidget(horizontal);

    QToolBar* tb = new QToolBar( this, "browser controls" );
    tb->setLabel( "Browser Controls" );
    (void)new QToolButton( QPixmap(back_xpm), "Back", QString::null,
                           info, SLOT(back()), tb, "back" );
    (void)new QToolButton( QPixmap(forward_xpm), "Forward", QString::null,
                           info, SLOT(forward()), tb, "forward" );

    QPopupMenu* file = new QPopupMenu( menuBar() );
    file->insertItem( "&Open",  this, SLOT(open()), CTRL+Key_O );
    file->insertItem( "&Save", this, SLOT(save()), CTRL+Key_S );
    file->insertSeparator();
    file->insertItem( "&Test all", this, SLOT(testAll()), CTRL+Key_T );
    file->insertSeparator();
    file->insertItem( "E&xit",  qApp, SLOT(quit()), CTRL+Key_Q );

    menuBar()->insertItem( "&File",file );

    menuBar()->insertSeparator();

    QPopupMenu *help = new QPopupMenu( menuBar() );
    help->insertItem( "&About", this, SLOT(about()) );
    help->insertItem( "About &Qt", this, SLOT(aboutQt()) );

    menuBar()->insertItem( "&Help", help );

    statusBar()->message( "Ready" );
}
Ejemplo n.º 15
0
void SmartPlaylistEditor::init(QString defaultName)
{
    makeVBoxMainWidget();

    m_fields.clear();
    m_fields << i18n("Artist") << i18n("Album") << i18n("Genre") << i18n("Title") << i18n("Length") << i18n("Track #") << i18n("Year")
             << i18n("Comment") << i18n("Play Counter") << i18n("Score") << i18n( "Rating" ) << i18n("First Play") << i18n("Last Play")
             << i18n("Modified Date") << i18n("File Path");

    m_dbFields.clear();
    m_dbFields << "artist.name" << "album.name" << "genre.name" << "tags.title" << "tags.length"
               << "tags.track" << "year.name" << "tags.comment" << "statistics.playcounter"
               << "statistics.percentage" << "statistics.rating" << "statistics.createdate"
               << "statistics.accessdate" << "tags.createdate" << "tags.url" << "tags.sampler";

    m_expandableFields.clear();
    m_expandableFields << i18n("Artist") << i18n("Album") << i18n("Genre") <<  i18n("Year");

    m_expandableDbFields.clear();
    m_expandableDbFields << "artist.name" << "album.name" << "genre.name" << "year.name";

    QHBox *hbox = new QHBox( mainWidget() );
    hbox->setSpacing( 5 );
    new QLabel( i18n("Playlist name:"), hbox );
    m_nameLineEdit = new KLineEdit( defaultName, hbox );

    QFrame *sep = new QFrame( mainWidget() );
    sep->setFrameStyle( QFrame::HLine | QFrame::Sunken );

    //match box (any)
    QHBox *matchAnyBox = new QHBox( mainWidget() );
    m_matchAnyCheck = new QCheckBox( i18n("Match Any of the following conditions" ), matchAnyBox );
    matchAnyBox->setStretchFactor( new QWidget( matchAnyBox ), 1 );

    //criteria box
    m_criteriaAnyGroupBox = new QVGroupBox( QString::null, mainWidget() );

    //match box (all)
    QHBox *matchAllBox = new QHBox( mainWidget() );
    m_matchAllCheck = new QCheckBox( i18n("Match All of the following conditions" ), matchAllBox );
    matchAllBox->setStretchFactor( new QWidget( matchAllBox ), 1 );

    //criteria box
    m_criteriaAllGroupBox = new QVGroupBox( QString::null, mainWidget() );

    //order box
    QHBox *hbox2 = new QHBox( mainWidget() );
    m_orderCheck = new QCheckBox( i18n("Order by"), hbox2 );
    QHBox *orderBox = new QHBox( hbox2 );
    orderBox->setSpacing( 5 );
    //fields combo
    m_orderCombo = new KComboBox( orderBox );
    m_orderCombo->insertStringList( m_fields );
    m_orderCombo->insertItem( i18n("Random") );
    //order type
    m_orderTypeCombo = new KComboBox( orderBox );
    updateOrderTypes(0); // populate the new m_orderTypeCombo
    hbox2->setStretchFactor( new QWidget( hbox2 ), 1 );

    //limit box
    QHBox *hbox1 = new QHBox( mainWidget() );
    m_limitCheck = new QCheckBox( i18n("Limit to"), hbox1 );
    QHBox *limitBox = new QHBox( hbox1 );
    limitBox->setSpacing( 5 );
    m_limitSpin = new KIntSpinBox( limitBox );
    m_limitSpin->setMinValue( 1 );
    m_limitSpin->setMaxValue( 1000 );
    m_limitSpin->setValue( 15 );
    new QLabel( i18n("tracks"), limitBox );
    hbox1->setStretchFactor( new QWidget( hbox1 ), 1 );

    //Expand By
    QHBox *hbox3 = new QHBox( mainWidget() );
    m_expandCheck = new QCheckBox( i18n("Expand by"), hbox3 );
    QHBox *expandBox = new QHBox( hbox3 );
    expandBox->setSpacing( 5 );
    m_expandCombo = new KComboBox( expandBox );
    m_expandCombo->insertStringList( m_expandableFields );
    hbox3->setStretchFactor( new QWidget( hbox3 ), 1 );

    //add stretch
    static_cast<QHBox *>(mainWidget())->setStretchFactor(new QWidget(mainWidget()), 1);

    connect( m_matchAnyCheck, SIGNAL( toggled(bool) ), m_criteriaAnyGroupBox, SLOT( setEnabled(bool) ) );
    connect( m_matchAllCheck, SIGNAL( toggled(bool) ), m_criteriaAllGroupBox, SLOT( setEnabled(bool) ) );
    connect( m_orderCheck, SIGNAL( toggled(bool) ), orderBox, SLOT( setEnabled(bool) ) );
    connect( m_limitCheck, SIGNAL( toggled(bool) ), limitBox, SLOT(  setEnabled(bool) ) );
    connect( m_expandCheck, SIGNAL( toggled(bool) ), expandBox, SLOT( setEnabled(bool) ) );
    connect( m_orderCombo, SIGNAL( activated(int) ), this, SLOT( updateOrderTypes(int) ) );

    m_criteriaAnyGroupBox->setEnabled( false );
    m_criteriaAllGroupBox->setEnabled( false );

    orderBox->setEnabled( false );
    limitBox->setEnabled( false );
    expandBox->setEnabled( false );

    m_nameLineEdit->setFocus();

    resize( 550, 200 );
}