Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
OpenWalnut
OpenWalnut Core
Commits
01e24d6e
Commit
01e24d6e
authored
Nov 05, 2009
by
schurade
Browse files
[ADD] icon manager class for storing and handling icons
parent
55fc5f30
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
154 additions
and
36 deletions
+154
-36
src/gui/icons/logoIcon.xpm
src/gui/icons/logoIcon.xpm
+1
-1
src/gui/qt4/WIconManager.cpp
src/gui/qt4/WIconManager.cpp
+50
-0
src/gui/qt4/WIconManager.h
src/gui/qt4/WIconManager.h
+64
-0
src/gui/qt4/WMainWindow.cpp
src/gui/qt4/WMainWindow.cpp
+30
-24
src/gui/qt4/WMainWindow.h
src/gui/qt4/WMainWindow.h
+9
-11
No files found.
src/gui/icons/logoIcon.xpm
View file @
01e24d6e
/* XPM */
static const char
*logoIcon_xpm[] = {
static const char*
const
logoIcon_xpm[] = {
/* columns rows colors chars-per-pixel */
"32 32 166 2",
" c gray25",
...
...
src/gui/qt4/WIconManager.cpp
0 → 100644
View file @
01e24d6e
//---------------------------------------------------------------------------
//
// Project: OpenWalnut ( http://www.openwalnut.org )
//
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
// For more information see http://www.openwalnut.org/copying
//
// This file is part of OpenWalnut.
//
// OpenWalnut is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// OpenWalnut is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
//
//---------------------------------------------------------------------------
#include <cassert>
#include <string>
#include "WIconManager.h"
WIconManager
::
WIconManager
()
{
}
WIconManager
::~
WIconManager
()
{
}
void
WIconManager
::
addIcon
(
std
::
string
name
,
const
char
*
const
xpm
[]
)
{
assert
(
(
m_iconList
.
count
(
name
)
==
0
)
);
QIcon
*
icon
=
new
QIcon
(
QPixmap
(
xpm
)
);
m_iconList
[
name
]
=
icon
;
}
QIcon
WIconManager
::
getIcon
(
const
std
::
string
name
)
{
assert
(
(
m_iconList
.
count
(
name
)
==
1
)
);
return
*
m_iconList
[
name
];
}
src/gui/qt4/WIconManager.h
0 → 100644
View file @
01e24d6e
//---------------------------------------------------------------------------
//
// Project: OpenWalnut ( http://www.openwalnut.org )
//
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
// For more information see http://www.openwalnut.org/copying
//
// This file is part of OpenWalnut.
//
// OpenWalnut is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// OpenWalnut is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
//
//---------------------------------------------------------------------------
#ifndef WICONMANAGER_H
#define WICONMANAGER_H
#include <map>
#include <string>
#include <QtGui/QIcon>
/**
* class to store and handle access to all available icons
*/
class
WIconManager
{
public:
/**
* default constructor
*/
WIconManager
();
/**
* destructor
*/
~
WIconManager
();
/**
* function to add an Icon to the icon store
*/
void
addIcon
(
std
::
string
name
,
const
char
*
const
xpm
[]
);
/**
* returns i previously stored icon
*/
QIcon
getIcon
(
const
std
::
string
name
);
protected:
private:
std
::
map
<
std
::
string
,
QIcon
*
>
m_iconList
;
};
#endif // WICONMANAGER_H
src/gui/qt4/WMainWindow.cpp
View file @
01e24d6e
...
...
@@ -39,9 +39,10 @@
#include "../icons/WIcons.h"
WMainWindow
::
WMainWindow
()
WMainWindow
::
WMainWindow
()
:
m_iconManager
(),
m_propertyManager
()
{
m_propertyManager
=
new
WPropertyManager
();
}
WMainWindow
::~
WMainWindow
()
...
...
@@ -53,14 +54,14 @@ WMainWindow::~WMainWindow()
void
WMainWindow
::
setupGUI
(
QMainWindow
*
mainWindow
)
{
m_
mainWindowIcon
.
addPixmap
(
QPixmap
(
logoIcon_xpm
)
);
m_
iconManager
.
addIcon
(
std
::
string
(
"logo"
),
logoIcon_xpm
);
if
(
mainWindow
->
objectName
().
isEmpty
()
)
{
mainWindow
->
setObjectName
(
QString
::
fromUtf8
(
"MainWindow"
)
);
}
mainWindow
->
resize
(
946
,
632
);
mainWindow
->
setWindowIcon
(
m_
mainWindowIcon
);
mainWindow
->
setWindowIcon
(
m_
iconManager
.
getIcon
(
"logo"
)
);
mainWindow
->
setWindowTitle
(
QApplication
::
translate
(
"MainWindow"
,
"OpenWalnut"
,
0
,
QApplication
::
UnicodeUTF8
)
);
m_centralwidget
=
new
QWidget
(
mainWindow
);
...
...
@@ -88,15 +89,15 @@ void WMainWindow::setupGUI( QMainWindow *mainWindow )
m_glWidgets
.
push_back
(
m_navSagittal
->
getGLWidget
()
);
mainWindow
->
addDockWidget
(
Qt
::
LeftDockWidgetArea
,
m_navSagittal
);
connect
(
m_navAxial
,
SIGNAL
(
navSliderValueChanged
(
QString
,
int
)
),
m_propertyManager
,
SLOT
(
slotIntChanged
(
QString
,
int
)
)
);
connect
(
m_navCoronal
,
SIGNAL
(
navSliderValueChanged
(
QString
,
int
)
),
m_propertyManager
,
SLOT
(
slotIntChanged
(
QString
,
int
)
)
);
connect
(
m_navSagittal
,
SIGNAL
(
navSliderValueChanged
(
QString
,
int
)
),
m_propertyManager
,
SLOT
(
slotIntChanged
(
QString
,
int
)
)
);
connect
(
m_navAxial
,
SIGNAL
(
navSliderValueChanged
(
QString
,
int
)
),
&
m_propertyManager
,
SLOT
(
slotIntChanged
(
QString
,
int
)
)
);
connect
(
m_navCoronal
,
SIGNAL
(
navSliderValueChanged
(
QString
,
int
)
),
&
m_propertyManager
,
SLOT
(
slotIntChanged
(
QString
,
int
)
)
);
connect
(
m_navSagittal
,
SIGNAL
(
navSliderValueChanged
(
QString
,
int
)
),
&
m_propertyManager
,
SLOT
(
slotIntChanged
(
QString
,
int
)
)
);
m_datasetBrowser
=
new
WQtDatasetBrowser
();
mainWindow
->
addDockWidget
(
Qt
::
RightDockWidgetArea
,
m_datasetBrowser
);
m_datasetBrowser
->
addSubject
(
"subject1"
);
connect
(
m_datasetBrowser
,
SIGNAL
(
dataSetBrowserEvent
(
QString
,
bool
)
),
m_propertyManager
,
SLOT
(
slotBoolChanged
(
QString
,
bool
)
)
);
connect
(
m_datasetBrowser
,
SIGNAL
(
dataSetBrowserEvent
(
QString
,
bool
)
),
&
m_propertyManager
,
SLOT
(
slotBoolChanged
(
QString
,
bool
)
)
);
setupToolBar
(
mainWindow
);
}
...
...
@@ -105,14 +106,14 @@ void WMainWindow::setupToolBar( QMainWindow *mainWindow )
{
m_toolBar
=
new
WQtRibbonMenu
(
mainWindow
);
m_
quitIcon
.
addPixmap
(
QPixmap
(
quit_xpm
)
);
m_
saveIcon
.
addPixmap
(
QPixmap
(
disc_xpm
)
);
m_
loadIcon
.
addPixmap
(
QPixmap
(
fileopen_xpm
)
);
m_
iconManager
.
addIcon
(
std
::
string
(
"quit"
),
quit_xpm
);
m_
iconManager
.
addIcon
(
std
::
string
(
"save"
),
disc_xpm
);
m_
iconManager
.
addIcon
(
std
::
string
(
"load"
),
fileopen_xpm
);
m_toolBar
->
addTab
(
QString
(
"File"
)
);
m_toolBar
->
addPushButton
(
QString
(
"buttonLoad"
),
QString
(
"File"
),
m_
loadIcon
,
QString
(
"load"
)
);
m_toolBar
->
addPushButton
(
QString
(
"buttonSave"
),
QString
(
"File"
),
m_
loadIcon
,
QString
(
"save"
)
);
m_toolBar
->
addPushButton
(
QString
(
"buttonQuit"
),
QString
(
"File"
),
m_
loadIcon
,
QString
(
"exit"
)
);
m_toolBar
->
addPushButton
(
QString
(
"buttonLoad"
),
QString
(
"File"
),
m_
iconManager
.
getIcon
(
"load"
)
,
QString
(
"load"
)
);
m_toolBar
->
addPushButton
(
QString
(
"buttonSave"
),
QString
(
"File"
),
m_
iconManager
.
getIcon
(
"save"
)
,
QString
(
"save"
)
);
m_toolBar
->
addPushButton
(
QString
(
"buttonQuit"
),
QString
(
"File"
),
m_
iconManager
.
getIcon
(
"quit"
)
,
QString
(
"exit"
)
);
m_toolBar
->
getButton
(
QString
(
"buttonLoad"
)
)
->
setMaximumSize
(
50
,
24
);
m_toolBar
->
getButton
(
QString
(
"buttonSave"
)
)
->
setMaximumSize
(
50
,
24
);
...
...
@@ -124,13 +125,13 @@ void WMainWindow::setupToolBar( QMainWindow *mainWindow )
m_toolBar
->
addTab
(
QString
(
"Modules"
)
);
m_toolBar
->
addTab
(
QString
(
"Help"
)
);
m_
axiIcon
.
addPixmap
(
QPixmap
(
axial_xpm
)
);
m_co
rIcon
.
addPixmap
(
QPixmap
(
cor_xpm
)
);
m_
sagIcon
.
addPixmap
(
QPixmap
(
sag_xpm
)
);
m_
iconManager
.
addIcon
(
std
::
string
(
"axial"
),
axial_xpm
);
m_
i
co
nManager
.
addIcon
(
std
::
string
(
"coronal"
),
cor_xpm
);
m_
iconManager
.
addIcon
(
std
::
string
(
"sagittal"
),
sag_xpm
);
m_toolBar
->
addPushButton
(
QString
(
"showAxial"
),
QString
(
"Modules"
),
m_
axiIcon
);
m_toolBar
->
addPushButton
(
QString
(
"showCoronal"
),
QString
(
"Modules"
),
m_co
rIcon
);
m_toolBar
->
addPushButton
(
QString
(
"showSagittal"
),
QString
(
"Modules"
),
m_
sagIcon
);
m_toolBar
->
addPushButton
(
QString
(
"showAxial"
),
QString
(
"Modules"
),
m_
iconManager
.
getIcon
(
"axial"
)
);
m_toolBar
->
addPushButton
(
QString
(
"showCoronal"
),
QString
(
"Modules"
),
m_
i
co
nManager
.
getIcon
(
"coronal"
)
);
m_toolBar
->
addPushButton
(
QString
(
"showSagittal"
),
QString
(
"Modules"
),
m_
iconManager
.
getIcon
(
"sagittal"
)
);
m_toolBar
->
getButton
(
QString
(
"showAxial"
)
)
->
setMaximumSize
(
24
,
24
);
m_toolBar
->
getButton
(
QString
(
"showCoronal"
)
)
->
setMaximumSize
(
24
,
24
);
...
...
@@ -145,11 +146,11 @@ void WMainWindow::setupToolBar( QMainWindow *mainWindow )
m_toolBar
->
getButton
(
QString
(
"showSagittal"
)
)
->
setChecked
(
true
);
connect
(
m_toolBar
->
getButton
(
QString
(
"showAxial"
)
),
SIGNAL
(
pushButtonToggled
(
QString
,
bool
)
),
m_propertyManager
,
SLOT
(
slotBoolChanged
(
QString
,
bool
)
)
);
SIGNAL
(
pushButtonToggled
(
QString
,
bool
)
),
&
m_propertyManager
,
SLOT
(
slotBoolChanged
(
QString
,
bool
)
)
);
connect
(
m_toolBar
->
getButton
(
QString
(
"showCoronal"
)
),
SIGNAL
(
pushButtonToggled
(
QString
,
bool
)
),
m_propertyManager
,
SLOT
(
slotBoolChanged
(
QString
,
bool
)
)
);
SIGNAL
(
pushButtonToggled
(
QString
,
bool
)
),
&
m_propertyManager
,
SLOT
(
slotBoolChanged
(
QString
,
bool
)
)
);
connect
(
m_toolBar
->
getButton
(
QString
(
"showSagittal"
)
),
SIGNAL
(
pushButtonToggled
(
QString
,
bool
)
),
m_propertyManager
,
SLOT
(
slotBoolChanged
(
QString
,
bool
)
)
);
SIGNAL
(
pushButtonToggled
(
QString
,
bool
)
),
&
m_propertyManager
,
SLOT
(
slotBoolChanged
(
QString
,
bool
)
)
);
mainWindow
->
addToolBar
(
Qt
::
TopToolBarArea
,
m_toolBar
);
}
...
...
@@ -200,5 +201,10 @@ boost::signal1< void, std::vector< std::string > >* WMainWindow::getLoaderSignal
WPropertyManager
*
WMainWindow
::
getPropertyManager
()
{
return
m_propertyManager
;
return
&
m_propertyManager
;
}
WIconManager
*
WMainWindow
::
getIconManager
()
{
return
&
m_iconManager
;
}
src/gui/qt4/WMainWindow.h
View file @
01e24d6e
...
...
@@ -40,6 +40,7 @@
#include "WQtNavGLWidget.h"
#include "ribbonMenu/WQtRibbonMenu.h"
#include "WIconManager.h"
#include "WPropertyManager.h"
#include "datasetbrowser/WQtDatasetBrowser.h"
// forward declarations
...
...
@@ -80,10 +81,15 @@ public:
/**
*
*
Return property manager
*/
WPropertyManager
*
getPropertyManager
();
/**
* Return icon manager
*/
WIconManager
*
getIconManager
();
/**
*
*/
...
...
@@ -98,9 +104,9 @@ public slots:
private:
void
setupToolBar
(
QMainWindow
*
mainWindow
);
Q
Icon
m_mainWindowIcon
;
W
Icon
Manager
m_iconManager
;
WPropertyManager
*
m_propertyManager
;
WPropertyManager
m_propertyManager
;
QWidget
*
m_centralwidget
;
WQtRibbonMenu
*
m_toolBar
;
...
...
@@ -112,14 +118,6 @@ private:
WQtNavGLWidget
*
m_navCoronal
;
WQtNavGLWidget
*
m_navSagittal
;
QIcon
m_quitIcon
;
QIcon
m_saveIcon
;
QIcon
m_loadIcon
;
QIcon
m_axiIcon
;
QIcon
m_corIcon
;
QIcon
m_sagIcon
;
boost
::
signal1
<
void
,
std
::
vector
<
std
::
string
>
>
m_loaderSignal
;
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment