--- as_assist.cpp 2002/11/24 18:03:24 1.12
+++ as_assist.cpp 2002/11/24 20:39:31 1.13
@@ -1,4 +1,12 @@
-// Qt headers
+// Qt style headers
+#include <qcdestyle.h>
+#include <qsgistyle.h>
+#include <qmotifstyle.h>
+#include <qmotifplusstyle.h>
+#include <qplatinumstyle.h>
+#include <qwindowsstyle.h>
+
+// Qt general headers
#include <qtooltip.h>
#include <qwhatsthis.h>
#include <qstringlist.h>
@@ -19,71 +27,46 @@
//
-// Construct the menu bar
+// Construct the preferences
//
-void Titraqform::setupMenubar(void)
+void Titraqform::setupPrefs(void)
{
- m_pMenubar = menuBar(); // Grab menu bar owned by QMainWindow
- if (m_pMenubar == NULL) // Sanity check
- throw Genexcept("Main window menu bar nonexistant.");
-
- // Make an easter egg ;-)
- QToolTip::add(m_pMenubar, QRect(0, 0, 2, 2), "Easter egg");
-
- // Construct and populate the file menu with actions
- QPopupMenu *pFilepopup = new QPopupMenu(this);
- if (pFilepopup == NULL) // Sanity check
- throw Genexcept("Main window file popup creation failed.");
- m_pMenubar->insertItem(trUtf8("&File"), pFilepopup);
- m_pFilenewact->addTo(pFilepopup);
- m_pFileopenact->addTo(pFilepopup);
- pFilepopup->insertSeparator();
- m_pFilecloseact->addTo(pFilepopup);
- pFilepopup->insertSeparator();
- m_pFilesaveact->addTo(pFilepopup);
- m_pFilesaveasact->addTo(pFilepopup);
- pFilepopup->insertSeparator();
- m_pFilequitact->addTo(pFilepopup);
-
- // Construct and populate the edit menu with subitems
- QPopupMenu *pEditpopup = new QPopupMenu(this);
- if (pEditpopup == NULL) // Sanity check
- throw Genexcept("Main window edit popup creation failed.");
- m_pMenubar->insertItem(trUtf8("&Edit"), pEditpopup);
- pEditpopup->insertItem("Cu&t", this, SLOT(cut()), CTRL+Key_X);
- pEditpopup->insertItem("&Copy", this, SLOT(copy()), CTRL+Key_C);
- pEditpopup->insertItem("&Paste", this, SLOT(paste()), CTRL+Key_V);
- pEditpopup->insertSeparator();
- pEditpopup->insertItem("&Add", this, SLOT(addEntry()), CTRL+Key_A);
- pEditpopup->insertItem("&Delete", this, SLOT(delEntry()), Key_Delete);
- pEditpopup->insertItem("Select &All", this, SLOT(selAll()), CTRL+Key_A);
- pEditpopup->insertSeparator();
- pEditpopup->insertItem("Preferences...", this, SLOT(configPrefs()));
-
- // Construct and populate the view menu with subitems
- QPopupMenu *pViewpopup = new QPopupMenu(this);
- if (pViewpopup == NULL) // Sanity check
- throw Genexcept("Main window view popup creation failed.");
- m_pMenubar->insertItem(trUtf8("&View"), pViewpopup);
- pViewpopup->insertItem(trUtf8("&Normal"), this, SLOT(normalView()));
- pViewpopup->insertItem(trUtf8("&Editing"), this, SLOT(editingView()));
- pViewpopup->insertItem(trUtf8("&Timing"), this, SLOT(timingView()));
-
- // Pad spacing to force help menu to appear far right
- m_pMenubar->insertSeparator();
+ m_pPrefs = new Preferences(TITRAQ_PREFNAME, TITRAQ_APPTITLE, TITRAQ_PREFVER);
+ if (!m_pPrefs->fileState()) { // No file was found, so assume a null state
+ m_pPrefs->setString(TITRAQ_PREFASFILE, TITRAQ_DEFASFILE);
+ m_pPrefs->setNumber(TITRAQ_PREFSTYLE, TITRAQ_STYLECDE);
+ m_pPrefs->setString(TITRAQ_PREFVIEW, TITRAQ_DEFVIEW);
+ m_pPrefs->setString(TITRAQ_PREFREMOTELOG, TITRAQ_DEFREMOTELOG);
+ m_pPrefs->setString(TITRAQ_PREFLOCALLOG, TITRAQ_DEFLOCALLOG);
+ m_pPrefs->flush(); // Write the new conf file
+ QTextStream cerr(stderr, IO_WriteOnly);
+ cerr << trUtf8("Created new preferences file ") << trUtf8(TITRAQ_PREFNAME) << endl;
+ }
- // Construct and populate the help menu with subitems
- QPopupMenu *pHelppopup = new QPopupMenu(this);
- if (pHelppopup == NULL) // Sanity check
- throw Genexcept("Main window help popup creation failed.");
- m_pMenubar->insertItem(trUtf8("&Help"), pHelppopup);
- pHelppopup->insertItem(trUtf8("&Contents"), this, SLOT(helpContents()), Key_F1);
- pHelppopup->insertSeparator();
- pHelppopup->insertItem(trUtf8("About &Titraq"), this, SLOT(aboutTitraq()));
- pHelppopup->insertItem(trUtf8("About &OSSP"), this, SLOT(aboutOSSP()));
- pHelppopup->insertItem(trUtf8("About &Qt"), this, SLOT(aboutQt()));
- pHelppopup->insertSeparator();
- pHelppopup->insertItem(QPixmap(s_kpcWhatsthis_xpm), trUtf8("What's &This"), this, SLOT(whatsThis()), SHIFT+Key_F1);
+ // Use the preferred configuration values to initialize titraq
+ switch (m_pPrefs->getNumber(TITRAQ_PREFSTYLE, TITRAQ_STYLECDE)) {
+ case TITRAQ_STYLECDE:
+ qApp->setStyle(new QCDEStyle);
+ break;
+ case TITRAQ_STYLESGI:
+ qApp->setStyle(new QSGIStyle);
+ break;
+ case TITRAQ_STYLEMOTIF:
+ qApp->setStyle(new QMotifStyle);
+ break;
+ case TITRAQ_STYLEMPLUS:
+ qApp->setStyle(new QMotifPlusStyle);
+ break;
+ case TITRAQ_STYLEPLAT:
+ qApp->setStyle(new QPlatinumStyle);
+ break;
+ case TITRAQ_STYLEMSOFT:
+ qApp->setStyle(new QWindowsStyle);
+ break;
+ default:
+ qApp->setStyle(new QCDEStyle);
+ break;
+ }
}
//
@@ -188,6 +171,74 @@
}
//
+// Construct the menu bar
+//
+void Titraqform::setupMenubar(void)
+{
+ m_pMenubar = menuBar(); // Grab menu bar owned by QMainWindow
+ if (m_pMenubar == NULL) // Sanity check
+ throw Genexcept("Main window menu bar nonexistant.");
+
+ // Make an easter egg ;-)
+ QToolTip::add(m_pMenubar, QRect(0, 0, 2, 2), "Easter egg");
+
+ // Construct and populate the file menu with actions
+ QPopupMenu *pFilepopup = new QPopupMenu(this);
+ if (pFilepopup == NULL) // Sanity check
+ throw Genexcept("Main window file popup creation failed.");
+ m_pMenubar->insertItem(trUtf8("&File"), pFilepopup);
+ m_pFilenewact->addTo(pFilepopup);
+ m_pFileopenact->addTo(pFilepopup);
+ pFilepopup->insertSeparator();
+ m_pFilecloseact->addTo(pFilepopup);
+ pFilepopup->insertSeparator();
+ m_pFilesaveact->addTo(pFilepopup);
+ m_pFilesaveasact->addTo(pFilepopup);
+ pFilepopup->insertSeparator();
+ m_pFilequitact->addTo(pFilepopup);
+
+ // Construct and populate the edit menu with subitems
+ QPopupMenu *pEditpopup = new QPopupMenu(this);
+ if (pEditpopup == NULL) // Sanity check
+ throw Genexcept("Main window edit popup creation failed.");
+ m_pMenubar->insertItem(trUtf8("&Edit"), pEditpopup);
+ pEditpopup->insertItem("Cu&t", this, SLOT(cut()), CTRL+Key_X);
+ pEditpopup->insertItem("&Copy", this, SLOT(copy()), CTRL+Key_C);
+ pEditpopup->insertItem("&Paste", this, SLOT(paste()), CTRL+Key_V);
+ pEditpopup->insertSeparator();
+ pEditpopup->insertItem("&Add", this, SLOT(addEntry()), CTRL+Key_A);
+ pEditpopup->insertItem("&Delete", this, SLOT(delEntry()), Key_Delete);
+ pEditpopup->insertItem("Select &All", this, SLOT(selAll()), CTRL+Key_A);
+ pEditpopup->insertSeparator();
+ pEditpopup->insertItem("Preferences...", this, SLOT(configPrefs()));
+
+ // Construct and populate the view menu with subitems
+ QPopupMenu *pViewpopup = new QPopupMenu(this);
+ if (pViewpopup == NULL) // Sanity check
+ throw Genexcept("Main window view popup creation failed.");
+ m_pMenubar->insertItem(trUtf8("&View"), pViewpopup);
+ pViewpopup->insertItem(trUtf8("&Normal"), this, SLOT(normalView()));
+ pViewpopup->insertItem(trUtf8("&Editing"), this, SLOT(editingView()));
+ pViewpopup->insertItem(trUtf8("&Timing"), this, SLOT(timingView()));
+
+ // Pad spacing to force help menu to appear far right
+ m_pMenubar->insertSeparator();
+
+ // Construct and populate the help menu with subitems
+ QPopupMenu *pHelppopup = new QPopupMenu(this);
+ if (pHelppopup == NULL) // Sanity check
+ throw Genexcept("Main window help popup creation failed.");
+ m_pMenubar->insertItem(trUtf8("&Help"), pHelppopup);
+ pHelppopup->insertItem(trUtf8("&Contents"), this, SLOT(helpContents()), Key_F1);
+ pHelppopup->insertSeparator();
+ pHelppopup->insertItem(trUtf8("About &Titraq"), this, SLOT(aboutTitraq()));
+ pHelppopup->insertItem(trUtf8("About &OSSP"), this, SLOT(aboutOSSP()));
+ pHelppopup->insertItem(trUtf8("About &Qt"), this, SLOT(aboutQt()));
+ pHelppopup->insertSeparator();
+ pHelppopup->insertItem(QPixmap(s_kpcWhatsthis_xpm), trUtf8("What's &This"), this, SLOT(whatsThis()), SHIFT+Key_F1);
+}
+
+//
// Construct the file tool bar
//
void Titraqform::setupFiletools(void)
@@ -427,18 +478,3 @@
connect(m_pQuitbutton, SIGNAL(clicked()), qApp, SLOT(quit()));
m_pControllayout->addWidget(m_pQuitbutton);
}
-
-//
-// Construct the preferences
-//
-void Titraqform::setupPrefs(void)
-{
- m_pPrefs = new Preferences(TITRAQ_PREFNAME, TITRAQ_APPTITLE, TITRAQ_PREFVER);
- if (m_pPrefs->fileState()) { // No file was found, so create a new one
- m_pPrefs->setString(TITRAQ_PREFASFILE, TITRAQ_DEFASFILE);
- m_pPrefs->setString(TITRAQ_PREFSTYLE, TITRAQ_DEFSTYLE);
- m_pPrefs->setString(TITRAQ_PREFVIEW, TITRAQ_DEFVIEW);
- m_pPrefs->setString(TITRAQ_PREFREMOTELOG, TITRAQ_DEFREMOTELOG);
- m_pPrefs->setString(TITRAQ_PREFLOCALLOG, TITRAQ_DEFLOCALLOG);
- }
-}
|