Esempio n. 1
0
void NMainMenuBar::setupFileMenu() {
    fileMenu = this->addMenu(tr("&File"));

    QFont f;
    f.setPointSize(8);
    restoreDatabaseAction = new QAction(tr("Restore Database"), this);
    restoreDatabaseAction->setToolTip(tr("Restore from a backup"));
    restoreDatabaseAction->setFont(f);
    connect(restoreDatabaseAction, SIGNAL(triggered()), parent, SLOT(databaseRestore()));
    setupShortcut(restoreDatabaseAction, QString("File_Restore_Database"));
    fileMenu->addAction(restoreDatabaseAction);


    fileMenu->addSeparator();

    exitAction = new QAction(tr("Exit"), this);
    exitAction->setToolTip(tr("Close the program"));
    connect(exitAction, SIGNAL(triggered()), parent, SLOT(closeNixNote()));
    exitAction->setShortcut(QKeySequence::Close);
    exitAction->setIcon(QIcon::fromTheme("exit"));
    exitAction->setFont(f);
    //exitAction->setIcon(QFileIconProvider().icon(QFileInfo("/home/randy/Dropbox/nixnote.jar")));
    setupShortcut(exitAction, QString("File_Exit"));
    fileMenu->addAction(exitAction);

}
Esempio n. 2
0
void NMainMenuBar::setupFileMenu() {
    QFont f = global.getGuiFont(QFont());
    this->setFont(f);

    fileMenu = this->addMenu(tr("&File"));
    fileMenu->setFont(f);


    emailAction = new QAction(tr("Email Note"), this);
    emailAction->setToolTip(tr("Email a copy of this note"));
    connect(emailAction, SIGNAL(triggered()), parent, SLOT(emailNote()));
    setupShortcut(emailAction, QString("File_Email"));
    fileMenu->addAction(emailAction);


    printPreviewAction = new QAction(tr("Print Preview Note"), this);
    printPreviewAction->setToolTip(tr("Print preview of this note"));
    connect(printPreviewAction, SIGNAL(triggered()), parent, SLOT(printPreviewNote()));
    setupShortcut(printPreviewAction, QString("File_Print_Preview"));
    fileMenu->addAction(printPreviewAction);
    //printPreviewAction->setVisible(false);  // for some reason images don't show up in print preview, so this is useless.  Check again in Qt5

    printAction = new QAction(tr("&Print Note"), this);
    printAction->setToolTip(tr("Print this note"));
    connect(printAction, SIGNAL(triggered()), parent, SLOT(printNote()));
    setupShortcut(printAction, QString("File_Print"));
    fileMenu->addAction(printAction);
    fileMenu->addSeparator();


    backupDatabaseAction = new QAction(tr("&Backup Database"), this);
    backupDatabaseAction->setToolTip(tr("Backup database to a file"));
    connect(backupDatabaseAction, SIGNAL(triggered()), parent, SLOT(databaseBackup()));
    setupShortcut(backupDatabaseAction, QString("File_Backup_Database"));
    fileMenu->addAction(backupDatabaseAction);

    restoreDatabaseAction = new QAction(tr("&Restore Database"), this);
    restoreDatabaseAction->setToolTip(tr("Restore from a backup"));
    connect(restoreDatabaseAction, SIGNAL(triggered()), parent, SLOT(databaseRestore()));
    setupShortcut(restoreDatabaseAction, QString("File_Restore_Database"));
    fileMenu->addAction(restoreDatabaseAction);

    fileMenu->addSeparator();

    exportNoteAction = new QAction(tr("&Export to NixNote Export"), this);
    exportNoteAction->setToolTip(tr("Export selected notes to a NNEX file"));
    connect(exportNoteAction, SIGNAL(triggered()), parent, SLOT(noteExport()));
    setupShortcut(exportNoteAction, QString("File_Note_Export"));
    fileMenu->addAction(exportNoteAction);

    exportAsPdfAction = new QAction(tr("&Export notes as PDF"), this);
    exportAsPdfAction->setToolTip(tr("Export selected notes to a PDF file"));
    connect(exportAsPdfAction, SIGNAL(triggered()), parent, SLOT(onExportAsPdf()));
    setupShortcut(exportAsPdfAction, QString("File_Note_Export_Pdf"));
    fileMenu->addAction(exportAsPdfAction);

    importNoteAction = new QAction(tr("&Import notes"), this);
    importNoteAction->setToolTip(tr("Import notes from an export file"));
    connect(importNoteAction, SIGNAL(triggered()), parent, SLOT(noteImport()));
    setupShortcut(importNoteAction, QString("File_Note_Import"));
    fileMenu->addAction(importNoteAction);

    fileMenu->addSeparator();
    QList<QString> names = global.accountsManager->nameList();
    QList<int> ids = global.accountsManager->idList();
    QList<QPair<int, QString>> pairList;
    for (int i = 0; i < ids.size(); i++) {
        pairList.append(QPair<int, QString>(ids[i], names[i]));
    }
    qSort(pairList.begin(), pairList.end(), QPairFirstComparer());
    for (int i = 0; i < ids.size(); i++) {
        QAction *accountAction = new QAction(pairList[i].second + " - (" + QString::number(pairList[i].first) + ")",
                                             this);
        accountAction->setData(pairList[i].first);
        accountAction->setCheckable(true);
        if (global.accountsManager->currentId == pairList[i].first)
            accountAction->setChecked(true);
        else {
            accountAction->setText(
                tr("Switch to ") + pairList[i].second + " - (" + QString::number(pairList[i].first) + ")");
        }
        fileMenu->addAction(accountAction);
        connect(accountAction, SIGNAL(triggered()), parent, SLOT(switchUser()));
        userAccountActions.append(accountAction);
    }

    addUserAction = new QAction(tr("&Add Another User..."), this);
    fileMenu->addAction(addUserAction);
    connect(addUserAction, SIGNAL(triggered()), parent, SLOT(addAnotherUser()));

    userMaintenanceAction = new QAction(tr("&User Account Maintenance"), this);
    fileMenu->addAction(userMaintenanceAction);
    connect(userMaintenanceAction, SIGNAL(triggered()), parent, SLOT(userMaintenance()));

    fileMenu->addSeparator();

    openCloseAction = new QAction(tr("&Open/Close Notebooks"), this);
    openCloseAction->setToolTip(tr("Open/Close Notebooks"));
    connect(openCloseAction, SIGNAL(triggered()), parent, SLOT(openCloseNotebooks()));
    setupShortcut(quitAction, QString("File_Notebook_OpenClose"));
    fileMenu->addAction(openCloseAction);

    fileMenu->addSeparator();

    quitAction = new QAction(tr("Quit"), this);
    quitAction->setToolTip(tr("Quit the program"));
    connect(quitAction, SIGNAL(triggered()), parent, SLOT(quitNixNote()));

    quitAction->setShortcut(QKeySequence::Close);
    quitAction->setIcon(QIcon::fromTheme("exit"));
    setupShortcut(quitAction, QString("File_Exit"));
    fileMenu->addAction(quitAction);

    QString menuCss = global.getThemeCss("menuCss");
    if (menuCss != "")
        this->setStyleSheet(menuCss);
}