Exemple #1
0
int
StopAction::plug( QWidget *w, int index )
{
    KToolBar *bar = dynamic_cast<KToolBar*>(w);

    if( bar && kapp->authorizeKAction( name() ) )
    {
        const int id = KAction::getToolButtonID();

        addContainer( bar, id );
        connect( bar, SIGNAL( destroyed() ), SLOT( slotDestroyed() ) );

        bar->insertButton( QString::null, id, SIGNAL( clicked() ), EngineController::instance(), SLOT( stop() ),
                           true, i18n( "Stop" ), index );

        KToolBarButton* button = bar->getButton( id );
        button->setDelayedPopup( Amarok::StopMenu::instance() );
        button->setName( "toolbutton_stop_menu" );
        button->setIcon( Amarok::icon( "stop" ) );
        button->setEnabled( EngineController::instance()->engine()->loaded() );  // Disable button at startup

        return containerCount() - 1;
    }
    else return KAction::plug( w, index );
}
Exemple #2
0
SxEditor::SxEditor( const QString& file, const QString& name, QObject *parent /*= NULL*/ )
: QObject(parent)
, m_szFile(file)
, m_pTextEdit(NULL)
{
	m_pWindow = KXmlUI::windowFromFile("res:/Resources/layout/sxeditor.xml");
	KXmlUI::setPropertyEx(m_pWindow, "titlebar.title", name);

	KWidget *rootWidget = m_pWindow->rootWidget();
	KToolBar *toolbar = rootWidget->findChild<KToolBar*>("edittoolbar");
	QGraphicsLinearLayout *linear = dynamic_cast<QGraphicsLinearLayout*>(toolbar->layout());
	for(int i = 0; i < linear->count(); i++)
	{
		QGraphicsLayoutItem * item = linear->itemAt(i);
		KPushButton *button = dynamic_cast<KPushButton*>(item);
		if(button)
		{
			bool bok = QObject::connect(button, SIGNAL(clicked()), this, SLOT(on_common_command_clicked()));
		}
	}

	m_pTextEdit = rootWidget->findChild<SxRichEdit*>("richtexteditor");
	QObject::connect(m_pTextEdit, SIGNAL(contextMenu(QMenu*,bool*)), this, SLOT(on_editor_contextMenu(QMenu*,bool*)));

	QFont font("SimSun", 9);
	m_pTextEdit->setFont(font);

	QPoint pt = KUtility::nextCascadesWindowPosition();
	m_pWindow->move(pt);
	m_pWindow->show();

	QObject::connect(m_pWindow, SIGNAL(aboutToClose()), this, SLOT(on_aboutToClose_triggered()));
	
	QMetaObject::invokeMethod(this, "asynOpen", Qt::QueuedConnection);
}
Exemple #3
0
int PMSpinBoxAction::plug( QWidget* w, int index )
{
    if( !w->inherits( "KToolBar" ) )
        return -1;

    KToolBar* toolBar = ( KToolBar* ) w;

    int id = KAction::getToolButtonID( );

    QSpinBox* spinBox = new QSpinBox( -1000, 1000, 1, w );
    toolBar->insertWidget( id, 70, spinBox, index );

    connect( spinBox, SIGNAL( valueChanged( int ) ), m_receiver, m_member );

    addContainer( toolBar, id );

    connect( toolBar, SIGNAL( destroyed( ) ), this, SLOT( slotDestroyed( ) ) );
    //toolBar->setItemAutoSized( id, false );

    m_spinBox = spinBox;

    emit plugged( );

    QWhatsThis::add( spinBox, whatsThis( ) );

    return containerCount( ) - 1;
}
Exemple #4
0
int
MenuAction::plug( QWidget *w, int index )
{
    KToolBar *bar = dynamic_cast<KToolBar*>(w);

    if( bar && kapp->authorizeKAction( name() ) )
    {
        const int id = KAction::getToolButtonID();

        addContainer( bar, id );
        connect( bar, SIGNAL( destroyed() ), SLOT( slotDestroyed() ) );

        //TODO create menu on demand
        //TODO create menu above and aligned within window
        //TODO make the arrow point upwards!
        bar->insertButton( QString::null, id, true, i18n( "Menu" ), index );
        bar->alignItemRight( id );

        KToolBarButton* button = bar->getButton( id );
        button->setPopup( Amarok::Menu::instance() );
        button->setName( "toolbutton_amarok_menu" );
        button->setIcon( "amarok" );

        return containerCount() - 1;
    }
    else return -1;
}
Exemple #5
0
int PMComboAction::plug( QWidget* w, int index )
{
    if( !w->inherits( "KToolBar" ) )
        return -1;

    KToolBar* toolBar = ( KToolBar* ) w;

    int id = KAction::getToolButtonID( );

    QComboBox* comboBox = new PMComboBox( toolBar );
    if( m_minWidth > 0 )
        comboBox->setMinimumWidth( m_minWidth );
    if( m_maxWidth > 0 )
        comboBox->setMaximumWidth( m_maxWidth );

    toolBar->insertWidget( id, m_minWidth > 0 ? m_minWidth : 300,
                           comboBox, index );
    connect( comboBox, SIGNAL( activated( int ) ), m_receiver, m_member );

    addContainer( toolBar, id );

    connect( toolBar, SIGNAL( destroyed( ) ), this, SLOT( slotDestroyed( ) ) );

    //toolBar->setItemAutoSized( id, true );

    m_combo = comboBox;

    emit plugged( );

    QWhatsThis::add( comboBox, whatsThis( ) );

    return containerCount( ) - 1;
}
int TKAction::plug(QWidget* widget, int index)
{
  if ( widget->inherits("KToolBar") ) {
    KToolBar* bar = static_cast<KToolBar*>(widget);
    int id_ = KAction::getToolButtonID();
    KInstance *instance;

    if ( parentCollection() )
      instance = parentCollection()->instance();
    else
      instance = KGlobal::instance();

    TKToolBarButton* b = new TKToolBarButton(icon(),plainText(),bar,name(),instance);
    // we don't need clicked() and buttonClicked(), do we?
    // connect(b,SIGNAL(clicked()),SLOT(slotActivated()));
    b->setIconMode(m_imode);
    initToolBarButton(b);

    bar->insertWidget( id_, 100, b, index );
    addContainer(bar,id_);
    connect( bar, SIGNAL(destroyed()), this, SLOT(slotDestroyed()) );

    return containerCount() - 1;
  }
  return KAction::plug(widget,index);
}
Exemple #7
0
QWidget* MainWindow::setupScriptPanel()
{
    m_hScriptSplitter = new QSplitter(this);
    m_hScriptSplitter->setOrientation(Qt::Horizontal);

    KToolBar *executeCommands = new KToolBar(this);
    executeCommands->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
    executeCommands->setOrientation(Qt::Vertical);
    m_runScript = new QAction(QIcon::fromTheme("media-playback-start"), i18nc("@action:intoolbar Script Execution", "Run"), this);
    m_runScript->setToolTip(i18nc("@info:tooltip", "Execute currently active script on active graph document."));
    m_stopScript = new QAction(QIcon::fromTheme("process-stop"), i18nc("@action:intoolbar Script Execution", "Stop"), this);
    m_stopScript->setToolTip(i18nc("@info:tooltip", "Stop script execution."));
    m_stopScript->setEnabled(false);
    executeCommands->addAction(m_runScript);
    executeCommands->addAction(m_stopScript);
    // add actions to action collection to be able to set shortcuts on them in the ui
    actionCollection()->addAction("_runScript", m_runScript);
    actionCollection()->addAction("_stopScript", m_stopScript);

    connect(m_runScript, &QAction::triggered, this, &MainWindow::executeScript);
    connect(m_stopScript, &QAction::triggered, this, &MainWindow::stopScript);

    m_hScriptSplitter->addWidget(m_codeEditorWidget);
    m_hScriptSplitter->addWidget(m_outputWidget);

    QWidget *scriptInterface = new QWidget(this);
    scriptInterface->setLayout(new QHBoxLayout);
    scriptInterface->layout()->addWidget(m_hScriptSplitter);
    scriptInterface->layout()->addWidget(executeCommands);

    return scriptInterface;
}
Exemple #8
0
UniversalPana::UniversalPana(KInstance *inst,QObject *parent,QWidget *widgetParent, QString &desktopName, const char* name):
                   KonqSidebarPlugin(inst,parent,widgetParent,desktopName,name)
{
    KGlobal::iconLoader()->addAppDir( "pana" );
    widget = new panaWidget( widgetParent );
//    widgetParent->resize(580,300);
    KToolBar *topBar = new KToolBar( widget, "Topbar" );
    topBar->setIconSize(16);
    topBar->insertButton( "today",    0, SIGNAL( clicked() ), this, SLOT( currentTrack() ) );
    topBar->insertButton( "document", 0, SIGNAL( clicked() ), this, SLOT( lyrics() ) );
    topBar->insertButton( "personal", 0, SIGNAL( clicked() ), this, SLOT( wiki() ) );

    browser = new KHTMLPart(widget, "widget-browser");
//browser=new KHTMLPart(widget);
    kdDebug() << "parentPart() << " << browser->parentPart() << endl;
    browser->setDNDEnabled( true );
    browser->setEncoding( "utf8", true );
    updateBrowser( HTML_FILE );
    browser->view()->installEventFilter( widget );
    panaDCOP = new DCOPClient();
    panaDCOP->attach();

    playerStub   = new PanaPlayerInterface_stub( panaDCOP, "pana", "player");
    playlistStub = new PanaPlaylistInterface_stub( panaDCOP, "pana", "playlist");
    contextStub = new PanaContextBrowserInterface_stub (panaDCOP, "pana", "contextbrowser");

    KToolBar* toolBar=new KToolBar(widget, "PlayerControls");

    toolBar->setIconSize(16);
    toolBar->insertButton( "player_start",0, SIGNAL( clicked() ), this, SLOT( sendPrev() ) );
    toolBar->insertButton( "player_play", 0, SIGNAL( clicked() ), this, SLOT( sendPlay() ) );
    toolBar->insertButton( "player_pause",0, SIGNAL( clicked() ), this, SLOT( sendPause() ) );
    toolBar->insertButton( "player_stop", 0, SIGNAL( clicked() ), this, SLOT( sendStop() ) );
    toolBar->insertButton( "player_end",  0, SIGNAL( clicked() ), this, SLOT( sendNext() ) );

    toolBar->insertSeparator();
    toolBar->insertButton( "arts",        0, SIGNAL( clicked() ), this, SLOT( sendMute() ) );

    vol_slider = new QSlider(0,100,1,0,Qt::Horizontal, toolBar,"volume");
    vol_slider->setLineStep(2);

    connect(vol_slider, SIGNAL( valueChanged(int) ), this, SLOT(volChanged(int ) ) );
    toolBar->insertWidget(1,2, vol_slider);

    fileInfo  = new QFileInfo(HTML_FILE);
    QTimer *t = new QTimer( this );

    connect( t, SIGNAL(timeout()), SLOT(updateStatus() ) );
    t->start( 2000, false );
    kdDebug() << "Connecting widget signal" << endl;

    connect( widget,                      SIGNAL( emitURL( const KURL &)),
             this,                        SLOT( openURLRequest( const KURL &) ) );
    connect( browser->browserExtension(), SIGNAL( openURLRequest( const KURL &, const KParts::URLArgs & ) ),
             this,                        SLOT( openURLRequest( const KURL & ) ) );
    widget->show();
}
KToolBar *ComposerWebEngineWidgetPrivate::createToolBar(const QList<ComposerWebEngine::ComposerWebEngineAction> &lstActions)
{
    KToolBar *toolbar = new KToolBar(q);
    toolbar->setIconSize(QSize(22, 22));
    toolbar->setToolButtonStyle(Qt::ToolButtonIconOnly);
    toolBarLayout->addWidget(toolbar);
    webEngine->createToolBar(lstActions, toolbar);
    listToolBar.append(toolbar);
    return toolbar;
}
Exemple #10
0
void KHelpMain::createLocationbar()
{
  KToolBar *tb = new KToolBar(this);

  tb->insertLined("", QLINEDIT_ITEM, SIGNAL( returnPressed() ), this, SLOT( slotLocationEntered() ) );
  tb->setFullWidth(TRUE);
  tb->setItemAutoSized( QLINEDIT_ITEM, TRUE);
  tb->enable(KToolBar::Show);

  location = tb;
}
Exemple #11
0
void PMSpinBoxAction::unplug( QWidget *w )
{
    if( !w->inherits( "KToolBar" ) )
        return;

    KToolBar *toolBar = (KToolBar *)w;

    int idx = findContainer( w );

    toolBar->removeItem( itemId( idx ) );

    removeContainer( idx );
    m_spinBox = 0L;
}
Exemple #12
0
FileBrowser::Private::Private( FileBrowser *parent )
    : placesModel( 0 )
    , showingPlaces( false )
    , q( parent )
{
    KHBox *topHBox = new KHBox( q );

    KToolBar *navigationToolbar = new KToolBar( topHBox );
    navigationToolbar->setToolButtonStyle( Qt::ToolButtonIconOnly );
    navigationToolbar->setIconDimensions( 16 );

    backAction = KStandardAction::back( q, SLOT(back()), topHBox );
    forwardAction = KStandardAction::forward( q, SLOT(forward()), topHBox );
    backAction->setEnabled( false );
    forwardAction->setEnabled( false );

    upAction = KStandardAction::up( q, SLOT(up()), topHBox );
    homeAction = KStandardAction::home( q, SLOT(home()), topHBox );
    placesAction = new KAction( KIcon( "folder-remote" ),
                               i18nc( "Show Dolphin Places the user configured", "Places" ),
                               topHBox );

    navigationToolbar->addAction( backAction );
    navigationToolbar->addAction( forwardAction );
    navigationToolbar->addAction( upAction );
    navigationToolbar->addAction( homeAction );
    navigationToolbar->addAction( placesAction );

    searchWidget = new SearchWidget( topHBox, false );
    searchWidget->setClickMessage( i18n( "Filter Files" ) );

    fileView = new FileView( q );
}
FileBrowser::Private::Private( FileBrowser *parent )
    : placesModel( 0 )
    , q( parent )
{
    KHBox *topHBox = new KHBox( q );

    KToolBar *navigationToolbar = new KToolBar( topHBox );
    navigationToolbar->setToolButtonStyle( Qt::ToolButtonIconOnly );
    navigationToolbar->setIconDimensions( 16 );

    backAction = KStandardAction::back( q, SLOT(back()), topHBox );
    forwardAction = KStandardAction::forward( q, SLOT(forward()), topHBox );
    backAction->setEnabled( false );
    forwardAction->setEnabled( false );

    upAction = KStandardAction::up( q, SLOT(up()), topHBox );
    homeAction = KStandardAction::home( q, SLOT(home()), topHBox );
    refreshAction = new KAction( KIcon("view-refresh"), i18n( "Refresh" ), topHBox );
    QObject::connect( refreshAction, SIGNAL(triggered(bool)), q, SLOT(refresh()) );

    navigationToolbar->addAction( backAction );
    navigationToolbar->addAction( forwardAction );
    navigationToolbar->addAction( upAction );
    navigationToolbar->addAction( homeAction );
    navigationToolbar->addAction( refreshAction );

    searchWidget = new SearchWidget( topHBox, false );
    searchWidget->setClickMessage( i18n( "Filter Files" ) );

    fileView = new FileView( q );
}
Exemple #14
0
void MainWindow::setupToolbars()
{
    kDebug() << "setup toolbars...";

    KAction *a;

    // location bar
    a = new KAction(i18n("Location Bar"), this);
    a->setDefaultWidget(m_view->widgetBar());
    actionCollection()->addAction( QL1S("url_bar"), a);

    KToolBar *mainBar = toolBar("mainToolBar");

    mainBar->show();  // this just to fix reopening rekonq after fullscreen close
}
Exemple #15
0
MainWindow::MainWindow( QWidget* parent, const char *name, WFlags f )
    : KMainWindow( parent, name, f )
{
  KToolBar *toolBar = new KToolBar( this );
  toolBar->insertButton("fileopen", Add, true, i18n("Add") );
  toolBar->insertButton("no", Remove, true, i18n("Remove") );
  toolBar->insertButton("reload", Refresh, true, i18n("Refresh") );
  connect( toolBar, SIGNAL(clicked(int)), this, SLOT(toolButton(int)) );

  m_list = new KListBox( this );
  setCentralWidget(m_list);
  
  m_pluginManager = new PluginManager;
  m_list->insertStringList(m_pluginManager->items());
}
Exemple #16
0
void PMLabelAction::unplug( QWidget *widget )
{
    if( widget->inherits( "KToolBar" ) )
    {
        KToolBar* bar = ( KToolBar* ) widget;

        int idx = findContainer( bar );

        if( idx != -1 )
        {
            bar->removeItem( itemId( idx ) );
            removeContainer( idx );
        }

        m_button = 0;
        return;
    }
}
Exemple #17
0
void TabBar::emptyAreaContextMenu(const QPoint &pos)
{
    setupHistoryActions();

    KMenu menu;
    MainWindow *mainWindow = Application::instance()->mainWindow();

    menu.addAction(mainWindow->actionByName( QL1S("new_tab") ));
    menu.addAction(mainWindow->actionByName( QL1S("open_last_closed_tab") ));
    menu.addAction(mainWindow->actionByName( QL1S("closed_tab_menu") ));
    menu.addSeparator();
    menu.addAction(mainWindow->actionByName( QL1S("reload_all_tabs") ));

    KToolBar *mainBar = mainWindow->toolBar("mainToolBar");
    if(!mainBar->isVisible())
    {
        menu.addAction( mainBar->toggleViewAction() );
    }

    menu.exec(pos);
}
Exemple #18
0
KWDocStruct::KWDocStruct(QWidget* parent, KWDocument* doc, KWGUI* gui)
    : QWidget(parent), m_doc(doc), m_gui(gui)
{
    m_layout = new QVBoxLayout( this );

    KToolBar* searchBar = new KToolBar( this );
    searchBar->setFlat( true );
    searchBar->setMovingEnabled( false );

    KToolBarButton* eraseButton = new KToolBarButton( "locationbar_erase", 0, searchBar );
    m_tree = new KWDocStructTree( this, doc, gui );
    m_tree->setAlternateBackground( KGlobalSettings::alternateBackgroundColor() );
    KListViewSearchLine* searchLine = new KListViewSearchLine( searchBar, m_tree );
    searchBar->setStretchableWidget( searchLine );
    connect( eraseButton, SIGNAL( clicked() ), searchLine, SLOT( clear() ) );

    m_layout->addWidget(searchBar);
    m_layout->addWidget(m_tree);
    m_tree->setup();
    dirtyTreeTypes = 0;
}
Exemple #19
0
FileDigger::FileDigger(MergedRepository *pRepository, QWidget *pParent)
   : KMainWindow(pParent)
{
	setWindowIcon(KIcon(QLatin1String("chronometer")));
	KToolBar *lAppToolBar = toolBar();
	lAppToolBar->addAction(KStandardAction::quit(this, SLOT(close()), this));
	QSplitter *lSplitter = new QSplitter();
	mMergedVfsModel = new MergedVfsModel(pRepository, this);
	mMergedVfsView = new QTreeView();
	mMergedVfsView->setHeaderHidden(true);
	mMergedVfsView->setSelectionMode(QAbstractItemView::SingleSelection);
	mMergedVfsView->setModel(mMergedVfsModel);
	lSplitter->addWidget(mMergedVfsView);
	connect(mMergedVfsView->selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)),
	        this, SLOT(updateVersionModel(QModelIndex,QModelIndex)));

	mVersionView = new QListView();
	mVersionView->setSelectionMode(QAbstractItemView::SingleSelection);
	mVersionModel = new VersionListModel(this);
	mVersionView->setModel(mVersionModel);
	VersionListDelegate *lVersionDelegate = new VersionListDelegate(mVersionView,this);
	mVersionView->setItemDelegate(lVersionDelegate);
	lSplitter->addWidget(mVersionView);
	connect(lVersionDelegate, SIGNAL(openRequested(QModelIndex)), SLOT(open(QModelIndex)));
	connect(lVersionDelegate, SIGNAL(restoreRequested(QModelIndex)), SLOT(restore(QModelIndex)));
	mMergedVfsView->setFocus();

	//expand all levels from the top until the node has more than one child
	QModelIndex lIndex;
	forever {
		mMergedVfsView->expand(lIndex);
		if(mMergedVfsModel->rowCount(lIndex) == 1) {
			lIndex = mMergedVfsModel->index(0, 0, lIndex);
		} else {
			break;
		}
	}
	mMergedVfsView->selectionModel()->setCurrentIndex(lIndex.child(0,0), QItemSelectionModel::Select);
	setCentralWidget(lSplitter);
}
Exemple #20
0
int PMLabelAction::plug( QWidget *widget, int index )
{
    //do not call the previous implementation here

    if( widget->inherits( "KToolBar" ) )
    {
        KToolBar* tb = ( KToolBar* ) widget;

        int id = KAction::getToolButtonID( );

        m_button = new PMToolBarLabel( text( ), widget );
        tb->insertWidget( id, m_button->width( ), m_button, index );

        addContainer( tb, id );

        connect( tb, SIGNAL( destroyed( ) ), this, SLOT( slotDestroyed( ) ) );

        return containerCount( ) - 1;
    }

    return -1;
}
Exemple #21
0
KonsolePreviewer::KonsolePreviewer(const QString & title, QWidget *parent, const QString& projectType,
                                   const QString& packagePath)
        : QDockWidget(title, parent),
        m_textEdit(0),
        m_projectType(projectType),
        m_packagePath(packagePath)
{
    QVBoxLayout *layout = new QVBoxLayout();
    KToolBar *toolBar = new KToolBar(this, true, true);

    KAction *clear = KStandardAction::clear(this, SLOT(clearOutput()), this);
    KAction *save = KStandardAction::save(this, SLOT(saveOutput()), this);

    //we want those only for the kwin scripts
    if (m_projectType == "KWin/Script") {
        KAction *execute = new KAction(this);
        execute->setText("Execute");
        execute->setIcon(KIcon("system-run"));
        connect(execute, SIGNAL(triggered(bool)), this, SLOT(executeKWinScript()));

        //add it to toolbar
        toolBar->addAction(execute);
    }
Exemple #22
0
int
AnalyzerAction::plug( QWidget *w, int index )
{
    //NOTE the analyzer will be deleted when the toolbar is deleted or cleared()
    //we are not designed for unplugging() yet so there would be a leak if that happens
    //but it's a rare event and unplugging is complicated.

    KToolBar *bar = dynamic_cast<KToolBar*>(w);

    if( bar && kapp->authorizeKAction( name() ) )
    {
        const int id = KAction::getToolButtonID();

        addContainer( w, id );
        connect( w, SIGNAL( destroyed() ), SLOT( slotDestroyed() ) );
        QWidget *container = new AnalyzerContainer( w );
        bar->insertWidget( id, 0, container, index );
        bar->setItemAutoSized( id, true );

        return containerCount() - 1;
    }
    else return -1;
}
Exemple #23
0
int
BurnMenuAction::plug( QWidget *w, int index )
{
    KToolBar *bar = dynamic_cast<KToolBar*>(w);

    if( bar && kapp->authorizeKAction( name() ) )
    {
        const int id = KAction::getToolButtonID();

        addContainer( bar, id );
        connect( bar, SIGNAL( destroyed() ), SLOT( slotDestroyed() ) );

        bar->insertButton( QString::null, id, true, i18n( "Burn" ), index );

        KToolBarButton* button = bar->getButton( id );
        button->setPopup( Amarok::BurnMenu::instance() );
        button->setName( "toolbutton_burn_menu" );
        button->setIcon( "k3b" );

        return containerCount() - 1;
    }
    else return -1;
}
Exemple #24
0
int TKBaseSelectAction::plug(QWidget* widget, int index)
{
  if ( widget->inherits("KToolBar") )
  {
    KToolBar* bar = static_cast<KToolBar*>( widget );
    int id_ = KAction::getToolButtonID();

    TKComboBox* cb = new TKComboBox(m_editable,bar);
    initComboBox(cb);
    cb->setMinimumWidth( cb->sizeHint().width() );
    QWidget* base = createLayout(bar,cb);

    bar->insertWidget( id_, 100, base, index );
    addContainer( bar, id_ );

    connect( bar, SIGNAL( destroyed() ), this, SLOT( slotDestroyed() ) );

    setCurrentItem(currentItem());

    return containerCount() - 1;
  }
  return -1;
}
Exemple #25
0
TextOutputWidget::TextOutputWidget(QWidget *parent)
: QWidget(parent)
{
  m_succesTextColor = QColor::fromRgb(3, 191, 3);
  m_succesBackgroundColor = QColor::fromRgb(231, 247, 231);

  m_errorTextColor = QColor::fromRgb(191, 3, 3);
  m_errorBackgroundColor = QColor::fromRgb(247, 231, 231);

  m_layout = new QHBoxLayout(this);

  m_output = new QTextEdit();
  m_output->setReadOnly(true);

  QFont fixedFont(KGlobalSettings::fixedFont());

  m_output->setCurrentFont(fixedFont);

  KToolBar *toolbar = new KToolBar(this);
  toolbar->setOrientation(Qt::Vertical);
  toolbar->setToolButtonStyle(Qt::ToolButtonIconOnly);
  toolbar->setIconSize(QSize(16, 16));

  /// TODO: disable actions if no results are displayed

  KAction *action;

  action = new KAction( KIcon("edit-clear"), i18nc("@action:intoolbar", "Clear"), this);
  toolbar->addAction(action);
  connect(action, SIGNAL(triggered()), m_output, SLOT(clear()));

  m_layout->addWidget(toolbar);
  m_layout->addWidget(m_output, 1);

  setLayout(m_layout);
}
KUI_project::KUI_project(QWidget* parent): KMainWindow(parent)
{
  model = 0;
  
  trayIcon = new KSystemTrayIcon("media-playback-stop", 0 );
  connect(trayIcon, SIGNAL( activated(QSystemTrayIcon::ActivationReason)), 
          this, SLOT( unhideSlot() ) );
  
  path.append( QDir::homePath() );
  
  
  recArea.setCoords( 0, 0, 0, 0);
  setupConfig();
  
  this->resize( 700, 300 );
    
  collection = new KActionCollection(this);
  
  setupCentralWidget();
  
  menuBar = new KMenuBar;
  setupMenuFile();
  setupMenuWindow();
  setupMenuSettings();
  menuBar->addMenu(helpMenu());
  this->setMenuBar(menuBar);
  
  setupActions();
  
  KToolBar *tools = new KToolBar(i18n("&Tools"), this);
  tools->addAction(collection->action("new_file"));
  tools->addAction(collection->action("open_file"));
  tools->addAction(collection->action("add"));
  collection->action("add")->setEnabled( false );
  tools->addAction(collection->action("remove"));
  collection->action("remove")->setEnabled( false );
  //tools->addAction(collection->action("save_file"));
  tools->setToolButtonStyle(Qt::ToolButtonIconOnly);
 
  
  
  playBar = new MainToolBar( collection, this);
  
  playBar->setAccessibleDescription("Play Bar");
  
  this->addToolBar(Qt::BottomToolBarArea, playBar);
  connect( playBar->timeSlider, SIGNAL( sliderMoved(int) ),
	   this, SLOT( seekSlot(int) ) );
  
  
}
Exemple #27
0
void MainWindow::setWidgetsVisible(bool makeVisible)
{
    // state flags
    static bool bookmarksToolBarFlag;
    static bool historyPanelFlag;
    static bool bookmarksPanelFlag;

    KToolBar *mainBar = toolBar("mainToolBar");
    KToolBar *bookBar = toolBar("bookmarksToolBar");

    if (!makeVisible)
    {
        // save current state, if in windowed mode
        if (!isFullScreen())
        {
            bookmarksToolBarFlag = bookBar->isHidden();
            historyPanelFlag = m_historyPanel->isHidden();
            bookmarksPanelFlag = m_bookmarksPanel->isHidden();
        }

        bookBar->hide();
        m_view->setTabBarHidden(true);
        m_historyPanel->hide();
        m_bookmarksPanel->hide();

        // hide main toolbar
        mainBar->hide();
    }
    else
    {
        // show main toolbar
        mainBar->show();
        m_view->setTabBarHidden(false);

        // restore state of windowed mode
        if (!bookmarksToolBarFlag)
            bookBar->show();
        if (!historyPanelFlag)
            m_historyPanel->show();
        if (!bookmarksPanelFlag)
            m_bookmarksPanel->show();
    }
}
MessageDock::MessageDock( const QString& title, QWidget* parent, Qt::WindowFlags flags )
    : QDockWidget( title, parent, flags ),
      d( new MessageDockPrivate )
{
    setObjectName( "MessageDock" );

    d->view = new QListWidget( this );
    d->view->addItem( new QListWidgetItem( i18n( "Welcome to Gluon Creator %1", GluonCore::Global::versionString() ), d->view ) );
    d->view->setSelectionMode( QAbstractItemView::ExtendedSelection );

    connect( GluonEngine::Game::instance(), SIGNAL( showDebug( const QString& ) ), SLOT( showDebug( const QString& ) ) );

    QWidget* widget = new QWidget( this );
    QVBoxLayout* layout = new QVBoxLayout();
    layout->setContentsMargins( 0, 0, 0, 0 );
    layout->setSpacing( 0 );
    widget->setLayout( layout );

    KToolBar* toolBar = new KToolBar( this );
    toolBar->setIconDimensions( 16 );

    QAction* selectAll = toolBar->addAction( KIcon( "edit-select-all" ), i18n( "Select All" ), this, SLOT( selectAll() ) );
    d->view->addAction( selectAll );

    QAction* copy = toolBar->addAction( KIcon( "edit-copy" ), i18n( "Copy" ), this, SLOT( copy() ) );
    d->view->addAction( copy );

    KAction* separator = new KAction( d->view );
    separator->setSeparator( true );
    d->view->addAction( separator );

    QAction* clearSelection = toolBar->addAction( KIcon( "edit-clear-list" ), i18n( "Clear Selection" ), this, SLOT( clearSelection() ) );
    d->view->addAction( clearSelection );

    QAction* clearAll = toolBar->addAction( KIcon( "edit-clear" ), i18n( "Clear All" ), d->view, SLOT( clear() ) );
    d->view->addAction( clearAll );

    layout->addWidget( toolBar );
    layout->addWidget( d->view );
    setWidget( widget );
}
DynamicCategory::DynamicCategory( QWidget* parent )
    : QWidget( parent )
    , m_biasListView( 0 )
    , m_biasModel( 0 )
    , m_biasDelegate( 0 )
{
    bool enabled = AmarokConfig::dynamicMode();

    setContentsMargins(0,0,0,0);

    m_vLayout = new QVBoxLayout( this );

    m_onOffCheckbox = new QCheckBox( this );
    m_onOffCheckbox->setIcon( KIcon( "dynamic-amarok" ) );
    m_onOffCheckbox->setText( i18n( "On" ) );
    m_onOffCheckbox->setToolTip( i18n( "Turn dynamic mode on." ) );
    m_onOffCheckbox->setCheckable( true );
    m_onOffCheckbox->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Fixed );
    QObject::connect( m_onOffCheckbox, SIGNAL( toggled( bool ) ), this, SLOT( OnOff ( bool ) ) );

    QObject::connect( (const QObject*)Amarok::actionCollection()->action( "playlist_clear" ),  SIGNAL( triggered( bool ) ),  this, SLOT( playlistCleared() ) );
    
    m_repopulateButton = new QPushButton( this );
    m_repopulateButton->setText( i18n("Repopulate") );
    m_repopulateButton->setToolTip( i18n("Replace the upcoming tracks with fresh ones.") );
    m_repopulateButton->setIcon( KIcon( "view-refresh-amarok" ) );
    m_repopulateButton->setEnabled( enabled );
    m_repopulateButton->setSizePolicy( 
            QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ) );
    QObject::connect( m_repopulateButton, SIGNAL( clicked(bool) ), The::playlistActions(), SLOT( repopulateDynamicPlaylist() ) );
            

    KHBox* presetLayout = new KHBox( this );


    QLabel* presetLabel = new QLabel( i18n( "Playlist:" ), presetLayout );

    m_presetComboBox = new KComboBox( presetLayout );
    m_presetComboBox->setPalette( QApplication::palette() );
    DynamicModel::instance()->loadPlaylists();
    m_presetComboBox->setModel( DynamicModel::instance() );
    
    connect( DynamicModel::instance(), SIGNAL( changeActive( int ) ),
            m_presetComboBox, SLOT(setCurrentIndex(int)) );

    connect( DynamicModel::instance(), SIGNAL( enableDynamicMode( bool ) ),
            SLOT(enableDynamicMode(bool)) );

    connect( m_presetComboBox, SIGNAL(currentIndexChanged( int ) ),
            this, SLOT(playlistSelectionChanged( int ) ) );

    presetLabel->setBuddy( m_presetComboBox );

    presetLayout->setStretchFactor( m_presetComboBox, 1 );



    KToolBar* presetToolbar = new KToolBar( presetLayout );
    presetToolbar->setToolButtonStyle( Qt::ToolButtonIconOnly );
    presetToolbar->setMovable( false );
    presetToolbar->setFloatable( false );
    presetToolbar->setSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::Preferred );
    m_saveButton   = new QToolButton( presetToolbar );
    //m_saveButton->setText( i18n("Save") );
    m_saveButton->setIcon( KIcon( "document-save-amarok" ) );
    m_saveButton->setToolTip( i18n( "Save the preset." ) );
    presetToolbar->addWidget( m_saveButton );

    connect( m_saveButton, SIGNAL( clicked( bool ) ), SLOT( save() ) );


    m_deleteButton = new QToolButton( presetToolbar );
    //m_deleteButton->setText( i18n("Delete") );
    m_deleteButton->setEnabled( false );
    m_deleteButton->setIcon( KIcon( "edit-delete-amarok" ) );
    m_deleteButton->setToolTip( i18n( "Delete the preset.") );
    presetToolbar->addWidget( m_deleteButton );

    connect( m_deleteButton, SIGNAL(clicked(bool)),
            DynamicModel::instance(), SLOT(removeActive()) );
        

    m_biasListView = new QListView( this );
    m_biasListView->setFrameShape( QFrame::NoFrame );


    m_biasListView->setAlternatingRowColors( true );
    The::paletteHandler()->updateItemView( m_biasListView );
    connect( The::paletteHandler(), SIGNAL( newPalette( const QPalette & ) ), SLOT( newPalette( const QPalette & ) ) );

    m_biasModel = new DynamicBiasModel( m_biasListView );
    m_biasListView->setModel( m_biasModel );

    connect( m_biasModel, SIGNAL(playlistModified(Dynamic::BiasedPlaylistPtr)),
             DynamicModel::instance(), SLOT(playlistModified(Dynamic::BiasedPlaylistPtr)) );

    m_biasDelegate = new DynamicBiasDelegate( m_biasListView );
    m_biasListView->setItemDelegate( m_biasDelegate );

    m_vLayout->addWidget( m_onOffCheckbox );
    m_vLayout->addWidget( m_repopulateButton );
    m_vLayout->addWidget( presetLayout );
    m_vLayout->addWidget( m_biasListView );

    this->setLayout( m_vLayout );


    int index = DynamicModel::instance()->playlistIndex( 
            AmarokConfig::lastDynamicMode() );

    debug() << "Setting index: " << index;
    if( index >= 0 )
    {
        m_presetComboBox->setCurrentIndex( index );
        playlistSelectionChanged( index );
    }
    else
    {
        m_presetComboBox->setCurrentIndex( 0 );
        playlistSelectionChanged( 0 );
    }

    m_onOffCheckbox->setChecked( AmarokConfig::dynamicMode() );
}
Exemple #30
0
void MainWindow::selectPlugin( Kontact::Plugin *plugin )
{
  if ( !plugin )
    return;

  if ( plugin->isRunningStandalone() ) {
    statusBar()->message( i18n( "Application is running standalone. Foregrounding..." ), 1000 );
    mSidePane->indicateForegrunding( plugin );
    plugin->bringToForeground();
    return;
  }

  KApplication::setOverrideCursor( QCursor( Qt::WaitCursor ) );

  KParts::Part *part = plugin->part();

  if ( !part ) {
    KApplication::restoreOverrideCursor();
    KMessageBox::error( this, i18n( "Cannot load part for %1." )
                              .arg( plugin->title() )
                        + "\n" + lastErrorMessage() );
    plugin->setDisabled( true );
    mSidePane->updatePlugins();
    return;
  }

  // store old focus widget
  QWidget *focusWidget = kapp->focusWidget();
  if ( mCurrentPlugin && focusWidget ) {
    // save the focus widget only when it belongs to the activated part
    QWidget *parent = focusWidget->parentWidget();
    while ( parent ) {
      if ( parent == mCurrentPlugin->part()->widget() )
        mFocusWidgets.insert( mCurrentPlugin->identifier(), QGuardedPtr<QWidget>( focusWidget ) );

      parent = parent->parentWidget();
    }
  }

  if ( mSidePane )
    mSidePane->selectPlugin( plugin );

  plugin->select();

  mPartManager->setActivePart( part );
  QWidget *view = part->widget();
  Q_ASSERT( view );

  if ( view ) {
    mPartsStack->raiseWidget( view );
    view->show();

    if ( mFocusWidgets.contains( plugin->identifier() ) ) {
      focusWidget = mFocusWidgets[ plugin->identifier() ];
      if ( focusWidget )
        focusWidget->setFocus();
    } else
      view->setFocus();

    mCurrentPlugin = plugin;
    KAction *newAction = plugin->newActions()->first();
    KAction *syncAction = plugin->syncActions()->first();

    createGUI( plugin->part() );

    KToolBar* navigatorToolBar = findToolBar( "navigatorToolBar" );
    // Let the navigator toolbar be always the last one, if it's in the top dockwindow
    if ( navigatorToolBar && !navigatorToolBar->isHidden() &&
         navigatorToolBar->barPos() == KToolBar::Top ) {
      topDock()->moveDockWindow( navigatorToolBar, -1 );
    }

    setCaption( i18n( "Plugin dependent window title" ,"%1 - Kontact" ).arg( plugin->title() ) );

    if ( newAction ) {
      mNewActions->setIcon( newAction->icon() );
      mNewActions->setText( newAction->text() );
    } else { // we'll use the action of the first plugin which offers one
      PluginList::Iterator it;
      for ( it = mPlugins.begin(); it != mPlugins.end(); ++it ) {
        newAction = (*it)->newActions()->first();
        if ( newAction ) {
          mNewActions->setIcon( newAction->icon() );
          mNewActions->setText( newAction->text() );
          break;
        }
      }
    }
    if ( mSyncActionsEnabled ) {
      if ( syncAction ) {
        mSyncActions->setIcon( syncAction->icon() );
        mSyncActions->setText( syncAction->text() );
      } else { // we'll use the action of the first plugin which offers one
        PluginList::Iterator it;
        for ( it = mPlugins.begin(); it != mPlugins.end(); ++it ) {
          syncAction = (*it)->syncActions()->first();
          if ( syncAction ) {
            mSyncActions->setIcon( syncAction->icon() );
            mSyncActions->setText( syncAction->text() );
            break;
          }
        }
      }
    }
  }
  QStringList invisibleActions = plugin->invisibleToolbarActions();

  QStringList::ConstIterator it;
  for ( it = invisibleActions.begin(); it != invisibleActions.end(); ++it ) {
    KAction *action = part->actionCollection()->action( (*it).latin1() );
    if ( action ) {
      QPtrListIterator<KToolBar> it(  toolBarIterator() );
      for (  ; it.current() ; ++it ) {
        action->unplug( it.current() );
      }
    }
  }

  KApplication::restoreOverrideCursor();
}