Commit a42dbdc6 authored by bonnell's avatar bonnell

Use QStyleFactory for list of available styles, and use those. Resolves #2492.

git-svn-id: http://visit.ilight.com/svn/visit/trunk/src@27945 18c085ea-50e0-402c-830e-de6fd14e8384
parent 1d95a0e8
...@@ -1044,7 +1044,7 @@ AppearanceAttributes::InitializeStyle() ...@@ -1044,7 +1044,7 @@ AppearanceAttributes::InitializeStyle()
#elif defined(__APPLE__) #elif defined(__APPLE__)
style = "macintosh"; style = "macintosh";
#else #else
style = "motif"; style = "gtk";
#endif #endif
} }
...@@ -27,7 +27,7 @@ AppearanceAttributes::InitializeStyle() ...@@ -27,7 +27,7 @@ AppearanceAttributes::InitializeStyle()
#elif defined(__APPLE__) #elif defined(__APPLE__)
style = "macintosh"; style = "macintosh";
#else #else
style = "motif"; style = "gtk";
#endif #endif
} }
...@@ -44,37 +44,13 @@ ...@@ -44,37 +44,13 @@
#include <QLabel> #include <QLabel>
#include <QLineEdit> #include <QLineEdit>
#include <QPushButton> #include <QPushButton>
#include <QStyleFactory>
#include <QvisColorButton.h> #include <QvisColorButton.h>
#include <QvisDialogLineEdit.h> #include <QvisDialogLineEdit.h>
#include <AppearanceAttributes.h> #include <AppearanceAttributes.h>
#include <ViewerProxy.h> #include <ViewerProxy.h>
//
// Tables of available styles.
//
static const char *styleNamesInMenu[] = {
#if defined(Q_WS_MACX) || defined(Q_OS_MAC)
"Macintosh",
#endif
#if defined(Q_WS_WIN) || defined(Q_OS_WIN)
"Windows XP", "Windows Vista",
#endif
"Windows", "Motif", "CDE", "Plastique", "CleanLooks"
};
static const char *styleNames[] = {
#if defined(Q_WS_MACX) || defined(Q_OS_MAC)
"macintosh",
#endif
#if defined(Q_WS_WIN) || defined(Q_OS_WIN)
"windowsxp", "windowsvista",
#endif
"windows", "motif", "cde", "plastique", "cleanlooks"
};
// Determine the number of styles.
static const int numStyleNames = sizeof(styleNamesInMenu) / sizeof(const char *);
// **************************************************************************** // ****************************************************************************
// Method: QvisAppearanceWindow::QvisAppearanceWindow // Method: QvisAppearanceWindow::QvisAppearanceWindow
...@@ -89,6 +65,9 @@ static const int numStyleNames = sizeof(styleNamesInMenu) / sizeof(const char *) ...@@ -89,6 +65,9 @@ static const int numStyleNames = sizeof(styleNamesInMenu) / sizeof(const char *)
// Brad Whitlock, Wed Apr 9 11:10:51 PDT 2008 // Brad Whitlock, Wed Apr 9 11:10:51 PDT 2008
// QString for caption, shortName. // QString for caption, shortName.
// //
// Kathleen Biagas, Fri Jan 22 14:12:09 PST 2016
// Retrieve style names from QStyleFactory.
//
// **************************************************************************** // ****************************************************************************
QvisAppearanceWindow::QvisAppearanceWindow(AppearanceAttributes *subj, QvisAppearanceWindow::QvisAppearanceWindow(AppearanceAttributes *subj,
...@@ -96,7 +75,7 @@ QvisAppearanceWindow::QvisAppearanceWindow(AppearanceAttributes *subj, ...@@ -96,7 +75,7 @@ QvisAppearanceWindow::QvisAppearanceWindow(AppearanceAttributes *subj,
QvisPostableWindowObserver(subj, caption, shortName, notepad, QvisPostableWindowObserver(subj, caption, shortName, notepad,
QvisPostableWindowObserver::ApplyButton) QvisPostableWindowObserver::ApplyButton)
{ {
// nothing here styleNames = QStyleFactory::keys();
} }
// **************************************************************************** // ****************************************************************************
...@@ -145,6 +124,9 @@ QvisAppearanceWindow::~QvisAppearanceWindow() ...@@ -145,6 +124,9 @@ QvisAppearanceWindow::~QvisAppearanceWindow()
// Cyrus Harrison, Mon Nov 24 11:57:42 PST 2008 // Cyrus Harrison, Mon Nov 24 11:57:42 PST 2008
// Support for default system appearance. // Support for default system appearance.
// //
// Kathleen Biagas, Fri Jan 22 14:12:31 PST 2016
// styleNames now stored as a QStringList.
//
// **************************************************************************** // ****************************************************************************
void void
...@@ -186,8 +168,8 @@ QvisAppearanceWindow::CreateWindowContents() ...@@ -186,8 +168,8 @@ QvisAppearanceWindow::CreateWindowContents()
// Create the style combo box. // Create the style combo box.
styleComboBox = new QComboBox(central); styleComboBox = new QComboBox(central);
for(int i = 0; i < numStyleNames; ++i) for(int i = 0; i < styleNames.size(); ++i)
styleComboBox->addItem(styleNamesInMenu[i]); styleComboBox->addItem(styleNames.at(i));
connect(styleComboBox, SIGNAL(activated(int)), connect(styleComboBox, SIGNAL(activated(int)),
this, SLOT(styleChanged(int))); this, SLOT(styleChanged(int)));
mainLayout->addWidget(styleComboBox, row, 1); mainLayout->addWidget(styleComboBox, row, 1);
...@@ -258,6 +240,9 @@ QvisAppearanceWindow::CreateWindowContents() ...@@ -258,6 +240,9 @@ QvisAppearanceWindow::CreateWindowContents()
// Make the window reflect the state object when we're using the // Make the window reflect the state object when we're using the
// system defaults. // system defaults.
// //
// Kathleen Biagas, Fri Jan 22 14:12:31 PST 2016
// styleNames now stored as a QStringList.
//
// **************************************************************************** // ****************************************************************************
void void
...@@ -326,9 +311,9 @@ QvisAppearanceWindow::UpdateWindow(bool doAll) ...@@ -326,9 +311,9 @@ QvisAppearanceWindow::UpdateWindow(bool doAll)
styleName = atts->GetDefaultStyle(); styleName = atts->GetDefaultStyle();
else else
styleName = atts->GetStyle(); styleName = atts->GetStyle();
for(j = 0; j < numStyleNames; ++j) for(j = 0; j < styleNames.size(); ++j)
{ {
if(styleName == styleNames[j]) if(styleName == styleNames.at(j).toStdString())
{ {
styleComboBox->blockSignals(true); styleComboBox->blockSignals(true);
styleComboBox->setCurrentIndex(j); styleComboBox->setCurrentIndex(j);
...@@ -615,13 +600,16 @@ QvisAppearanceWindow::foregroundChanged(const QColor &fg) ...@@ -615,13 +600,16 @@ QvisAppearanceWindow::foregroundChanged(const QColor &fg)
// Brad Whitlock, Fri Aug 15 13:11:13 PST 2003 // Brad Whitlock, Fri Aug 15 13:11:13 PST 2003
// I made it use a table lookup. // I made it use a table lookup.
// //
// Kathleen Biagas, Fri Jan 22 14:12:31 PST 2016
// styleNames now stored as a QStringList.
//
// **************************************************************************** // ****************************************************************************
void void
QvisAppearanceWindow::styleChanged(int index) QvisAppearanceWindow::styleChanged(int index)
{ {
AppearanceAttributes *atts = (AppearanceAttributes *)subject; AppearanceAttributes *atts = (AppearanceAttributes *)subject;
atts->SetStyle(styleNames[index]); atts->SetStyle(styleNames.at(index).toStdString());
SetUpdate(false); SetUpdate(false);
Apply(); Apply();
} }
......
...@@ -78,6 +78,9 @@ class QvisDialogLineEdit; ...@@ -78,6 +78,9 @@ class QvisDialogLineEdit;
// Cyrus Harrison, Mon Nov 24 11:57:42 PST 2008 // Cyrus Harrison, Mon Nov 24 11:57:42 PST 2008
// Support for default system appearance. // Support for default system appearance.
// //
// Kathleen Biagas, Fri Jan 22 14:11:18 PST 2016
// Add styleNames.
//
// **************************************************************************** // ****************************************************************************
class GUI_API QvisAppearanceWindow : public QvisPostableWindowObserver class GUI_API QvisAppearanceWindow : public QvisPostableWindowObserver
...@@ -120,6 +123,7 @@ private: ...@@ -120,6 +123,7 @@ private:
QLabel *orientationLabel; QLabel *orientationLabel;
QvisDialogLineEdit *fontName; QvisDialogLineEdit *fontName;
QLabel *fontLabel; QLabel *fontLabel;
QStringList styleNames;
}; };
#endif #endif
...@@ -55,6 +55,7 @@ ...@@ -55,6 +55,7 @@
#include <QSocketNotifier> #include <QSocketNotifier>
#include <QStatusBar> #include <QStatusBar>
#include <QStyle> #include <QStyle>
#include <QStyleFactory>
#include <QTranslator> #include <QTranslator>
#if defined(Q_WS_MACX) || defined(Q_OS_MAC) #if defined(Q_WS_MACX) || defined(Q_OS_MAC)
...@@ -2219,6 +2220,9 @@ QvisGUIApplication::Quit() ...@@ -2219,6 +2220,9 @@ QvisGUIApplication::Quit()
// Brad Whitlock, Wed Oct 6 12:20:28 PDT 2010 // Brad Whitlock, Wed Oct 6 12:20:28 PDT 2010
// Detect whether the user wants -viewer_geometry. // Detect whether the user wants -viewer_geometry.
// //
// Kathleen Biagas, Fri Jan 22 14:14:56 PST 2016
// Use QStyleFactory to determine list of available styles.
//
// **************************************************************************** // ****************************************************************************
void void
...@@ -2469,24 +2473,20 @@ QvisGUIApplication::ProcessArguments(int &argc, char **argv) ...@@ -2469,24 +2473,20 @@ QvisGUIApplication::ProcessArguments(int &argc, char **argv)
<< endl; << endl;
continue; continue;
} }
std::string style(argv[i + 1]); QStringList availableStyles = QStyleFactory::keys();
if( QString style(argv[i+1]);
#if defined(Q_WS_MACX) || defined(Q_OS_MAC) if (availableStyles.contains(style, Qt::CaseInsensitive))
style == "macintosh" ||
#endif
#if defined(Q_WS_WIN) || defined(Q_OS_WIN)
style == "windowsxp" ||
style == "windowsvista" ||
#endif
style == "windows" ||
style == "motif" ||
style == "cde" ||
style == "plastique" ||
style == "cleanlooks"
)
{ {
applicationStyle = argv[i + 1]; applicationStyle = argv[i + 1];
} }
else
{
cerr << "Invalid style: " << style.toStdString() << endl;
cerr << "Available styles are: ";
for (int i = 0; i < availableStyles.size(); ++i)
cerr << availableStyles.at(i).toStdString() << " ";
cerr << endl;
}
++i; ++i;
} }
else if(current == std::string("-font")) else if(current == std::string("-font"))
......
...@@ -164,6 +164,7 @@ ...@@ -164,6 +164,7 @@
#include <QApplication> #include <QApplication>
#include <QSocketNotifier> #include <QSocketNotifier>
#include <QStyleFactory>
#include <QvisColorTableButton.h> #include <QvisColorTableButton.h>
#include <QvisNoDefaultColorTableButton.h> #include <QvisNoDefaultColorTableButton.h>
...@@ -2369,6 +2370,9 @@ ViewerSubject::ReadConfigFiles(int argc, char **argv) ...@@ -2369,6 +2370,9 @@ ViewerSubject::ReadConfigFiles(int argc, char **argv)
// Eric Brugger, Fri May 10 14:44:11 PDT 2013 // Eric Brugger, Fri May 10 14:44:11 PDT 2013
// I removed support for mangled mesa. // I removed support for mangled mesa.
// //
// Kathleen Biagas, Fri Jan 22 14:09:28 PST 2016
// Use QStyleFactory for list of possible styles.
//
// **************************************************************************** // ****************************************************************************
void void
...@@ -2541,26 +2545,24 @@ ViewerSubject::ProcessCommandLine(int argc, char **argv) ...@@ -2541,26 +2545,24 @@ ViewerSubject::ProcessCommandLine(int argc, char **argv)
<< endl; << endl;
continue; continue;
} }
if ( QStringList availableStyles = QStyleFactory::keys();
#ifdef QT_WS_MACX QString style(argv[i+1]);
strcmp(argv[i + 1], "macintosh") == 0 || if (availableStyles.contains(style, Qt::CaseInsensitive))
#endif
#ifdef QT_WS_WIN
strcmp(argv[i + 1], "windowsxp") == 0 ||
strcmp(argv[i + 1], "windowsvista") == 0 ||
#endif
strcmp(argv[i + 1], "windows") == 0 ||
strcmp(argv[i + 1], "motif") == 0 ||
strcmp(argv[i + 1], "cde") == 0 ||
strcmp(argv[i + 1], "plastique") == 0 ||
strcmp(argv[i + 1], "cleanlooks") == 0
)
{ {
clientArguments.push_back(argv[i]); clientArguments.push_back(argv[i]);
clientArguments.push_back(argv[i+1]); clientArguments.push_back(argv[i+1]);
GetViewerState()->GetAppearanceAttributes()->SetStyle(argv[i+1]); GetViewerState()->GetAppearanceAttributes()->SetStyle(argv[i+1]);
} }
else
{
cerr << "Invalid style: " << style.toStdString() << endl;
cerr << "Available styles are: ";
for (int i = 0; i < availableStyles.size(); ++i)
cerr << availableStyles.at(i).toStdString() << " ";
cerr << endl;
}
++i; ++i;
} }
else if (strcmp(argv[i], "-font") == 0) else if (strcmp(argv[i], "-font") == 0)
......
...@@ -62,6 +62,11 @@ ...@@ -62,6 +62,11 @@
// I changed the function so we pass in the application and the appearance // I changed the function so we pass in the application and the appearance
// attributes that we want to populate. // attributes that we want to populate.
// //
// Kathleen Biagas, Fri Jan 22 14:06:33 PST 2016
// We are using styles directly from Qt' Style factory, so no need to
// compare against our list of styles, simply remove 'Q' from the beginning
// and 'Style' from the end of the style name.
//
// **************************************************************************** // ****************************************************************************
void void
...@@ -72,23 +77,8 @@ GetAppearance(QApplication *a, AppearanceAttributes *aa) ...@@ -72,23 +77,8 @@ GetAppearance(QApplication *a, AppearanceAttributes *aa)
// get system default style // get system default style
QStyle *style = a->style(); QStyle *style = a->style();
QString style_class(style->metaObject()->className()); QString style_class(style->metaObject()->className());
std::string styleName = "windows";
if(style_class == "QWindowsStyle") std::string styleName = style_class.toStdString().substr(1, style_class.length()-6);
styleName = "windows";
else if(style_class == "QWindowsVistaStyle")
styleName = "windowsvista";
else if(style_class == "QWindowsXPStyle")
styleName = "windowsxp";
else if(style_class == "QMotifStyle")
styleName = "motif";
else if(style_class == "QCleanlooksStyle")
styleName = "cleanlooks";
else if(style_class == "QPlastiqueStyle")
styleName = "plastique";
else if(style_class == "QCDEStyle")
styleName = "cde";
else if(style_class == "QMacStyle")
styleName = "macintosh";
debug1 << mName << "Default System Style is: " << styleName << endl; debug1 << mName << "Default System Style is: " << styleName << endl;
aa->SetDefaultStyle(styleName); aa->SetDefaultStyle(styleName);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment