Skip to content

Commit

Permalink
Easy Buttons part 2
Browse files Browse the repository at this point in the history
  • Loading branch information
HeikoKoehn committed May 12, 2009
1 parent dcf8163 commit 256d210
Show file tree
Hide file tree
Showing 10 changed files with 275 additions and 26 deletions.
135 changes: 132 additions & 3 deletions src/ActionUnit.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/***************************************************************************
* Copyright (C) 2008 by Heiko Koehn *
* Copyright (C) 2008-2009 by Heiko Koehn *
* KoehnHeiko@googlemail.com *
* *
* This program is free software; you can redistribute it and/or modify *
Expand Down Expand Up @@ -223,6 +223,47 @@ std::list<TToolBar *> ActionUnit::getToolBarList()
return mToolBarList;
}

std::list<TEasyButtonBar *> ActionUnit::getEasyButtonBarList()
{
typedef list<TAction *>::iterator I;
for( I it = mActionRootNodeList.begin(); it != mActionRootNodeList.end(); it++)
{
bool found = false;
TEasyButtonBar * pTB;
typedef list<TEasyButtonBar *>::iterator I2;
for( I2 it2 = mEasyButtonBarList.begin(); it2!=mEasyButtonBarList.end(); it2++ )
{
if( *it2 == (*it)->mpEasyButtonBar )
{
found = true;
pTB = *it2;
}
}
if( ! found )
{
pTB = new TEasyButtonBar( *it, (*it)->getName(), mpHost->mpConsole->mpTopToolBar );
mpHost->mpConsole->mpTopToolBar->layout()->addWidget( pTB );
//pTB->mpTAction = *it;
mEasyButtonBarList.push_back( pTB );
}
if( (*it)->mOrientation == 1 )
{
qDebug()<<"orientation vertikal name="<<(*it)->getName();
pTB->setVerticalOrientation();
}
else
{
qDebug()<<"orientation horizontal: name="<<(*it)->getName();
pTB->setHorizontalOrientation();
}
constructToolbar( *it, mudlet::self(), pTB );
(*it)->mpEasyButtonBar = pTB;
pTB->setStyleSheet( pTB->mpTAction->css );
}

return mEasyButtonBarList;
}

TAction * ActionUnit::getHeadAction( TToolBar * pT )
{
typedef list<TAction *>::iterator I;
Expand Down Expand Up @@ -274,13 +315,13 @@ void ActionUnit::constructToolbar( TAction * pA, mudlet * pMainWindow, TToolBar
pTB->setTitleBarWidget( noTitleBar );
}
pTB->setFeatures( QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetFloatable );
switch( pA->mLocation )
/*switch( pA->mLocation )
{
case 0: mudlet::self()->addDockWidget( Qt::TopDockWidgetArea, pTB ); break;
case 1: mudlet::self()->addDockWidget( Qt::BottomDockWidgetArea, pTB ); break;
case 2: mudlet::self()->addDockWidget( Qt::LeftDockWidgetArea, pTB ); break;
case 3: mudlet::self()->addDockWidget( Qt::RightDockWidgetArea, pTB ); break;
}
}*/
if( pA->mLocation == 4 )
{
mudlet::self()->addDockWidget( Qt::LeftDockWidgetArea, pTB ); //float toolbar
Expand All @@ -295,6 +336,94 @@ void ActionUnit::constructToolbar( TAction * pA, mudlet * pMainWindow, TToolBar
pTB->show();
pTB->setStyleSheet( pTB->mpTAction->css );
}
/*
std::list<TEasyButtonBar *> ActionUnit::getToolBarList()
{
typedef list<TAction *>::iterator I;
for( I it = mActionRootNodeList.begin(); it != mActionRootNodeList.end(); it++)
{
bool found = false;
TEasyButtonBar * pTB;
typedef list<TEasyButtonBar *>::iterator I2;
for( I2 it2 = mToolBarList.begin(); it2!=mToolBarList.end(); it2++ )
{
if( *it2 == (*it)->mpToolBar )
{
found = true;
pTB = *it2;
}
}
if( ! found )
{
pTB = new TEasyButtonBar( *it, (*it)->getName(), mudlet::self() );
//pTB->mpTAction = *it;
mToolBarList.push_back( pTB );
}
if( (*it)->mOrientation == 1 )
{
qDebug()<<"orientation vertikal name="<<(*it)->getName();
pTB->setVerticalOrientation();
}
else
{
qDebug()<<"orientation horizontal: name="<<(*it)->getName();
pTB->setHorizontalOrientation();
}
constructToolbar( *it, mudlet::self(), pTB );
(*it)->mpToolBar = pTB;
pTB->setStyleSheet( pTB->mpTAction->css );
}
return mToolBarList;
}*/

TAction * ActionUnit::getHeadAction( TEasyButtonBar * pT )
{
typedef list<TAction *>::iterator I;
for( I it = mActionRootNodeList.begin(); it != mActionRootNodeList.end(); it++)
{
bool found = false;
typedef list<TEasyButtonBar *>::iterator I2;
for( I2 it2 = mEasyButtonBarList.begin(); it2!=mEasyButtonBarList.end(); it2++ )
{
if( pT == (*it)->mpEasyButtonBar )
{
found = true;
return *it;
}
}
}
return 0;
}

void ActionUnit::constructToolbar( TAction * pA, mudlet * pMainWindow, TEasyButtonBar * pTB )
{
qDebug()<<"constructToolbar#NEW() called";
pTB->clear();
qDebug()<<"trace#1";
pA->expandToolbar( pMainWindow, pTB, 0 );
qDebug()<<"trace#2";
pTB->finalize();
qDebug()<<"trace#3";
if( pA->mOrientation == 0 )
pTB->setHorizontalOrientation();
else
pTB->setVerticalOrientation();
qDebug()<<"trace#4";
switch( pA->mLocation )
{
case 0: mpHost->mpConsole->mpTopToolBar->layout()->addWidget( pTB ); break;
//case 1: mpHost->mpConsole->mpTopToolBar->layout()->addWidget( pTB ); break;
case 2: mpHost->mpConsole->mpLeftToolBar->layout()->addWidget( pTB ); break;
case 3: mpHost->mpConsole->mpRightToolBar->layout()->addWidget( pTB ); break;
}
qDebug()<<"trace#5";
pTB->show();
qDebug()<<"trace#6";
pTB->setStyleSheet( pTB->mpTAction->css );
qDebug()<<"trace#7";
}


void ActionUnit::updateToolbar()
{
Expand Down
9 changes: 8 additions & 1 deletion src/ActionUnit.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/***************************************************************************
* Copyright (C) 2008 by Heiko Koehn *
* Copyright (C) 2008-2009 by Heiko Koehn *
* KoehnHeiko@googlemail.com *
* *
* This program is free software; you can redistribute it and/or modify *
Expand Down Expand Up @@ -27,9 +27,11 @@
#include <QMutex>
#include <QDataStream>
#include "TToolBar.h"
#include "TEasyButtonBar.h"
#include <QMenu>

class TToolBar;
class TEasyButtonBar;
class TAction;
class Host;

Expand All @@ -50,9 +52,12 @@ class ActionUnit
qint64 getNewID();
void updateToolbar();
std::list<TToolBar *> getToolBarList();
std::list<TEasyButtonBar *> getEasyButtonBarList();
TAction * getHeadAction( TToolBar * );
TAction * getHeadAction( TEasyButtonBar * );
void processDataStream( QString & );
void constructToolbar( TAction *, mudlet * pMainWindow, TToolBar * pTB );
void constructToolbar( TAction *, mudlet * pMainWindow, TEasyButtonBar * pTB );
QMutex mActionUnitLock;

private:
Expand All @@ -67,7 +72,9 @@ class ActionUnit
std::list<TAction *> mActionRootNodeList;
qint64 mMaxID;
TToolBar * mpToolBar;
TEasyButtonBar * mpEasyButtonBar;
std::list<TToolBar *> mToolBarList;
std::list<TEasyButtonBar *> mEasyButtonBarList;

};

Expand Down
61 changes: 60 additions & 1 deletion src/TAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ TAction::TAction( TAction * parent, Host * pHost )
, mpHost( pHost )
, mNeedsToBeCompiled( true )
, mpToolBar( 0 )
, mpEasyButtonBar( 0 )
, mButtonColumns( 1 )
, mIsLabel( false )
, mUseCustomLayout( false )
Expand All @@ -61,6 +62,7 @@ TAction::TAction( QString name, Host * pHost )
, mpHost( pHost )
, mNeedsToBeCompiled( true )
, mpToolBar( 0 )
, mpEasyButtonBar( 0 )
, mButtonColumns( 1 )
, mIsLabel( false )
, mUseCustomLayout( false )
Expand Down Expand Up @@ -227,7 +229,64 @@ void TAction::insertActions( mudlet * pMainWindow, TToolBar * pT, QMenu * menu )
}
}



void TAction::expandToolbar( mudlet * pMainWindow, TEasyButtonBar * pT, QMenu * menu )
{
typedef list<TAction *>::const_iterator I;
for( I it = mpMyChildrenList->begin(); it != mpMyChildrenList->end(); it++)
{
TAction * pChild = *it;

QIcon icon( pChild->mIcon );
QString name = pChild->getName();
TFlipButton * button = new TFlipButton( pT,pChild, pChild->mID, mpHost );
button->setIcon( icon );
button->setText( name );
button->setCheckable( pChild->mIsPushDownButton );
button->setFlat( mButtonFlat );
button->setStyleSheet( css );

pT->addButton( button );

if( pChild->mIsFolder )
{
QMenu * newMenu = new QMenu( pT );
button->setMenu( newMenu );
newMenu->setStyleSheet( css );
pChild->insertActions( pMainWindow, pT, newMenu );
}
}
}


void TAction::insertActions( mudlet * pMainWindow, TEasyButtonBar * pT, QMenu * menu )
{
mpEasyButtonBar = pT;
QIcon icon( mIcon );
EAction * action = new EAction( icon, mName, pMainWindow );
action->setCheckable( mIsPushDownButton );
action->mID = mID;
action->mpHost = mpHost;
action->setStatusTip( mName );
menu->addAction( action );
mudlet::self()->bindMenu( menu, action );

if( mIsFolder )
{
QMenu * newMenu = new QMenu( pT );//pMainWindow );
newMenu->setStyleSheet( css );
action->setMenu( newMenu );

typedef list<TAction *>::const_iterator I;
for( I it = mpMyChildrenList->begin(); it != mpMyChildrenList->end(); it++)
{
TAction * pChild = *it;
pChild->insertActions( pMainWindow, pT, newMenu );
}
}
}



bool TAction::serialize( QDataStream & ofs )
{
Expand Down
7 changes: 7 additions & 0 deletions src/TAction.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,15 @@ class TAction : public Tree<TAction>, QObject
void expandToolbar( mudlet * pMainWindow,
TToolBar * pT,
QMenu * menu );
void insertActions( mudlet * pMainWindow,
TEasyButtonBar * pT,
QMenu * menu );
void expandToolbar( mudlet * pMainWindow,
TEasyButtonBar * pT,
QMenu * menu );
bool isClone(TAction & ) const;
TToolBar * mpToolBar;
TEasyButtonBar * mpEasyButtonBar;
int mButtonState;
int mPosX;
int mPosY;
Expand Down
37 changes: 32 additions & 5 deletions src/TConsole.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,6 @@ TConsole::TConsole( Host * pH, bool isDebugConsole, QWidget * parent )
QSizePolicy sizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding);
QSizePolicy sizePolicy3( QSizePolicy::Expanding, QSizePolicy::Expanding);
QSizePolicy sizePolicy2( QSizePolicy::Expanding, QSizePolicy::Fixed);

QPalette mainPalette;
mainPalette.setColor( QPalette::Text, QColor(0,0,0) );
mainPalette.setColor( QPalette::Highlight, QColor(55,55,255) );
Expand Down Expand Up @@ -172,10 +171,29 @@ TConsole::TConsole( Host * pH, bool isDebugConsole, QWidget * parent )
layout()->setMargin( 0 );
setContentsMargins( 0, 0, 0, 0 );

QVBoxLayout * topBarLayout = new QVBoxLayout;
mpTopToolBar->setLayout( topBarLayout );
mpTopToolBar->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed));
mpTopToolBar->setContentsMargins(0,0,0,0);
topBarLayout->setMargin( 0 );
topBarLayout->setSpacing(0);
QVBoxLayout * leftBarLayout = new QVBoxLayout;
mpLeftToolBar->setLayout( leftBarLayout );
mpLeftToolBar->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed));
leftBarLayout->setMargin( 0 );
leftBarLayout->setSpacing(0);
mpLeftToolBar->setContentsMargins(0,0,0,0);
QVBoxLayout * rightBarLayout = new QVBoxLayout;
mpRightToolBar->setLayout( rightBarLayout );
mpRightToolBar->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed));
rightBarLayout->setMargin( 0 );
rightBarLayout->setSpacing(0);
mpRightToolBar->setContentsMargins(0,0,0,0);

QPalette baseVPalette;
baseVPalette.setColor( QPalette::Text, QColor(0,0,0) );
baseVPalette.setColor( QPalette::Highlight, QColor(55,55,255) );
baseVPalette.setColor( QPalette::Window, QColor(255,0,0,255) );
baseVPalette.setColor( QPalette::Window, QColor(255,0,255,255) );

QPalette baseHPalette;
baseHPalette.setColor( QPalette::Text, QColor(0,0,0) );
Expand All @@ -187,8 +205,9 @@ TConsole::TConsole( Host * pH, bool isDebugConsole, QWidget * parent )
mpBaseVFrame->setAutoFillBackground(true);
mpBaseVFrame->setContentsMargins(0,0,0,0);
baseVFrameLayout->setSpacing(0);
baseVFrameLayout->setMargin( 0 );
mpTopToolBar->setContentsMargins(0,0,0,0);
mpBaseVFrame->setContentsMargins(0,0,0,0);
mpTopToolBar->setPalette(baseHPalette);
baseVFrameLayout->addWidget( mpTopToolBar );
baseVFrameLayout->addWidget( mpBaseHFrame );
baseHFrameLayout->addWidget( mpLeftToolBar );
Expand Down Expand Up @@ -244,7 +263,8 @@ TConsole::TConsole( Host * pH, bool isDebugConsole, QWidget * parent )
layer->setSizePolicy( sizePolicy );
layer->setFocusPolicy( Qt::NoFocus );

QHBoxLayout * layoutLayer = new QHBoxLayout( layer );
QHBoxLayout * layoutLayer = new QHBoxLayout;
layer->setLayout( layoutLayer );
layoutLayer->setMargin(0);
QSizePolicy sizePolicyLayer(QSizePolicy::Expanding, QSizePolicy::Expanding);

Expand Down Expand Up @@ -357,6 +377,7 @@ TConsole::TConsole( Host * pH, bool isDebugConsole, QWidget * parent )
layoutLayer2->addWidget( networkLatency );
layoutLayer2->setContentsMargins(0,0,0,0);
layout->addWidget( layer );

//layout->addWidget( layerCommandLine );
QPalette whitePalette;
whitePalette.setColor( QPalette::Window, QColor(255,255,255,255) );
Expand Down Expand Up @@ -393,6 +414,12 @@ TConsole::TConsole( Host * pH, bool isDebugConsole, QWidget * parent )
layerCommandLine->hide();
}

mpBaseVFrame->setContentsMargins(0,0,0,0);
mpBaseHFrame->setContentsMargins(0,0,0,0);
mpBaseVFrame->layout()->setMargin(0);
mpBaseVFrame->layout()->setSpacing(0);
mpBaseHFrame->layout()->setMargin(0);
mpBaseHFrame->layout()->setSpacing(0);
changeColors();
}

Expand Down Expand Up @@ -442,7 +469,7 @@ void TConsole::refresh()
int x = mpMainFrame->size().width();
int y = mpMainFrame->size().height();
mpMainFrame->resize( x, y );
mpMainDisplay->resize( x - mMainFrameLeftWidth - mMainFrameRightWidth,
mpMainDisplay->resize( x - mMainFrameLeftWidth - mMainFrameRightWidth - 15,
y - mMainFrameTopHeight - mMainFrameBottomHeight );
mpMainDisplay->move( mMainFrameLeftWidth, mMainFrameTopHeight );
}
Expand Down
Loading

0 comments on commit 256d210

Please sign in to comment.