コード例 #1
0
ファイル: mainwindow.cpp プロジェクト: dakerfp/Iceberg
void MainWindow::readSettings()
{
    QSettings cfg;
    QString viewId = cfg.value("CurrentView").toString();

    m_viewMode->blockSignals(true);

    if (viewId == "list") {
        setupListView();
        m_listView->setChecked(true);
    } else if (viewId == "detailedhost") {
        setupDetailedHostView();
        m_detailedView->setChecked(true);
    } else {
        setupStarView();
        m_starView->setChecked(true);
    }

    // "icecream" is the default netname used by iceccd
    if (m_monitor->currentNet().isEmpty()) {
        QByteArray netname = cfg.value("netname", "icecream").toByteArray();
        setCurrentNet(netname);
    }

    // Load window geometry
    QRect geom = cfg.value("geometry").toRect();
    if (geom.isNull()) {
        QDesktopWidget w;
        QRect screenGeometry = w.availableGeometry(this);
        geom = QRect(screenGeometry.center()/2, screenGeometry.size()/2 );
    }
    setGeometry(geom);

    m_viewMode->blockSignals(false);
}
コード例 #2
0
ファイル: mainwindow.cpp プロジェクト: hugopl/Iceberg
MainWindow::MainWindow(QWidget* parent)
    : QMainWindow(parent), m_view(0)
{
    m_hostInfoManager = new HostInfoManager;

    m_monitor = new Monitor(m_hostInfoManager, this);

    m_viewMode = new QActionGroup(this);

    QMenu* fileMenu = menuBar()->addMenu(tr("&File"));
    QAction* quitAction = fileMenu->addAction(tr("&Quit"));
    quitAction->setShortcut(QKeySequence::Quit);
    connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit()));

    QMenu* viewMenu = menuBar()->addMenu(tr("&View"));
    QMenu* modeMenu = viewMenu->addMenu(tr("&Mode"));

    m_listView = modeMenu->addAction(tr("&List View"));
    m_listView->setCheckable(true);
    m_viewMode->addAction(m_listView);
    connect(m_listView, SIGNAL(triggered()), this, SLOT(setupListView()));

    m_starView = modeMenu->addAction(tr("&Star View"));
    m_starView->setCheckable(true);
    m_viewMode->addAction(m_starView);
    connect(m_starView, SIGNAL(triggered()), this, SLOT(setupStarView()));

    m_detailedView = modeMenu->addAction(tr("&Detailed Host View"));
    m_detailedView->setCheckable(true);
    m_viewMode->addAction(m_detailedView);
    connect(m_detailedView, SIGNAL(triggered()), this, SLOT(setupDetailedHostView()));


    QAction* actionStart = viewMenu->addAction(tr("&Start"));
    connect(actionStart, SIGNAL(triggered()), this, SLOT(startView()));
    QAction* actionStop = viewMenu->addAction(tr("Stop"));
    connect(actionStop, SIGNAL(triggered()), this, SLOT(stopView()));
    viewMenu->addSeparator();
    QAction* actionCheckNodes = viewMenu->addAction(tr("Check Nodes"));
    connect(actionCheckNodes, SIGNAL(triggered()), this, SLOT(checkNodes()));
    viewMenu->addSeparator();
    m_configView = viewMenu->addAction(tr("Configure View..."));
    connect(m_configView, SIGNAL(triggered()), this, SLOT( configureView()));

    m_systrayAction = viewMenu->addAction(tr("System Tray"));
    m_systrayAction->setCheckable(true);

    QMenu* helpMenu = menuBar()->addMenu(tr("&Help"));
    helpMenu->addAction(tr("About..."), this, SLOT(showAboutDialog()));

    readSettings();

    // Avoid useless creation and connection if the system does not have a systray
    if (QSystemTrayIcon::isSystemTrayAvailable()) {
        m_systemTrayIcon = new QSystemTrayIcon(this);
        m_systemTrayIcon->setIcon(QIcon(":bigIcon.png"));

        m_systemTrayMenu = new QMenu(this);
        m_systemTrayMenu->addAction(quitAction);

        m_systemTrayIcon->setContextMenu(m_systemTrayMenu);

        connect(m_systemTrayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)),
                this, SLOT(systemTrayIconActivated(QSystemTrayIcon::ActivationReason)));

        connect(m_systrayAction, SIGNAL(triggered(bool)), m_systemTrayIcon, SLOT(setVisible(bool)));

        // Only show the systray if enabled
        if (m_systrayAction->isChecked())
            m_systemTrayIcon->show();
    } else {
        m_systrayAction->setEnabled(false);
    }

    setWindowIcon(QIcon(":bigIcon.png"));

    m_monitor->checkScheduler();
}