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()
#elif defined(__APPLE__)
style = "macintosh";
#else
style = "motif";
style = "gtk";
#endif
}
......@@ -27,7 +27,7 @@ AppearanceAttributes::InitializeStyle()
#elif defined(__APPLE__)
style = "macintosh";
#else
style = "motif";
style = "gtk";
#endif
}
......@@ -44,37 +44,13 @@
#include <QLabel>
#include <QLineEdit>
#include <QPushButton>
#include <QStyleFactory>
#include <QvisColorButton.h>
#include <QvisDialogLineEdit.h>
#include <AppearanceAttributes.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
......@@ -89,6 +65,9 @@ static const int numStyleNames = sizeof(styleNamesInMenu) / sizeof(const char *)
// Brad Whitlock, Wed Apr 9 11:10:51 PDT 2008
// QString for caption, shortName.
//
// Kathleen Biagas, Fri Jan 22 14:12:09 PST 2016
// Retrieve style names from QStyleFactory.
//
// ****************************************************************************
QvisAppearanceWindow::QvisAppearanceWindow(AppearanceAttributes *subj,
......@@ -96,7 +75,7 @@ QvisAppearanceWindow::QvisAppearanceWindow(AppearanceAttributes *subj,
QvisPostableWindowObserver(subj, caption, shortName, notepad,
QvisPostableWindowObserver::ApplyButton)
{
// nothing here
styleNames = QStyleFactory::keys();
}
// ****************************************************************************
......@@ -145,6 +124,9 @@ QvisAppearanceWindow::~QvisAppearanceWindow()
// Cyrus Harrison, Mon Nov 24 11:57:42 PST 2008
// Support for default system appearance.
//
// Kathleen Biagas, Fri Jan 22 14:12:31 PST 2016
// styleNames now stored as a QStringList.
//
// ****************************************************************************
void
......@@ -186,8 +168,8 @@ QvisAppearanceWindow::CreateWindowContents()
// Create the style combo box.
styleComboBox = new QComboBox(central);
for(int i = 0; i < numStyleNames; ++i)
styleComboBox->addItem(styleNamesInMenu[i]);
for(int i = 0; i < styleNames.size(); ++i)
styleComboBox->addItem(styleNames.at(i));
connect(styleComboBox, SIGNAL(activated(int)),
this, SLOT(styleChanged(int)));
mainLayout->addWidget(styleComboBox, row, 1);
......@@ -258,6 +240,9 @@ QvisAppearanceWindow::CreateWindowContents()
// Make the window reflect the state object when we're using the
// system defaults.
//
// Kathleen Biagas, Fri Jan 22 14:12:31 PST 2016
// styleNames now stored as a QStringList.
//
// ****************************************************************************
void
......@@ -326,9 +311,9 @@ QvisAppearanceWindow::UpdateWindow(bool doAll)
styleName = atts->GetDefaultStyle();
else
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->setCurrentIndex(j);
......@@ -615,13 +600,16 @@ QvisAppearanceWindow::foregroundChanged(const QColor &fg)
// Brad Whitlock, Fri Aug 15 13:11:13 PST 2003
// I made it use a table lookup.
//
// Kathleen Biagas, Fri Jan 22 14:12:31 PST 2016
// styleNames now stored as a QStringList.
//
// ****************************************************************************
void
QvisAppearanceWindow::styleChanged(int index)
{
AppearanceAttributes *atts = (AppearanceAttributes *)subject;
atts->SetStyle(styleNames[index]);
atts->SetStyle(styleNames.at(index).toStdString());
SetUpdate(false);
Apply();
}
......
......@@ -78,6 +78,9 @@ class QvisDialogLineEdit;
// Cyrus Harrison, Mon Nov 24 11:57:42 PST 2008
// Support for default system appearance.
//
// Kathleen Biagas, Fri Jan 22 14:11:18 PST 2016
// Add styleNames.
//
// ****************************************************************************
class GUI_API QvisAppearanceWindow : public QvisPostableWindowObserver
......@@ -120,6 +123,7 @@ private:
QLabel *orientationLabel;
QvisDialogLineEdit *fontName;
QLabel *fontLabel;
QStringList styleNames;
};
#endif
......@@ -55,6 +55,7 @@
#include <QSocketNotifier>
#include <QStatusBar>
#include <QStyle>
#include <QStyleFactory>
#include <QTranslator>
#if defined(Q_WS_MACX) || defined(Q_OS_MAC)
......@@ -2219,6 +2220,9 @@ QvisGUIApplication::Quit()
// Brad Whitlock, Wed Oct 6 12:20:28 PDT 2010
// 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
......@@ -2469,24 +2473,20 @@ QvisGUIApplication::ProcessArguments(int &argc, char **argv)
<< endl;
continue;
}
std::string style(argv[i + 1]);
if(
#if defined(Q_WS_MACX) || defined(Q_OS_MAC)
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"
)
QStringList availableStyles = QStyleFactory::keys();
QString style(argv[i+1]);
if (availableStyles.contains(style, Qt::CaseInsensitive))
{
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;
}
else if(current == std::string("-font"))
......
......@@ -164,6 +164,7 @@
#include <QApplication>
#include <QSocketNotifier>
#include <QStyleFactory>
#include <QvisColorTableButton.h>
#include <QvisNoDefaultColorTableButton.h>
......@@ -2369,6 +2370,9 @@ ViewerSubject::ReadConfigFiles(int argc, char **argv)
// Eric Brugger, Fri May 10 14:44:11 PDT 2013
// I removed support for mangled mesa.
//
// Kathleen Biagas, Fri Jan 22 14:09:28 PST 2016
// Use QStyleFactory for list of possible styles.
//
// ****************************************************************************
void
......@@ -2541,26 +2545,24 @@ ViewerSubject::ProcessCommandLine(int argc, char **argv)
<< endl;
continue;
}
if (
#ifdef QT_WS_MACX
strcmp(argv[i + 1], "macintosh") == 0 ||
#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
)
QStringList availableStyles = QStyleFactory::keys();
QString style(argv[i+1]);
if (availableStyles.contains(style, Qt::CaseInsensitive))
{
clientArguments.push_back(argv[i]);
clientArguments.push_back(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;
}
else if (strcmp(argv[i], "-font") == 0)
......
......@@ -62,6 +62,11 @@
// I changed the function so we pass in the application and the appearance
// 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
......@@ -72,23 +77,8 @@ GetAppearance(QApplication *a, AppearanceAttributes *aa)
// get system default style
QStyle *style = a->style();
QString style_class(style->metaObject()->className());
std::string styleName = "windows";
if(style_class == "QWindowsStyle")
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";
std::string styleName = style_class.toStdString().substr(1, style_class.length()-6);
debug1 << mName << "Default System Style is: " << styleName << endl;
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