Import upstream version 0.99.2
[fmit.git] / src / modules / View.cpp
index 9d944e9..6c1252e 100644 (file)
 #include <iostream>
 using namespace std;
 #include <qtooltip.h>
+#include <qevent.h>
+#include <qwidgetaction.h>
 
 list<View*> View::s_views;
-QSettings* View::s_settings = NULL;
+AutoQSettings* View::s_settings = NULL;
 
 void View::saveAll()
 {
@@ -34,7 +36,7 @@ void View::saveAll()
        for(list<View*>::iterator it=s_views.begin(); it!=s_views.end(); ++it)
        {
                s_settings->beginGroup((*it)->getName());
-               s_settings->writeEntry("show", (*it)->setting_show->isOn());
+               s_settings->setValue("show", (*it)->setting_show->isChecked());
                (*it)->save();
                s_settings->endGroup();
        }
@@ -46,7 +48,7 @@ void View::loadAll()
        for(list<View*>::iterator it=s_views.begin(); it!=s_views.end(); ++it)
        {
                s_settings->beginGroup((*it)->getName());
-               (*it)->setting_show->setOn(s_settings->readBoolEntry("show", (*it)->setting_show->isOn()));
+               (*it)->setting_show->setChecked(s_settings->value("show", (*it)->setting_show->isChecked()).toBool());
                (*it)->load();
                s_settings->endGroup();
        }
@@ -58,7 +60,7 @@ void View::clearAllSettings()
        for(list<View*>::iterator it=s_views.begin(); it!=s_views.end(); ++it)
        {
                s_settings->beginGroup((*it)->getName());
-               s_settings->removeEntry("show");
+               s_settings->remove("show");
                (*it)->clearSettings();
                s_settings->endGroup();
        }
@@ -72,14 +74,16 @@ View::View(const QString& name, QWidget* parent)
 , m_popup_menu(parent)
 {
        // settings
-       m_popup_menu.insertItem(new Title("<b>"+QWidget::tr(m_name)+"</b>", &m_popup_menu));
-       m_popup_menu.insertSeparator();
+       QWidgetAction* caption = new QWidgetAction(&m_popup_menu);
+       caption->setDefaultWidget(new Title(QString("<b>%1</b>").arg(QObject::tr(m_name.toAscii().constData())), &m_popup_menu));
+       m_popup_menu.addAction(caption);
 
-       setting_show = new QAction(parent);
-       setting_show->setMenuText(QWidget::tr("Show ")+getName()+QWidget::tr(" view"));
-       setting_show->setToggleAction(true);
+       m_popup_menu.addSeparator();
+
+       setting_show = new QAction(m_name, parent);
+       setting_show->setCheckable(true);
        parent->connect(setting_show, SIGNAL(toggled(bool)), parent, SLOT(setShown(bool)));
-       setting_show->setToolTip(QWidget::tr(m_name));
+       setting_show->setToolTip(QObject::tr("Show \"%1\" view").arg(m_name));
 
        parent->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding));