Ejemplo n.º 1
0
int
main(int argc, char **argv)
{
	int pid, ret;
	struct sigaction new_action, old_action;
	GOptionContext *ctx;
	GError *parse_err = NULL;

	daemon_pid_file_ident = daemon_log_ident = daemon_ident_from_argv0(argv[0]);
	daemon_pid_file_proc = conf_pid_file_proc;
	if (conf_init() < 0)
		return EXIT_FAILURE;

	ctx = g_option_context_new("");
	g_option_context_add_main_entries(ctx, options, PACKAGE);
	g_option_context_set_summary(ctx, PACKAGE"-"VERSION GITHEAD" - mpd cron daemon");

	if (!g_option_context_parse(ctx, &argc, &argv, &parse_err)) {
		g_printerr("option parsing failed: %s\n", parse_err->message);
		g_option_context_free(ctx);
		g_error_free(parse_err);
		return EXIT_FAILURE;
	}
	g_option_context_free(ctx);

	if (optv) {
		about();
		cleanup();
		return EXIT_SUCCESS;
	}

#ifdef DAEMON_SET_VERBOSITY_AVAILABLE
	if (conf.no_daemon)
		daemon_set_verbosity(LOG_DEBUG);
#endif /* DAEMON_SET_VERBOSITY_AVAILABLE */

	/* Version to environment variable */
	g_setenv("MPDCRON_PACKAGE", PACKAGE, 1);
	g_setenv("MPDCRON_VERSION", VERSION, 1);
	g_setenv("MPDCRON_GITHEAD", GITHEAD, 1);

	/* Command line options to environment variables */
	if (conf.no_daemon)
		g_unsetenv("MCOPT_DAEMONIZE");
	else
		g_setenv("MCOPT_DAEMONIZE", "1", 1);

	/* Important! Parse configuration file before killing the daemon
	 * because the configuration file has a pidfile and killwait option.
	 */
	cfd = g_key_file_new();
	if (keyfile_load(&cfd) < 0) {
		cleanup();
		return EXIT_FAILURE;
	}

	if (optk) {
		if (daemon_pid_file_kill_wait(SIGINT, conf.killwait) < 0) {
			g_warning("Failed to kill daemon: %s", strerror(errno));
			cleanup();
			return EXIT_FAILURE;
		}
		daemon_pid_file_remove();
		cleanup();
		return EXIT_SUCCESS;
	}

	/* Logging */
	g_log_set_default_handler(log_handler, GINT_TO_POINTER(conf.no_daemon ? 5 : conf.loglevel));

	/* Signal handling */
	new_action.sa_handler = sig_cleanup;
	sigemptyset(&new_action.sa_mask);
	new_action.sa_flags = 0;

#define HANDLE_SIGNAL(sig)					\
	do {							\
		sigaction((sig), NULL, &old_action);		\
		if (old_action.sa_handler != SIG_IGN)		\
			sigaction((sig), &new_action, NULL);	\
	} while (0)

	HANDLE_SIGNAL(SIGABRT);
	HANDLE_SIGNAL(SIGSEGV);
	HANDLE_SIGNAL(SIGINT);
	HANDLE_SIGNAL(SIGTERM);

#undef HANDLE_SIGNAL

	if (conf.no_daemon) {
		/* Create the main loop */
		loop = g_main_loop_new(NULL, FALSE);

#ifdef HAVE_GMODULE
		/* Load modules which may add initial events */
		keyfile_load_modules(&cfd);
#endif /* HAVE_GMODULE */
		g_key_file_free(cfd);
		cfd = NULL;

		/* Add default initial events */
		loop_connect();

		/* Run the main loop */
		g_main_loop_run(loop);
		cleanup();
		return EXIT_SUCCESS;
	}

	/* Daemonize */
	if ((pid = daemon_pid_file_is_running()) > 0) {
		g_critical("Daemon already running on PID %u", pid);
		return EXIT_FAILURE;
	}

	daemon_retval_init();
	pid = daemon_fork();
	if (pid < 0) {
		g_critical("Failed to fork: %s", strerror(errno));
		daemon_retval_done();
		return EXIT_FAILURE;
	}
	else if (pid != 0) { /* Parent */
		cleanup();

		if ((ret = daemon_retval_wait(2)) < 0) {
			g_critical("Could not receive return value from daemon process: %s",
				strerror(errno));
			return 255;
		}

		if (ret != 0)
			g_critical("Daemon returned %i as return value", ret);
		else
			g_critical("Daemon returned %i as return value", ret);
		return ret;
	}
	else { /* Daemon */
		if (daemon_close_all(-1) < 0) {
			g_critical("Failed to close all file descriptors: %s",
					strerror(errno));
			daemon_retval_send(1);
			return EXIT_FAILURE;
		}

		if (daemon_pid_file_create() < 0) {
			g_critical("Failed to create PID file: %s",
					strerror(errno));
			daemon_retval_send(2);
			return EXIT_FAILURE;
		}

		/* Send OK to parent process */
		daemon_retval_send(0);

		/* Create the main loop */
		loop = g_main_loop_new(NULL, FALSE);

#ifdef HAVE_GMODULE
		/* Load modules which may add initial events */
		keyfile_load_modules(&cfd);
#endif /* HAVE_GMODULE */
		g_key_file_free(cfd);
		cfd = NULL;

		/* Add default initial events */
		loop_connect();

		/* Run the main loop */
		g_main_loop_run(loop);
		cleanup();
		return EXIT_SUCCESS;
	}
	return EXIT_SUCCESS;
}
Ejemplo n.º 2
0
DesktopScene::DesktopScene(QObject * parent)
    : QGraphicsScene(parent),
      m_wheelDesktopSwitch(false),
      m_menu(0),
      m_actArrangeWidgets(0),
      m_actAddNewPlugin(0),
      m_actRemovePlugin(0),
      m_actConfigurePlugin(0),
      m_actSetbackground(0),
      m_actAbout(0),
      m_activePlugin(0)
{
    m_power = new PowerManager(this);
    m_screenSaver = new ScreenSaver(this);

    DesktopConfig::instance()->config->beginGroup("razor");
    QStringList plugins =  DesktopConfig::instance()->config->value("plugins").toStringList();
    m_menuFile = DesktopConfig::instance()->config->value("menu_file", "").toString();
    m_wheelDesktopSwitch = DesktopConfig::instance()->config->value("mouse_wheel_desktop_switch", false).toBool();
    DesktopConfig::instance()->config->endGroup();
    if (m_menuFile.isEmpty())
        m_menuFile = XdgMenu::getMenuFileName();

    m_xdgMenu.setEnvironments(QStringList() << "X-RAZOR" << "Razor");
    bool res = m_xdgMenu.read(m_menuFile);
    connect(&m_xdgMenu, SIGNAL(changed()), this, SLOT(buildMenu()));

    if (res)
    {
        QTimer::singleShot(1000, this, SLOT(buildMenu()));
    }
    else
    {
        QMessageBox::warning(0, "Menu Parse error", m_xdgMenu.errorString());
        return;
    }

    m_actArrangeWidgets = new QAction(tr("Unlock Desktop..."), this);
    m_actArrangeWidgets->setIcon(XdgIcon::fromTheme("object-locked"));
    m_actArrangeWidgets->setCheckable(true);
    connect(m_actArrangeWidgets, SIGNAL(toggled(bool)),
            this, SLOT(arrangeWidgets(bool)));

    m_actAddNewPlugin = new QAction(tr("Add New Desktop Widget..."), this);
    connect(m_actAddNewPlugin, SIGNAL(triggered()),
            this, SLOT(showAddPluginDialog()));

    m_actRemovePlugin = new QAction(tr("Remove Plugin..."), this);
    connect(m_actRemovePlugin, SIGNAL(triggered()),
            this, SLOT(removePlugin()));

    m_actConfigurePlugin = new QAction(tr("Configure Plugin..."), this);
    connect(m_actConfigurePlugin, SIGNAL(triggered()),
            this, SLOT(configurePlugin()));

    m_actSetbackground = new QAction(tr("Set Desktop Background..."), this);
    m_actSetbackground->setIcon(XdgIcon::fromTheme("preferences-desktop-wallpaper"));
    connect(m_actSetbackground, SIGNAL(triggered()),
            this, SLOT(setDesktopBackground()));

    m_actAbout = new QAction(tr("About Razor..."), this);
    m_actAbout->setIcon(XdgIcon::fromTheme("help-browser"));
    connect(m_actAbout, SIGNAL(triggered()), this, SLOT(about()));

    // load plugins
    QStringList desktopDirs = pluginDesktopDirs();
    foreach (QString configId, plugins)
    {
        DesktopConfig::instance()->config->beginGroup(configId);
        QString libName(DesktopConfig::instance()->config->value("plugin", "").toString());

        qreal x = DesktopConfig::instance()->config->value("x", 10.0).toReal();
        qreal y = DesktopConfig::instance()->config->value("y", 10.0).toReal();
        qreal w = DesktopConfig::instance()->config->value("w", 10.0).toReal();
        qreal h = DesktopConfig::instance()->config->value("h", 10.0).toReal();
        QPointF position(x, y);
        QSizeF size(w, h);
        DesktopConfig::instance()->config->endGroup();

        RazorPluginInfoList list = RazorPluginInfo::search(desktopDirs, "RazorDesktop/Plugin", QString("%1.desktop").arg(libName));
        if( !list.count())
        {
            qWarning() << QString("Plugin \"%1\" not found.").arg(libName);
            continue;
        }
        QLibrary* lib = loadPluginLib(list.first());
        if (!lib)
        {
            qWarning() << "RazorWorkSpace::setConfig() Library" << libName << "is not loaded";
            continue;
        }

        DesktopWidgetPlugin * item = m_plugins[configId];
        if (!item)
        {
            item = loadPlugin(lib, configId, list.first());
            m_plugins.insert(configId, item);
        }

        item->setSizeAndPosition(position, size);
    }
Ejemplo n.º 3
0
int main(void)
{
      char n;
      int x=10,y=10;
      clrscr();
      textbackground(0);
      ipn();
      Sleep(600);
      voca3();
      Sleep(1000);
      marco();
      textcolor(10);
      Sleep(200);
      textbackground(0);
      gotoxy(10,11);
      printf("Altas");
      Sleep(200);
      gotoxy(10,12);
      textbackground(0);
      printf("Bajas");
      Sleep(200);
      gotoxy(10,13);
      textbackground(0);
      printf("Modificaciones");
      Sleep(200);
      textbackground(0);
      gotoxy(10,14);
      printf("Consultas");
      Sleep(200);
      gotoxy(10,15);
      textbackground(0);
      printf("Reportes");
      Sleep(200);
      gotoxy(10,16);
      textbackground(0);
      printf("Salir");
      Sleep(500);
      about();

      do
      {
             n = tolower(getch());
             switch(n)
             {
                      case 'w':
                           if(y<=16 && y>=12)
                           {
                                    y=y-1;
                                    menu(&x,&y);
                                    about();
                           }
                           else
                           {
                               Beep(9000,300);
                               if(y==12)
                               {
                                        y=9;
                                        menu(&x,&y);
                                        about();
                               }
                           }
                           break;

                      case 's':
                           if(y<=15 && y>=10)
                           {
                                    y=y+1;
                                    menu(&x,&y);
                                    about();
                           }
                           
                           else
                           {
                               y=16;
                               Beep(9000,300);
                               menu(&x,&y);
                               about();
                           }
                           break;

                      case enter:
                           if(y==11)
                           {
                                    daralta();
                           }
                           if(y==12)
                           {
                                    darbaja();
                           }
                           if(y==13)
                           {
                                    modificaciones();
                           }
                           if(y==14)
                           {
                                    consultas();
                           }
                           if(y==15)
                           {
                                    reportes();
                           }
                           if(y==16)
                           {
                                    salir();
                           }
                           break;
                      
             }  
      }
      while(n !='v');
}
Ejemplo n.º 4
0
int main(int argc, char **argv)
{
    QCoreApplication app(argc, argv);
    KAboutData about("kde4-config", "kdelibs4", ki18n("kde4-config"), "1.0",
                     ki18n("A little program to output installation paths"),
                     KAboutData::License_GPL,
                     ki18n("(C) 2000 Stephan Kulow"));
    KCmdLineArgs::init( argc, argv, &about);

    KCmdLineOptions options;
    options.add("expandvars",  ki18n("Left for legacy support"));
    options.add("prefix",      ki18n("Compiled in prefix for KDE libraries"));
    options.add("exec-prefix", ki18n("Compiled in exec_prefix for KDE libraries"));
    options.add("libsuffix",   ki18n("Compiled in library path suffix"));
    options.add("localprefix", ki18n("Prefix in $HOME used to write files"));
    options.add("kde-version", ki18n("Compiled in version string for KDE libraries"));
    options.add("types",       ki18n("Available KDE resource types"));
    options.add("path type",       ki18n("Search path for resource type"));
    options.add("locate filename", ki18n("Find filename inside the resource type given to --path"));
    options.add("userpath type",   ki18n("User path: desktop|autostart|document"));
    options.add("install type",    ki18n("Prefix to install resource files to"));
    options.add("qt-prefix",   ki18n("Installation prefix for Qt"));
    options.add("qt-binaries", ki18n("Location of installed Qt binaries"));
    options.add("qt-libraries", ki18n("Location of installed Qt libraries"));
    options.add("qt-plugins", ki18n("Location of installed Qt plugins"));
    KCmdLineArgs::addCmdLineOptions( options ); // Add my own options.

    KComponentData a(&about);
    (void)KGlobal::dirs(); // trigger the creation
    (void)KGlobal::config();

    // Get application specific arguments
    KCmdLineArgs *args = KCmdLineArgs::parsedArgs();

    if (args->isSet("prefix"))
    {
        printResult(QFile::decodeName(KDEDIR));
        return 0;
    }

    if (args->isSet("exec-prefix"))
    {
        printResult(QFile::decodeName(EXEC_INSTALL_PREFIX));
        return 0;
    }

    if (args->isSet("libsuffix"))
    {
        QString tmp(QFile::decodeName(KDELIBSUFF));
        tmp.remove(QLatin1Char('"'));
        printResult(tmp);
        return 0;
    }

    if (args->isSet("localprefix"))
    {
        printResult(KGlobal::dirs()->localkdedir());
        return 0;
    }

    if (args->isSet("kde-version"))
    {
        printf("%s\n", KDE_VERSION_STRING);
        return 0;
    }

    if (args->isSet("types"))
    {
        QStringList types = KGlobal::dirs()->allTypes();
        types.sort();
        const char *helptexts[] = {
            "apps", I18N_NOOP("Applications menu (.desktop files)"),
            "autostart", I18N_NOOP("Autostart directories"),
            "cache", I18N_NOOP("Cached information (e.g. favicons, web-pages)"),
            "cgi", I18N_NOOP("CGIs to run from kdehelp"),
            "config", I18N_NOOP("Configuration files"),
            "data", I18N_NOOP("Where applications store data"),
            "emoticons", I18N_NOOP("Emoticons"),
            "exe", I18N_NOOP("Executables in $prefix/bin"),
            "html", I18N_NOOP("HTML documentation"),
            "icon", I18N_NOOP("Icons"),
            "kcfg", I18N_NOOP("Configuration description files"),
            "lib", I18N_NOOP("Libraries"),
            "include", I18N_NOOP("Includes/Headers"),
            "locale", I18N_NOOP("Translation files for KLocale"),
            "mime", I18N_NOOP("Mime types"),
            "module", I18N_NOOP("Loadable modules"),
            "pixmap", I18N_NOOP("Legacy pixmaps"),
            "qtplugins", I18N_NOOP("Qt plugins"),
            "services", I18N_NOOP("Services"),
            "servicetypes", I18N_NOOP("Service types"),
            "sound", I18N_NOOP("Application sounds"),
            "templates", I18N_NOOP("Templates"),
            "wallpaper", I18N_NOOP("Wallpapers"),
            "xdgdata-apps", I18N_NOOP("XDG Application menu (.desktop files)"),
            "xdgdata-dirs", I18N_NOOP("XDG Menu descriptions (.directory files)"),
            "xdgdata-icon", I18N_NOOP("XDG Icons"),
            "xdgdata-pixmap", I18N_NOOP("Legacy pixmaps"),
            "xdgdata-mime", I18N_NOOP("XDG Mime Types"),
            "xdgconf-menu", I18N_NOOP("XDG Menu layout (.menu files)"),
            "xdgconf-autostart", I18N_NOOP("XDG autostart directory"),
            "tmp", I18N_NOOP("Temporary files (specific for both current host and current user)"),
            "socket", I18N_NOOP("UNIX Sockets (specific for both current host and current user)"),
            0, 0
        };
        Q_FOREACH(const QString &type, types)
        {
            int index = 0;
            while (helptexts[index] && type != QLatin1String(helptexts[index])) {
                index += 2;
            }
            if (helptexts[index]) {
                printf("%s - %s\n", helptexts[index], i18n(helptexts[index+1]).toLocal8Bit().constData());
            } else {
                printf("%s", i18n("%1 - unknown type\n", type).toLocal8Bit().constData());
            }
        }
ossimQtSingleImageWindow::ossimQtSingleImageWindow(QWidget* parent,
        const char* name,
        Qt::WFlags f)
    : QMainWindow(parent, name, f),
      ossimConnectableObject(),
      ossimConnectableDisplayListener(),
      theImageWidget(0),
      theLastOpenedDirectory(),
      theResolutionLevelMenu(0)
{
    ossimReferenced::ref();
    setCaption("iview");

    QSize size(DEFAULT_WIDTH, DEFAULT_HEIGHT);
    setBaseSize(size);

    // This set the window's widget size.
    setGeometry(0,0,DEFAULT_WIDTH-1,DEFAULT_HEIGHT-1);

    // Create the image widget parenting it to this.
    theImageWidget = new ossimQtScrollingImageWidget(this, "image_widget");

    // This will clear out any initial garbage in the widget.
    theImageWidget->refresh();

    // Disable random caching scheme.
    theImageWidget->setRandomPriorityQueueEnabledFlag(false);

    // Set the the width and height of the window.
    theImageWidget->resize(DEFAULT_WIDTH, DEFAULT_HEIGHT);

    // Make the image widget the centralized widget.
    setCentralWidget(theImageWidget);

    // Make the "File" pull down menu.
    QMenu* file = new QMenu( this );
    menuBar()->insertItem( "&File", file );
    file->insertItem( "&Open Image",  this, SLOT(openImage()), Qt::CTRL+Qt::Key_O );
    file->insertItem( "&Close Image",  this, SLOT(closeImage()), Qt::CTRL+Qt::Key_C );
    file->insertItem( "&Export",  this, SLOT(exportImage()), Qt::CTRL+Qt::Key_E );
    file->insertItem( "&Quit",  this, SLOT(closeWindow()), Qt::CTRL+Qt::Key_Q );

    // Make the "Edit" pull down menu.
    QMenu* edit = new QMenu( this );
    menuBar()->insertItem( "&Edit", edit );
    edit->insertItem( "Image Chain",  this, SLOT(editImageChain()));

    // Make the "Utilities" pull down menu.
    QMenu* utilities = new QMenu( this );
    menuBar()->insertItem( "&Utilities", utilities );
    utilities->insertItem( "Refresh",  this, SLOT(refreshDisplay()));

    // Make the "Resolution_Level" pull down menu.
    theResolutionLevelMenu = new QMenu( this );
    menuBar()->insertItem( "&Resolution_Level",  theResolutionLevelMenu);

    QAction* rsetAct = new QAction(QString("0"), this);
    rsetAct->setCheckable(true);
    rsetAct->setChecked(true);
    rsetAct->setData(0);
    rsetAct->setEnabled(false);

    theResolutionLevelMenu->addAction( rsetAct );

    // Connect the activated signal to the changeResolutionLevel slot.
    connect( theResolutionLevelMenu, SIGNAL( triggered( QAction * ) ),
             this, SLOT ( changeResolutionLevel( QAction * ) ) );

    // Make the "Help" pull down menu.
    QMenu* help = new QMenu( this );
    menuBar()->insertItem( "&Help", help );
    help->insertItem( "&About",  this, SLOT(about()), Qt::CTRL+Qt::Key_A );

    // Connect up the slot to capture mouse events.
    connect(theImageWidget,
            SIGNAL(scrollingImageWidgetMouseEvent(ossimQtMouseEvent*)),
            this,
            SLOT(trackImageWidget(ossimQtMouseEvent*)));

    // Add us in as a listener for display events like refresh.
    addListener((ossimConnectableDisplayListener*)this);

    //---
    // Connect this display up to "theImageWidget" so that event propagation
    // comes up the chain to us.
    //---
    connectMyInputTo(theImageWidget);

    // Send a dummy message to make the status bar show.
    statusBar()->message( QString(" ") );

    //---
    // Set the last open directory to the current working dir so the open image
    // dialog will come up where you started.
    //---
    theLastOpenedDirectory = getenv("PWD");
}
Ejemplo n.º 6
0
//! [17]
void MainWindow::createActions()
//! [17] //! [18]
{
    newAct = new QAction(QIcon(":/images/new.png"), tr("&New"), this);
    newAct->setShortcuts(QKeySequence::New);
    newAct->setStatusTip(tr("Create a new file"));
    connect(newAct, SIGNAL(triggered()), this, SLOT(newFile()));

//! [19]
    openAct = new QAction(QIcon(":/images/open.png"), tr("&Open..."), this);
    openAct->setShortcuts(QKeySequence::Open);
    openAct->setStatusTip(tr("Open an existing file"));
    connect(openAct, SIGNAL(triggered()), this, SLOT(open()));
//! [18] //! [19]

    saveAct = new QAction(QIcon(":/images/save.png"), tr("&Save"), this);
    saveAct->setShortcuts(QKeySequence::Save);
    saveAct->setStatusTip(tr("Save the document to disk"));
    connect(saveAct, SIGNAL(triggered()), this, SLOT(save()));

    saveAsAct = new QAction(tr("Save &As..."), this);
    saveAsAct->setShortcuts(QKeySequence::SaveAs);
    saveAsAct->setStatusTip(tr("Save the document under a new name"));
    connect(saveAsAct, SIGNAL(triggered()), this, SLOT(saveAs()));

//! [20]
    exitAct = new QAction(tr("E&xit"), this);
    exitAct->setShortcuts(QKeySequence::Quit);
//! [20]
    exitAct->setStatusTip(tr("Exit the application"));
    connect(exitAct, SIGNAL(triggered()), this, SLOT(close()));

//! [21]
    cutAct = new QAction(QIcon(":/images/cut.png"), tr("Cu&t"), this);
//! [21]
    cutAct->setShortcuts(QKeySequence::Cut);
    cutAct->setStatusTip(tr("Cut the current selection's contents to the "
                            "clipboard"));
    connect(cutAct, SIGNAL(triggered()), textEdit, SLOT(cut()));

    copyAct = new QAction(QIcon(":/images/copy.png"), tr("&Copy"), this);
    copyAct->setShortcuts(QKeySequence::Copy);
    copyAct->setStatusTip(tr("Copy the current selection's contents to the "
                             "clipboard"));
    connect(copyAct, SIGNAL(triggered()), textEdit, SLOT(copy()));

    pasteAct = new QAction(QIcon(":/images/paste.png"), tr("&Paste"), this);
    pasteAct->setShortcuts(QKeySequence::Paste);
    pasteAct->setStatusTip(tr("Paste the clipboard's contents into the current "
                              "selection"));
    connect(pasteAct, SIGNAL(triggered()), textEdit, SLOT(paste()));

    aboutAct = new QAction(tr("&About"), this);
    aboutAct->setStatusTip(tr("Show the application's About box"));
    connect(aboutAct, SIGNAL(triggered()), this, SLOT(about()));

//! [22]
    aboutQtAct = new QAction(tr("About &Qt"), this);
    aboutQtAct->setStatusTip(tr("Show the Qt library's About box"));
    connect(aboutQtAct, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
//! [22]

//! [23]
    cutAct->setEnabled(false);
//! [23] //! [24]
    copyAct->setEnabled(false);
    connect(textEdit, SIGNAL(copyAvailable(bool)),
            cutAct, SLOT(setEnabled(bool)));
    connect(textEdit, SIGNAL(copyAvailable(bool)),
            copyAct, SLOT(setEnabled(bool)));
}
Ejemplo n.º 7
0
void MainWindow::createMenus()
{
    openAct = new QAction(tr("读取地图(&M)"), this);
    saveAct = new QAction(tr("存档(&S)"), this);
    loadAct = new QAction(tr("读档(&R)"), this);
    rechargeAct = new QAction(tr("充值(&C)"), this);
    exitAct = new QAction(tr("退出(&E)"), this);

    restartAct = new QAction(tr("重新开始(&L)"), this);
    hardAct = new QAction(tr("困难"), this);
    mediumAct = new QAction(tr("中等"), this);
    easyAct = new QAction(tr("简单"), this);
    foresoundAct = new QAction(tr("音效开关(&O)"), this);

    manualAct = new QAction(tr("用户手册(&U)"), this);
    aboutAct = new QAction(tr("关于(&A)"), this);

    fileMenu = menuBar()->addMenu(tr("文件(&F)"));
    settingMenu = menuBar()->addMenu(tr("游戏设置(&G)"));
    helpMenu = menuBar()->addMenu(tr("帮助(&H)"));

    fileMenu->addAction(openAct);
    openAct->setShortcut(QKeySequence("Ctrl+m"));
    fileMenu->addSeparator();
    fileMenu->addAction(saveAct);
    saveAct->setShortcut(QKeySequence("Ctrl+s"));
    fileMenu->addAction(loadAct);
    loadAct->setShortcut(QKeySequence("Ctrl+r"));
    fileMenu->addSeparator();
    fileMenu->addAction(rechargeAct);
    rechargeAct->setShortcut(QKeySequence("Ctrl+c"));
    fileMenu->addSeparator();
    fileMenu->addAction(exitAct);
    exitAct->setShortcut(QKeySequence("Ctrl+e"));

    settingMenu->addAction(restartAct);
    restartAct->setShortcut(QKeySequence("Ctrl+l"));
    settingMenu->addSeparator();
    difficultyMenu = settingMenu->addMenu(tr("选择难度(&D)"));
    settingMenu->addSeparator();
    settingMenu->addAction(foresoundAct);
    foresoundAct->setCheckable(true);
    foresoundAct->setChecked(true);
    foresoundAct->setShortcut(QKeySequence("Ctrl+o"));

    difficultyMenu->addAction(hardAct);
    hardAct->setCheckable(true);
    hardAct->setChecked(false);
    difficultyMenu->addAction(mediumAct);
    mediumAct->setCheckable(true);
    mediumAct->setChecked(true);
    difficultyMenu->addAction(easyAct);
    easyAct->setCheckable(true);
    easyAct->setChecked(false);

    helpMenu->addAction(manualAct);
    manualAct->setShortcut(QKeySequence("Ctrl+u"));
    helpMenu->addAction(aboutAct);
    aboutAct->setShortcut(QKeySequence("Ctrl+a"));

    connect(exitAct, SIGNAL(triggered()), this, SLOT(close()));
    connect(openAct, SIGNAL(triggered()), this, SLOT(open()));
    connect(saveAct, SIGNAL(triggered()), this, SLOT(save()));
    connect(loadAct, SIGNAL(triggered()), this, SLOT(load()));
    connect(rechargeAct, SIGNAL(triggered()),this, SLOT(recharge()));

    connect(restartAct, SIGNAL(triggered()), this, SLOT(restart()));
    connect(hardAct, SIGNAL(triggered()), this, SLOT(hard()));
    connect(mediumAct, SIGNAL(triggered()), this, SLOT(medium()));
    connect(easyAct, SIGNAL(triggered()), this, SLOT(easy()));
    connect(foresoundAct, SIGNAL(triggered()), this, SLOT(foresound()));

    connect(manualAct, SIGNAL(triggered()), this, SLOT(manual()));
    connect(aboutAct, SIGNAL(triggered()), this, SLOT(about()));
}
Ejemplo n.º 8
0
int main( int argc, char **argv )
{

    qRegisterMetaType<ElementList>();

    options.add("convert-sqlite3", ki18n("Convert the current SQLite 2.x database to SQLite 3 and exit") , 0 );
    options.add( 0, KLocalizedString(), 0 );


    KAboutData about( "krecipes", 0, ki18n( "Krecipes" ), version, ki18n( "The KDE Cookbook" ), KAboutData::License_GPL, ki18n( "(C) 2003 Unai Garro\n(C) 2004-2006 Jason Kivlighn"), ki18n("This product is RecipeML compatible.\nYou can get more information about this file format in:\nhttp://www.formatdata.com/recipeml" ), "http://krecipes.sourceforge.net/" );
    about.addAuthor( ki18n("Unai Garro"), KLocalizedString(), "*****@*****.**", 0 );
    about.addAuthor( ki18n("Jason Kivlighn"), KLocalizedString(), "*****@*****.**", 0 );
    about.addAuthor( ki18n("Cyril Bosselut"), KLocalizedString(), "*****@*****.**", "http://b1project.com" );

    about.addCredit( ki18n("Colleen Beamer"), ki18n("Testing, bug reports, suggestions"), "*****@*****.**", 0 );
    about.addCredit( ki18n("Robert Wadley"), ki18n("Icons and artwork"), "*****@*****.**", 0 );
    about.addAuthor( ki18n("Daniel Sauvé"), ki18n("Porting to KDE4"), "*****@*****.**", "http://metres.homelinux.com" );

    about.addAuthor( ki18n("Laurent Montel"), ki18n("Porting to KDE4"), "*****@*****.**", 0 );
    about.addAuthor( ki18n("José Manuel Santamaría Lema"), ki18n("Porting to KDE4, current maintainer"), "*****@*****.**", 0 );
    about.addAuthor( ki18n("Martin Engelmann"), ki18n("Porting to KDE4, developer"), "*****@*****.**", 0 );

    about.addCredit( ki18n("Patrick Spendrin"), ki18n("Patches to make Krecipes work under Windows"), "*****@*****.**", 0 );
    about.addCredit( ki18n("Mike Ferguson"), ki18n("Help with bugs, patches"), "", 0 );
    about.addCredit( ki18n("Warren Severin"), ki18n("Code to export recipes to *.mx2 files"), "", 0 );

    about.addCredit( ki18n("Eduardo Robles Elvira"),
                     ki18n("He advised using WebKit to fix printing support during Akademy-es 2010."),
                     "*****@*****.**", 0 );
    about.addCredit( ki18n("José Millán Soto"),
                     ki18n("He advised using WebKit to fix printing support during Akademy-es 2010."),
                     "", 0 );

    KCmdLineArgs::init( argc, argv, &about );
    KCmdLineArgs::addCmdLineOptions( options );
    KUniqueApplication::addCmdLineOptions();

    if ( !KUniqueApplication::start() ) {
        std::cerr << "Krecipes is already running!" << std::endl;
        return 0;
    }

    KUniqueApplication app;

    // see if we are starting with session management
    if ( app.isSessionRestored() ) {
        RESTORE( Krecipes );
    }
    else {
        // no session.. just start up normally
        KCmdLineArgs *args = KCmdLineArgs::parsedArgs();

        QApplication::flush();

        if ( args->isSet("convert-sqlite3") ) {
            ConvertSQLite3 sqliteConverter;
            sqliteConverter.convert();
            return 0;
        }

        Krecipes * widget = new Krecipes;
        app.setTopWidget( widget );
        widget->show();

        args->clear();
    }

    return app.exec();
}
Ejemplo n.º 9
0
Window::Window(QWidget *parent)
{
    chek = false;

    //Inicializa componentes
    quadro = new Board(0);
    if(quadro == NULL){
        qDebug() << "quadro Falhou!";
        chek = true;
    }else{
        qDebug() << "quadro Sucesso!";

    }

    layout = new QGridLayout;
    if(layout == NULL){
        qDebug() << "layout Falhou!";
        chek = true;
    }else{
        qDebug() << "layout Sucesso!";
    }

    file = new QFile();
    if(file == NULL){
        qDebug() << "file Falhou!";
        chek = true;
    }else{
        qDebug() << "file Sucesso!";
    }

    lcdLevel = new QLCDNumber();
    if(lcdLevel == NULL){
        qDebug() << "lcdLevel Falhou!";
        chek = true;
    }else{
        qDebug() << "lcdLevel Sucesso!";
    }

    lcdScore = new QLCDNumber();
    if(lcdScore == NULL){
        qDebug() << "lcdScore Falhou!";
        chek = true;
    }else{
        qDebug() << "lcdScore Sucesso!";
    }

    labelLevel = new QLabel("Level:",this);
    if(labelLevel == NULL){
        qDebug() << "labelLevel Falhou!";
        chek = true;
    }else{
        qDebug() << "labelLevel Sucesso!";
    }

    labelScore = new QLabel("Score:",this);    
    if(labelScore == NULL){
        qDebug() << "labelScore Falhou!";
        chek = true;
    }else{
        qDebug() << "labelScore Sucesso!";
    }

    labelLife = new QLabel("Vida:",this);
    if(labelLife == NULL){
        qDebug() << "labelLife Falhou!";
        chek = true;
    }else{
        qDebug() << "labelLife Sucesso!";
    }

    botaoStart = new QPushButton("Start");
    if(botaoStart == NULL){
        qDebug() << "botaoStart Falhou!";
        chek = true;
    }else{
        qDebug() << "botaoStart Sucesso!";
    }

    botaoPause = new QPushButton("Pause");
    if(botaoPause == NULL){
        qDebug() << "botaoPause Falhou!";
        chek = true;
    }else{
        qDebug() << "botaoPause Sucesso!";
    }

    botaoReset = new QPushButton("Reset");
    if(botaoReset == NULL){
        qDebug() << "botaoReset Falhou!";
        chek = true;
    }else{
        qDebug() << "botaoReset Sucesso!";
    }

    menuBar = new QMenuBar;
    if(menuBar == NULL){
        qDebug() << "menuBar Falhou!";
        chek = true;
    }else{
        qDebug() << "menuBar Sucesso!";
    }

    fileMenu = new QMenu(tr("&File"), this);
    if(fileMenu == NULL){
        qDebug() << "fileMenu Falhou!";
        chek = true;
    }else{
        qDebug() << "fileMenu Sucesso!";
    }

    barraProgresso = new QProgressBar();    
    if(barraProgresso == NULL){
        qDebug() << "barraProgresso Falhou!";
        chek = true;
    }else{
        qDebug() << "barraProgresso Sucesso!";
    }

    barraVida = new QProgressBar();
    if(barraVida == NULL){
        qDebug() << "barraVida Falhou!";
        chek = true;
    }else{
        qDebug() << "barraVida Sucesso!";
    }

    tempoScore = new QTimer(this);
    if(tempoScore == NULL){
        qDebug() << "tempo Falhou!";
        chek = true;
    }else{
        qDebug() << "tempo Sucesso!";
    }

    contadorBarra = 1;
    baseScore =5;
    tamInicioBarra = 0;
    tamFimBarra = baseScore;
    barraVida->setMaximum(3);
    contadorVida = 0;

    aboutAct = new QAction(tr("&About"), this);
    if(aboutAct == NULL){
        qDebug() << "aboutAct Falhou!";
        chek = true;
    }else{
        qDebug() << "aboutAct Sucesso!";
    }

    aboutAct->setStatusTip(tr("Show the application's About box"));

    connect(aboutAct, SIGNAL(triggered()), this, SLOT(about()));
    connect(botaoStart, SIGNAL(clicked()), quadro, SLOT(inicio()));
    connect(botaoPause, SIGNAL(clicked()), quadro, SLOT(pausa()));
    connect(botaoReset, SIGNAL(clicked()), quadro, SLOT(reset()));
    connect(quadro, SIGNAL(nivelDificuldade(int)), lcdLevel, SLOT(display(int)));
    connect(quadro, SIGNAL(pontosGanho(int)), lcdScore, SLOT(display(int)));
    connect(quadro, SIGNAL(barra_Progresso()), this, SLOT(barraDeProgresso()));
    connect(quadro, SIGNAL(barra_Vida()), this, SLOT(barraDeVida()));
    connect(quadro, SIGNAL(sinalReset()), this, SLOT(resetJogo()));
    connect(quadro, SIGNAL(salvaScore()), this, SLOT(save()));

    this->resize(304,400);
    this->setMaximumSize(304,400);

    quadro->setMinimumSize(104,200);
    quadro->setMaximumSize(304,400);

    createMenu();
    layout->addWidget(menuBar);
    layout->addWidget(quadro,3,0,10,3);
    layout->addWidget(labelLevel, 3, 4);
    layout->addWidget(lcdLevel,4,4);
    layout->addWidget(labelScore, 5,4);
    layout->addWidget(lcdScore,6,4);
    layout->addWidget(botaoStart,7,4);
    layout->addWidget(botaoPause,8,4);
    layout->addWidget(botaoReset,9,4);
    layout->addWidget(barraProgresso);
    layout->addWidget(labelLife);
    layout->addWidget(barraVida);

    this->setLayout(layout);
    this->show();

    if(chek == true)
    {
        falhaCritica();
    }
}
Ejemplo n.º 10
0
void BoxContainerItem::about()
{
    KAboutApplication about(0, "KOrn About", true);
    about.exec();  //modal: it doesn't recheck anymore
}
Ejemplo n.º 11
0
void MainWindow::createActions() {

    _openiTunesAction = new QAction(QIcon(":/images/iTunes.png"),
                                    tr("Open i&Tunes Library..."), this);
    _openiTunesAction->setShortcut(tr("Ctrl+T"));
    _openiTunesAction->setStatusTip(tr("Open iTunes Library file"));
    connect(_openiTunesAction, SIGNAL(triggered()), this, SLOT(openiTunesLibrary()));

    _openCollectionAction = new QAction(QIcon(":/images/openCollection.png"),
                                        tr("Open Collection File"), this);
    _openCollectionAction->setShortcut(tr("Ctrl+T"));
    _openCollectionAction->setStatusTip(tr("Open Collection file"));
    connect(_openCollectionAction, SIGNAL(triggered()), this, SLOT(openCollectionFile()));

    _exitAction = new QAction(tr("E&xit"), this);
    _exitAction->setShortcut(tr("Ctrl+Q"));
    connect(_exitAction, SIGNAL(triggered()), this, SLOT(close()));

    _coutAction = new QAction(tr("&Cout Library"), this);
    _coutAction->setShortcut(tr("Ctrl+E"));
    connect(_coutAction, SIGNAL(triggered()), this, SLOT(display()));

    _predictAction = new QAction(QIcon(":/images/predict.png"),
                                 tr("&Predict"), this);
    _predictAction->setShortcut(tr("Ctrl+3"));
    _predictAction->setStatusTip(tr("Predict the the placement of the prediction tracks"));
    connect(_predictAction, SIGNAL(triggered()), _display, SLOT(predict()));

    _extractAction = new QAction(QIcon(":/images/extract.png"),
                                 tr("&Extract"), this);
    _extractAction->setShortcut(tr("Ctrl+1"));
    _extractAction->setStatusTip(tr("Extract features from the defined training tracks"));
    connect(_extractAction, SIGNAL(triggered()), _display, SLOT(extract()));

    _trainingAction = new QAction(QIcon(":/images/train.png"),
                                  tr("&Train"), this);
    _trainingAction->setShortcut(tr("Ctrl+2"));
    _trainingAction->setStatusTip(tr("Train the grid using the defined training tracks"));
    connect(_trainingAction, SIGNAL(triggered()), _display, SLOT(train()));

    _initAction = new QAction(QIcon(":/images/init.png"), tr("&Initlize"), this);
    connect(_initAction, SIGNAL(triggered()), _display, SLOT(init()));

    _aboutAction = new QAction(tr("&About"), this);
    connect(_aboutAction, SIGNAL(triggered()), this, SLOT(about()));

    _saveGridAction = new QAction(tr("&Save Grid"), this);
    connect(_saveGridAction, SIGNAL(triggered()), this, SLOT(saveCurrentGrid()) );

    _loadGridAction = new QAction(tr("&Load Saved Grid"),this);
    connect(_loadGridAction, SIGNAL(triggered()), this, SLOT(openSavedGrid()));
    _playModeAction = new QAction(tr("&Continuous"), this);
    connect(_playModeAction, SIGNAL(triggered()), this, SLOT(changedPlayMode()));

    _cancelAction = new QAction(tr("&Cancel Action"), this);
    connect(_cancelAction, SIGNAL(triggered()), this, SLOT(cancelButton()));

    _normHashAction = new QAction(tr("Open Saved Hash"), this);
    connect(_normHashAction, SIGNAL(triggered()), _display, SLOT(hashLoad()));

    _fullScreenAction = new QAction (tr("&Full Screen Mouse Mode"), this);
    connect(_fullScreenAction, SIGNAL(triggered()), _display, SLOT(fullScreenMouse()));

    _colourMapMode = new QAction (tr("&Colour Mapping Mode"),this);
    connect(_colourMapMode, SIGNAL(triggered()), _display, SLOT(colourMapMode()));

    _resetButtonAction = new QAction (tr("&Reset"), this);
    connect (_resetButtonAction, SIGNAL(triggered()), this, SLOT(resetButtonPressed()));

    _optionsDialogAction = new QAction(tr("&Options"), this);
    connect(_optionsDialogAction, SIGNAL(triggered()), this, SLOT(optionsDialogTriggered()));
}
Ejemplo n.º 12
0
int main(int argc, char** argv)
{
    QCoreApplication app(argc, argv);
    KAboutData about(QStringLiteral("kdeconnect-cli"),
                     QStringLiteral("kdeconnect-cli"),
                     QStringLiteral(KDECONNECT_VERSION_STRING),
                     i18n("KDE Connect CLI tool"),
                     KAboutLicense::GPL, 
                     i18n("(C) 2015 Aleix Pol Gonzalez"));
    KAboutData::setApplicationData(about);

    about.addAuthor( i18n("Aleix Pol Gonzalez"), QString(), QStringLiteral("*****@*****.**") );
    about.addAuthor( i18n("Albert Vaca Cintora"), QString(), QStringLiteral("*****@*****.**") );
    QCommandLineParser parser;
    parser.addOption(QCommandLineOption(QStringList(QStringLiteral("l")) << QStringLiteral("list-devices"), i18n("List all devices")));
    parser.addOption(QCommandLineOption(QStringList(QStringLiteral("a")) << QStringLiteral("list-available"), i18n("List available (paired and reachable) devices")));
    parser.addOption(QCommandLineOption(QStringLiteral("id-only"), i18n("Make --list-devices or --list-available print only the devices id, to ease scripting")));
    parser.addOption(QCommandLineOption(QStringLiteral("refresh"), i18n("Search for devices in the network and re-establish connections")));
    parser.addOption(QCommandLineOption(QStringLiteral("pair"), i18n("Request pairing to a said device")));
    parser.addOption(QCommandLineOption(QStringLiteral("ring"), i18n("Find the said device by ringing it.")));
    parser.addOption(QCommandLineOption(QStringLiteral("unpair"), i18n("Stop pairing to a said device")));
    parser.addOption(QCommandLineOption(QStringLiteral("ping"), i18n("Sends a ping to said device")));
    parser.addOption(QCommandLineOption(QStringLiteral("ping-msg"), i18n("Same as ping but you can set the message to display"), i18n("message")));
    parser.addOption(QCommandLineOption(QStringLiteral("share"), i18n("Share a file to a said device"), QStringLiteral("path")));
    parser.addOption(QCommandLineOption(QStringLiteral("list-notifications"), i18n("Display the notifications on a said device")));
    parser.addOption(QCommandLineOption(QStringLiteral("lock"), i18n("Lock the specified device")));
    parser.addOption(QCommandLineOption(QStringLiteral("send-sms"), i18n("Sends an SMS. Requires destination"), i18n("message")));
    parser.addOption(QCommandLineOption(QStringLiteral("destination"), i18n("Phone number to send the message"), i18n("phone number")));
    parser.addOption(QCommandLineOption(QStringList(QStringLiteral("device")) << QStringLiteral("d"), i18n("Device ID"), QStringLiteral("dev")));
    parser.addOption(QCommandLineOption(QStringList(QStringLiteral("name")) << QStringLiteral("n"), i18n("Device Name"), QStringLiteral("name")));
    parser.addOption(QCommandLineOption(QStringLiteral("encryption-info"), i18n("Get encryption info about said device")));
    parser.addOption(QCommandLineOption(QStringLiteral("list-commands"), i18n("Lists remote commands and their ids")));
    parser.addOption(QCommandLineOption(QStringLiteral("execute-command"), i18n("Executes a remote command by id"), QStringLiteral("id")));
    about.setupCommandLine(&parser);

    parser.addHelpOption();
    parser.process(app);
    about.processCommandLine(&parser);

    const QString id = "kdeconnect-cli-"+QString::number(QCoreApplication::applicationPid());
    DaemonDbusInterface iface;

    if(parser.isSet(QStringLiteral("l")) || parser.isSet(QStringLiteral("a"))) {
        bool paired = true, reachable = false;
        if (parser.isSet(QStringLiteral("a"))) {
            reachable = true;
        } else {
            iface.acquireDiscoveryMode(id);
            QThread::sleep(2);
        }
        QDBusPendingReply<QStringList> reply = iface.devices(paired, reachable);
        reply.waitForFinished();

        const QStringList devices = reply.value();
        Q_FOREACH (const QString& id, devices) {
            if (parser.isSet(QStringLiteral("id-only"))) {
                QTextStream(stdout) << id << endl;
            } else {
                DeviceDbusInterface deviceIface(id);
                QString statusInfo;
                const bool isReachable = deviceIface.isReachable();
                const bool isTrusted = deviceIface.isTrusted();
                if (isReachable && isTrusted) {
                    statusInfo = i18n("(paired and reachable)");
                } else if (isReachable) {
                    statusInfo = i18n("(reachable)");
                } else if (isTrusted) {
                    statusInfo = i18n("(paired)");
                }
                QTextStream(stdout) << "- " << deviceIface.name()
                        << ": " << deviceIface.id() << ' ' << statusInfo << endl;
            }
        }
        if (!parser.isSet(QStringLiteral("id-only"))) {
            QTextStream(stdout) << i18np("1 device found", "%1 devices found", devices.size()) << endl;
        } else if (devices.isEmpty()) {
            QTextStream(stderr) << i18n("No devices found") << endl;
        }

        iface.releaseDiscoveryMode(id);
    } else if(parser.isSet(QStringLiteral("refresh"))) {
Ejemplo n.º 13
0
void MainTab::showAboutDialogST(){
  AboutDialog about(this);
  about.exec();
}
Ejemplo n.º 14
0
/*! MyWindow constructor
 * \param w - window width
 * \param h - window hight
 */
MyWindow::MyWindow(int w, int h) : num_of_colors(18)
{
  myBar = new QTabWidget(this);
  setCentralWidget(myBar);
  m_width = w;
  m_height = h;
  tab_number = 0;
  number_of_tabs = 0;
  testlayer = new Qt_layer( myBar );
  colors_flag = true;
  statusBar();

  m_scailing_factor = 2;

  // Traits Group
  QActionGroup *traitsGroup = new QActionGroup( this ); // Connected later
  traitsGroup->setExclusive( TRUE );

  setSegmentTraits = new QAction("Segment Traits",
                                 QPixmap( (const char**)line_xpm ),
                                 "&Segment Traits", 0 ,traitsGroup,
                                 "Segment Traits" );
  setSegmentTraits->setToggleAction( TRUE );

  setPolylineTraits = new QAction("Polyline Traits",
                                  QPixmap( (const char**)polyline_xpm ),
                                  "&Polyline Traits", 0 , traitsGroup,
                                  "Polyline Traits" );
  setPolylineTraits->setToggleAction( TRUE );

#ifdef CGAL_USE_CORE
  setConicTraits = new QAction("Conic Traits",
                               QPixmap( (const char**)conic_xpm ),
                               "&Conic Traits", 0 , traitsGroup,
                               "Conic Traits" );
  setConicTraits->setToggleAction( TRUE );
#endif

  // Snap Mode Group

  setSnapMode = new QAction("Snap Mode", QPixmap( (const char**)snapvertex_xpm ),
                            "&Snap Mode", 0 , this, "Snap Mode" );
  setSnapMode->setToggleAction( TRUE );

  setGridSnapMode = new QAction("Grid Snap Mode",
                                QPixmap( (const char**)snapgrid_xpm ),
                                "&Grid Snap Mode", 0 , this,
                                "Grid Snap Mode" );
  setGridSnapMode->setToggleAction( TRUE );

  // insert - delete - point_location Mode Group
  QActionGroup *modeGroup = new QActionGroup( this ); // Connected later
  modeGroup->setExclusive( TRUE );

  insertMode = new QAction("Insert", QPixmap( (const char**)insert_xpm ),
                           "&Insert", 0 , modeGroup, "Insert" );
  insertMode->setToggleAction( TRUE );

  deleteMode = new QAction("Delete", QPixmap( (const char**)delete_xpm ),
                           "&Delete", 0 , modeGroup, "Delete" );
  deleteMode->setToggleAction( TRUE );

  pointLocationMode = new QAction("PointLocation",
                                  QPixmap( (const char**)pointlocation_xpm ),
                                  "&Point Location", 0 , modeGroup,
                                  "Point Location" );
  pointLocationMode->setToggleAction( TRUE );

  rayShootingUpMode = new QAction("RayShootingUp",
                                QPixmap( (const char**)demo_rayshoot_up_xpm ),
                                "&Ray Shooting Up", 0 , modeGroup,
                                "Ray Shooting Up" );
  rayShootingUpMode->setToggleAction( TRUE );

  rayShootingDownMode = new QAction("RayShootingDown",
                                QPixmap( (const char**)demo_rayshoot_down_xpm ),
                                "&Ray Shooting Down", 0 , modeGroup,
                                "Ray Shooting Down" );
  rayShootingDownMode->setToggleAction( TRUE );

  dragMode = new QAction("Drag", QPixmap( (const char**)hand_xpm ),
                         "&Drag", 0 , modeGroup, "Drag" );
  dragMode->setToggleAction( TRUE );

  mergeMode = new QAction("Merge", QPixmap( (const char**)merge_xpm ),
                         "&Merge", 0 , modeGroup, "Merge" );
  mergeMode->setToggleAction( TRUE );

  splitMode = new QAction("Split", QPixmap( (const char**)split_xpm ),
                         "&Split", 0 , modeGroup, "Split" );
  splitMode->setToggleAction( TRUE );

   fillfaceMode = new QAction("Fill", QPixmap( (const char**)demo_fill_xpm ),
                         "&Fill", 0 , modeGroup, "Fill" );
  fillfaceMode->setToggleAction( TRUE );



  // zoom in
  zoominBt = new QAction("Zoom in", QPixmap( (const char**)zoomin_xpm ),
                         "&Zoom in", 0 , this, "Zoom in" );
  // zoom out
  zoomoutBt = new QAction("Zoom out", QPixmap( (const char**)zoomout_xpm ),
                          "&Zoom out", 0 , this, "Zoom out" );

   // color dialog
  color_dialog_bt = new QAction("Choose color", QPixmap( (const char**)demo_colors_xpm ),
                         "&choose color", 0 , this, "choose color" );

  lower_env_dialog_bt = new QAction("Lower envelope", QPixmap( (const char**)lower_env_xpm ),
                             "&lower envelope", 0, this, "Lower envelop" );
  lower_env_dialog_bt->setToggleAction( TRUE );

  upper_env_dialog_bt = new QAction("Upper envelope", QPixmap( (const char**)upper_env_xpm ),
                             "&upper envelope", 0, this, "Upper envelop" );
  upper_env_dialog_bt->setToggleAction( TRUE );

#ifdef CGAL_USE_CORE
  // Conic Type Group
  QActionGroup *conicTypeGroup = new QActionGroup( this ); // Connected later
  conicTypeGroup->setExclusive( TRUE );

  setCircle = new QAction("Circle",
                                 QPixmap( (const char**)demo_conic_circle_xpm ),
                                 "&Circle", 0 ,conicTypeGroup,
                                 "Circle" );
  setCircle->setToggleAction( TRUE );
  setSegment = new QAction("Segment",
                                 QPixmap( (const char**)demo_conic_segment_xpm ),
                                 "&Segment", 0 ,conicTypeGroup,
                                 "Segment" );
  setSegment->setToggleAction( TRUE );
  setEllipse = new QAction("Ellipse",
                                 QPixmap( (const char**)demo_conic_ellipse_xpm ),
                                 "&Ellipse", 0 ,conicTypeGroup,
                                 "Ellipse" );
  setEllipse->setToggleAction( TRUE );
  setParabola = new QAction("3 Points Arc",
                                 QPixmap( (const char**)demo_conic_3points_xpm ),
                                 "&3 Points Arc", 0 ,conicTypeGroup,
                                 "3 Points Arc" );
  setParabola->setToggleAction( TRUE );
  setHyperbola = new QAction("5 Points Arc",
                                 QPixmap( (const char**)demo_conic_5points_xpm ),
                                 "&5 Points Arc", 0 ,conicTypeGroup,
                                 "5 Points Arc" );
  setHyperbola->setToggleAction( TRUE );
#endif

  //create a timer for checking if somthing changed
  QTimer *timer = new QTimer( this );
  connect( timer, SIGNAL(timeout()),
           this, SLOT(timer_done()) );
  timer->start( 200, FALSE );

  // file menu
  QPopupMenu * file = new QPopupMenu( this );
  menuBar()->insertItem( "&File", file );
  file->insertItem("&Open Segment File...", this, SLOT(fileOpenSegment()));
  file->insertItem("&Open Polyline File...", this, SLOT(fileOpenPolyline()));\

#ifdef CGAL_USE_CORE
  file->insertItem("&Open Conic File...", this, SLOT(fileOpenConic()));
#endif

  file->insertItem("&Open Segment Arr File...", this, SLOT(fileOpenSegmentPm()));
  file->insertItem("&Open Polyline Arr File...", this, SLOT(fileOpenPolylinePm()));
  //file->insertItem("&Open Conic Pm File", this, SLOT(fileOpenConicPm()));
  file->insertItem("&Save...", this, SLOT(fileSave()));
  file->insertItem("&Save As...", this, SLOT(fileSaveAs()));
  //file->insertItem("&Save to ps...", this, SLOT(fileSave_ps()));
  file->insertSeparator();
  file->insertItem("&Print...", this , SLOT(print()));
  file->insertSeparator();
  file->insertItem( "&Close", this, SLOT(close()), CTRL+Key_X );
  file->insertItem( "&Quit", qApp, SLOT( closeAllWindows() ), CTRL+Key_Q );
  menuBar()->insertSeparator();

  // tab menu
  QPopupMenu * tab = new QPopupMenu( this );
  menuBar()->insertItem( "&Tab", tab );
  tab->insertItem("Add &Segment Tab", this, SLOT(add_segment_tab()));
  tab->insertItem("Add &Polyline Tab", this, SLOT(add_polyline_tab()));

#ifdef CGAL_USE_CORE
  tab->insertItem("Add &Conic Tab", this, SLOT(add_conic_tab()));
  tab->insertSeparator();
#endif

  tab->insertItem("Remove &Tab", this, SLOT(remove_tab()));
  menuBar()->insertSeparator();

  // mode menu
  QPopupMenu * mode = new QPopupMenu( this );
  menuBar()->insertItem( "&Mode", mode );
  insertMode->addTo( mode );
  deleteMode->addTo( mode );
  pointLocationMode->addTo( mode );
  rayShootingUpMode->addTo( mode );
  rayShootingDownMode->addTo( mode );
  dragMode->addTo( mode );
  mergeMode->addTo( mode );
  splitMode->addTo( mode );
  fillfaceMode->addTo( mode );
  menuBar()->insertSeparator();

  // snap mode menu
  QPopupMenu * snap_mode = new QPopupMenu( this );
  menuBar()->insertItem( "&Snap mode", snap_mode );
  setSnapMode->addTo(snap_mode);
  setGridSnapMode->addTo(snap_mode);
  menuBar()->insertSeparator();

  // traits menu
  QPopupMenu * traits = new QPopupMenu( this );
  menuBar()->insertItem( "&Traits Type", traits );
  setSegmentTraits->addTo(traits);
  setPolylineTraits->addTo(traits);
#ifdef CGAL_USE_CORE
  setConicTraits->addTo(traits);
#endif

  // options menu
  QPopupMenu * options = new QPopupMenu( this );
  menuBar()->insertItem( "&Options", options );
  options->insertSeparator();
  options->insertItem("Overlay...", this, SLOT(overlay_pm()));
  options->insertSeparator();
  options->insertItem("Properties...", this, SLOT(properties()));
  options->insertSeparator();
  options->insertItem("Show Grid", this, SLOT(showGrid()));
  options->insertItem("Hide Grid", this, SLOT(hideGrid()));
  options->insertSeparator();
  //options->insertItem("Conic Type", this, SLOT(conicType()));
  //options->insertSeparator();
  options->insertItem("Unbounded Face Color...", this, SLOT(backGroundColor()));
  options->insertSeparator();
  options->insertItem("Edge Color...", this, SLOT(changeEdgeColor()));
  options->insertSeparator();
  options->insertItem("Vertex Color...", this, SLOT(changeVertexColor()));
  options->insertSeparator();
  options->insertItem("Point-Locaiton Strategy....", this ,
                                         SLOT(pointLocationStrategy()));


  // help menu
  QPopupMenu * help = new QPopupMenu( this );
  menuBar()->insertItem( "&Help", help );
  help->insertItem("How To...", this, SLOT(howto()), Key_F1);
  help->insertSeparator();
  help->insertItem("&About...", this, SLOT(about()), CTRL+Key_A );
  help->insertItem("About &Qt...", this, SLOT(aboutQt()) );

  QToolBar *modeTools = new QToolBar( this, "mode operations" );
  modeTools->setLabel( "Mode Operations" );
  insertMode->addTo( modeTools );
  deleteMode->addTo( modeTools );
  dragMode->addTo( modeTools );
  pointLocationMode->addTo( modeTools );
  rayShootingUpMode->addTo( modeTools );
  rayShootingDownMode->addTo( modeTools );
  mergeMode->addTo( modeTools );
  splitMode->addTo( modeTools );
  fillfaceMode->addTo( modeTools );
  modeTools->addSeparator();

  QToolBar *snapModeTools = new QToolBar( this, "snapMode operations" );
  snapModeTools->setLabel( "Snap Mode Operations" );
  snapModeTools->addSeparator();
  setSnapMode->addTo( snapModeTools );
  setGridSnapMode->addTo( snapModeTools );
  snapModeTools->addSeparator();

  QToolBar *traitsTool = new QToolBar( this, "traits type" );
  traitsTool->setLabel( "Traits Type" );
  traitsTool->addSeparator();
  setSegmentTraits->addTo( traitsTool );
  setPolylineTraits->addTo( traitsTool );
#ifdef CGAL_USE_CORE
  setConicTraits->addTo( traitsTool );
#endif
  traitsTool->addSeparator();

  QToolBar *zoomTool = new QToolBar( this, "zoom" );
  zoomTool->setLabel( "Zoom" );
  zoomTool->addSeparator();
  zoomoutBt->addTo( zoomTool );
  zoominBt->addTo( zoomTool );
  zoomTool->addSeparator();

  QToolBar *colorTool = new QToolBar( this, "color" );
  colorTool->addSeparator();
  colorTool->setLabel("Choose color");
  color_dialog_bt->addTo(colorTool);
  colorTool->addSeparator();

  QToolBar *envelopeTool = new QToolBar( this, "envelopes" );
  envelopeTool->addSeparator();
  envelopeTool->setLabel("Envelopes");
  lower_env_dialog_bt->addTo(envelopeTool);
  upper_env_dialog_bt->addTo(envelopeTool);
  envelopeTool->addSeparator();


#ifdef CGAL_USE_CORE
  conicTypeTool = new QToolBar( this, "conic type" );
  conicTypeTool->setLabel( "Conic Type" );
  conicTypeTool->addSeparator();
  setSegment->addTo( conicTypeTool );
  setCircle->addTo( conicTypeTool );
  setEllipse->addTo( conicTypeTool );
  setParabola->addTo( conicTypeTool );
  setHyperbola->addTo( conicTypeTool );
#endif

  connect( zoomoutBt, SIGNAL( activated () ) ,
       this, SLOT( zoomout() ) );

  connect( zoominBt, SIGNAL( activated () ) ,
       this, SLOT( zoomin() ) );

  connect (color_dialog_bt , SIGNAL( activated()) ,
          this , SLOT(openColorDialog() ) );

  connect (lower_env_dialog_bt, SIGNAL(toggled(bool)) ,
           this, SLOT(lowerEnvelope(bool) ));

  connect (upper_env_dialog_bt, SIGNAL(toggled(bool)) ,
           this, SLOT(upperEnvelope(bool) ));
  // connect mode group
  connect( modeGroup, SIGNAL( selected(QAction*) ),
           this, SLOT( updateMode(QAction*) ) );

  // connect Traits Group
  connect( traitsGroup, SIGNAL( selected(QAction*) ),
           this, SLOT( updateTraitsType(QAction*) ) );

#ifdef CGAL_USE_CORE
  // connect Conic Type Group
  connect( conicTypeGroup, SIGNAL( selected(QAction*) ),
           this, SLOT( updateConicType(QAction*) ) );
#endif

  // connect Snap Mode

  connect( setSnapMode, SIGNAL( toggled( bool ) ) ,
           this, SLOT( updateSnapMode( bool ) ) );

  connect( setGridSnapMode, SIGNAL( toggled( bool ) ) ,
       this, SLOT( updateGridSnapMode( bool ) ) );

  // connect the change of current tab
  connect( myBar, SIGNAL( currentChanged(QWidget * )  ),
           this, SLOT( update() ) );

  colors = new QColor[num_of_colors];
  colors[0]  =  Qt::blue;
  colors[1]  =  Qt::gray;
  colors[2]  =  Qt::green;
  colors[3]  =  Qt::cyan;
  colors[4]  =  Qt::magenta;
  colors[5]  =  Qt::darkRed;
  colors[6]  =  Qt::darkGreen;
  colors[7]  =  Qt::darkBlue;
  colors[8]  =  Qt::darkMagenta;
  colors[9]  =  Qt::darkCyan;
  colors[10] =  Qt::yellow;
  colors[11] =  Qt::white;
  colors[12] =  Qt::darkGray;
  colors[13] =  Qt::gray;
  colors[14] =  Qt::red;
  colors[15] =  Qt::cyan;
  colors[16] =  Qt::darkYellow;
  colors[17] =  Qt::lightGray;

  //state flag
  old_state = 0;
  add_segment_tab();
  resize(m_width,m_height);
}
Ejemplo n.º 15
0
void MainWindow::createActions()
//POST: Actions are initialized and connected to the appropriate slots for handling
{
    //This is very repetitive. Format for creating an action:
    /*
    	actionPointer = new QAction("n&ame", parent);			//Initiliaze action of name
    															// "name" with alt-shortcut indicated
    															// by character following '&'
    	actionPointer->setShorcut(tr("keyboard shortcut"));		//Sets the action's shortcut
    															// ex. "Ctrl+Alt+K"
    	connect(actionPointer, SIGNAL(triggered),				//When the action is triggered (via menu
    		    someWidgetPointer, SLOT(someSlot()));			// click et al.), handle this via a slot
    */													        //method of someWidget
    //If the action just switches some property on or off (true or false), one can use
    //  actionPointer->setCheckable() to indicate this. To check if the property is on or off
    //  use actionPointer->isChecked()

    // File menu actions
    openAct = new QAction("&Open", this);
    openAct->setShortcut(tr("Ctrl+O"));
    connect(openAct, SIGNAL(triggered()), this, SLOT(open()));

    enqueueAct = new QAction("&Add to Playlist", this);
    enqueueAct->setShortcut(tr("Ctrl+A"));
    connect(enqueueAct, SIGNAL(triggered()), this, SLOT(addToPlaylist()));

    quitAct = new QAction("&Quit", this);
    quitAct->setShortcut(tr("Ctrl+Q"));
    connect(quitAct, SIGNAL(triggered()), this, SLOT(quit()));

    // Controls toolbar actions
    pauseAct = new QAction(style()->standardIcon(QStyle::SP_MediaPause), tr("P&ause"), this);
    connect(pauseAct, SIGNAL(triggered()), myPlayer, SLOT(pause()));
    connect(pauseAct, SIGNAL(triggered()), glWindow, SLOT(pauseSong()));

    playAct = new QAction(style()->standardIcon(QStyle::SP_MediaPlay), "P&lay", this);
    connect(playAct, SIGNAL(triggered()), this, SLOT(resumeTest()));

    prevAct = new QAction(style()->standardIcon(QStyle::SP_MediaSkipBackward), "&Prev", this);
    connect(prevAct, SIGNAL(triggered()), this, SLOT(gotoPrevSong()));

    nextAct = new QAction(style()->standardIcon(QStyle::SP_MediaSkipForward), "&Next", this);
    connect(nextAct, SIGNAL(triggered()), this, SLOT(gotoNextSong()));

    stopAct = new QAction(style()->standardIcon(QStyle::SP_MediaStop), "&Stop", this);
    connect(stopAct, SIGNAL(triggered()), myPlayer, SLOT(stop()));
    connect(stopAct, SIGNAL(triggered()), glWindow, SLOT(stopSong()));

    // Visualization menu actions
    redAct = new QAction("Increase &Red", this);
    redAct->setShortcut(tr("Ctrl+R"));
    connect(redAct, SIGNAL(triggered()), glWindow, SLOT(IncreaseRed()));

    greenAct = new QAction("Increase &Green", this);
    greenAct->setShortcut(tr("Ctrl+G"));
    connect(greenAct, SIGNAL(triggered()), glWindow, SLOT(IncreaseGreen()));

    blueAct = new QAction("Increase &Blue", this);
    blueAct->setShortcut(tr("Ctrl+B"));
    connect(blueAct, SIGNAL(triggered()), glWindow, SLOT(IncreaseBlue()));

    prevVisAct = new QAction("&Previous Visualization", this);
    prevVisAct->setShortcut(tr("Ctrl+Z"));
    connect(prevVisAct, SIGNAL(triggered()), glWindow, SLOT(LastVisualization()));

    nextVisAct = new QAction("&Next Visualization", this);
    nextVisAct->setShortcut(tr("Ctrl+X"));
    connect(nextVisAct, SIGNAL(triggered()), glWindow, SLOT(NextVisualization()));

    fullScreenAct = new QAction("&Fullscreen", this);
    fullScreenAct->setShortcut(tr("Ctrl+F"));
    fullScreenAct->setCheckable(true);
    connect(fullScreenAct, SIGNAL(triggered()), this, SLOT(fullScreen()));

    //Playlist actions
    repeatOneAct = new QAction("Repeat &One", this);
    repeatOneAct->setShortcut(tr("Ctrl+T"));
    repeatOneAct->setCheckable(true);

    repeatAllAct = new QAction("Repeat &All", this);
    repeatAllAct->setShortcut(tr("Ctrl+Alt+T"));
    repeatAllAct->setCheckable(true);

    // About action
    aboutAct = new QAction("&About", this);
    connect(aboutAct, SIGNAL(triggered()), this, SLOT(about()));
}
Ejemplo n.º 16
0
void MainWindow::createActions() {
    qaHome = new QAction( IconLoader::Load( "go-home" ), tr( "Home" ), this );
        qaHome->setShortcut( Qt::ControlModifier + Qt::Key_H );
        qaHome->setStatusTip( tr( "Click to go home" ));

    qaExit = new QAction( IconLoader::Load( "system-shutdown" ), tr( "&Exit" ), this);
        qaExit->setShortcut( QKeySequence::Quit );
        qaExit->setStatusTip( tr( "Exit the application" ));
        connect( qaExit, SIGNAL( triggered()), qApp, SLOT( quit()));

    qaBack = new QAction( IconLoader::Load( "go-previous" ), tr( "Back" ), this);
        qaBack->setShortcut( Qt::ControlModifier + Qt::Key_Left );
        qaBack->setStatusTip(  tr( "Click to go back" ));

    qaForward = new QAction( IconLoader::Load( "go-next" ), tr( "Forward" ), this );
        qaForward->setShortcut( Qt::ControlModifier + Qt::Key_Right );
        qaForward->setStatusTip( tr( "Click to go forward" ));

    qaStop = new QAction( IconLoader::Load( "process-stop" ), tr( "Stop" ), this);
        qaStop->setShortcut( Qt::Key_Escape );
        qaStop->setStatusTip( tr( "Click to go stop" ));

    qaReload = new QAction( IconLoader::Load( "view-refresh" ), tr( "Reload" ), this );
        qaReload->setShortcut( QKeySequence::Refresh );
        qaReload->setStatusTip( tr( "Click to go reload" ));

     qaAbout = new QAction( IconLoader::Load( "help-about" ), tr( "&About" ), this );
        qaAbout->setStatusTip( tr( "About the application" ));
        connect( qaAbout, SIGNAL( triggered()), this, SLOT( about()));

    qaAboutQt = new QAction( tr( "About &Qt" ), this);
        qaAboutQt->setStatusTip( tr( "About the Qt version" ));
        connect( qaAboutQt, SIGNAL( triggered()), qApp, SLOT( aboutQt()));

    qagNavigation = new QActionGroup ( this );
        qagNavigation->addAction ( qaHome );
        qagNavigation->addAction ( qaBack );
        qagNavigation->addAction ( qaReload );
        qagNavigation->addAction ( qaForward );
        qagNavigation->addAction ( qaStop );
        connect ( qagNavigation, SIGNAL( triggered( QAction* )), this, SLOT( navigationActionTriggered( QAction* )));

    qaSearch = new QAction ( IconLoader::Load ( "edit-find" ), tr ( "Search" ), this );
        qaSearch->setShortcut ( QKeySequence::Find );
        qaSearch->setStatusTip ( tr( "Search words" ));
        connect( qaSearch, SIGNAL( triggered()), this, SLOT( search()));

    qaClearSearch = new QAction ( IconLoader::Load ( "edit-find" ), "", this );
        qaClearSearch->setStatusTip( tr ( "Clear search words" ));
        connect( qaClearSearch, SIGNAL( triggered()), this, SLOT( clearSearch ()));

    qaPrintDialog = new QAction( IconLoader::Load ( "document-print-preview" ), tr ( "Print" ), this );
        qaPrintDialog->setShortcut( QKeySequence::Print );
        qaPrintDialog->setStatusTip( tr ( "Print Preview" ));
        connect( qaPrintDialog, SIGNAL( triggered ()), this, SLOT( printpreview ()));

    qaZoomIn = new QAction( IconLoader::Load ( "zoom-in" ), tr ( "Zoom &In" ), this );
        qaZoomIn->setShortcut( QKeySequence::ZoomIn );
        qaZoomIn->setStatusTip( tr ( "Zoom in of the page" ));

    qaZoomOut = new QAction( IconLoader::Load( "zoom-out" ), tr ( "Zoom &Out" ), this );
        qaZoomOut->setShortcut( QKeySequence::ZoomOut );
        qaZoomOut->setStatusTip( tr( "Zoom out of the page" ));

   qaZoomNormal = new QAction( IconLoader::Load( "zoom-original" ), tr ( "Zoom &Normal" ), this );
        qaZoomNormal->setShortcut( QKeySequence( "CTRL+0" ));
        qaZoomNormal->setStatusTip( tr ( "Zoom normal of the page" ));

    qagZoom = new QActionGroup( this );
        qagZoom->addAction ( qaZoomIn );
        qagZoom->addAction ( qaZoomNormal );
        qagZoom->addAction ( qaZoomOut );
        connect ( qagZoom, SIGNAL( triggered( QAction* )), this, SLOT( zoomActionTriggered( QAction* )));

    qaEnglish = new QAction( QIcon( ":/flags/en.svg" ), tr( "English" ), this );
        qaEnglish->setCheckable( true );
    qaSpanish = new QAction( QIcon( ":/flags/es.svg" ), tr( "Spanish" ), this );
        qaSpanish->setCheckable( true );
    qaFrench = new QAction( QIcon( ":/flags/fr.svg" ), tr( "French" ), this );
        qaFrench->setCheckable( true );
    qaItalian = new QAction( QIcon( ":/flags/it.svg" ), tr( "Italian" ), this );
        qaItalian->setCheckable( true );
    qaChinese = new QAction( QIcon( ":/flags/cn.svg" ), tr( "Chinese" ), this );
        qaChinese->setCheckable( true );
    qaRussian = new QAction( QIcon( ":/flags/ru.svg" ), tr( "Russian" ), this );
        qaRussian->setCheckable( true );

    qagLanguages = new QActionGroup( this );
        qagLanguages->addAction ( qaEnglish );
        qagLanguages->addAction ( qaSpanish );
        qagLanguages->addAction ( qaFrench );
        qagLanguages->addAction ( qaItalian );
        qagLanguages->addAction ( qaChinese );
        qagLanguages->addAction ( qaRussian );
        connect( qagLanguages, SIGNAL( triggered( QAction* )), this, SLOT( languageActionTriggered( QAction* )));

}
Ejemplo n.º 17
0
ApplicationWindow::ApplicationWindow()
    : QMainWindow( 0, "example application main window", WDestructiveClose )
{
    printer = new QPrinter( QPrinter::HighResolution );

    QAction * fileNewAction;
    QAction * fileOpenAction;
    QAction * fileSaveAction, * fileSaveAsAction, * filePrintAction;
    QAction * fileCloseAction, * fileQuitAction;

    fileNewAction = new QAction( "&New", CTRL+Key_N, this, "new" );
    connect( fileNewAction, SIGNAL( activated() ) , this,
             SLOT( newDoc() ) );

    fileOpenAction = new QAction( QPixmap( fileopen ), "&Open...",
                                  CTRL+Key_O, this, "open" );
    connect( fileOpenAction, SIGNAL( activated() ) , this, SLOT( choose() ) );

    const char * fileOpenText = "<p><img source=\"fileopen\"> "
                     "Click this button to open a <em>new file</em>. <br>"
                     "You can also select the <b>Open</b> command "
                     "from the <b>File</b> menu.</p>";
    QMimeSourceFactory::defaultFactory()->setPixmap( "fileopen",
                          fileOpenAction->iconSet().pixmap() );
    fileOpenAction->setWhatsThis( fileOpenText );

    fileSaveAction = new QAction( QPixmap( filesave ),
                                  "&Save", CTRL+Key_S, this, "save" );
    connect( fileSaveAction, SIGNAL( activated() ) , this, SLOT( save() ) );

    const char * fileSaveText = "<p>Click this button to save the file you "
                     "are editing. You will be prompted for a file name.\n"
                     "You can also select the <b>Save</b> command "
                     "from the <b>File</b> menu.</p>";
    fileSaveAction->setWhatsThis( fileSaveText );

    fileSaveAsAction = new QAction( "Save File As", "Save &As...", 0,  this,
                                    "save as" );
    connect( fileSaveAsAction, SIGNAL( activated() ) , this,
             SLOT( saveAs() ) );
    fileSaveAsAction->setWhatsThis( fileSaveText );

    filePrintAction = new QAction( "Print File", QPixmap( fileprint ),
                                   "&Print...", CTRL+Key_P, this, "print" );
    connect( filePrintAction, SIGNAL( activated() ) , this,
             SLOT( print() ) );

    const char * filePrintText = "Click this button to print the file you "
                     "are editing.\n You can also select the Print "
                     "command from the File menu.";
    filePrintAction->setWhatsThis( filePrintText );

    fileCloseAction = new QAction( "Close", "&Close", CTRL+Key_W, this,
                                   "close" );
    connect( fileCloseAction, SIGNAL( activated() ) , this,
             SLOT( close() ) );

    fileQuitAction = new QAction( "Quit", "&Quit", CTRL+Key_Q, this,
                                  "quit" );
    connect( fileQuitAction, SIGNAL( activated() ) , qApp,
             SLOT( closeAllWindows() ) );

    // populate a tool bar with some actions

    QToolBar * fileTools = new QToolBar( this, "file operations" );
    fileTools->setLabel( "File Operations" );
    fileOpenAction->addTo( fileTools );
    fileSaveAction->addTo( fileTools );
    filePrintAction->addTo( fileTools );
    (void)QWhatsThis::whatsThisButton( fileTools );


    // populate a menu with all actions

    QPopupMenu * file = new QPopupMenu( this );
    menuBar()->insertItem( "&File", file );
    fileNewAction->addTo( file );
    fileOpenAction->addTo( file );
    fileSaveAction->addTo( file );
    fileSaveAsAction->addTo( file );
    file->insertSeparator();
    filePrintAction->addTo( file );
    file->insertSeparator();
    fileCloseAction->addTo( file );
    fileQuitAction->addTo( file );


    menuBar()->insertSeparator();

    // add a help menu

    QPopupMenu * help = new QPopupMenu( this );
    menuBar()->insertItem( "&Help", help );
    help->insertItem( "&About", this, SLOT(about()), Key_F1 );
    help->insertItem( "About &Qt", this, SLOT(aboutQt()) );
    help->insertSeparator();
    help->insertItem( "What's &This", this, SLOT(whatsThis()),
                      SHIFT+Key_F1 );


    // create and define the central widget

    e = new QTextEdit( this, "editor" );
    e->setFocus();
    setCentralWidget( e );
    statusBar()->message( "Ready", 2000 );

    resize( 450, 600 );
}
Ejemplo n.º 18
0
App::App(QWidget* parent, const char* name, WFlags fl) : QMainWindow(parent, name, fl)
{
    showFullScreen = false;
    setCaption("IQNotes");

    toolbar = new QPEToolBar(this);
    toolbar->setVerticalStretchable(false);
    toolbar->setHorizontalStretchable(false);
    
    setToolBarsMovable(false);
    multiTB = new QToolButton(toolbar);
    
    // File menu
    filePopupMenu = new QPopupMenu(this);
	menu = new QPEMenuBar(this);

    int fileID;
	fileID = menu->insertItem("File", filePopupMenu);
	
#ifndef DEMO
    newID = filePopupMenu->insertItem("New", this, SLOT(newFile()), SHIFT+Key_N);
    openID = filePopupMenu->insertItem("Open", this, SLOT(openFile()), SHIFT+Key_O);
    saveID = filePopupMenu->insertItem("Save", this, SLOT(saveFile()), SHIFT+Key_S);
    // file->insertItem("Save as", this, SLOT(saveAsFile()));
    closeID = filePopupMenu->insertItem("Close", this, SLOT(closeFileMenu()));
    filePopupMenu->insertSeparator();
#endif
	
    filePopupMenu->insertItem("Quit", this, SLOT(goodBye()));

    // Tree menu
    treePopupMenu = new QPopupMenu(this);
    treeID = menu->insertItem("Tree", treePopupMenu);

    searchA = new QAction("Search", ToolBarIcon::prepare("iqnotes/find"), QString::null, Key_F, this, 0 );
    connect(searchA, SIGNAL(activated()), this, SLOT(search()));
    //  searchA->addTo(toolbar);
    searchA->addTo(treePopupMenu);
    multiTB->setIconSet(ToolBarIcon::prepare("iqnotes/find"));
    connect(multiTB, SIGNAL(clicked()), this, SLOT(search()));
	//    toolbar->addSeparator(); // no room for this

    treePopupMenu->insertSeparator();

    quickAddA = new QAction("Quick add", ToolBarIcon::prepare("iqnotes/quick_add"), QString::null, Key_Q, this, 0 );
    connect(quickAddA, SIGNAL(activated()), this, SLOT(quickAdd()));
    quickAddA->addTo(toolbar);
    quickAddA->addTo(treePopupMenu);

    addBeforeA = new QAction("Add before", ToolBarIcon::prepare("iqnotes/add_before"), QString::null, 0, this, 0 );
    connect(addBeforeA, SIGNAL(activated()), this, SLOT(addBefore()));
    addBeforeA->addTo(toolbar);
    addBeforeA->addTo(treePopupMenu);

    addAfterA = new QAction("Add after", ToolBarIcon::prepare("iqnotes/add_after"), QString::null, Key_A, this, 0 );
    connect(addAfterA, SIGNAL(activated()), this, SLOT(addAfter()));
    addAfterA->addTo(toolbar);
    addAfterA->addTo(treePopupMenu);

    addChildA = new QAction("Add child", ToolBarIcon::prepare("iqnotes/add_child"), QString::null, Key_E, this, 0 );
    connect(addChildA, SIGNAL(activated()), this, SLOT(addChild()));
    addChildA->addTo(toolbar);
    addChildA->addTo(treePopupMenu);

    treePopupMenu->insertSeparator();
    sortID = treePopupMenu->insertItem("Sort", this, SLOT(sort()));
    treePopupMenu->insertSeparator();

    expandTreeID = treePopupMenu->insertItem("Expand tree", this, SLOT(expandTree()));
    collapseTreeID = treePopupMenu->insertItem("Collapse tree", this, SLOT(collapseTree()));

    treePopupMenu->insertSeparator();

    taskListPopupMenu = new QPopupMenu(this);
    taskListPopupMenu->insertItem("From whole tree", this, SLOT(taskListWholeTree()));
    taskListPopupMenu->insertItem("From current note down", this, SLOT(taskListCurrent()));

    eventListPopupMenu = new QPopupMenu(this);
    eventListPopupMenu->insertItem("From whole tree", this, SLOT(eventListWholeTree()));
    eventListPopupMenu->insertItem("From current note down", this, SLOT(eventListCurrent()));

    taskListID = treePopupMenu->insertItem("Task list", taskListPopupMenu);
    eventListID = treePopupMenu->insertItem("Event list", eventListPopupMenu);

    treePopupMenu->insertSeparator();
    reminderID = treePopupMenu->insertItem("Reminder", this, SLOT(showReminder()));

    toolbar->addSeparator();

    /*
    closeSearchTreeA = new QAction("Close search tree", Resource::loadPixmap("iqnotes/close_search_tree"), QString::null, 0, this, 0 );
    connect(closeSearchTreeA, SIGNAL(activated()), this, SLOT(closeSearchTree()));
    closeSearchTreeA->addTo(tree);*/

    // Note menu
    notePopupMenu = new QPopupMenu(this);
    noteID = menu->insertItem("Note", notePopupMenu);

    renameNoteID = notePopupMenu->insertItem("Rename", this, SLOT(renameNote()), Key_R);

    editA = new QAction("Edit", ToolBarIcon::prepare("iqnotes/edit"), QString::null, Key_Return, this, 0 );
    editA->setToolTip("Edit note");
    connect(editA, SIGNAL(activated()), this, SLOT(editNote()));
    editA->addTo(toolbar);
    editA->addTo(notePopupMenu);

    cutA = new QAction("Cut", ToolBarIcon::prepare("iqnotes/bin"), QString::null, Key_X, this, 0 );
    cutA->setToolTip("Cut note");
    connect(cutA, SIGNAL(activated()), this, SLOT(cutNote()));
    cutA->addTo(toolbar);
    cutA->addTo(notePopupMenu);

    copyNotePopupMenu = new QPopupMenu(this);
    copyNotePopupMenu->insertItem("Only current note", this, SLOT(copyNoteOnlyCurrent()));
    copyNotePopupMenu->insertItem("Current note and down", this, SLOT(copyNoteCurrentAndDown()));
    copyNoteID = notePopupMenu->insertItem("Copy", copyNotePopupMenu);

    pasteNotePopupMenu = new QPopupMenu(this);
    pasteNotePopupMenu->insertItem("Before", this, SLOT(pasteNoteBefore()));
    pasteNotePopupMenu->insertItem("After", this, SLOT(pasteNoteAfter()), SHIFT+Key_A);
    pasteNotePopupMenu->insertItem("As child", this, SLOT(pasteNoteChild()), SHIFT+Key_E);
    pasteNoteID = notePopupMenu->insertItem("Paste", pasteNotePopupMenu);

    notePopupMenu->insertSeparator();

    setPictureA = new QAction("Set picture", ToolBarIcon::prepare("iqnotes/set_picture"), QString::null, CTRL+Key_P, this, 0);
    setPictureA->setToolTip("Set picture");
    connect(setPictureA, SIGNAL(activated()), this, SLOT(setPicture()));
    //setPictureA->addTo(toolbar);
    setPictureA->addTo(notePopupMenu);

    notePopupMenu->insertSeparator();

    setTaskA = new QAction("Set task", ToolBarIcon::prepare("iqnotes/set_task"), QString::null, CTRL+Key_T, this, 0);
    setTaskA->setToolTip("Set task");
    connect(setTaskA, SIGNAL(activated()), this, SLOT(setTask()));
    //setTaskA->addTo(toolbar);
    setTaskA->addTo(notePopupMenu);
    setEventA = new QAction("Set event", ToolBarIcon::prepare("iqnotes/set_event"), QString::null, CTRL+Key_E, this, 0);
    setEventA->setToolTip("Set event");
    connect(setEventA, SIGNAL(activated()), this, SLOT(setEvent()));
    //setEventA->addTo(toolbar);
    setEventA->addTo(notePopupMenu);
    unsetTaskEventID = notePopupMenu->insertItem("Unset", this, SLOT(unsetTaskEvent()));

    notePopupMenu->insertSeparator();
    setReminderID = notePopupMenu->insertItem("Set reminder", this, SLOT(setReminder()));
    unsetReminderID = notePopupMenu->insertItem("Unset reminder", this, SLOT(unsetReminder()));

    // View menu
    viewPopupMenu = new QPopupMenu(this);
    viewID = menu->insertItem("View", viewPopupMenu);

    toolbar->addSeparator();

    hideNoteA = new QAction("Hide note", ToolBarIcon::prepare("iqnotes/hide_note"), QString::null, Key_1, this, 0 );
    hideNoteA->setToolTip("Hide note");
    connect(hideNoteA, SIGNAL(activated()), this, SLOT(hideNote()));
    hideNoteA->addTo(toolbar);
    hideNoteA->addTo(viewPopupMenu);

    hideTreeA = new QAction("Hide tree", ToolBarIcon::prepare("iqnotes/hide_tree"), QString::null, Key_2, this, 0 );
    hideTreeA->setToolTip("Hide tree");
    connect(hideTreeA, SIGNAL(activated()), this, SLOT(hideTree()));
    hideTreeA->addTo(toolbar);
    hideTreeA->addTo(viewPopupMenu);

    halfViewA = new QAction("Half view", ToolBarIcon::prepare("iqnotes/half_view"), QString::null, Key_3, this, 0 );
    halfViewA->setToolTip("Half view");
    connect(halfViewA, SIGNAL(activated()), this, SLOT(halfView()));
    halfViewA->addTo(toolbar);
    halfViewA->addTo(viewPopupMenu);

	/*
    viewPopupMenu->insertSeparator();
    toggleToolBarID = viewPopupMenu->insertItem("Toggle toolbar", this, SLOT(toggleToolBar()));
    toggleFullScreenID = viewPopupMenu->insertItem("Toggle fullscreen", this, SLOT(toggleFullScreen()));
    */
	
    // Options menu
    optionsPopupMenu = new QPopupMenu(this);
    optionsID = menu->insertItem("Options", optionsPopupMenu);

    optionsPopupMenu->insertItem("Define new entry", this, SLOT(defineNewEntry()));
    optionsPopupMenu->insertItem("Change entry", this, SLOT(changeEntry()));
    optionsPopupMenu->insertItem("Delete entry", this, SLOT(deleteEntry()));

    optionsPopupMenu->insertSeparator();

    optionsPopupMenu->insertItem("Preferences", this, SLOT(preferenc()));

    // Help menu
    helpPopupMenu = new QPopupMenu(this);
    menu->insertItem("Help", helpPopupMenu);

    helpPopupMenu->insertItem("About", this, SLOT(about()));

    addToolBar(toolbar);

    IQApp = this;

    //
    notes = new Notes(this, "bla");
    setCentralWidget(notes);

    connect(notes, SIGNAL(emptyNoteTree()), this, SLOT(isEmptyNoteTree()));
    connect(notes, SIGNAL(noEmptyNoteTree()), this, SLOT(isNotEmptyNoteTree()));
    connect(notes, SIGNAL(searchTreeShown()), this, SLOT(searchTreeShown()));
    connect(notes, SIGNAL(searchTreeClosed()), this, SLOT(searchTreeClosed()));
    connect(notes, SIGNAL(taskListShown()), this, SLOT(taskListShown()));
    connect(notes, SIGNAL(taskListClosed()), this, SLOT(taskListClosed()));
    connect(notes, SIGNAL(eventListShown()), this, SLOT(eventListShown()));
    connect(notes, SIGNAL(eventListClosed()), this, SLOT(eventListClosed()));
    connect(notes, SIGNAL(reminderShown()), this, SLOT(reminderShown()));
    connect(notes, SIGNAL(reminderClosed()), this, SLOT(reminderClosed()));
    connect(notes, SIGNAL(noteModified(bool)), this, SLOT(setModified(bool)));

    readConfig();
    changeFont();
    
    noNoteTree();
}
Ejemplo n.º 19
0
void PmChart::helpAbout()
{
    AboutDialog about(this);
    about.exec();
}
Ejemplo n.º 20
0
CamlDevWindow::CamlDevWindow(QString wd, QWidget *parent) :
QMainWindow(parent)
{
   
   this->camlProcess = new QProcess(this);
   this->camlStarted = false;
   this->currentFile = "";
   this->cwd = wd;
   this->unsavedChanges = false;
   this->programTitle = "LemonCaml";
   /* The window title and icon */
   this->setWindowTitle(this->programTitle + " - " + "untitled");
   this->setWindowIcon(QIcon(":/progicon.png"));
   
   this->settings = new QSettings("Cocodidou", "LemonCaml");
   this->globalSettings = new QSettings(QSettings::SystemScope, "Cocodidou", "LemonCaml");
   
   /* The main window elements : two text-areas and a splitter */
   this->centralBox = new QVBoxLayout();
   this->split = new QSplitter(Qt::Horizontal,this);
   
   this->inputZone = new InputZone();
   this->inputZone->setTabStopWidth(20);
   this->inputZone->setAcceptRichText(false);
   
   this->resize(settings->value("Size/y",800).toInt(), settings->value("Size/x",600).toInt());
   this->move(settings->value("Pos/x",0).toInt(), settings->value("Pos/y",0).toInt());
   this->setWindowFlags( (windowFlags() | Qt::CustomizeWindowHint));
   
#ifndef WIN32
   QString defaultFont = "Andale Mono,10,-1,5,50,0,0,0,0,0";
#else
   QString defaultFont = "Courier New,10,-1,5,50,0,0,0,0,0";
#endif
   
   QString iFont = settings->value("Input/Font", defaultFont).toString();
   QFont inputFont;
   inputFont.fromString(iFont);
   this->inputZone->setFont(inputFont);
   
   this->outputZone = new QTextEdit(this);
   this->outputZone->setReadOnly(true);
   this->outputZone->setTabStopWidth(20);
   
   QString kwfileloc = settings->value("General/keywordspath", (globalSettings->value("General/keywordspath", "./keywords").toString())).toString();
   
   QFile kwfile(kwfileloc);
   QStringList kwds;
   
   if(kwfile.open(QIODevice::ReadOnly | QIODevice::Text))
   {
      QTextStream kstream(&kwfile);
      QString st = kstream.readLine(256);
      while(st != "")
      {
         kwds << st;
         st = kstream.readLine(256);
      }
      kwfile.close();
   }
   else
   {
      QMessageBox::warning(this, tr("Warning"), tr("Unable to open the keywords file. There will likely be no syntax highlighting."));
   }
   this->hilit = new highlighter(inputZone->document(), &kwds, this->settings);
   bool isHighlighting = (settings->value("Input/syntaxHighlight",1).toInt() == 1);
   
   if(!isHighlighting)
   {
      this->hilit->setDocument(NULL);
   }


   
   QString oFont = settings->value("Output/Font", defaultFont).toString();
   QFont outputFont;
   outputFont.fromString(oFont);
   this->outputZone->setFont(outputFont);
   

   
   /* Find/Replace */
   
   this->find = new findReplace(inputZone, hilit);
   split->addWidget(this->inputZone);
   split->addWidget(this->outputZone);
   split->showMaximized();
   
   centralBox->addWidget(split);
   centralBox->addWidget(find);
   if(!centralBox->setStretchFactor(split, 100))
      qDebug() << "There will be a problem with Find/replace!";

   centralBox->setContentsMargins(0,0,0,0);
   
   /* a wrapper widget */
   QWidget *window = new QWidget();
   window->setLayout(centralBox);
   window->setContentsMargins(0,0,0,0);

   
   this->setCentralWidget(window);
   
   find->setVisible(false);
   
   if(settings->value("Input/indentOnFly",0).toInt() == 1)
      inputZone->setHandleEnter(true);
   
   /* the printer*/
   this->printer = new QPrinter(QPrinter::HighResolution);
   
   /* The actions */
   this->actionNew = new QAction(tr("New"),this);
   this->actionNew->setIcon(QIcon(":/new.png"));
   this->actionNew->setShortcut(QKeySequence(QKeySequence::New));
   this->actionOpen = new QAction(tr("Open"),this);
   this->actionOpen->setIcon(QIcon(":/open.png"));
   this->actionOpen->setShortcut(QKeySequence(QKeySequence::Open));
   this->actionSaveAs = new QAction(tr("Save As"),this);
   this->actionSaveAs->setIcon(QIcon(":/saveas.png"));
   this->actionSaveAs->setShortcut(QKeySequence(QKeySequence::SaveAs));
   this->actionSave = new QAction(tr("Save"),this);
   this->actionSave->setIcon(QIcon(":/save.png"));
   this->actionSave->setShortcut(QKeySequence(QKeySequence::Save));
   this->actionAutoIndent = new QAction(tr("Indent code"),this);
   this->actionAutoIndent->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_W));
   this->actionFollowCursor = new QAction(tr("Indent code while typing"),this);
   this->actionFollowCursor->setCheckable(true);
   this->actionFollowCursor->setChecked(inputZone->getHandleEnter());
   this->actionFollowCursor->setIcon(QIcon(":/autoindent.png"));
   this->actionPrint = new QAction(tr("Print"),this);
   this->actionPrint->setIcon(QIcon(":/print.png"));
   this->actionPrint->setShortcut(QKeySequence(QKeySequence::Print));
   this->actionClearOutput = new QAction(tr("Clear output"),this);
   this->actionQuit = new QAction(tr("Quit"),this);
   this->actionQuit->setIcon(QIcon(":/exit.png"));
   this->actionQuit->setShortcut(QKeySequence(QKeySequence::Quit));
   
   this->actionUndo = new QAction(tr("Undo"),this);
   this->actionUndo->setIcon(QIcon(":/undo.png"));
   this->actionUndo->setShortcut(QKeySequence(QKeySequence::Undo));
   this->actionRedo = new QAction(tr("Redo"),this);
   this->actionRedo->setIcon(QIcon(":/redo.png"));
   this->actionRedo->setShortcut(QKeySequence(QKeySequence::Redo));
   this->actionDelete = new QAction(tr("Delete"),this);
   this->actionChangeInputFont = new QAction(tr("Change Input Font"),this);
   this->actionChangeOutputFont = new QAction(tr("Change Output Font"),this);
   
   this->actionSendCaml = new QAction(tr("Send Code to Caml"),this);
   this->actionSendCaml->setIcon(QIcon(":/sendcaml.png"));
   this->actionSendCaml->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Return));
   this->actionInterruptCaml = new QAction(tr("Interrupt Caml"),this);
   this->actionInterruptCaml->setIcon(QIcon(":/interrupt.png"));
   this->actionStopCaml = new QAction(tr("Stop Caml"),this);
   this->actionStopCaml->setIcon(QIcon(":/stopcaml.png"));
   this->actionShowSettings = new QAction(tr("Settings"),this);
   this->actionShowSettings->setShortcut(QKeySequence(QKeySequence::Preferences));
   
   this->actionAbout = new QAction(tr("About LemonCaml..."),this);
   this->actionAboutQt = new QAction(tr("About Qt..."),this);
   
   this->actionHighlightEnable = new QAction(tr("Enable syntax highlighting"), this);
   this->actionHighlightEnable->setIcon(QIcon(":/highlight.png"));
   this->actionHighlightEnable->setCheckable(true);
   this->actionHighlightEnable->setChecked(isHighlighting);
   
   this->actionZoomIn = new QAction(tr("Zoom in"), this);
   this->actionZoomIn->setShortcut(QKeySequence(QKeySequence::ZoomIn));
   this->actionZoomOut = new QAction(tr("Zoom out"), this);
   this->actionZoomOut->setShortcut(QKeySequence(QKeySequence::ZoomOut));
   this->actionFind = new QAction(tr("Find/Replace..."), this);
   this->actionFind->setShortcut(QKeySequence(QKeySequence::Find));
   this->actionFind->setIcon(QIcon(":/find.png"));
   this->actionFind->setCheckable(true);
   this->actionFind->setChecked(false);
   
   /* The toolbar */
   this->toolbar = new QToolBar(tr("Tools"),this);
   this->toolbar->addAction(actionNew);
   this->toolbar->addAction(actionOpen);
   this->toolbar->addAction(actionSave);
   this->toolbar->addAction(actionSaveAs);
   this->toolbar->addAction(actionPrint);
   this->toolbar->addSeparator();
   this->toolbar->addAction(actionUndo);
   this->toolbar->addAction(actionRedo);
   this->toolbar->addSeparator();
   this->toolbar->addAction(actionSendCaml);
   this->toolbar->addAction(actionInterruptCaml);
   this->toolbar->addAction(actionStopCaml);
   this->toolbar->addAction(actionHighlightEnable);
   this->toolbar->addAction(actionFollowCursor);
   this->addToolBar(this->toolbar);
   
   /* The menubar */
   this->menuFile = this->menuBar()->addMenu(tr("File"));
   this->menuFile->addAction(actionNew);
   this->menuFile->addAction(actionOpen);
   this->menuRecent = this->menuFile->addMenu(tr("Recent files"));
   this->menuFile->addAction(actionSave);
   this->menuFile->addAction(actionSaveAs);
   this->menuFile->addAction(actionPrint);
   this->menuFile->addAction(actionQuit);
   
   this->menuEdit = this->menuBar()->addMenu(tr("Edit"));
   this->menuEdit->addAction(actionUndo);
   this->menuEdit->addAction(actionRedo);
   this->menuEdit->addAction(actionDelete);
   this->menuEdit->addSeparator();
   this->menuEdit->addAction(actionAutoIndent);
   this->menuEdit->addAction(actionFollowCursor);
   this->menuEdit->addSeparator();
   this->menuEdit->addAction(actionFind);
   this->menuEdit->addAction(actionClearOutput);
   this->menuEdit->addAction(actionHighlightEnable);
   this->menuEdit->addAction(actionChangeInputFont);
   this->menuEdit->addAction(actionChangeOutputFont);
   this->menuEdit->addAction(actionZoomIn);
   this->menuEdit->addAction(actionZoomOut);
   
   this->menuCaml = this->menuBar()->addMenu(tr("Caml"));
   this->menuCaml->addAction(actionSendCaml);
   this->menuCaml->addAction(actionInterruptCaml);
   this->menuCaml->addAction(actionStopCaml);
   this->menuCaml->addAction(actionShowSettings);
   
   this->menuHelp = this->menuBar()->addMenu(tr("Help"));
   this->menuHelp->addAction(actionAbout);
   this->menuHelp->addAction(actionAboutQt);
   

   
   /* Connections */
   connect(inputZone,SIGNAL(returnPressed()),this,SLOT(handleLineBreak()));
   
   connect(actionSendCaml,SIGNAL(triggered()),this,SLOT(sendCaml()));
   connect(camlProcess,SIGNAL(readyReadStandardOutput()),this,SLOT(readCaml()));
   connect(camlProcess,SIGNAL(readyReadStandardError()),this,SLOT(readCamlErrors()));
   connect(camlProcess,SIGNAL(stateChanged(QProcess::ProcessState)),this,SLOT(updateCamlStatus(QProcess::ProcessState)));
   connect(actionStopCaml,SIGNAL(triggered()),this,SLOT(stopCaml()));
   connect(camlProcess,SIGNAL(started()),this,SLOT(camlOK()));
   connect(actionInterruptCaml,SIGNAL(triggered()),this,SLOT(interruptCaml()));
   
   
   connect(actionSave,SIGNAL(triggered()),this,SLOT(save()));
   connect(actionSaveAs,SIGNAL(triggered()),this,SLOT(saveAs()));
   connect(actionOpen,SIGNAL(triggered()),this,SLOT(open()));
   connect(inputZone,SIGNAL(textChanged()),this,SLOT(textChanged()));
   connect(actionNew,SIGNAL(triggered()),this,SLOT(newFile()));
   connect(actionClearOutput,SIGNAL(triggered()),this->outputZone,SLOT(clear()));
   connect(actionChangeInputFont,SIGNAL(triggered()),this,SLOT(changeInputFont()));
   connect(actionChangeOutputFont,SIGNAL(triggered()),this,SLOT(changeOutputFont()));
   connect(actionQuit,SIGNAL(triggered()),this,SLOT(close()));
   connect(actionPrint,SIGNAL(triggered()),this,SLOT(print()));
   connect(actionUndo,SIGNAL(triggered()),this->inputZone,SLOT(undo()));
   connect(actionRedo,SIGNAL(triggered()),this->inputZone,SLOT(redo()));
   connect(actionDelete,SIGNAL(triggered()),this->inputZone,SLOT(paste()));
   connect(actionShowSettings,SIGNAL(triggered()),this,SLOT(showSettings()));
   connect(actionHighlightEnable,SIGNAL(toggled(bool)),this,SLOT(toggleHighlightOn(bool)));
   connect(actionAutoIndent,SIGNAL(triggered()),this,SLOT(autoIndentCode()));
   connect(actionFollowCursor,SIGNAL(triggered(bool)),this,SLOT(toggleAutoIndentOn(bool)));
   
   connect(actionZoomIn,SIGNAL(triggered()),this,SLOT(zoomIn()));
   connect(actionZoomOut,SIGNAL(triggered()),this,SLOT(zoomOut()));
   connect(actionFind,SIGNAL(triggered(bool)),this,SLOT(triggerFindReplace(bool)));
   connect(find,SIGNAL(hideRequest(bool)),this,SLOT(triggerFindReplace(bool)));
   
   connect(inputZone, SIGNAL(unindentKeyStrokePressed()), this, SLOT(unindent()));
   
   connect(actionAbout,SIGNAL(triggered()),this,SLOT(about()));
   connect(actionAboutQt,SIGNAL(triggered()),this,SLOT(aboutQt()));
   
   this->generateRecentMenu();
   this->populateRecent();
   
   this->highlightTriggered = false;
   fillIndentWords(&indentWords);
   
   //Draw trees?
   this->drawTrees = (settings->value("General/drawTrees",0).toInt() == 1)?true:false;
   this->graphCount = 0;
   
   this->startCamlProcess();
}
Ejemplo n.º 21
0
MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
{
    GlobalCache *globalCache = new GlobalCache();
    loginStatus = false;

    updateTimer = startTimer(100);

    QTimerEvent *e= new QTimerEvent(updateTimer);

    setWindowTitle("#precIsioN Billing Software 1.2");

    /* Setting height and width properties */
    QDesktopWidget *desktop = QApplication::desktop();
    int width = desktop->width();
    int height = desktop->height();
    GlobalCache::setScreenWidth(width);
    GlobalCache::setScreenHeight(height);
    resize(width/2, height/2);
    int sideWidth = 10; //width/48;
    int sideHeight = (height-50)/14;
    widgetWidth = width - 20; //sideWidth *46;
    widgetHeight = sideHeight * 14;

    /* Creating menu bar and status bar */
    menubar = new QMenuBar(this);
    setMenuBar(menubar);

    menuAdministrator = new QMenu(menubar);
    menuAdministrator->setTitle("Administrator");
    menubar->addMenu(menuAdministrator);

    QAction *homeAct = new QAction(("&Home"), this);
    homeAct->setShortcut(QKeySequence(tr("Ctrl+H")));
    menuAdministrator->addAction(homeAct);
    menuAdministrator->addSeparator();
    QAction *changePasswordAct = new QAction("Change Password", this);
    menuAdministrator->addAction(changePasswordAct);
    QAction *refreshAct = new QAction(("&Refresh"), this);
    refreshAct->setShortcut(QKeySequence(tr("Ctrl+R")));
    menuAdministrator->addAction(refreshAct);
    QAction *fullScreenAct = new QAction(("&Full Screen"), this);
    fullScreenAct->setShortcut(Qt::Key_F11);
    menuAdministrator->addAction(fullScreenAct);
    QAction *restartAct = new QAction("Restart", this);
    restartAct->setShortcut(QKeySequence((tr("Shift+Ctrl+X"))));
    menuAdministrator->addAction(restartAct);
    QAction *quitAct = new QAction(("Quit Application"), this);
    quitAct->setShortcut(QKeySequence(tr("Ctrl+X")));
    menuAdministrator->addAction(quitAct);

    menuStock = new QMenu(menubar);
    menuStock->setTitle("Stock");
    menubar->addMenu(menuStock);

    QAction *manageStockAct = new QAction(("Manage Stock"), this);
    manageStockAct->setShortcut(QKeySequence(tr("Ctrl+M")));
    menuStock->addAction(manageStockAct);
    QAction *bulkStockUpdationAct = new QAction("Bulk Stock Updation", this);
    bulkStockUpdationAct->setShortcut(QKeySequence(tr("Ctrl+U")));
    menuStock->addAction(bulkStockUpdationAct);
    menuStock->addSeparator();
    QAction *stockPruchaseInvoiceAct = new QAction(("Stock Purchase Invoice"), this);
    menuStock->addAction(stockPruchaseInvoiceAct);
    QAction *oldStockPurchaseInvoiceAct = new QAction(("Old Stock Purchase Invoice"), this);
    menuStock->addAction(oldStockPurchaseInvoiceAct);
    menuStock->addSeparator();
    QAction *stockUpdationAct = new QAction(("Single Stock Updation"), this);
    menuStock->addAction(stockUpdationAct);
    menuStock->addSeparator();
    QAction *addNewStockAct = new QAction(("Add New Stock"), this);
    menuStock->addAction(addNewStockAct);
    QAction *deleteStockact = new QAction(("Remove Stock"), this);
    menuStock->addAction(deleteStockact);
    QAction *updateStockAct = new QAction(("Edit Stock Details"), this);
    menuStock->addAction(updateStockAct);
    menuStock->addSeparator();
    QAction *checkStockAct = new QAction("Check Stock", this);
    checkStockAct->setShortcut(QKeySequence("Ctrl+F"));
    menuStock->addAction(checkStockAct);

    menuInvoice = new QMenu(menubar);
    menuInvoice->setTitle("Invoice");
    menubar->addMenu(menuInvoice);

    QAction *invoiceAct = new QAction(("&New Invoice"), this);
    invoiceAct->setShortcut(QKeySequence(tr("Ctrl+N")));
    menuInvoice->addAction(invoiceAct);
    QAction *setInvoiceAct = new QAction(("Set Invoice No"), this);
    menuInvoice->addAction(setInvoiceAct);
    QAction *cancelInvoiceAct = new QAction(("Cancel Invoice"), this);
    menuInvoice->addAction(cancelInvoiceAct);
    QAction *oldInvoiceAct = new QAction(("Old Invoices"), this);
    menuInvoice->addAction(oldInvoiceAct);

    menuEstimate = new QMenu(menubar);
    menuEstimate->setTitle("Estimate");
    menubar->addMenu(menuEstimate);

    QAction *estimateAct = new QAction(("&New Estimate"), this);
    estimateAct->setShortcut(QKeySequence(tr("Ctrl+E")));
    menuEstimate->addAction(estimateAct);
    QAction *setEstimateAct = new QAction(("Set Estimate No"), this);
    menuEstimate->addAction(setEstimateAct);
    QAction *cancelEstimateAct = new QAction(("Cancel Estimate"), this);
    menuEstimate->addAction(cancelEstimateAct);
    QAction *oldEstimateAct = new QAction(("Old Estimates"), this);
    menuEstimate->addAction(oldEstimateAct);
    menuEstimate->addSeparator();
    QAction *itemEstimateAct = new QAction("Item Estimates", this);
    menuEstimate->addAction(itemEstimateAct);


    menuDealer = new QMenu(menubar);
    menuDealer->setTitle("Dealer");
//    menubar->addMenu(menuDealer);

    QAction *dealerHomeAct = new QAction(("&Dealer Home"), this);
    dealerHomeAct->setShortcut(QKeySequence(tr("Ctrl+D")));
    menuDealer->addAction(dealerHomeAct);
    QAction *salesDetailsAct = new QAction(("Sales De&tais"), this);
    salesDetailsAct->setShortcut(QKeySequence(tr("Ctrl+T")));
    menuDealer->addAction(salesDetailsAct);
    QAction *addNewDealerAct = new QAction(("Add New Dealer"), this);
    menuDealer->addAction(addNewDealerAct);
    QAction *deleteDealerAct = new QAction(("Delete Dealer"), this);
    menuDealer->addAction(deleteDealerAct);
    QAction *updateDealerAct = new QAction(("Edit Dealer Details"), this);
    menuDealer->addAction(updateDealerAct);

    menuAccounts = new QMenu(menubar);
    menuAccounts->setTitle("Accounts");
    menubar->addMenu(menuAccounts);

    QAction *accountsAct = new QAction(("Accounts"), this);
    accountsAct->setShortcut(QKeySequence(tr("Ctrl+A")));
    menuAccounts->addAction(accountsAct);

    menuReports = new QMenu(menubar);
    menuReports->setTitle("Reports");
    menubar->addMenu(menuReports);

    QAction *todaysItemSalesAct = new QAction(("Today's &Item Sales"), this);
    todaysItemSalesAct->setShortcut(QKeySequence(tr("Ctrl+I")));
    menuReports->addAction(todaysItemSalesAct);
    QAction *dailyReportAct = new QAction(("Daily Sales &Report"), this);
    dailyReportAct->setShortcut(QKeySequence(tr("Ctrl+R")));
    menuReports->addAction(dailyReportAct);
    QAction *itemSalesReportAct = new QAction("Selected Item Sales Report", this);
    menuReports->addAction(itemSalesReportAct);
    QAction *historyItemSalesAct = new QAction(("History Item Sales"), this);
    menuReports->addAction(historyItemSalesAct);
    menuReports->addSeparator();
    QAction *purchaseReportAct = new QAction("Purchase Report", this);
    menuReports->addAction(purchaseReportAct);
    QAction *purchaseItemsAct = new QAction("Purchased Item Report", this);
    menuReports->addAction(purchaseItemsAct);

    menuSettings = new QMenu(menubar);
    menuSettings->setTitle("Settings");
    menubar->addMenu(menuSettings);

    QAction *configurationAct = new QAction(("Configure Product"), this);
    menuSettings->addAction(configurationAct);
    QAction *deleteDataAct = new QAction("Clear Data", this);
    menuSettings->addAction(deleteDataAct);
    QAction *backupAct = new QAction(("Backup"), this);
    menuSettings->addAction(backupAct);

    menuHelp = new QMenu(menubar);
    menuHelp->setTitle("Help");
    menubar->addMenu(menuHelp);

    QAction *shortcutAct = new QAction(("Shorcuts Used"), this);
    menuHelp->addAction(shortcutAct);
    QAction *aboutAct = new QAction(("About"), this);
    menuHelp->addAction(aboutAct);

    adminHome = new AdminHomeWidget(widgetWidth, this);
    adminHome->setGeometry(sideWidth, 50, widgetWidth, widgetHeight - 50);
    manageStock = new ManageStockWidget(widgetWidth, this);
    manageStock->setGeometry(sideWidth, 50, widgetWidth, widgetHeight - 50);
    purchaseInvoice = new StockPurchaseInvoiceWidget(widgetWidth, this);
    purchaseInvoice->setGeometry(sideWidth, 50, widgetWidth, widgetHeight - 50);
    oldPurchaseInvoice = new OldPurchaseInvoiceWidget(widgetWidth, this);
    oldPurchaseInvoice->setGeometry(sideWidth, 50, widgetWidth, widgetHeight - 50);
    invoice = new InvoiceWidget(widgetWidth, this);
    invoice->setGeometry(sideWidth, 50, widgetWidth, widgetHeight - 50);
    dailyReport = new DailySalesReportWidget(widgetWidth, this);
    dailyReport->setGeometry(sideWidth, 50, widgetWidth, widgetHeight - 50);
    itemSales = new TodaysItemSalesWidget(widgetWidth, this);
    itemSales->setGeometry(sideWidth, 50, widgetWidth, widgetHeight - 50);
    oldInvoice = new OldInvoicesWidget(widgetWidth, this);
    oldInvoice->setGeometry(sideWidth, 50, widgetWidth, widgetHeight - 50);
    allInvoices = new AllInvoices(widgetWidth, this);
    allInvoices->setGeometry(sideWidth, 50, widgetWidth, widgetHeight - 50);
    oldEstimate = new OldEstimates(widgetWidth, this);
    oldEstimate->setGeometry(sideWidth, 50, widgetWidth, widgetHeight - 50);
    itemEstimate = new ItemEstimateWidget(widgetWidth, this);
    itemEstimate->setGeometry(sideWidth, 50, widgetWidth, widgetHeight - 50);
    estimate = new EstimateWidget(widgetWidth, this);
    estimate->setGeometry(sideWidth, 50, widgetWidth, widgetHeight - 50);
    salesDetails = new SalesDetailsWidget(widgetWidth, this);
    salesDetails->setGeometry(sideWidth, 50, widgetWidth, widgetHeight - 50);
    accounts = new AccountsWidget(widgetWidth, this);
    accounts->setGeometry(sideWidth, 50, widgetWidth, widgetHeight - 50);
    purchaseReport = new PurchaseReportWidget(widgetWidth, this);
    purchaseReport->setGeometry(sideWidth, 50, widgetWidth, widgetHeight - 50);
    purchasedItems = new PurchasedItemWidget(widgetWidth, this);
    purchasedItems->setGeometry(sideWidth, 50, widgetWidth, widgetHeight - 50);
    historyDsr = new HistoryDSRWidget(widgetWidth, this);
    historyDsr->setGeometry(sideWidth, 50, widgetWidth, widgetHeight - 50);
    historyItemSales = new HistoryItemSalesWidget(widgetWidth, this);
    historyItemSales->setGeometry(sideWidth, 50, widgetWidth, widgetHeight - 50);
    historyinvoice = new HistoryInvoiceWidget(widgetWidth, this);
    historyinvoice->setGeometry(sideWidth, 50, widgetWidth, widgetHeight - 50);

    /* Main Window setup */

    connect( homeAct, SIGNAL(triggered()), this, SLOT(getAdminHome()));
    connect( todaysItemSalesAct, SIGNAL(triggered()), this, SLOT(getItemSales()));
    connect( dailyReportAct, SIGNAL(triggered()), this, SLOT(getDailySalesReport()));
    connect( itemSalesReportAct, SIGNAL(triggered()), this, SLOT(getItemSalesReport()));
    connect( bulkStockUpdationAct, SIGNAL(triggered()), this, SLOT(getBulkStockUpdationDialog()));
    connect( stockUpdationAct, SIGNAL(triggered()), this, SLOT(getStockUpdationDialog()));
    connect( addNewStockAct, SIGNAL(triggered()), this, SLOT(getAddNewStockDialog()));
    connect( deleteStockact, SIGNAL(triggered()), this, SLOT(getDeleteStockDialog()));
    connect( updateStockAct, SIGNAL(triggered()), this, SLOT(getUpdateStockDialog()));
    connect( checkStockAct, SIGNAL(triggered()), this, SLOT(getCheckStockDialog()));
    connect( changePasswordAct, SIGNAL(triggered()), this, SLOT(getChangePasswordDialog()));
    connect( refreshAct, SIGNAL(triggered()), this, SLOT(refresh()));
    connect( fullScreenAct, SIGNAL(triggered()), this, SLOT(getFullScreen()));
    connect( restartAct, SIGNAL(triggered()), this, SLOT(restart()));
    connect( quitAct, SIGNAL(triggered()), qApp, SLOT(quit()));
    connect( manageStockAct, SIGNAL(triggered()), this, SLOT(getManageStockWidget()));
    connect( stockPruchaseInvoiceAct, SIGNAL(triggered()), this, SLOT(getStockPurchaseInvoice()));
    connect( oldStockPurchaseInvoiceAct, SIGNAL(triggered()), this, SLOT(getOldStockPurchaseInvoice()));
    connect( invoiceAct, SIGNAL(triggered()), this, SLOT(getInvoice()));
    connect( setInvoiceAct, SIGNAL(triggered()), this, SLOT(getSetInvoiceDialog()));
    connect( cancelInvoiceAct, SIGNAL(triggered()), this, SLOT(cancelInvoice()));
    connect( oldInvoiceAct, SIGNAL(triggered()), this, SLOT(getOldInvoice()));
    connect( estimateAct, SIGNAL(triggered()), this, SLOT(getEstimate()));
    connect( setEstimateAct, SIGNAL(triggered()), this, SLOT(getSetEstimateDialog()));
    connect( cancelEstimateAct, SIGNAL(triggered()), this, SLOT(cancelEstimate()));
    connect( oldEstimateAct, SIGNAL(triggered()), this, SLOT(getOldEstimates()));
    connect( itemEstimateAct, SIGNAL(triggered()), this, SLOT(getItemEstimate()));
    connect( salesDetailsAct, SIGNAL(triggered()), this, SLOT(getSalesDetails()));
    connect( accountsAct, SIGNAL(triggered()), this, SLOT(getAccountsWidget()));
    connect( purchaseReportAct, SIGNAL(triggered()), this, SLOT(getPurchaseReport()));
    connect( purchaseItemsAct, SIGNAL(triggered()), this, SLOT(getPurchasedItems()));
    connect( historyItemSalesAct, SIGNAL(triggered()), this, SLOT(getHistoryItemSales()));
    connect( configurationAct, SIGNAL(triggered()), this, SLOT(getConfiguration()));
    connect( deleteDataAct, SIGNAL(triggered()), this, SLOT(getDeleteDataAct()));
    connect( backupAct, SIGNAL(triggered()), this, SLOT(getBackup()));
    connect( shortcutAct, SIGNAL(triggered()), this, SLOT(shortcuts()));
    connect( aboutAct, SIGNAL(triggered()), this, SLOT(about()));
    connect( qApp, SIGNAL(lastWindowClosed()), qApp, SLOT(quit()));

    hideAllWidgets();
    showMinimized();
}
Ejemplo n.º 22
0
void TIGLViewerWindow::connectSignals()
{
    connect(newAction, SIGNAL(triggered()), this, SLOT(newFile()));
    connect(openAction, SIGNAL(triggered()), this, SLOT(open()));
    connect(openScriptAction, SIGNAL(triggered()), this, SLOT(openScript()));
    connect(closeAction, SIGNAL(triggered()), this, SLOT(closeConfiguration()));

    for (int i = 0; i < MaxRecentFiles; ++i) {
        recentFileActions[i] = new QAction(this);
        recentFileActions[i]->setVisible(false);
        connect(recentFileActions[i], SIGNAL(triggered()),
                this, SLOT(openRecentFile()));
    }

    connect(saveAction, SIGNAL(triggered()), this, SLOT(save()));
    connect(saveScreenshotAction, SIGNAL(triggered()), this, SLOT(makeScreenShot()));
    connect(setBackgroundAction, SIGNAL(triggered()), this, SLOT(setBackgroundImage()));
    connect(exitAction, SIGNAL(triggered()), this, SLOT(close()));
    connect(aboutAction, SIGNAL(triggered()), this, SLOT(about()));
    connect(aboutQtAction, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
    connect(aboutQtAction, SIGNAL(triggered()), this, SLOT(aboutQt()));

    // Misc drawing actions
    connect(drawPointAction, SIGNAL(triggered()), this, SLOT(drawPoint()));
    connect(drawVectorAction, SIGNAL(triggered()), this, SLOT(drawVector()));
    

    // view->actions menu
    connect(fitAction, SIGNAL(triggered()), myOCC, SLOT(fitExtents()));
    connect(fitAllAction, SIGNAL(triggered()), myOCC, SLOT(fitAll()));
    //connect(zoomAction, SIGNAL(triggered()), myOCC, SLOT(fitArea()));
    connect(zoomAction, SIGNAL(triggered()),myOCC, SLOT(zoom()));
    connect(panAction, SIGNAL(triggered()), myOCC, SLOT(pan()));
    connect(rotAction, SIGNAL(triggered()), myOCC, SLOT(rotation()));
    connect(selectAction, SIGNAL(triggered()), myOCC, SLOT(selecting()));

    // view->grid menu
    connect(gridOnAction, SIGNAL(toggled(bool)), myScene, SLOT(toggleGrid(bool)));
    connect(gridXYAction, SIGNAL(triggered()), myScene, SLOT(gridXY()));
    connect(gridXZAction, SIGNAL(triggered()), myScene, SLOT(gridXZ()));
    connect(gridYZAction, SIGNAL(triggered()), myScene, SLOT(gridYZ()));
    connect(gridRectAction, SIGNAL(triggered()), myScene, SLOT(gridRect()));
    connect(gridCircAction, SIGNAL(triggered()), myScene, SLOT(gridCirc()));

    // Standard View
    connect(viewFrontAction, SIGNAL(triggered()), myOCC, SLOT(viewFront()));
    connect(viewBackAction, SIGNAL(triggered()), myOCC, SLOT(viewBack()));
    connect(viewTopAction, SIGNAL(triggered()), myOCC, SLOT(viewTop()));
    connect(viewBottomAction, SIGNAL(triggered()), myOCC, SLOT(viewBottom()));
    connect(viewLeftAction, SIGNAL(triggered()), myOCC, SLOT(viewLeft()));
    connect(viewRightAction, SIGNAL(triggered()), myOCC, SLOT(viewRight()));
    connect(viewAxoAction, SIGNAL(triggered()), myOCC, SLOT(viewAxo()));
    connect(viewGridAction, SIGNAL(triggered()), myOCC, SLOT(viewGrid()));
    connect(viewResetAction, SIGNAL(triggered()), myOCC, SLOT(viewReset()));
    connect(viewZoomInAction, SIGNAL(triggered()), myOCC, SLOT(zoomIn()));
    connect(viewZoomOutAction, SIGNAL(triggered()), myOCC, SLOT(zoomOut()));
    connect(showConsoleAction, SIGNAL(toggled(bool)), consoleDockWidget, SLOT(setVisible(bool)));
    connect(consoleDockWidget, SIGNAL(visibilityChanged(bool)), showConsoleAction, SLOT(setChecked(bool)));
    connect(showWireframeAction, SIGNAL(toggled(bool)), myScene, SLOT(wireFrame(bool)));

    connect(openTimer, SIGNAL(timeout()), this, SLOT(reopenFile()));

    // The co-ordinates from the view
    connect( myOCC, SIGNAL(mouseMoved(V3d_Coordinate,V3d_Coordinate,V3d_Coordinate)),
             this,   SLOT(xyzPosition(V3d_Coordinate,V3d_Coordinate,V3d_Coordinate)) );

    // Add a point from the view
    connect( myOCC, SIGNAL(pointClicked(V3d_Coordinate,V3d_Coordinate,V3d_Coordinate)),
             this,   SLOT (addPoint    (V3d_Coordinate,V3d_Coordinate,V3d_Coordinate)) );

    connect( myOCC, SIGNAL(sendStatus(const QString)), this,  SLOT  (statusMessage(const QString)) );

    connect(stdoutStream, SIGNAL(sendString(QString)), console, SLOT(output(QString)));
    connect(errorStream , SIGNAL(sendString(QString)), console, SLOT(output(QString)));

    connect(logDirect.get(), SIGNAL(newMessage(QString)), console, SLOT(output(QString)));

    connect(scriptEngine, SIGNAL(scriptResult(QString)), console, SLOT(output(QString)));
    connect(scriptEngine, SIGNAL(scriptError(QString)), console, SLOT(outputError(QString)));
    connect(scriptEngine, SIGNAL(evalDone()), console, SLOT(endCommand()));
    connect(console, SIGNAL(onChange(QString)), scriptEngine, SLOT(textChanged(QString)));
    connect(console, SIGNAL(onCommand(QString)), scriptEngine, SLOT(eval(QString)));

    connect(settingsAction, SIGNAL(triggered()), this, SLOT(changeSettings()));
}
Ejemplo n.º 23
0
Korn::Korn(QWidget *parent, KornSettings *settings, WFlags f)
	: QFrame(parent, "korn", f)
{
	int count=0;
	KornButton *button;
	QBoxLayout::Direction dir= QBoxLayout::TopToBottom;

	_optionsDialog = 0;
	_noConfig = false;

	// popup menu

	menu = new QPopupMenu();
	menu->insertItem(i18n("&Setup"), this, SLOT( optionDlg() ));
	menu->insertSeparator();
	menu->insertItem(i18n("&Help"), this, SLOT( help() ));
	menu->insertItem(i18n("&About"), this, SLOT( about() ));
	menu->insertSeparator();
	menu->insertItem(i18n("E&xit"), qApp, SLOT( quit() ));

	// widget decorations
	if(settings->layout() == KornSettings::horizontal )
		dir = QBoxLayout::LeftToRight;

	QBoxLayout *layout = new QBoxLayout(this, dir, 2);

	setFrameStyle(Panel | Raised);
	setLineWidth(1);

	// read settings and create boxes
	options = new QList<KornBox>;
	options->setAutoDelete( true );

	while( !settings->done() ) {
		// create a new button with these settings

		button = new KornButton(this, settings);	
		button->resize(20,20);
		layout->addWidget(button);

		connect( button, SIGNAL( rightClick() ), 
			this, SLOT( popupMenu() ));

		button->show();

		/// keep track of settings locally

		KornBox *thisBox = new KornBox;

		thisBox->name = settings->name().data();
		thisBox->caption = settings->caption().data();
		thisBox->path = settings->file().data();
		thisBox->poll = settings->pollTime();
		thisBox->notify = settings->audioCmd().data();
		thisBox->click = settings->clickCmd().data();

		options->append( thisBox );

		count++;
		settings->nextBox();
	}

	// dont layout or resize if no buttons were created
	// This should be changed, perhaps to a default single button

	if( !settings->valid() || count == 0 ) {
	
		// no valid config
		_noConfig = true;

		int result =	KMsgBox::yesNo(0, 
				i18n("korn: configure now?"), 
				i18n("you have not yet configured korn.\n"
				"would you like to do this now?"),
				KMsgBox::QUESTION,
				i18n("Yes"),
				i18n("No - Quit"));

		if( result == 1 ) {
			// create a list with the default mailbox in it.
			KornBox *box = new KornBox;
			box->name	= i18n("personal");
			box->caption	= i18n("Inbox");
			box->path	= (const char *)getenv("MAIL");
			box->poll	= 240;
			
			options->append( box );

			optionDlg();
		} else {
			qApp->quit();
		}

		return;
	} 

	if( dir == QBoxLayout::LeftToRight )
		resize(count*(2+20)+2,4+20);
	else
		resize(4+20, count*(2+20)+2);

	// move to the saved position if a position was saved

	if( settings->geomSet() ) {
		setGeometry( settings->geom().x(), settings->geom().y(),
				width(), height() );
	} else {
		// save position
		KConfig *config = KApplication::getKApplication()->getConfig();

		config->setGroup("Korn");
		config->writeEntry("PosX", frameGeometry().x(), true);
		config->writeEntry("PosY", frameGeometry().y(), true);
		config->writeEntry("winHeight", frameGeometry().height(), true);
	}

	if( settings->noMouse() ) {

		XSelectInput( x11Display(), handle(), ExposureMask 
				| StructureNotifyMask );
	}
}
Ejemplo n.º 24
0
void MainWindow::createActions() {
  newAct = new QAction(QIcon(":/images/filenew.png"), tr("&New"), this);
  newAct->setShortcut(tr("Ctrl+N"));
  newAct->setStatusTip(tr("Create a new file"));
  connect(newAct, SIGNAL(triggered()), this, SLOT(newFile()));

  closeAct = new QAction(QIcon(":/images/fileclose.png"), tr("&Close"), this);
#ifndef Q_WS_MAC
  closeAct->setShortcut(tr("Ctrl+F4"));
#else
  closeAct->setShortcut(tr("Ctrl+W"));
#endif
  closeAct->setStatusTip(tr("Close the current file"));
  connect(closeAct, SIGNAL(triggered()), this, SLOT(closeFile()));

  openAct = new QAction(QIcon(":/images/fileopen.png"), tr("&Open..."), this);
  openAct->setShortcut(tr("Ctrl+O"));
  openAct->setStatusTip(tr("Open an existing file"));
  connect(openAct, SIGNAL(triggered()), this, SLOT(open()));

  saveAct = new QAction(QIcon(":/images/filesave.png"), tr("&Save"), this);
  saveAct->setShortcut(tr("Ctrl+S"));
  saveAct->setStatusTip(tr("Save the document to disk"));
  connect(saveAct, SIGNAL(triggered()), this, SLOT(save()));

  saveAsAct = new QAction(QIcon(":/images/filesaveas.png"), tr("Save &As..."), this);
  saveAsAct->setStatusTip(tr("Save the document under a new name"));
  connect(saveAsAct, SIGNAL(triggered()), this, SLOT(saveAs()));

  exitAct = new QAction(QIcon(":/images/fileexit.png"), tr("E&xit"), this);
  exitAct->setShortcut(tr("Ctrl+Q"));
  exitAct->setStatusTip(tr("Exit QSciTE"));
  connect(exitAct, SIGNAL(triggered()), launcher, SLOT(quitApplication()));

  undoAct = new QAction(QIcon(":/images/undo.png"), tr("Undo"), this);
  undoAct->setShortcut(tr("Ctrl+Z"));
  undoAct->setStatusTip(tr("Undo the last action performed."));
  connect(undoAct, SIGNAL(triggered()), this, SLOT(undo()));

  redoAct = new QAction(QIcon(":/images/redo.png"), tr("Redo"), this);
  redoAct->setShortcut(tr("Ctrl+Shift+Z"));
  redoAct->setStatusTip(tr("Redo an action previously undone."));
  connect(redoAct, SIGNAL(triggered()), this, SLOT(redo()));

  cutAct = new QAction(QIcon(":/images/editcut.png"), tr("Cu&t"), this);
  cutAct->setShortcut(tr("Ctrl+X"));
  cutAct->setStatusTip(tr("Cut the current selection's contents to the "
                          "clipboard"));
  connect(cutAct, SIGNAL(triggered()), this, SLOT(editCut()));

  copyAct = new QAction(QIcon(":/images/editcopy.png"), tr("&Copy"), this);
  copyAct->setShortcut(tr("Ctrl+C"));
  copyAct->setStatusTip(tr("Copy the current selection's contents to the "
                           "clipboard"));
  connect(copyAct, SIGNAL(triggered()), this, SLOT(editCopy()));

  pasteAct = new QAction(QIcon(":/images/editpaste.png"), tr("&Paste"), this);
  pasteAct->setShortcut(tr("Ctrl+V"));
  pasteAct->setStatusTip(tr("Paste the clipboard's contents into the current "
                            "selection"));
  connect(pasteAct, SIGNAL(triggered()), this, SLOT(editPaste()));

  prefsAct = new QAction(QIcon(":/images/configure.png"), tr("P&references"), this);
  // TODO: set shortcut, tip, etc.
  connect(prefsAct, SIGNAL(triggered()), this, SLOT(globalPrefs()));

  fontAct = new QAction(QIcon(":/images/font.png"), tr("&Font"), this);
  //fontAct->setShortcut(tr(""))
  fontAct->setStatusTip(tr("Set the display font."));

  connect(fontAct, SIGNAL(triggered()), this, SLOT(fontDialog()));

  terminalAct = new QAction(QIcon(":/images/terminal.png"), tr("Terminal"), this);
  terminalAct->setStatusTip(tr("Show/hide terminal"));
  connect(terminalAct, SIGNAL(triggered()), this, SLOT(toggleTerminal()));

  textDisplayAct = new QAction(QIcon(":/images/font.png"), tr("Text &Display..."), this);
  connect(textDisplayAct, SIGNAL(triggered()), this, SLOT(textDisplay()));

  aboutAct = new QAction(tr("&About QSciTE"), this);
  aboutAct->setStatusTip(tr("Show QSciTE's About box"));
  connect(aboutAct, SIGNAL(triggered()), this, SLOT(about()));

  aboutQtAct = new QAction(tr("About &Qt"), this);
  aboutQtAct->setStatusTip(tr("Show the Qt library's About box"));
  connect(aboutQtAct, SIGNAL(triggered()), qApp, SLOT(aboutQt()));

  nextAct = new QAction(QIcon(":/images/nextTab.png"), tr("Forward"), this);
  nextAct->setStatusTip(tr("Change to the next open document"));
  nextAct->setShortcut(tr("Alt+Right"));
  connect(nextAct, SIGNAL(triggered()), this, SLOT(nextDoc()));

  prevAct = new QAction(QIcon(":/images/prevTab.png"), tr("Back"), this);
  prevAct->setStatusTip(tr("Change to the previous open document"));
  prevAct->setShortcut(tr("Alt+Left"));
  connect(prevAct, SIGNAL(triggered()), this, SLOT(prevDoc()));

  cutAct->setEnabled(false);
  copyAct->setEnabled(false);

  convertEndings = new QAction(tr("&Convert Line End Characters"), this);
  connect(convertEndings, SIGNAL(triggered()), this, SLOT(convertEols()));
  lineEndCr = new QAction(tr("&CR (old Macintosh)"), this);
  lineEndCr->setCheckable(true);
  connect(lineEndCr, SIGNAL(triggered()), this, SLOT(setEolCr()));
  lineEndLf = new QAction(tr("&LF (Unix)"), this);
  lineEndLf->setCheckable(true);
  connect(lineEndLf, SIGNAL(triggered()), this, SLOT(setEolLf()));
  lineEndCrLf = new QAction(tr("CR &+ LF (Windows)"), this);
  lineEndCrLf->setCheckable(true);
  connect(lineEndCrLf, SIGNAL(triggered()), this, SLOT(setEolCrLf()));

  lineEnds = new QActionGroup(this);
  lineEnds->addAction(lineEndCr);
  lineEnds->addAction(lineEndLf);
  lineEnds->addAction(lineEndCrLf);
  lineEndLf->setChecked(true);

  showLineEndsAct = new QAction(tr("&Show End of Line"), this);
  showLineEndsAct->setCheckable(true);
  connect(showLineEndsAct, SIGNAL(toggled(bool)), this, SLOT(setEolVisibility(bool)));

  convertIndentAct = new QAction(tr("Convert &Indentation..."), this);
  connect(convertIndentAct, SIGNAL(triggered()), this, SLOT(convertIndentation()));

  codeFoldingAct = new QAction(tr("Use Code Folding"), this);
  codeFoldingAct->setCheckable(true);
  connect(codeFoldingAct, SIGNAL(triggered()), this, SLOT(toggleFolding()));

  findTextAct = new QAction(tr("&Find..."), this);
  findTextAct->setShortcut(tr("Ctrl+F"));
  connect(findTextAct, SIGNAL(triggered()), this, SLOT(showFindDialog()));
  
  replaceTextAct = new QAction(tr("Replace..."), this);
  replaceTextAct->setShortcut(tr("Ctrl+H"));
  connect(replaceTextAct, SIGNAL(triggered()), this, SLOT(showReplaceDialog()));

  //ScriptConsole
  scriptConsoleAct = new QAction(tr("Script Console"), this);
  connect(scriptConsoleAct, SIGNAL(triggered()), this, SLOT(showScriptConsole()));

  newWindowAct = new QAction(QIcon(":/images/newwindow.png"), tr("&New Window"), this);
  connect(newWindowAct, SIGNAL(triggered()), this, SLOT(newWindow()));

  lexers = new QActionGroup(this);
  for (int i = 0; !supportedLexers[i].isEmpty(); ++i) {
    QAction * tmp = new QAction(tr(supportedLexers[i].toStdString().c_str()), this);
    tmp->setCheckable(true);
    connect(tmp, SIGNAL(triggered()), this, SLOT(lexerMenuChanged()));
    lexers->addAction(tmp);
  }
  
}
Ejemplo n.º 25
0
MainWindow::MainWindow()
  : m_settings(QString::fromAscii("Doxygen.org"), QString::fromAscii("Doxywizard"))
{
  QMenu *file = menuBar()->addMenu(tr("File"));
  file->addAction(tr("Open..."), 
                  this, SLOT(openConfig()), Qt::CTRL+Qt::Key_O);
  m_recentMenu = file->addMenu(tr("Open recent"));
  file->addAction(tr("Save"), 
                  this, SLOT(saveConfig()), Qt::CTRL+Qt::Key_S);
  file->addAction(tr("Save as..."), 
                  this, SLOT(saveConfigAs()), Qt::SHIFT+Qt::CTRL+Qt::Key_S);
  file->addAction(tr("Quit"),  
                  this, SLOT(quit()), Qt::CTRL+Qt::Key_Q);

  QMenu *settings = menuBar()->addMenu(tr("Settings"));
  settings->addAction(tr("Reset to factory defaults"),
                  this,SLOT(resetToDefaults()));
  settings->addAction(tr("Use current settings at startup"),
                  this,SLOT(makeDefaults()));
  settings->addAction(tr("Clear recent list"),
                  this,SLOT(clearRecent()));

  QMenu *help = menuBar()->addMenu(tr("Help"));
  help->addAction(tr("Online manual"), 
                  this, SLOT(manual()), Qt::Key_F1);
  help->addAction(tr("About"), 
                  this, SLOT(about()) );

  m_expert = new Expert;
  m_wizard = new Wizard(m_expert->modelData());

  // ----------- top part ------------------
  QWidget *topPart = new QWidget;
  QVBoxLayout *rowLayout = new QVBoxLayout(topPart);

  // select working directory
  QHBoxLayout *dirLayout = new QHBoxLayout;
  m_workingDir = new QLineEdit;
  m_selWorkingDir = new QPushButton(tr("Select..."));
  dirLayout->addWidget(m_workingDir);
  dirLayout->addWidget(m_selWorkingDir);

  //------------- bottom part --------------
  QWidget *runTab = new QWidget;
  QVBoxLayout *runTabLayout = new QVBoxLayout(runTab);

  // run doxygen
  QHBoxLayout *runLayout = new QHBoxLayout;
  m_run = new QPushButton(tr("Run doxygen"));
  m_run->setEnabled(false);
  m_runStatus = new QLabel(tr("Status: not running"));
  m_saveLog = new QPushButton(tr("Save log..."));
  m_saveLog->setEnabled(false);
  QPushButton *showSettings = new QPushButton(tr("Show configuration"));
  runLayout->addWidget(m_run);
  runLayout->addWidget(m_runStatus);
  runLayout->addStretch(1);
  runLayout->addWidget(showSettings);
  runLayout->addWidget(m_saveLog);

  // output produced by doxygen
  runTabLayout->addLayout(runLayout);
  runTabLayout->addWidget(new QLabel(tr("Output produced by doxygen")));
  QGridLayout *grid = new QGridLayout;
  m_outputLog = new QTextEdit;
  m_outputLog->setReadOnly(true);
  m_outputLog->setFontFamily(QString::fromAscii("courier"));
  m_outputLog->setMinimumWidth(600);
  grid->addWidget(m_outputLog,0,0);
  grid->setColumnStretch(0,1);
  grid->setRowStretch(0,1);
  QHBoxLayout *launchLayout = new QHBoxLayout;
  m_launchHtml = new QPushButton(tr("Show HTML output"));
  launchLayout->addWidget(m_launchHtml);

  launchLayout->addStretch(1);
  grid->addLayout(launchLayout,1,0);
  runTabLayout->addLayout(grid);

  m_tabs = new QTabWidget;
  m_tabs->addTab(m_wizard,tr("Wizard"));
  m_tabs->addTab(m_expert,tr("Expert"));
  m_tabs->addTab(runTab,tr("Run"));

  rowLayout->addWidget(new QLabel(tr("Step 1: Specify the working directory from which doxygen will run")));
  rowLayout->addLayout(dirLayout);
  rowLayout->addWidget(new QLabel(tr("Step 2: Configure doxygen using the Wizard and/or Expert tab, then switch to the Run tab to generate the documentation")));
  rowLayout->addWidget(m_tabs);

  setCentralWidget(topPart);
  statusBar()->showMessage(tr("Welcome to Doxygen"),messageTimeout);

  m_runProcess = new QProcess;
  m_running = false;
  m_timer = new QTimer;

  // connect signals and slots
  connect(m_tabs,SIGNAL(currentChanged(int)),SLOT(selectTab(int)));
  connect(m_selWorkingDir,SIGNAL(clicked()),SLOT(selectWorkingDir()));
  connect(m_recentMenu,SIGNAL(triggered(QAction*)),SLOT(openRecent(QAction*)));
  connect(m_workingDir,SIGNAL(returnPressed()),SLOT(updateWorkingDir()));
  connect(m_runProcess,SIGNAL(readyReadStandardOutput()),SLOT(readStdout()));
  connect(m_runProcess,SIGNAL(finished(int, QProcess::ExitStatus)),SLOT(runComplete()));
  connect(m_timer,SIGNAL(timeout()),SLOT(readStdout()));
  connect(m_run,SIGNAL(clicked()),SLOT(runDoxygen()));
  connect(m_launchHtml,SIGNAL(clicked()),SLOT(showHtmlOutput()));
  connect(m_saveLog,SIGNAL(clicked()),SLOT(saveLog()));
  connect(showSettings,SIGNAL(clicked()),SLOT(showSettings()));
  connect(m_expert,SIGNAL(changed()),SLOT(configChanged()));
  connect(m_wizard,SIGNAL(done()),SLOT(selectRunTab()));
  connect(m_expert,SIGNAL(done()),SLOT(selectRunTab()));

  loadSettings();
  updateLaunchButtonState();
  m_modified = false;
  updateTitle();
  m_wizard->refresh();
}
Ejemplo n.º 26
0
Themes::Themes( QWidget *parent, const char *name, WFlags f )
    : QMainWindow( parent, name, f )
{
    appFont = QApplication::font();
    tabwidget = new QTabWidget( this );

    tabwidget->addTab( new ButtonsGroups( tabwidget ), "Buttons/Groups" );
    QHBox *hbox = new QHBox( tabwidget );
    hbox->setMargin( 5 );
    (void)new LineEdits( hbox );
    (void)new ProgressBar( hbox );
    tabwidget->addTab( hbox, "Lineedits/Progressbar" );
    tabwidget->addTab( new ListBoxCombo( tabwidget ), "Listboxes/Comboboxes" );
    tabwidget->addTab( new CheckLists( tabwidget ), "Listviews" );
    tabwidget->addTab( new RangeControls( tabwidget ), "Rangecontrols" );
    tabwidget->addTab( new MyRichText( tabwidget ), "Fortune" );

    setCentralWidget( tabwidget );

    QPopupMenu *style = new QPopupMenu( this );
    style->setCheckable( TRUE );
    menuBar()->insertItem( "&Style" , style );

    style->setCheckable( TRUE );
    QActionGroup *ag = new QActionGroup( this, 0 );
    ag->setExclusive( TRUE );
    QSignalMapper *styleMapper = new QSignalMapper( this );
    connect( styleMapper, SIGNAL( mapped( const QString& ) ), this, SLOT( makeStyle( const QString& ) ) );
    QStringList list = QStyleFactory::keys();
    list.sort();
#ifndef QT_NO_STYLE_WINDOWS
    list.insert(list.begin(), "Norwegian Wood");
    list.insert(list.begin(), "Metal");
#endif
    QDict<int> stylesDict( 17, FALSE );
    for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) {
	QString styleStr = *it;
	QString styleAccel = styleStr;
	if ( stylesDict[styleAccel.left(1)] ) {
	    for ( uint i = 0; i < styleAccel.length(); i++ ) {
		if ( !stylesDict[styleAccel.mid( i, 1 )] ) {
		    stylesDict.insert(styleAccel.mid( i, 1 ), (const int *)1);
		    styleAccel = styleAccel.insert( i, '&' );
		    break;
		}
	    }
	} else {
	    stylesDict.insert(styleAccel.left(1), (const int *)1);
	    styleAccel = "&"+styleAccel;
	}
	QAction *a = new QAction( styleStr, QIconSet(), styleAccel, 0, ag, 0, ag->isExclusive() );
	connect( a, SIGNAL( activated() ), styleMapper, SLOT(map()) );
	styleMapper->setMapping( a, a->text() );
    }
    ag->addTo(style);
    style->insertSeparator();
    style->insertItem("&Quit", qApp, SLOT( quit() ), CTRL | Key_Q );

    QPopupMenu * help = new QPopupMenu( this );
    menuBar()->insertSeparator();
    menuBar()->insertItem( "&Help", help );
    help->insertItem( "&About", this, SLOT(about()), Key_F1);
    help->insertItem( "About &Qt", this, SLOT(aboutQt()));

#ifndef QT_NO_STYLE_WINDOWS
    qApp->setStyle( new NorwegianWoodStyle );
#endif
}
Ejemplo n.º 27
0
        QAction *action = new QAction(text, this);
        action->setData(format);
        connect(action, SIGNAL(triggered()), this, SLOT(export_as()));
        exportAsActs.append(action);
    }

    printAct = new QAction(QIcon(":/images/print.png"),tr("&Print ..."),this);
    printAct->setShortcut(tr("Ctrl+E"));
    connect(printAct, SIGNAL(triggered()), this, SLOT(print()));

    exitAct = new QAction(tr("E&xit"), this);
    exitAct->setShortcut(tr("Ctrl+Q"));
    connect(exitAct, SIGNAL(triggered()), this, SLOT(close()));

    aboutAct = new QAction(QIcon(":/images/about.png"),tr("&About"), this);
    connect(aboutAct, SIGNAL(triggered()), this, SLOT(about()));
}

void MainWindow::createMenus()
{
    exportMenu = new QMenu(tr("&Export As"), this);
    foreach (QAction *action, exportAsActs)
        exportMenu->addAction(action);

    fileMenu = new QMenu(tr("&File"),this);
    fileMenu->addAction(openAct);
    fileMenu->addAction(saveAct);
    fileMenu->addMenu(exportMenu);
    fileMenu->addAction(printAct);
    fileMenu->addSeparator();
    fileMenu->addAction(exitAct);
Ejemplo n.º 28
0
Archivo: main.c Proyecto: bochf/testing
/* ========================================================================= */
int main(int argc, char *argv[])
{
   struct options *o;

   /* API data */
   ipcinfo_shm_t *shmbuf = NULL;
   int size;
   char fact_string[32];

   /* Result data */
   long count = 0;
   int no_attach_cnt = 0;
   size64_t total_size = 0;
   size64_t min_size = 0;
   size64_t max_size = 0;
   struct per_user *ulist = NULL;
   struct barray *ba = NULL;

   /* General usage */
   int i;
   int keep_trying;



   if ( NULL == (o = ReadOptions(argc, argv)) )
      return(1);

   if ( o->bError )
      return(1);

   if ( o->bAbout )
      return(about());

   if ( o->bHelp )
      return(help());

   keep_trying = 1;
   while ( keep_trying )
   {
      if ( shmbuf )
         free(shmbuf);

      /*** Determine size of required buffer ***/
      if ( ENOSPC != get_ipc_info(0,
                                  GET_IPCINFO_SHM_ALL,
                                  IPCINFO_SHM_VERSION_1,
                                  NULL,
                                  &size))
      {
         fprintf(stderr, "ERROR: Unable to determine size/count of data.\n");
         return(1);
      }

      /*** Allocate memory for the buffer/array */
      if ( NULL == (shmbuf = (ipcinfo_shm_t *)malloc(size)) )
      {
         fprintf(stderr, "ERROR: Failed to allocate memory.\n");
         return(1);
      }
      
      /* Copy in the data to the allocated array ***/
      switch (  get_ipc_info(0,
                         GET_IPCINFO_SHM_ALL,
                         IPCINFO_SHM_VERSION_1,
                         (char *)shmbuf,
                         &size) )
      {
      case 0:
         keep_trying = 0;
         break;
      case ENOSPC:
         break;
      default:
         fprintf(stderr, "ERROR: Problems retrieving IPC data.\n");
         return(1);
         /* Unreachable */
         break;
      }
   }

   /* Determine count from size */
   count = size / (int)(sizeof(ipcinfo_shm_t));

   if ( o->bSizeGph )
   {
      ba = InitBuckets(BA_BASE10);
   }


   /*** Walk through the array deriving results as we go ***/
   i = 0;
   while ( i < count )
   {
      if ( shmbuf[i].shm_nattch = 0 )
         no_attach_cnt++;

      total_size += shmbuf[i].shm_segsz;

      if ( i == 0 )
      {
         min_size = shmbuf[i].shm_segsz;
         min_size = shmbuf[i].shm_segsz;
      }

      if ( min_size > shmbuf[i].shm_segsz )
          min_size = shmbuf[i].shm_segsz;

      if ( max_size < shmbuf[i].shm_segsz )
          max_size = shmbuf[i].shm_segsz;


      if ( o->bSizeGph )
         BucketValue(ba, shmbuf[i].shm_segsz);

      if ( o->bPerUser )
         ulist = collect_per_user(ulist, &shmbuf[i]);

      i++;
   }

   /*** Display results ***/
   printf("Number of shm segments               : %d\n", count);
   printf("Number of no-attach segments         : %d\n", no_attach_cnt);
   factor_bytes(fact_string, total_size);
   printf("Total size of shm segments (human)   : %s\n", fact_string);
   printf("Total size of shm segments (bytes)   : %llu\n", total_size);
   factor_bytes(fact_string, max_size);
   printf("Maximum sized shm segment            : %s\n", fact_string);
   factor_bytes(fact_string, min_size);
   printf("Minimum sized shm segment            : %s\n", fact_string);


   if ( ulist )
      dump_ulist(ulist);

   if ( ba )
   {
      int max_count;

      max_count = GetMaxCount(ba);

      printf("Size distribution data:\n");
      DumpBucketArray(ba, max_count);
   }
   fflush(stdout);

   return(0);
}
Ejemplo n.º 29
0
void TasmaMainWin::aboutModule()
{
    KAboutApplication about( _currentModule->aboutData() );
    about.exec();
}
Ejemplo n.º 30
0
extern "C" KDE_EXPORT int kdemain(int argc, char **argv)
{
    static KCmdLineOptions options[] = {
        { "+[directory]", I18N_NOOP("The sandbox to be loaded"), 0 },
        { "resolve <file>", I18N_NOOP("Show resolve dialog for the given file"), 0 },
        { "log <file>", I18N_NOOP("Show log dialog for the given file"), 0 },
        { "annotate <file>", I18N_NOOP("Show annotation dialog for the given file"), 0 },
        KCmdLineLastOption
    };
    KAboutData about("cervisia", I18N_NOOP("Cervisia"), CERVISIA_VERSION,
                     I18N_NOOP("A CVS frontend"), KAboutData::License_GPL,
                     I18N_NOOP("Copyright (c) 1999-2002 Bernd Gehrmann\n"
                               "Copyright (c) 2002-2007 the Cervisia authors"), 0,
                     "http://www.kde.org/apps/cervisia");

    about.addAuthor("Bernd Gehrmann", I18N_NOOP("Original author and former "
                    "maintainer"), "*****@*****.**", 0);
    about.addAuthor("Christian Loose", I18N_NOOP("Maintainer"),
                    "*****@*****.**", 0);
    about.addAuthor("Andr\303\251 W\303\266bbeking", I18N_NOOP("Developer"),
                    "*****@*****.**", 0);
    about.addAuthor("Carlos Woelz", I18N_NOOP("Documentation"),
                    "*****@*****.**", 0);

    about.addCredit("Richard Moore", I18N_NOOP("Conversion to KPart"),
                    "*****@*****.**", 0);

    KCmdLineArgs::init(argc, argv, &about);
    KCmdLineArgs::addCmdLineOptions(options);

    KApplication app;

    QString resolvefile = KCmdLineArgs::parsedArgs()->getOption("resolve");
    if (!resolvefile.isEmpty())
        return ShowResolveDialog(resolvefile);

    // is command line option 'show log dialog' specified?
    QString logFile = KCmdLineArgs::parsedArgs()->getOption("log");
    if( !logFile.isEmpty() )
        return ShowLogDialog(logFile);

    // is command line option 'show annotation dialog' specified?
    QString annotateFile = KCmdLineArgs::parsedArgs()->getOption("annotate");
    if( !annotateFile.isEmpty() )
        return ShowAnnotateDialog(annotateFile);

    if ( app.isRestored() ) {
        RESTORE(CervisiaShell);
    } else {
        CervisiaShell* shell = new CervisiaShell();

        const KCmdLineArgs* args = KCmdLineArgs::parsedArgs();
        if( args->count() )
        {
            KURL directory = args->url(0);
            shell->openURL(directory);
        }
        else
            shell->openURL();

        shell->setIcon(app.icon());
        app.setMainWidget(shell);
        shell->show();
    }

    int res = app.exec();
    cleanupTempFiles();
    return res;
}