K3bInteractionDialog::K3bInteractionDialog( QWidget* parent, const char* name, const QString& title, const QString& subTitle, int buttonMask, int defaultButton, const QString& configGroup, bool modal, WFlags fl ) : KDialog( parent, name, modal, fl ), m_mainWidget(0), m_defaultButton(defaultButton), m_configGroup(configGroup), m_exitLoopOnHide(true), m_inLoop(false), m_inToggleMode(false), m_delayedInit(false) { installEventFilter( this ); mainGrid = new QGridLayout( this ); mainGrid->setSpacing( spacingHint() ); mainGrid->setMargin( marginHint() ); // header // --------------------------------------------------------------------------------------------------- m_dialogHeader = new K3bThemedHeader( this ); mainGrid->addMultiCellWidget( m_dialogHeader, 0, 0, 0, 2 ); // settings buttons // --------------------------------------------------------------------------------------------------- if( !m_configGroup.isEmpty() ) { QHBoxLayout* layout2 = new QHBoxLayout( 0, 0, spacingHint(), "layout2"); m_buttonLoadSettings = new K3bToolButton( /*i18n("User Defaults"), */this ); ((K3bToolButton*)m_buttonLoadSettings)->setIconSet( SmallIconSet( "revert" ) ); QPopupMenu* userDefaultsPopup = new QPopupMenu( m_buttonLoadSettings ); userDefaultsPopup->insertItem( i18n("Load default settings"), this, SLOT(slotLoadK3bDefaults()) ); userDefaultsPopup->insertItem( i18n("Load saved settings"), this, SLOT(slotLoadUserDefaults()) ); userDefaultsPopup->insertItem( i18n("Load last used settings"), this, SLOT(slotLoadLastSettings()) ); ((QToolButton*)m_buttonLoadSettings)->setPopup( userDefaultsPopup ); ((K3bToolButton*)m_buttonLoadSettings)->setInstantMenu( true ); layout2->addWidget( m_buttonLoadSettings ); m_buttonSaveSettings = new QToolButton( /*i18n("Save User Defaults"), */this, "m_buttonSaveSettings" ); ((QToolButton*)m_buttonSaveSettings)->setIconSet( SmallIconSet( "filesave" ) ); layout2->addWidget( m_buttonSaveSettings ); mainGrid->addLayout( layout2, 2, 0 ); } QSpacerItem* spacer = new QSpacerItem( 10, 10, QSizePolicy::Expanding, QSizePolicy::Minimum ); mainGrid->addItem( spacer, 2, 1 ); // action buttons // --------------------------------------------------------------------------------------------------- QHBoxLayout* layout5 = new QHBoxLayout( 0, 0, spacingHint(), "layout5"); if( buttonMask & START_BUTTON ) { KGuiItem startItem = KStdGuiItem::ok(); m_buttonStart = new KPushButton( startItem, this, "m_buttonStart" ); // refine the button text setButtonText( START_BUTTON, i18n("Start"), i18n("Start the task") ); QFont fnt( m_buttonStart->font() ); fnt.setBold(true); m_buttonStart->setFont( fnt ); } else m_buttonStart = 0; if( buttonMask & SAVE_BUTTON ) { m_buttonSave = new KPushButton( KStdGuiItem::save(), this, "m_buttonSave" ); } else m_buttonSave = 0; if( buttonMask & CANCEL_BUTTON ) { m_buttonCancel = new KPushButton( KConfigGroup( k3bcore->config(), "General Options" ) .readBoolEntry( "keep action dialogs open", false ) ? KStdGuiItem::close() : KStdGuiItem::cancel(), this, "m_buttonCancel" ); } else m_buttonCancel = 0; // we only handle some of the possible settings since // our buttons are always to the right of the dialog int btl = 0; #if KDE_IS_VERSION(3,3,0) btl = KGlobalSettings::buttonLayout(); #endif switch( btl ) { case 0: // KDE default default: if ( m_buttonStart ) layout5->addWidget( m_buttonStart ); if ( m_buttonSave ) layout5->addWidget( m_buttonSave ); if ( m_buttonCancel ) layout5->addWidget( m_buttonCancel ); break; case 1: // something different if ( m_buttonCancel ) layout5->addWidget( m_buttonCancel ); if ( m_buttonSave ) layout5->addWidget( m_buttonSave ); if ( m_buttonStart ) layout5->addWidget( m_buttonStart ); break; case 2: // GTK-Style if ( m_buttonSave ) layout5->addWidget( m_buttonSave ); if ( m_buttonCancel ) layout5->addWidget( m_buttonCancel ); if ( m_buttonStart ) layout5->addWidget( m_buttonStart ); break; } mainGrid->addLayout( layout5, 2, 2 ); mainGrid->setRowStretch( 1, 1 ); setTitle( title, subTitle ); initConnections(); initToolTipsAndWhatsThis(); setDefaultButton( START_BUTTON ); }
K3b::InteractionDialog::InteractionDialog( QWidget* parent, const QString& title, const QString& subTitle, int buttonMask, int defaultButton, const QString& configGroup ) : QDialog( parent ), m_mainWidget(0), m_defaultButton(defaultButton), m_configGroup(configGroup), m_inToggleMode(false), m_delayedInit(false) { installEventFilter( this ); mainGrid = new QGridLayout( this ); // header // --------------------------------------------------------------------------------------------------- m_dialogHeader = new K3b::ThemedHeader( this ); mainGrid->addWidget( m_dialogHeader, 0, 0, 1, 3 ); // settings buttons // --------------------------------------------------------------------------------------------------- if( !m_configGroup.isEmpty() ) { QHBoxLayout* layout2 = new QHBoxLayout; m_buttonLoadSettings = new QToolButton( this ); m_buttonLoadSettings->setIcon( QIcon::fromTheme( "document-revert" ) ); m_buttonLoadSettings->setPopupMode( QToolButton::InstantPopup ); QMenu* userDefaultsPopup = new QMenu( m_buttonLoadSettings ); userDefaultsPopup->addAction( i18n("Load default settings"), this, SLOT(slotLoadK3bDefaults()) ); userDefaultsPopup->addAction( i18n("Load saved settings"), this, SLOT(slotLoadUserDefaults()) ); userDefaultsPopup->addAction( i18n("Load last used settings"), this, SLOT(slotLoadLastSettings()) ); m_buttonLoadSettings->setMenu( userDefaultsPopup ); layout2->addWidget( m_buttonLoadSettings ); m_buttonSaveSettings = new QToolButton( this ); m_buttonSaveSettings->setIcon( QIcon::fromTheme( "document-save" ) ); layout2->addWidget( m_buttonSaveSettings ); mainGrid->addLayout( layout2, 2, 0 ); } QSpacerItem* spacer = new QSpacerItem( 10, 10, QSizePolicy::Expanding, QSizePolicy::Minimum ); mainGrid->addItem( spacer, 2, 1 ); // action buttons // --------------------------------------------------------------------------------------------------- QDialogButtonBox *buttonBox = new QDialogButtonBox( this ); connect( buttonBox, SIGNAL(accepted()), this, SLOT(accept()) ); connect( buttonBox, SIGNAL(rejected()), this, SLOT(reject()) ); if( buttonMask & START_BUTTON ) { m_buttonStart = new QPushButton( buttonBox ); KGuiItem::assign( m_buttonStart, KStandardGuiItem::ok() ); // refine the button text setButtonText( START_BUTTON, i18n("Start"), i18n("Start the task") ); QFont fnt( m_buttonStart->font() ); fnt.setBold(true); m_buttonStart->setFont( fnt ); buttonBox->addButton( m_buttonStart, QDialogButtonBox::AcceptRole ); } if( buttonMask & SAVE_BUTTON ) { m_buttonSave = new QPushButton( buttonBox ); KGuiItem::assign( m_buttonSave, KStandardGuiItem::save() ); buttonBox->addButton( m_buttonSave, QDialogButtonBox::ApplyRole ); } else { m_buttonSave = 0; } if( buttonMask & CANCEL_BUTTON ) { m_buttonCancel = new QPushButton( buttonBox ); KGuiItem::assign( m_buttonCancel, KConfigGroup( KSharedConfig::openConfig(), "General Options" ) .readEntry( "keep action dialogs open", false ) ? KStandardGuiItem::close() : KStandardGuiItem::cancel() ); buttonBox->addButton( m_buttonCancel, QDialogButtonBox::RejectRole ); } else { m_buttonCancel = 0; } mainGrid->addWidget( buttonBox, 2, 2 ); mainGrid->setRowStretch( 1, 1 ); setTitle( title, subTitle ); initConnections(); initToolTipsAndWhatsThis(); setDefaultButton( START_BUTTON ); }