Beispiel #1
0
KSaneWidget::KSaneWidget(QWidget* parent)
    : QWidget(parent), d(new KSaneWidgetPrivate)
{
    KPushButton *openDialog = new KPushButton;
    openDialog->setText(i18n("Open scan dialog"));
    QHBoxLayout *lay = new QHBoxLayout;
    lay->addWidget(openDialog);
    setLayout(lay);

    connect(openDialog, SIGNAL(clicked()), d, SLOT(ReOpenDialog()));

    // Forward signals from the private class
    //connect(d, SIGNAL(scanProgress(int)), this, SIGNAL(scanProgress(int)));
    connect(d, SIGNAL(ImageReady(QByteArray &, int, int, int, int)),
            this, SIGNAL(imageReady(QByteArray &, int, int, int, int)));
    //connect(d, SIGNAL(scanDone(int, QString)), this, SIGNAL(scanDone(int, QString)));
    


}
Beispiel #2
0
void EstateDetails::addButton(QString command, QString caption, bool enabled)
{
	KPushButton *button = new KPushButton(caption, this);
	m_buttons.append(button);
	m_buttonCommandMap[(QObject *)button] = command;
	m_buttonBox->addWidget(button);

	if (m_estate)
	{
		QColor bgColor, fgColor;
		bgColor = m_estate->bgColor().light(110);
		fgColor = ( bgColor.red() + bgColor.green() + bgColor.blue() < 255 ) ? Qt::white : Qt::black;

		button->setPaletteForegroundColor( fgColor );
		button->setPaletteBackgroundColor( bgColor );
	}
	button->setEnabled(enabled);
	button->show();

	connect(button, SIGNAL(pressed()), this, SLOT(buttonPressed()));
}
Beispiel #3
0
ConfigGuiSunbird::ConfigGuiSunbird( const QSync::Member &member, QWidget *parent )
  : ConfigGui( member, parent )
{
  QTabWidget *tabWidget = new QTabWidget( this );
  topLayout()->addWidget( tabWidget );

  mLocalWidget = new QWidget( tabWidget );
  mLocalLayout = new QVBoxLayout( mLocalWidget, KDialog::spacingHint() );

  mWebdavWidget = new QWidget( tabWidget );
  mWebdavLayout = new QVBoxLayout( mWebdavWidget, KDialog::spacingHint() );

  tabWidget->addTab( mLocalWidget, i18n( "Local Calendars" ) );
  tabWidget->addTab( mWebdavWidget, i18n( "WebDAV Calendars" ) );

  KPushButton *mLocalAddButton = new KPushButton( mLocalWidget );
  mLocalAddButton->setText( i18n( "Add new calendar" ) );
  mLocalAddButton->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) );
  mLocalLayout->addWidget( mLocalAddButton );
  connect( mLocalAddButton, SIGNAL( clicked() ),
           this, SLOT( addLocalCalendar() ) );

  KPushButton *mWebdavAddButton = new KPushButton( mWebdavWidget );
  mWebdavAddButton->setText( i18n( "Add new calendar" ) );
  mWebdavAddButton->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) );
  mWebdavLayout->addWidget( mWebdavAddButton );
  connect( mWebdavAddButton, SIGNAL( clicked() ),
           this, SLOT( addWebdavCalendar() ) );

  mLocalSpacer = new QSpacerItem( 20, 40, QSizePolicy::Expanding );
  mLocalLayout->addItem( mLocalSpacer );
  mWebdavSpacer = new QSpacerItem( 20, 40, QSizePolicy::Expanding );
  mWebdavLayout->addItem( mWebdavSpacer );
}
Beispiel #4
0
MainWindow::MainWindow(QWidget *parent)
    : KMainWindow(parent)
{
  QWidget *central_widget = new QWidget(this);
  QVBoxLayout *central_layout = new QVBoxLayout(this);

  QHBoxLayout *h_layout = new QHBoxLayout(this);

  QVBoxLayout *v_layout = new QVBoxLayout(this);
  QHBoxLayout *layout = new QHBoxLayout(this);
  layout->addWidget(new QLabel(i18n("tag:"), this));
  layout->addWidget(tag = new KLineEdit(this));
  v_layout->addLayout(layout);

  layout = new QHBoxLayout(this);
  layout->addWidget(new QLabel(i18n("text:"), this));
  layout->addWidget(text = new KTextEdit(this));
  text->setMaximumHeight(100);
  v_layout->addLayout(layout);
  h_layout->addLayout(v_layout);

  KPushButton *button = new KPushButton(i18n("Search"), this);
  connect(button, SIGNAL(clicked()), this, SLOT(query()));
  h_layout->addWidget(button);

  central_layout->addLayout(h_layout);
  central_layout->addWidget(new QLabel(i18n("Result:"), this));
  central_layout->addWidget(result = new KTextBrowser(this));
  central_layout->addWidget(new QLabel(i18n("Url:"), this));
  central_layout->addWidget(url = new KTextBrowser(this));

  central_widget->setLayout(central_layout);
  setCentralWidget(central_widget);

  setMinimumSize(650,485);

  if (Nepomuk2::ResourceManager::instance()->init())
    button->setEnabled(false);
}
Beispiel #5
0
void LocalCalendar::initGui()
{
  QBoxLayout *bottomLayout = new QHBoxLayout();

  mDaysCheckBox = new QCheckBox( this );
  mDaysCheckBox->setText( i18n( "Sync only events newer than" ) );

  mDaysSpinBox = new QSpinBox( this );
  mDaysSpinBox->setDisabled( true );
  mDaysSpinBox->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) );

  connect( mDaysCheckBox, SIGNAL( toggled( bool ) ),
           this, SLOT( toggleDays( bool ) ) );

  bottomLayout->addWidget( mDaysCheckBox );
  bottomLayout->addWidget( mDaysSpinBox );
  bottomLayout->addWidget( new QLabel( i18n( "day(s)" ), this ) );

  QGridLayout *localLayout = new QGridLayout( this );

  mPathRequester = new KURLRequester( this );

  KPushButton *removeButton = new KPushButton( this );
  removeButton->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) );
  removeButton->setText( i18n( "Remove" ) );
  connect( removeButton, SIGNAL( clicked() ),
           this, SLOT( deleteWidget() ) );

  mDefaultCheckBox = new QCheckBox( this );
  mDefaultCheckBox->setText( i18n( "Set as Default" ) );

  localLayout->addItem( new QSpacerItem( 40, 20, QSizePolicy::Expanding ), 0, 0 );
  localLayout->addWidget( new QLabel( i18n( "Location:" ), this ), 1, 0 );
  localLayout->addWidget( mPathRequester, 1, 1 );
  localLayout->addItem( new QSpacerItem( 40, 20, QSizePolicy::Fixed ), 1, 2 );
  localLayout->addWidget( removeButton, 1, 3 );
  localLayout->addMultiCellLayout( bottomLayout, 2, 2, 0, 2 );
  localLayout->addWidget( mDefaultCheckBox, 2, 3 ); 
}
QList<QWidget*> CommentItemsViewDelegate::createItemWidgets() const
{
    QList<QWidget*> list;

    KSqueezedTextLabel* author = new KSqueezedTextLabel();
    author->setOpenExternalLinks( true );
    // not so nice - work around constness to install the event filter
    CommentItemsViewDelegate* delegate = const_cast<CommentItemsViewDelegate*>( this );
    author->installEventFilter( delegate );
    list << author;

    KSqueezedTextLabel* title = new KSqueezedTextLabel();
    title->setOpenExternalLinks( true );
    list << title;

    KSqueezedTextLabel* dateTime = new KSqueezedTextLabel();
    dateTime->setOpenExternalLinks( true );
    list << dateTime;

    KSqueezedTextLabel* rating = new KSqueezedTextLabel();
    rating->setOpenExternalLinks( true );
    list << rating;

    KSqueezedTextLabel* body = new KSqueezedTextLabel();
    body->setOpenExternalLinks( true );
    body->setSizePolicy( QSizePolicy::Maximum, QSizePolicy::MinimumExpanding );
    list << body;

    KPushButton* replyButton = new KPushButton();
    replyButton->setSizePolicy( QSizePolicy::Maximum, QSizePolicy::MinimumExpanding );
    list << replyButton;
    setBlockedEventTypes( replyButton, QList<QEvent::Type>() << QEvent::MouseButtonPress
                          << QEvent::MouseButtonRelease << QEvent::MouseButtonDblClick );
    connect( replyButton, SIGNAL( clicked() ), SLOT( slotReplyClicked() ) );

    return list;
}
void ServiceItemDelegate::updateItemWidgets(const QList<QWidget*> widgets,
                                              const QStyleOptionViewItem& option,
                                              const QPersistentModelIndex& index) const
{
    QCheckBox* checkBox = static_cast<QCheckBox*>(widgets[0]);
    KPushButton *configureButton = static_cast<KPushButton*>(widgets[1]);

    const int itemHeight = sizeHint(option, index).height();

    // Update the checkbox showing the service name and icon
    const QAbstractItemModel* model = index.model();
    checkBox->setText(model->data(index).toString());
    const QString iconName = model->data(index, Qt::DecorationRole).toString();
    if (!iconName.isEmpty()) {
        checkBox->setIcon(KIcon(iconName));
    }
    checkBox->setChecked(model->data(index, Qt::CheckStateRole).toBool());

    const bool configurable = model->data(index, ServiceModel::ConfigurableRole).toBool();

    int checkBoxWidth = option.rect.width();
    if (configurable) {
        checkBoxWidth -= configureButton->sizeHint().width();
    }
    checkBox->resize(checkBoxWidth, checkBox->sizeHint().height());
    checkBox->move(0, (itemHeight - checkBox->height()) / 2);

    // Update the configuration button
    if (configurable) {
        configureButton->setEnabled(checkBox->isChecked());
        configureButton->setIcon(KIcon("configure"));
        configureButton->resize(configureButton->sizeHint());
        configureButton->move(option.rect.right() - configureButton->width(),
                              (itemHeight - configureButton->height()) / 2);
    }
    configureButton->setVisible(configurable);
}
void kiptablesgenerator::setupInterfacesPage()
{
  interfacesPage = new QFrame(this);
  
  QVBoxLayout *layout = new QVBoxLayout(interfacesPage);
  
  QLabel *intro = new QLabel(i18n(
    "<p>Which of the following interfaces do you want to filter?</p>"
    "<p>It is strongly advised <b>not</b> to filter '<tt>lo</tt>'.</p>"), interfacesPage);
  intro->show();
  layout->addWidget(intro);
  
  KListBox *interfaces = new KListBox(interfacesPage);

  char buffer[IFNAMSIZ];
  for(unsigned int i = 1; if_indextoname(i, buffer) != NULL; i++)
  {
          interfaces->insertItem((QString)buffer);
  }
  
  interfaces->setSelectionMode(QListBox::Multi);
  for (unsigned short i = 0; i < interfaces->count(); i++)
    if (interfaces->item(i)->text() != "lo")
      interfaces->setSelected(i, true);
  interfaces->show();
  layout->addWidget(interfaces);
  namedWidgets["iInterfaces"] = interfaces;
  
  KPushButton *newInterface = new KPushButton(i18n("A&dd Interface..."), interfacesPage);
  newInterface->show();
  layout->addWidget(newInterface);
  connect(newInterface, SIGNAL(clicked()), this, SLOT(slotNewInterface()));
  
  interfacesPage->show();
  this->addPage(interfacesPage, i18n("Interfaces"));
}
SearchPane::SearchPane( FileBrowser *parent )
        : QVBox( parent )
        , m_lineEdit( 0 )
        , m_listView( 0 )
        , m_lister( 0 )
{
    QFrame *container = new QVBox( this, "container" );
    container->hide();

    {
        QFrame *box = new QHBox( container );
        box->setMargin( 5 );
        box->setBackgroundMode( Qt::PaletteBase );

        m_lineEdit = new ClickLineEdit( i18n("Search here..."), box );
        connect( m_lineEdit, SIGNAL(textChanged( const QString& )), SLOT(searchTextChanged( const QString& )) );

        m_listView = new KURLView( container );

        container->setFrameStyle( m_listView->frameStyle() );
        container->setMargin( 5 );
        container->setBackgroundMode( Qt::PaletteBase );

        m_listView->setFrameStyle( QFrame::NoFrame );
        connect( m_listView, SIGNAL(executed( QListViewItem* )), SLOT(activate( QListViewItem* )) );
    }

    KPushButton *button = new KPushButton( KGuiItem( i18n("&Show Search Panel"), "find" ), this );
    button->setToggleButton( true );
    connect( button, SIGNAL(toggled( bool )), SLOT(toggle( bool )) );

    m_lister = new MyDirLister( true /*delay mimetypes*/ );
    insertChild( m_lister );
    connect( m_lister, SIGNAL(newItems( const KFileItemList& )), SLOT(searchMatches( const KFileItemList& )) );
    connect( m_lister, SIGNAL(completed()), SLOT(searchComplete()) );
}
void kiptablesgenerator::setupIPortsPage()
{
  iPortsPage = new QFrame(this);
  QGridLayout *layout = new QGridLayout(iPortsPage, 6, 2);
  
  QLabel *intro = new QLabel(
    i18n("<p>Here you can select which services are available to the outside world.</p>"),
    iPortsPage);
  intro->show();
  layout->addMultiCellWidget(intro, 0, 0, 0, 1);
  
  KListView *ports = new KListView(iPortsPage);
  ports->addColumn(i18n("Port"));
  ports->addColumn(i18n("Protocol"));
  ports->addColumn(i18n("Action"));
  ports->addColumn(i18n("Service"));
  ports->setSorting(-1);
  ports->show();
  layout->addMultiCellWidget(ports, 1, 5, 0, 0);
  namedWidgets["iPorts"] = ports;
  
  KPushButton *newService = new KPushButton(i18n("A&dd Service"), iPortsPage);
  newService->show();
  layout->addWidget(newService, 1, 1);
  connect(newService, SIGNAL(clicked()), newServiceDialog, SLOT(show()));
  
  KPushButton *delService = new KPushButton(i18n("&Remove Service"), iPortsPage);
  delService->show();
  layout->addWidget(delService, 2, 1);
  connect(delService, SIGNAL(clicked()), this, SLOT(slotDelService()));
  
  KPushButton *upService = new KPushButton(i18n("&Move Up"), iPortsPage);
  upService->show();
  layout->addWidget(upService, 3, 1);
  connect(upService, SIGNAL(clicked()), this, SLOT(slotUpService()));
  
  KPushButton *downService = new KPushButton(i18n("M&ove Down"), iPortsPage);
  downService->show();
  layout->addWidget(downService, 4, 1);
  connect(downService, SIGNAL(clicked()), this, SLOT(slotDownService()));
  
  iPortsPage->show();
  this->addPage(iPortsPage, i18n("Incoming Ports"));
}
void ItemsViewDelegate::updateItemWidgets( const QList<QWidget*> widgets,
        const QStyleOptionViewItem& option,
        const QPersistentModelIndex& index ) const
{
    const GluonPlayer::GameItemsModel* model = qobject_cast<const GluonPlayer::GameItemsModel*>( index.model() );
    if( !model )
    {
        kDebug() << "Warning - Invalid Model!";
        return;
    }

    // setup the install button
    int margin = option.fontMetrics.height() / 2;
    int right = option.rect.width();

    const_cast<QSize&>( m_buttonSize ) = QSize( 32, 32 );

    KPushButton* playButton = qobject_cast<KPushButton*>( widgets.at( DelegatePlayButton ) );
    if( playButton )
    {
        playButton->setIcon( KIcon( "media-playback-start" ) );
        playButton->setSizePolicy( QSizePolicy::Maximum, QSizePolicy::MinimumExpanding );
        playButton->resize( m_buttonSize );
        playButton->move( right - playButton->width() - margin, option.fontMetrics.height() + playButton->height() * 0.5 );
    }

    GameTextLabel* gameName = qobject_cast<GameTextLabel*>( widgets.at( DelegateGameName ) );
    // gameName->setWordWrap(true);
    if( gameName )
    {
        gameName->move( margin + m_buttonSize.width() * 3, option.fontMetrics.height() );
        gameName->resize( QSize( option.rect.width() - ( margin * 4 ) - m_buttonSize.width() * 4, option.fontMetrics.height() * 2 ) );
        gameName->setText( index.data( GluonPlayer::GameItemsModel::GameNameRole ).toString() );
    }

    GameTextLabel* gameDescription = qobject_cast<GameTextLabel*>( widgets.at( DelegateGameDescription ) );
    // gameName->setWordWrap(true);
    if( gameDescription )
    {
        gameDescription->move( margin + m_buttonSize.width() * 3,  option.fontMetrics.height() * 1 + gameName->size().height() );
        gameDescription->resize( QSize( option.rect.width() - ( margin * 4 ) - m_buttonSize.width() * 4, option.fontMetrics.height() * 2 ) );
        gameDescription->setText( index.data( GluonPlayer::GameItemsModel::GameDescriptionRole ).toString() );
    }

}
Beispiel #12
0
DietWizardDialog::DietWizardDialog( QWidget *parent, RecipeDB *db ) : KVBox( parent )
{
	// Initialize internal variables
	database = db;
	mealNumber = 1;
	dayNumber = 1;
	dietRList = new RecipeList();

	//Design the dialog
	setSpacing( 5 );
	// Options Box
	optionsBox = new KHBox( this );

	daysSliderBox = new QGroupBox( optionsBox );
	daysSliderBox->setTitle( i18nc( "@label:slider", "Number of Days" ) );
	QHBoxLayout *daysSliderBoxLayout = new QHBoxLayout;
	daysSliderBox->setLayout( daysSliderBoxLayout );
	dayNumberLabel = new QLabel;
	dayNumberLabel->setText( "- 1 -" );
	dayNumberLabel->setAlignment( Qt::AlignCenter );
	dayNumberSelector = new QSlider;

	daysSliderBoxLayout->addWidget( dayNumberSelector );
	daysSliderBoxLayout->addWidget( dayNumberLabel );

	dayNumberSelector->setOrientation( Qt::Horizontal );
	dayNumberSelector->setRange( 1, 10 );
	dayNumberSelector->setSingleStep( 1 );
	dayNumberSelector->setPageStep( 1 );
	dayNumberSelector->setTickPosition( QSlider::TicksBelow );
	dayNumberSelector->setFixedWidth( 100 );

	mealsSliderBox = new QGroupBox( optionsBox );
	mealsSliderBox->setTitle( i18nc( "@label:slider", "Meals per Day" ) );
	QHBoxLayout *mealsSliderBoxLayout = new QHBoxLayout;
	mealsSliderBox->setLayout( mealsSliderBoxLayout );
	mealNumberLabel = new QLabel;
	mealNumberLabel->setText( "- 1 -" );
	mealNumberLabel->setAlignment( Qt::AlignCenter );
	mealNumberSelector = new QSlider;

	mealsSliderBoxLayout->addWidget( mealNumberSelector );
	mealsSliderBoxLayout->addWidget( mealNumberLabel );

	mealNumberSelector->setOrientation( Qt::Horizontal );
	mealNumberSelector->setRange( 1, 10 );
	mealNumberSelector->setSingleStep( 1 );
	mealNumberSelector->setPageStep( 1 );
	mealNumberSelector->setTickPosition( QSlider::TicksBelow );
	mealNumberSelector->setFixedWidth( 100 );

	// Tabs
	mealTabs = new KTabWidget( this );
	mealTabs->setContentsMargins( 5 , 5, 5, 5 );

	// Button bar
	KHBox *bottom_layout = new KHBox( this );
	//bottom_layout->layout()->addItem( new QSpacerItem( 10,10, QSizePolicy::MinimumExpanding, QSizePolicy::Fixed ) );

	okButton = new KPushButton( bottom_layout );
	okButton->setIcon( KIcon( "dialog-ok" ) );
	okButton->setText( i18nc( "@action:button", "Create the diet" ) );

	KPushButton *clearButton = new KPushButton( bottom_layout );
	clearButton->setIcon( KIcon( "edit-clear" ) );
	clearButton->setText( i18nc( "@action:button Clear Diet","Clear" ) );

	// Create Tabs
	//don't use newTab, it'll load data and we don't want it to do that at startup
	mealTab = new MealInput( mealTabs, database );
	// keep this string the same as when creating the other tabs to ease translation
	mealTabs->addTab( mealTab, i18ncp( "@title:tab" , "Meal 1" , "Meal %1" , 1 ) );
	mealTabs->setCurrentIndex( mealTabs->indexOf( mealTab ) );

	// Signals & Slots
	connect( mealNumberSelector, SIGNAL( valueChanged( int ) ), this, SLOT( changeMealNumber( int ) ) );
	connect( dayNumberSelector, SIGNAL( valueChanged( int ) ), this, SLOT( changeDayNumber( int ) ) );
	connect( okButton, SIGNAL( clicked() ), this, SLOT( createDiet() ) );
	connect( clearButton, SIGNAL( clicked() ), this, SLOT( clear() ) );
}
CKeyReferenceWidget::CKeyReferenceWidget( CSwordBibleModuleInfo *mod, CSwordVerseKey *key, QWidget *parent, const char *name) : QWidget(parent,name) {

	updatelock = false;
	m_module = mod;

	setFocusPolicy(QWidget::WheelFocus);

	// Erase button
	KGuiItem erase_picture;
	erase_picture.setIconName("locationbar_erase");
	KPushButton *clearRef = new KPushButton(this);
	clearRef->setGuiItem(erase_picture);
	connect(clearRef, SIGNAL(clicked( ) ), SLOT(slotClearRef( )));

	m_bookScroller = new CScrollerWidgetSet(this);

	m_textbox = new CKeyReferenceLineEdit( this );
	setKey(key);	// The order of these two functions is important.
	setModule();

	m_chapterScroller = new CScrollerWidgetSet(this);
	m_verseScroller = new CScrollerWidgetSet(this);

	m_mainLayout = new QHBoxLayout( this );
	m_mainLayout->addWidget(clearRef);
	m_mainLayout->addWidget(m_bookScroller);
	m_mainLayout->addWidget(m_textbox);
	m_mainLayout->addWidget(m_chapterScroller);
	m_mainLayout->addWidget(m_verseScroller);

	setTabOrder(m_textbox, 0);

        m_bookScroller->setToolTips(
                CResMgr::displaywindows::bibleWindow::nextBook::tooltip,
                CResMgr::displaywindows::general::scrollButton::tooltip,
                CResMgr::displaywindows::bibleWindow::previousBook::tooltip
        );
        m_chapterScroller->setToolTips(
                CResMgr::displaywindows::bibleWindow::nextChapter::tooltip,
                CResMgr::displaywindows::general::scrollButton::tooltip,
                CResMgr::displaywindows::bibleWindow::previousChapter::tooltip
        );
        m_verseScroller->setToolTips(
                CResMgr::displaywindows::bibleWindow::nextVerse::tooltip,
                CResMgr::displaywindows::general::scrollButton::tooltip,
                CResMgr::displaywindows::bibleWindow::previousVerse::tooltip
        );


	// signals and slots connections

	connect(m_bookScroller, SIGNAL(change(int)), SLOT(slotBookChange(int)));
	connect(m_bookScroller, SIGNAL(scroller_pressed()), SLOT(slotUpdateLock()));
	connect(m_bookScroller, SIGNAL(scroller_released()), SLOT(slotUpdateUnlock()));
	connect(m_textbox, SIGNAL(returnPressed()), SLOT(slotReturnPressed()));
	connect(m_chapterScroller, SIGNAL(change(int)), SLOT(slotChapterChange(int)));
	connect(m_chapterScroller, SIGNAL(scroller_pressed()), SLOT(slotUpdateLock()));
	connect(m_chapterScroller, SIGNAL(scroller_released()), SLOT(slotUpdateUnlock()));
	connect(m_verseScroller, SIGNAL(change(int)), SLOT(slotVerseChange(int)));
	connect(m_verseScroller, SIGNAL(scroller_pressed()), SLOT(slotUpdateLock()));
	connect(m_verseScroller, SIGNAL(scroller_released()), SLOT(slotUpdateUnlock()));
}
Beispiel #14
0
void CommandMonitorItem::setupActions() {
  KPushButton* btnView = new KPushButton();
  btnView->setIcon(KIcon(KStandardDirs::locate( "appdata", "pixmap/22x22/eye.png")));
  btnView->setMinimumSize(40,22);
  btnView->setStyleSheet("border: 1px black solid;border-color:#555555;border-style:solid;border-radius:3px;");
  actionLayout->addWidget(btnView);
  QObject::connect(btnView, SIGNAL(clicked()), this, SLOT(connectTerm()));
  
  KPushButton* btnStartNow = new KPushButton();
  btnStartNow->setIcon(KIcon("arrow-right"));
  btnStartNow->setMinimumSize(40,22);
  btnStartNow->setStyleSheet("border: 1px black solid;border-color:#555555;border-style:solid;border-radius:3px;");
  actionLayout->addWidget(btnStartNow);
  
  KPushButton* btnPause = new KPushButton();
  btnPause->setIcon(KIcon(KStandardDirs::locate( "appdata", "pixmap/22x22/pause.png")));
  btnPause->setMinimumSize(40,22);
  btnPause->setStyleSheet("border: 1px black solid;border-color:#555555;border-style:solid;border-radius:3px;");
  actionLayout->addWidget(btnPause);
  
  KPushButton* btnStop = new KPushButton();
  btnStop->setIcon(KIcon("dialog-close"));
  btnStop->setMinimumSize(40,22);
  btnStop->setStyleSheet("border: 1px black solid;border-color:#555555;border-style:solid;border-radius:3px;");
  actionLayout->addWidget(btnStop);
  
  horizontalSpacer = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
  actionLayout->addItem(horizontalSpacer);
}
CollectionSetup::CollectionSetup( QWidget *parent )
        : QWidget( parent )
        , m_rescanDirAction( new QAction( this ) )
{
    m_ui.setupUi(this);

    setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding );

    setObjectName( "CollectionSetup" );
    s_instance = this;

    if( KGlobalSettings::graphicEffectsLevel() != KGlobalSettings::NoEffects )
        m_ui.view->setAnimated( true );
    connect( m_ui.view, SIGNAL(clicked(QModelIndex)),
             this, SIGNAL(changed()) );

    connect( m_ui.view, SIGNAL(pressed(QModelIndex)),
             this, SLOT(slotPressed(QModelIndex)) );
    connect( m_rescanDirAction, SIGNAL(triggered()),
             this, SLOT(slotRescanDirTriggered()) );

    KPushButton *rescan = new KPushButton( KIcon( "collection-rescan-amarok" ), i18n( "Full rescan" ), m_ui.buttonContainer );
    rescan->setToolTip( i18n( "Rescan your entire collection. This will <i>not</i> delete any statistics." ) );
    connect( rescan, SIGNAL(clicked()), CollectionManager::instance(), SLOT(startFullScan()) );

    KPushButton *import = new KPushButton( KIcon( "tools-wizard" ), i18n( "Import" ), m_ui.buttonContainer );
    import->setToolTip( i18n( "Import collection and/or statistics from older Amarok versions, the batch scanner or media players." ) );
    connect( import, SIGNAL(clicked()), this, SLOT(importCollection()) );

    QHBoxLayout *buttonLayout = new QHBoxLayout();
    buttonLayout->addWidget( rescan );
    buttonLayout->addWidget( import );
    m_ui.buttonContainer->setLayout( buttonLayout );

    m_recursive = new QCheckBox( i18n("&Scan folders recursively (requires full rescan if newly checked)"), m_ui.checkboxContainer );
    m_monitor   = new QCheckBox( i18n("&Watch folders for changes"), m_ui.checkboxContainer );
    connect( m_recursive, SIGNAL(toggled(bool)), this, SIGNAL(changed()) );
    connect( m_monitor  , SIGNAL(toggled(bool)), this, SIGNAL(changed()) );

    QVBoxLayout *checkboxLayout = new QVBoxLayout();
    checkboxLayout->addWidget( m_recursive );
    checkboxLayout->addWidget( m_monitor );
    m_ui.checkboxContainer->setLayout( checkboxLayout );

    m_recursive->setToolTip( i18n( "If selected, Amarok will read all subfolders." ) );
    m_monitor->setToolTip( i18n( "If selected, the collection folders will be watched "
            "for changes.\nThe watcher will not notice changes behind symbolic links." ) );

    m_recursive->setChecked( AmarokConfig::scanRecursively() );
    m_monitor->setChecked( AmarokConfig::monitorChanges() );

    // set the model _after_ constructing the checkboxes
    m_model = new CollectionFolder::Model( this );
    m_ui.view->setModel( m_model );
    #ifndef Q_OS_WIN
    m_ui.view->setRootIndex( m_model->setRootPath( QDir::rootPath() ) );
    #else
    m_ui.view->setRootIndex( m_model->setRootPath( m_model->myComputer().toString() ) );
    #endif

    Collections::Collection *primaryCollection = CollectionManager::instance()->primaryCollection();
    QStringList dirs = primaryCollection ? primaryCollection->property( "collectionFolders" ).toStringList() : QStringList();
    m_model->setDirectories( dirs );

    // make sure that the tree is expanded to show all selected items
    foreach( const QString &dir, dirs )
    {
        QModelIndex index = m_model->index( dir );
        m_ui.view->scrollTo( index, QAbstractItemView::EnsureVisible );
    }
Beispiel #16
0
AmarokConfigDialog::AmarokConfigDialog( QWidget *parent, const char* name, KConfigSkeleton *config )
        : KConfigDialog( parent, name, config )
        , m_engineConfig( 0 )
        , m_opt4( 0 )
{
    setWFlags( WDestructiveClose );

    // IMPORTANT Don't simply change the page names, they are used as identifiers in other parts of the app.
            m_opt1 = new Options1( 0, "General" );
            m_opt2 = new Options2( 0, "Appearance" );
            m_opt4 = new Options4( 0, "Playback" );
    Options5 *opt5 = new Options5( 0, "OSD" );
    QVBox    *opt6 = new QVBox;
            m_opt7 = new Options7( 0, "Collection" );
    Options8 *opt8 = new Options8( 0, "Scrobbler" );
    QVBox    *opt9 = new QVBox;

    // Sound System
    opt6->setName( "Engine" );
    opt6->setSpacing( KDialog::spacingHint() );
    QWidget *groupBox, *aboutEngineButton;
    groupBox            = new QGroupBox( 2, Qt::Horizontal, i18n("Sound System"), opt6 );
    m_engineConfigFrame = new QGroupBox( 1, Qt::Horizontal, opt6 );
    m_soundSystem       = new QComboBox( false, groupBox );
    aboutEngineButton   = new QPushButton( i18n("About"), groupBox );

    QToolTip::add( m_soundSystem, i18n("Click to select the sound system to use for playback.") );
    QToolTip::add( aboutEngineButton, i18n("Click to get the plugin information.") );

    /// Populate the engine selection combo box
    KTrader::OfferList offers = PluginManager::query( "[X-KDE-amaroK-plugintype] == 'engine'" );
    KTrader::OfferList::ConstIterator end( offers.end() );
    for( KTrader::OfferList::ConstIterator it = offers.begin(); it != end; ++it ) {
        // Don't list the <no engine> (void engine) entry if it's not currenty active,
        // cause there's no point in choosing this engine (it's a dummy, after all).
        if( (*it)->property( "X-KDE-amaroK-name" ).toString() == "void-engine"
            && AmarokConfig::soundSystem() != "void-engine" ) continue;

        m_soundSystem->insertItem( (*it)->name() );
        // Save name properties in QMap for lookup
        m_pluginName[(*it)->name()] = (*it)->property( "X-KDE-amaroK-name" ).toString();
        m_pluginAmarokName[(*it)->property( "X-KDE-amaroK-name" ).toString()] = (*it)->name();
    }

    // Collection
#if !defined(USE_MYSQL) && !defined(USE_POSTGRESQL)
    m_opt7->databaseBox->hide();
#endif

#ifndef USE_MYSQL
    //FIXME we do this because this widget breaks the Apply button (always enabled).
    //It breaks because it is set to type="password" in the .kcfg file. Setting to
    //type="string" also fixes this bug, but means the password is stored in plain
    //text. This is a temporary fix so that the majority of users get a fixed Apply
    //button.
    delete m_opt7->dbSetupFrame->kcfg_MySqlPassword2;
#endif
    m_opt7->collectionFoldersBox->setColumns( 1 );
    new CollectionSetup( m_opt7->collectionFoldersBox ); //TODO this widget doesn't update the apply/ok buttons

    // Media Devices
    opt9->setName( "Media Devices" );
    opt9->setSpacing( KDialog::spacingHint() );
    QVBox *topbox = new QVBox( opt9 );
    topbox->setSpacing( KDialog::spacingHint() );
    QGroupBox *mediaBox  = new QGroupBox( 2, Qt::Horizontal, i18n("Media Devices"), topbox );
    mediaBox->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Minimum );
    QVBox *vbox = new QVBox( mediaBox );
    vbox->setSpacing( KDialog::spacingHint() );
    m_deviceManager = new MediumPluginManager( vbox );

    QHBox *hbox = new QHBox( topbox );
    hbox->setSpacing( KDialog::spacingHint() );
    hbox->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Minimum );
    KPushButton *autodetect = new KPushButton( i18n( "Autodetect Devices" ), hbox );
    autodetect->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
    connect( autodetect, SIGNAL(clicked()), m_deviceManager, SLOT(redetectDevices()) );
    KPushButton *add = new KPushButton( i18n( "Add Device..." ), hbox );
    add->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
    connect( add, SIGNAL(clicked()), m_deviceManager, SLOT(newDevice()) );

    QFrame *frame = new QFrame( topbox );
    frame->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding );

    // add pages
    addPage( m_opt1, i18n( "General" ), "misc", i18n( "Configure General Options" ) );
    addPage( m_opt2, i18n( "Appearance" ), "colors", i18n( "Configure amaroK's Appearance" ) );
    addPage( m_opt4, i18n( "Playback" ), "kmix", i18n( "Configure Playback" ) );
    addPage( opt5,   i18n( "OSD" ), "tv", i18n( "Configure On-Screen-Display" ) );
    addPage( opt6,   i18n( "Engine" ), "amarok", i18n( "Configure Engine" ) );
    addPage( m_opt7, i18n( "Collection" ), amaroK::icon( "collection" ), i18n( "Configure Collection" ) );
    addPage( opt8,   i18n( "last.fm" ), "audioscrobbler", i18n( "Configure last.fm Support" ) );
    addPage( opt9,   i18n( "Media Devices" ), amaroK::icon( "device" ), i18n( "Configure Portable Player Support" ) );

    // Show information labels (must be done after insertions)
    QObjectList *list = queryList( "QLabel", "infoPixmap" );
    for( QObject *label = list->first(); label; label = list->next() )
        static_cast<QLabel*>(label)->setPixmap( QMessageBox::standardIcon( QMessageBox::Information ) );
    delete list;

    //stop KFont Requesters getting stupidly large
    list = queryList( "QLabel", "m_sampleLabel" );
    for( QObject *label = list->first(); label; label = list->next() )
        static_cast<QLabel*>(label)->setMaximumWidth( 250 );
    delete list;

    connect( m_deviceManager, SIGNAL(changed()), SLOT(updateButtons()) );
    connect( m_soundSystem, SIGNAL(activated( int )), SLOT(updateButtons()) );
    connect( aboutEngineButton, SIGNAL(clicked()), SLOT(aboutEngine()) );
    connect( opt5, SIGNAL(settingsChanged()), SLOT(updateButtons()) ); //see options5.ui.h
    connect( m_opt2->styleComboBox, SIGNAL( activated( int ) ), SLOT( updateButtons() ) );
    connect( m_opt7->dbSetupFrame->databaseEngine, SIGNAL( activated( int ) ), SLOT( updateButtons() ) );
    connect( m_opt1->kComboBox_browser, SIGNAL( activated( int ) ), SLOT( updateButtons() ) );
    connect( m_opt1->kLineEdit_customBrowser, SIGNAL( textChanged( const QString& ) ), SLOT( updateButtons() ) );
}
ConfigBackendsPage::ConfigBackendsPage( Config *_config, QWidget *parent )
    : ConfigPageBase( parent ),
    config( _config )
{
    QVBoxLayout *box = new QVBoxLayout( this );

    QFont groupFont;
    groupFont.setBold( true );

    QLabel *lCdRipper = new QLabel( i18n("CD ripper"), this );
    lCdRipper->setFont( groupFont );
    box->addWidget( lCdRipper );

    box->addSpacing( ConfigDialogSpacingSmall );

    QHBoxLayout *ripperBox = new QHBoxLayout();
    ripperBox->addSpacing( ConfigDialogOffset );
    box->addLayout( ripperBox );
    QLabel *lSelectorRipper = new QLabel( i18n("Use plugin:"), this );
    ripperBox->addWidget( lSelectorRipper );
    ripperBox->setStretchFactor( lSelectorRipper, 2 );
    cSelectorRipper = new KComboBox( this );
    cSelectorRipper->addItems( config->data.backends.rippers );
    ripperBox->addWidget( cSelectorRipper );
    ripperBox->setStretchFactor( cSelectorRipper, 1 );
    connect( cSelectorRipper, SIGNAL(activated(int)), this, SLOT(somethingChanged()) );
    connect( cSelectorRipper, SIGNAL(activated(const QString&)), this, SLOT(ripperChanged(const QString&)) );
    pConfigureRipper = new KPushButton( KIcon("configure"), "", this );
    pConfigureRipper->setFixedSize( cSelectorRipper->sizeHint().height(), cSelectorRipper->sizeHint().height() );
    pConfigureRipper->setFlat( true );
    ripperBox->addWidget( pConfigureRipper );
    ripperBox->setStretchFactor( pConfigureRipper, 1 );
    connect( pConfigureRipper, SIGNAL(clicked()), this, SLOT(configureRipper()) );

    box->addSpacing( ConfigDialogSpacingBig );

    QLabel *lFilters = new QLabel( i18n("Filters"), this );
    lFilters->setFont( groupFont );
    box->addWidget( lFilters );

    box->addSpacing( ConfigDialogSpacingSmall );

    QHBoxLayout *filterBox = new QHBoxLayout();
    filterBox->addSpacing( ConfigDialogOffset );
    box->addLayout( filterBox );
    QGridLayout *filterGrid = new QGridLayout();

    int row = 0;
    foreach( const QString filterPluginName, config->data.backends.filters )
    {
        if( row == 0 )
        {
            QLabel *lSelectorFilter = new QLabel( i18n("Enable plugins:"), this );
            filterGrid->addWidget( lSelectorFilter, row, 0 );
        }

        QCheckBox *newCheckBox = new QCheckBox( filterPluginName, this );
        newCheckBox->setChecked( config->data.backends.enabledFilters.contains(filterPluginName) );
        filterGrid->addWidget( newCheckBox, row, 1 );
        filterCheckBoxes.append( newCheckBox );
        connect( newCheckBox, SIGNAL(stateChanged(int)), this, SLOT(somethingChanged()) );

        KPushButton *newConfigButton = new KPushButton( KIcon("configure"), "", this );
        newConfigButton->setFixedSize( cSelectorRipper->sizeHint().height(), cSelectorRipper->sizeHint().height() );
        newConfigButton->setFlat( true );
        filterGrid->addWidget( newConfigButton, row, 2 );
        connect( newConfigButton, SIGNAL(clicked()), this, SLOT(configureFilter()) );
        filterConfigButtons.append( newConfigButton );

        FilterPlugin *plugin = qobject_cast<FilterPlugin*>(config->pluginLoader()->backendPluginByName(filterPluginName));
        if( plugin )
        {
            newConfigButton->setEnabled( plugin->isConfigSupported(BackendPlugin::General,"") );
        }
        else
        {
            newConfigButton->setEnabled( false );
        }

        if( newConfigButton->isEnabled() )
            newConfigButton->setToolTip( i18n("Configure %1 ...",filterPluginName) );

        row++;
    }

    filterGrid->setColumnStretch( 0, 2 );
    filterGrid->setColumnStretch( 1, 1 );
    filterBox->addLayout( filterGrid );

    box->addSpacing( ConfigDialogSpacingBig );

    QLabel *lPriorities = new QLabel( i18n("Priorities"), this );
    lPriorities->setFont( groupFont );
    box->addWidget( lPriorities );

    box->addSpacing( ConfigDialogSpacingSmall );

    QVBoxLayout *formatBox = new QVBoxLayout();
    box->addLayout( formatBox, 1 );

    QHBoxLayout *formatSelectorBox = new QHBoxLayout();
    formatSelectorBox->addSpacing( ConfigDialogOffset );
    formatBox->addLayout( formatSelectorBox );
    QLabel *lSelectorFormat = new QLabel( i18n("Configure plugin priorities for format:"), this );
    formatSelectorBox->addWidget( lSelectorFormat );
    cSelectorFormat = new KComboBox( this );
    cSelectorFormat->addItems( config->pluginLoader()->formatList(PluginLoader::Possibilities(PluginLoader::Encode|PluginLoader::Decode|PluginLoader::ReplayGain),PluginLoader::CompressionType(PluginLoader::InferiorQuality|PluginLoader::Lossy|PluginLoader::Lossless|PluginLoader::Hybrid)) );
    cSelectorFormat->removeItem( cSelectorFormat->findText("wav") );
    cSelectorFormat->removeItem( cSelectorFormat->findText("audio cd") );
    formatSelectorBox->addWidget( cSelectorFormat );
    connect( cSelectorFormat, SIGNAL(activated(const QString&)), this, SLOT(formatChanged(const QString&)) );
    formatSelectorBox->addStretch();

    QHBoxLayout *formatBackendsBox = new QHBoxLayout();
    formatBackendsBox->addSpacing( ConfigDialogOffset );
    formatBox->addLayout( formatBackendsBox );
    decoderList = new BackendsListWidget( i18n("Decoder"), config, this );
    formatBackendsBox->addWidget( decoderList );
    connect( decoderList, SIGNAL(orderChanged()), this, SLOT(somethingChanged()) );
    encoderList = new BackendsListWidget( i18n("Encoder"), config, this );
    formatBackendsBox->addWidget( encoderList );
    connect( encoderList, SIGNAL(orderChanged()), this, SLOT(somethingChanged()) );
    replaygainList = new BackendsListWidget( i18n("Replay Gain"), config, this );
    formatBackendsBox->addWidget( replaygainList );
    connect( replaygainList, SIGNAL(orderChanged()), this, SLOT(somethingChanged()) );

    QHBoxLayout *optimizationsBox = new QHBoxLayout();
    optimizationsBox->addSpacing( ConfigDialogOffset );
    formatBox->addLayout( optimizationsBox );
    optimizationsBox->addStretch();
    pShowOptimizations = new KPushButton( KIcon("games-solve"), i18n("Show possible optimizations"), this );
    optimizationsBox->addWidget( pShowOptimizations );
    connect( pShowOptimizations, SIGNAL(clicked()), this, SLOT(showOptimizations()) );
    optimizationsBox->addStretch();

    box->addStretch( 2 );

    ripperChanged( cSelectorRipper->currentText() );
    formatChanged( cSelectorFormat->currentText() );
}
KMultiFormListBoxWindowed::KMultiFormListBoxWindowed(KMultiFormListBoxFactory *factory, QWidget *parent,
																	 bool showUpDownButtons, bool showHelpButton,
																	 QString addButtonText)
  : QWidget( parent )
{
  _layout = new QVBoxLayout(this);

	QHBoxLayout *innerLayout = new QHBoxLayout();
	_layout->addLayout(innerLayout);

  _listbox = new KListWidget(this/*,"listbox"*/);
  _listbox->setSelectionMode(QAbstractItemView::SingleSelection);
  innerLayout->addWidget(_listbox);

  QVBoxLayout *buttons = new QVBoxLayout();
  innerLayout->addLayout(buttons);

  KPushButton *but = new KPushButton(addButtonText, this);
  but->setObjectName("Add Button");
  buttons->addWidget(but,0);
  connect(but, SIGNAL(clicked()), this, SLOT(addNewElement()));

  but = new KPushButton(i18n("Edit"), this);
  but->setObjectName("Edit Button");
  buttons->addWidget(but,0);
  connect(but,SIGNAL(clicked()), this, SLOT(slotEditSelected()));
  connect(_listbox, SIGNAL(itemDoubleClicked(QListWidgetItem *)), this, SLOT(slotEditSelected(QListWidgetItem *)));
	_buttonList.append(but);

  but = new KPushButton(i18n("Delete"), this);
  but->setObjectName("Delete Button");
  buttons->addWidget(but,0);
  connect(but, SIGNAL(clicked()), this, SLOT(slotDeleteEntry()));
	_buttonList.append(but);

  but = new KPushButton(i18n("Copy"), this);
  but->setObjectName("Copy Button");
  buttons->addWidget(but,0);
  connect(but, SIGNAL(clicked()), this, SLOT(slotCopySelected()));
	_buttonList.append(but);

	if (showUpDownButtons) {
		but = new KPushButton(i18n("Up"), this);
		but->setObjectName("Up Button");
		buttons->addWidget(but, 0);
		connect(but, SIGNAL(clicked()), this, SLOT(slotMoveItemUp()));
		_buttonList.append(but);

		but = new KPushButton(i18n("Down"), this);
		but->setObjectName( "Down Button");
		buttons->addWidget(but, 0);
		connect(but, SIGNAL(clicked()), this, SLOT(slotMoveItemDown()));
		_buttonList.append(but);
	}

	if (showHelpButton) {
		but = new KPushButton(KStandardGuiItem::help(), this);
		but->setObjectName( "Help Button");
		buttons->addWidget(but, 0);
		connect(but, SIGNAL(clicked()), this, SIGNAL(showHelp()));
	}

  buttons->addStretch(1);
  _factory = factory;
	slotUpdateButtonState();

}
void CommentItemsViewDelegate::updateItemWidgets( const QList<QWidget*> widgets,
        const QStyleOptionViewItem& option,
        const QPersistentModelIndex& index ) const
{
    const GluonPlayer::CommentItemsModel* model = qobject_cast<const GluonPlayer::CommentItemsModel*>( index.model() );
    if( !model )
    {
        kDebug() << "Warning - Invalid Model!";
        return;
    }

    // setup the install button
    int margin = option.fontMetrics.height() / 2;
    int right = option.rect.width();
    int bottom = option.rect.height();

    const_cast<QSize&>( m_buttonSize ) = QSize( 32, 32 );

    KPushButton* replyButton = qobject_cast<KPushButton*>( widgets.at( DelegateCommentReplyButton ) );
    if( replyButton )
    {
        replyButton->setVisible( const_cast<GluonPlayer::CommentItemsModel*>( model )->isOnline() );
        replyButton->setIcon( KIcon( "edit-undo" ) );
        replyButton->setSizePolicy( QSizePolicy::Maximum, QSizePolicy::MinimumExpanding );
        replyButton->resize( m_buttonSize );
        replyButton->move( right - replyButton->width() - margin, bottom - m_buttonSize.height() * 1.5 );
    }

    KSqueezedTextLabel* author = qobject_cast<KSqueezedTextLabel*>( widgets.at( DelegateCommentAuthor ) );
    if( author )
    {
        author->setSizePolicy( QSizePolicy::Maximum, QSizePolicy::MinimumExpanding );
        author->resize( right / 5, m_buttonSize.height() );
        author->move( margin, option.fontMetrics.height() );
        author->setText( index.data( GluonPlayer::CommentItemsModel::AuthorRole ).toString() );
    }

    KSqueezedTextLabel* dateTime = qobject_cast<KSqueezedTextLabel*>( widgets.at( DelegateCommentDateTime ) );
    if( dateTime )
    {
        dateTime->resize( author->size().width(), author->size().height() );
        dateTime->move( author->x() + author->size().width(), author->y() );
        dateTime->setText( index.data( GluonPlayer::CommentItemsModel::DateTimeRole ).toString() );
    }

    KSqueezedTextLabel* title = qobject_cast<KSqueezedTextLabel*>( widgets.at( DelegateCommentTitle ) );
    if( title )
    {
        title->resize( dateTime->size().width(), dateTime->size().height() );
        title->move( dateTime->x() + dateTime->size().width(), dateTime->y() );
        title->setText( index.data( GluonPlayer::CommentItemsModel::TitleRole ).toString() );
    }

    KSqueezedTextLabel* rating = qobject_cast<KSqueezedTextLabel*>( widgets.at( DelegateCommentRating ) );
    if( rating )
    {
        rating->resize( title->size().width(), title->size().height() );
        rating->move( title->x() + title->size().width(), title->y() );
        rating->setText( index.data( GluonPlayer::CommentItemsModel::RatingRole ).toString() );
    }

    KSqueezedTextLabel* body = qobject_cast<KSqueezedTextLabel*>( widgets.at( DelegateCommentBody ) );
    if( body )
    {
        body->resize( right - 2 * margin, bottom - author->size().height() - 2 * margin );
        body->move( margin, option.fontMetrics.height()  + author->size().height() );
        body->setText( index.data( GluonPlayer::CommentItemsModel::BodyRole ).toString() );
    }
}
Beispiel #20
0
bool
StdWidgetFactory::startEditing(const QCString &classname, QWidget *w, KFormDesigner::Container *container)
{
	setWidget(w, container);
//	m_container = container;
	if(classname == "KLineEdit")
	{
		KLineEdit *lineedit = static_cast<KLineEdit*>(w);
		createEditor(classname, lineedit->text(), lineedit, container, lineedit->geometry(), lineedit->alignment(), true);
		return true;
	}
	else if(classname == "QLabel")
	{
		QLabel *label = static_cast<QLabel*>(w);
		if(label->textFormat() == RichText)
		{
			//m_widget = w;
//			setWidget(w, container);
			editText();
		}
		else
			createEditor(classname, label->text(), label, container, label->geometry(), label->alignment());
		return true;
	}
	else if(classname == "KPushButton")
	{
		KPushButton *push = static_cast<KPushButton*>(w);
		QRect r = w->style().subRect(QStyle::SR_PushButtonContents, w);
		QRect editorRect = QRect(push->x() + r.x(), push->y() + r.y(), r.width(), r.height());
		//r.setX(r.x() + 5);
		//r.setY(r.y() + 5);
		//r.setWidth(r.width()-10);
		//r.setHeight(r.height() - 10);
		createEditor(classname, push->text(), push, container, editorRect, Qt::AlignCenter, false, false, Qt::PaletteButton);
		return true;
	}
	else if(classname == "QRadioButton")
	{
		QRadioButton *radio = static_cast<QRadioButton*>(w);
		QRect r = w->style().subRect(QStyle::SR_RadioButtonContents, w);
		QRect editorRect = QRect(radio->x() + r.x(), radio->y() + r.y(), r.width(), r.height());
		createEditor(classname, radio->text(), radio, container, editorRect, Qt::AlignAuto);
		return true;
	}
	else if(classname == "QCheckBox")
	{
		QCheckBox *check = static_cast<QCheckBox*>(w);
		//QRect r(check->geometry());
		//r.setX(r.x() + 20);
		QRect r = w->style().subRect(QStyle::SR_CheckBoxContents, w);
		QRect editorRect = QRect(check->x() + r.x(), check->y() + r.y(), r.width(), r.height());
		createEditor(classname, check->text(), check, container, editorRect, Qt::AlignAuto);
		return true;
	}
	else if((classname == "KComboBox") || (classname == "KListBox"))
	{
		QStringList list;
		if(classname == "KListBox")
		{
			KListBox *listbox = (KListBox*)w;
			for(uint i=0; i < listbox->count(); i++)
				list.append(listbox->text(i));
		}
		else if(classname == "KComboBox")
		{
			KComboBox *combo = (KComboBox*)w;
			for(int i=0; i < combo->count(); i++)
				list.append(combo->text(i));
		}

		if(editList(w, list))
		{
			if(classname == "KListBox")
			{
				((KListBox*)w)->clear();
				((KListBox*)w)->insertStringList(list);
			}
			else if(classname == "KComboBox")
			{
				((KComboBox*)w)->clear();
				((KComboBox*)w)->insertStringList(list);
			}
		}
		return true;
	}
	else if((classname == "KTextEdit") || (classname == "KDateTimeWidget") || (classname == "KTimeWidget") ||
		(classname == "KDateWidget") || (classname == "KIntSpinBox")) {
		disableFilter(w, container);
		return true;
	}
	return false;
}
Beispiel #21
0
CoverFoundDialog::CoverFoundDialog( const CoverFetchUnit::Ptr unit,
                                    const CoverFetch::Metadata &data,
                                    QWidget *parent )
    : KDialog( parent )
    , m_album( unit->album() )
    , m_isSorted( false )
    , m_sortEnabled( false )
    , m_unit( unit )
    , m_queryPage( 0 )
{
    DEBUG_BLOCK
    setButtons( KDialog::Ok | KDialog::Cancel |
                KDialog::User1 ); // User1: clear icon view

    setButtonGuiItem( KDialog::User1, KStandardGuiItem::clear() );
    connect( button( KDialog::User1 ), SIGNAL(clicked()), SLOT(clearView()) );

    m_save = button( KDialog::Ok );

    QSplitter *splitter = new QSplitter( this );
    m_sideBar = new CoverFoundSideBar( m_album, splitter );

    KVBox *vbox = new KVBox( splitter );
    vbox->setSpacing( 4 );

    KHBox *breadcrumbBox = new KHBox( vbox );
    QLabel *breadcrumbLabel = new QLabel( i18n( "Finding cover for" ), breadcrumbBox );
    AlbumBreadcrumbWidget *breadcrumb = new AlbumBreadcrumbWidget( m_album, breadcrumbBox );

    QFont breadcrumbLabelFont;
    breadcrumbLabelFont.setBold( true );
    breadcrumbLabel->setFont( breadcrumbLabelFont );
    breadcrumbLabel->setIndent( 4 );

    connect( breadcrumb, SIGNAL(artistClicked(const QString&)), SLOT(addToCustomSearch(const QString&)) );
    connect( breadcrumb, SIGNAL(albumClicked(const QString&)), SLOT(addToCustomSearch(const QString&)) );

    KHBox *searchBox = new KHBox( vbox );
    vbox->setSpacing( 4 );

    QStringList completionNames;
    QString firstRunQuery( m_album->name() );
    completionNames << firstRunQuery;
    if( m_album->hasAlbumArtist() )
    {
        const QString &name = m_album->albumArtist()->name();
        completionNames << name;
        firstRunQuery += ' ' + name;
    }
    m_query = firstRunQuery;
    m_album->setSuppressImageAutoFetch( true );

    m_search = new KComboBox( searchBox );
    m_search->setEditable( true ); // creates a KLineEdit for the combobox
    m_search->setTrapReturnKey( true );
    m_search->setInsertPolicy( QComboBox::NoInsert ); // insertion is handled by us
    m_search->setCompletionMode( KGlobalSettings::CompletionPopup );
    m_search->setSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::Fixed );
    qobject_cast<KLineEdit*>( m_search->lineEdit() )->setClickMessage( i18n( "Enter Custom Search" ) );
    m_search->completionObject()->setOrder( KCompletion::Insertion );
    m_search->completionObject()->setIgnoreCase( true );
    m_search->completionObject()->setItems( completionNames );
    m_search->insertItem( 0, KStandardGuiItem::find().icon(), QString() );
    m_search->insertSeparator( 1 );
    m_search->insertItem( 2, KIcon("filename-album-amarok"), m_album->name() );
    if( m_album->hasAlbumArtist() )
        m_search->insertItem( 3, KIcon("filename-artist-amarok"), m_album->albumArtist()->name() );

    m_searchButton = new KPushButton( KStandardGuiItem::find(), searchBox );
    KPushButton *sourceButton = new KPushButton( KStandardGuiItem::configure(), searchBox );
    updateSearchButton( firstRunQuery );

    QMenu *sourceMenu = new QMenu( sourceButton );
    QAction *lastFmAct = new QAction( i18n( "Last.fm" ), sourceMenu );
    QAction *googleAct = new QAction( i18n( "Google" ), sourceMenu );
    QAction *yahooAct = new QAction( i18n( "Yahoo!" ), sourceMenu );
    QAction *discogsAct = new QAction( i18n( "Discogs" ), sourceMenu );
    lastFmAct->setCheckable( true );
    googleAct->setCheckable( true );
    yahooAct->setCheckable( true );
    discogsAct->setCheckable( true );
    connect( lastFmAct, SIGNAL(triggered()), this, SLOT(selectLastFm()) );
    connect( googleAct, SIGNAL(triggered()), this, SLOT(selectGoogle()) );
    connect( yahooAct, SIGNAL(triggered()), this, SLOT(selectYahoo()) );
    connect( discogsAct, SIGNAL(triggered()), this, SLOT(selectDiscogs()) );

    m_sortAction = new QAction( i18n( "Sort by size" ), sourceMenu );
    m_sortAction->setCheckable( true );
    connect( m_sortAction, SIGNAL(triggered(bool)), this, SLOT(sortingTriggered(bool)) );

    QActionGroup *ag = new QActionGroup( sourceButton );
    ag->addAction( lastFmAct );
    ag->addAction( googleAct );
    ag->addAction( yahooAct );
    ag->addAction( discogsAct );
    sourceMenu->addActions( ag->actions() );
    sourceMenu->addSeparator();
    sourceMenu->addAction( m_sortAction );
    sourceButton->setMenu( sourceMenu );

    connect( m_search, SIGNAL(returnPressed(const QString&)), SLOT(insertComboText(const QString&)) );
    connect( m_search, SIGNAL(returnPressed(const QString&)), SLOT(processQuery(const QString&)) );
    connect( m_search, SIGNAL(returnPressed(const QString&)), SLOT(updateSearchButton(const QString&)) );
    connect( m_search, SIGNAL(editTextChanged(const QString&)), SLOT(updateSearchButton(const QString&)) );
    connect( m_search->lineEdit(), SIGNAL(clearButtonClicked()), SLOT(clearQueryButtonClicked()));
    connect( m_searchButton, SIGNAL(clicked()), SLOT(processQuery()) );

    m_view = new KListWidget( vbox );
    m_view->setAcceptDrops( false );
    m_view->setContextMenuPolicy( Qt::CustomContextMenu );
    m_view->setDragDropMode( QAbstractItemView::NoDragDrop );
    m_view->setDragEnabled( false );
    m_view->setDropIndicatorShown( false );
    m_view->setMovement( QListView::Static );
    m_view->setGridSize( QSize( 140, 150 ) );
    m_view->setIconSize( QSize( 120, 120 ) );
    m_view->setSpacing( 4 );
    m_view->setViewMode( QListView::IconMode );
    m_view->setResizeMode( QListView::Adjust );

    connect( m_view, SIGNAL(currentItemChanged(QListWidgetItem*, QListWidgetItem*)),
             this,   SLOT(currentItemChanged(QListWidgetItem*, QListWidgetItem*)) );
    connect( m_view, SIGNAL(itemDoubleClicked(QListWidgetItem*)),
             this,   SLOT(itemDoubleClicked(QListWidgetItem*)) );
    connect( m_view, SIGNAL(customContextMenuRequested(const QPoint&)),
             this,   SLOT(itemMenuRequested(const QPoint&)) );

    splitter->addWidget( m_sideBar );
    splitter->addWidget( vbox );
    setMainWidget( splitter );

    const KConfigGroup config = Amarok::config( "Cover Fetcher" );
    const QString source = config.readEntry( "Interactive Image Source", "LastFm" );
    m_sortEnabled = config.readEntry( "Sort by Size", false );
    m_sortAction->setChecked( m_sortEnabled );
    m_isSorted = m_sortEnabled;
    restoreDialogSize( config ); // call this after setMainWidget()

    if( source == "LastFm" )
        lastFmAct->setChecked( true );
    else if( source == "Yahoo" )
        yahooAct->setChecked( true );
    else if( source == "Discogs" )
        discogsAct->setChecked( true );
    else
        googleAct->setChecked( true );

    typedef CoverFetchArtPayload CFAP;
    const CFAP *payload = dynamic_cast< const CFAP* >( unit->payload() );
    if( !m_album->hasImage() )
        m_sideBar->setPixmap( QPixmap::fromImage( m_album->image(190 ) ) );
    else if( payload )
        add( m_album->image(), data, payload->imageSize() );
    else
        add( m_album->image(), data );
    m_view->setCurrentItem( m_view->item( 0 ) );
    updateGui();
    
    connect( The::networkAccessManager(), SIGNAL( requestRedirected( QNetworkReply*, QNetworkReply* ) ),
             this, SLOT( fetchRequestRedirected( QNetworkReply*, QNetworkReply* ) ) );
}
GalleryWindow::GalleryWindow(Interface* interface, QWidget *parent, Gallery* pGallery)
    : KDialog(parent),
      m_interface(interface),
      mpGallery(pGallery),
      d(new Private(this))
{
    setWindowTitle( i18n("Gallery Export") );
    setButtons( KDialog::Close | KDialog::User1 | KDialog::Help);
    setModal(false);

    // About data.
    m_about = new KPAboutData(ki18n("Gallery Export"),
                              0,
                              KAboutData::License_GPL,
                              ki18n("A Kipi plugin to export image collections to a remote Gallery server."),
                              ki18n("(c) 2003-2005, Renchi Raju\n"
                                    "(c) 2006-2007, Colin Guthrie\n"
                                    "(c) 2006-2009, Gilles Caulier\n"
                                    "(c) 2008, Andrea Diamantini\n"));

    m_about->addAuthor(ki18n("Renchi Raju"), ki18n("Author"),
                       "renchi dot raju at gmail dot com");

    m_about->addAuthor(ki18n("Colin Guthrie"), ki18n("Maintainer"),
                       "kde at colin dot guthr dot ie");

    m_about->addAuthor(ki18n("Andrea Diamantini"), ki18n("Developer"),
                       "adjam7 at gmail dot com");

    m_about->addAuthor(ki18n("Gilles Caulier"), ki18n("Developer"),
                       "caulier dot gilles at gmail dot com");

    // help button

    disconnect(this, SIGNAL(helpClicked()),
               this, SLOT(slotHelp()));

    KHelpMenu *helpMenu = new KHelpMenu(this, m_about, false);
    helpMenu->menu()->removeAction(helpMenu->menu()->actions().first());
    QAction *handbook   = new QAction(i18n("Handbook"), this);
    connect(handbook, SIGNAL(triggered(bool)),
            this, SLOT(slotHelp()));
    helpMenu->menu()->insertAction(helpMenu->menu()->actions().first(), handbook);
    button(Help)->setMenu(helpMenu->menu());

    // User1 Button : to conf gallery settings
    KPushButton *confButton = button( User1 );
    confButton->setText( i18n("Settings") );
    confButton->setIcon( KIcon("configure") );
    connect(confButton, SIGNAL(clicked()),
            this, SLOT(slotSettings()) );

    // we need to let m_talker work..
    m_talker = new GalleryTalker(d->widget);

    // setting progressDlg and its numeric hints
    m_progressDlg = new QProgressDialog(this);
    m_progressDlg->setModal(true);
    m_progressDlg->setAutoReset(true);
    m_progressDlg->setAutoClose(true);
    m_uploadCount = 0;
    m_uploadTotal = 0;
    mpUploadList  = new QStringList;

    // connect functions
    connectSignals();

    // read Settings
    readSettings();

    slotDoLogin();
}