Changeset View
Changeset View
Standalone View
Standalone View
kstyle/demo/oxygenmdidemowidget.cpp
Show All 34 Lines | |||||
35 | { | 35 | { | ||
36 | 36 | | |||
37 | //______________________________________________________________ | 37 | //______________________________________________________________ | ||
38 | MdiDemoWidget::MdiDemoWidget( QWidget* parent ): | 38 | MdiDemoWidget::MdiDemoWidget( QWidget* parent ): | ||
39 | DemoWidget( parent ) | 39 | DemoWidget( parent ) | ||
40 | { | 40 | { | ||
41 | setLayout( new QVBoxLayout() ); | 41 | setLayout( new QVBoxLayout() ); | ||
42 | QMenuBar* menuBar = new QMenuBar( this ); | 42 | QMenuBar* menuBar = new QMenuBar( this ); | ||
43 | // let the menubar appear in the MDI window on all platforms | ||||
44 | menuBar->setNativeMenuBar( false ); | ||||
43 | layout()->addWidget( menuBar ); | 45 | layout()->addWidget( menuBar ); | ||
44 | 46 | | |||
45 | QWidget* widget = new QWidget( this ); | 47 | QWidget* widget = new QWidget( this ); | ||
46 | layout()->addWidget( widget ); | 48 | layout()->addWidget( widget ); | ||
47 | ui.setupUi( widget ); | 49 | ui.setupUi( widget ); | ||
48 | 50 | | |||
49 | QMenu* menu = menuBar->addMenu( i18n( "Layout" ) ); | 51 | QMenu* menu = menuBar->addMenu( i18n( "Layout" ) ); | ||
50 | connect( menu->addAction( i18n( "Tile" ) ), SIGNAL(triggered()), this, SLOT(setLayoutTiled()) ); | 52 | QActionGroup *aGroup = new QActionGroup( menu ); | ||
51 | connect( menu->addAction( i18n( "Cascade" ) ), SIGNAL(triggered()), this, SLOT(setLayoutCascade()) ); | 53 | QAction *action = menu->addAction( i18n( "Tile" ) ); | ||
52 | connect( menu->addAction( i18n( "Tabs" ) ), SIGNAL(triggered()), this, SLOT(setLayoutTabbed()) ); | 54 | action->setCheckable( true ); | ||
55 | aGroup->addAction( action ); | ||||
56 | connect( action, SIGNAL(triggered()), this, SLOT(setLayoutTiled()) ); | ||||
57 | action = menu->addAction( i18n( "Cascade" ) ); | ||||
58 | action->setCheckable( true ); | ||||
59 | aGroup->addAction( action ); | ||||
60 | connect( action, SIGNAL(triggered()), this, SLOT(setLayoutCascade()) ); | ||||
61 | action = menu->addAction( i18n( "Tabs" ) ); | ||||
62 | action->setCheckable( true ); | ||||
63 | aGroup->addAction( action ); | ||||
64 | connect( action, SIGNAL(triggered()), this, SLOT(setLayoutTabbed()) ); | ||||
65 | | ||||
66 | menu->addSeparator(); | ||||
67 | | ||||
68 | _rightToLeftLayout = menu->addAction( i18n( "Right to left layout" ) ); | ||||
69 | _rightToLeftLayout->setCheckable( true ); | ||||
70 | connect( _rightToLeftLayout, SIGNAL(triggered()), this, SLOT(toggleDirection()) ); | ||||
71 | connect( qApp, SIGNAL(layoutDirectionChanged(Qt::LayoutDirection)), SLOT(layoutDirectionChanged(Qt::LayoutDirection)) ); | ||||
53 | 72 | | |||
54 | menu = menuBar->addMenu( i18n( "Tools" ) ); | 73 | menu = menuBar->addMenu( i18n( "Tools" ) ); | ||
55 | QAction* action; | | |||
56 | connect( action = menu->addAction( QIcon::fromTheme( QStringLiteral( "arrow-right" ) ), i18n( "Select Next Window" ) ), SIGNAL(triggered()), ui.mdiArea, SLOT(activateNextSubWindow()) ); | 74 | connect( action = menu->addAction( QIcon::fromTheme( QStringLiteral( "arrow-right" ) ), i18n( "Select Next Window" ) ), SIGNAL(triggered()), ui.mdiArea, SLOT(activateNextSubWindow()) ); | ||
57 | action->setShortcut( Qt::CTRL + Qt::Key_Tab ); | 75 | action->setShortcut( Qt::CTRL + Qt::Key_Tab ); | ||
58 | addAction( action ); | 76 | addAction( action ); | ||
59 | 77 | | |||
60 | connect( action = menu->addAction( QIcon::fromTheme( QStringLiteral( "arrow-left" ) ), i18n( "Select Previous Window" ) ), SIGNAL(triggered()), ui.mdiArea, SLOT(activatePreviousSubWindow()) ); | 78 | connect( action = menu->addAction( QIcon::fromTheme( QStringLiteral( "arrow-left" ) ), i18n( "Select Previous Window" ) ), SIGNAL(triggered()), ui.mdiArea, SLOT(activatePreviousSubWindow()) ); | ||
61 | action->setShortcut( Qt::CTRL + Qt::SHIFT + Qt::Key_Tab ); | 79 | action->setShortcut( Qt::CTRL + Qt::SHIFT + Qt::Key_Tab ); | ||
62 | addAction( action ); | 80 | addAction( action ); | ||
63 | 81 | | |||
Show All 13 Lines | 93 | { | |||
77 | ui.mdiArea->cascadeSubWindows(); | 95 | ui.mdiArea->cascadeSubWindows(); | ||
78 | } | 96 | } | ||
79 | 97 | | |||
80 | //______________________________________________________________ | 98 | //______________________________________________________________ | ||
81 | void MdiDemoWidget::setLayoutTabbed( void ) | 99 | void MdiDemoWidget::setLayoutTabbed( void ) | ||
82 | { ui.mdiArea->setViewMode( QMdiArea::TabbedView ); } | 100 | { ui.mdiArea->setViewMode( QMdiArea::TabbedView ); } | ||
83 | 101 | | |||
84 | //______________________________________________________________ | 102 | //______________________________________________________________ | ||
103 | void MdiDemoWidget::toggleDirection( void ) | ||||
104 | { qApp->setLayoutDirection( qApp->isLeftToRight() ? Qt::RightToLeft : Qt::LeftToRight ); } | ||||
105 | | ||||
106 | //_______________________________________________________________ | ||||
107 | void MdiDemoWidget::layoutDirectionChanged( Qt::LayoutDirection direction ) | ||||
108 | { _rightToLeftLayout->setChecked( direction == Qt::RightToLeft ); } | ||||
109 | | ||||
110 | //______________________________________________________________ | ||||
85 | void MdiDemoWidget::benchmark( void ) | 111 | void MdiDemoWidget::benchmark( void ) | ||
86 | { | 112 | { | ||
87 | if( !isVisible() ) return; | 113 | if( !isVisible() ) return; | ||
88 | 114 | | |||
89 | if( true ) | 115 | if( true ) | ||
90 | { | 116 | { | ||
91 | // slide windows | 117 | // slide windows | ||
92 | foreach( QMdiSubWindow* window, ui.mdiArea->findChildren<QMdiSubWindow*>() ) | 118 | foreach( QMdiSubWindow* window, ui.mdiArea->findChildren<QMdiSubWindow*>() ) | ||
Show All 21 Lines |