⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.cpp

📁 QStars is a Qt-based screen saver. It displays an image within a field of moving stars.
💻 CPP
字号:
// Copyright (C) 2004, 2005 Andi Peredri <andi@ukr.net>#include <qapplication.h>#include <qcheckbox.h>#include <qdatetimeedit.h>#include <qlabel.h>#include <qsettings.h>#include <qslider.h>#include <qtabdialog.h>#include <qvbox.h>#include <qvgroupbox.h>#include "mainwindow.h"#include "vroot.h"// Main ---------------------------------------------------------------------int main(int argc, char** argv){    QApplication app(argc, argv);    QString mode = "-demo";    if(app.argc() > 1) mode = app.argv()[1];    WId wid = 0;    if(mode == "-window-id" && app.argc() > 2)	wid = QString(app.argv()[2]).toULong();    else if(mode == "-root")	wid = DefaultRootWindow(qt_xdisplay());    if(mode == "-help")    {	qWarning("Usage: " +QString(app.argv()[0])+ " [options]\n"		 "QStars Screensaver\n"		 "Options:\n"		 "  -help            Show help about options.\n"		 "  -setup           Setup screen saver.\n"		 "  -window-id wid   Run in the specified XWindow.\n"		 "  -root            Run in the root XWindow.\n"		 "  -demo            Start screen saver in demo mode. [default]\n");    }    else if(mode == "-setup")    {        QTime time;	QSettings settings;	settings.beginGroup("QStars");	unsigned int density = settings.readNumEntry("Density", 50);	unsigned int timeout = settings.readNumEntry("Timer", 30);	unsigned int speed = settings.readNumEntry("Speed", 50);	bool showasteroids = settings.readBoolEntry("ShowAsteroids", true);	bool showgalaxies = settings.readBoolEntry("ShowGalaxies", true);	bool showplanets = settings.readBoolEntry("ShowPlanets", true);	bool showships = settings.readBoolEntry("ShowShips", true);	QTabDialog dialog;        dialog.setCancelButton();	dialog.setCaption("QStars Setup");	dialog.setIcon(QPixmap::fromMimeSource("qstars.png"));	QVBox tab1(&dialog);        tab1.setMargin(5);	dialog.addTab(&tab1, "Setup");	QGroupBox box1(2, Qt::Horizontal, "Parameters", &tab1);	QLabel label1("Speed:", &box1);	QSlider slider1(0, 100, 1, speed, Qt::Horizontal, &box1);        slider1.setTickInterval(25);	slider1.setTickmarks(QSlider::Left);	QLabel label2("Stars Density:", &box1);	QSlider slider2(0, 100, 1, density, Qt::Horizontal, &box1);        slider2.setTickInterval(25);	slider2.setTickmarks(QSlider::Left);	QLabel label3("Cycle timer (min:sec): ", &box1);	QTimeEdit editor(time.addSecs(timeout), &box1);        editor.setAutoAdvance(true);	editor.setDisplay(QTimeEdit::Minutes | QTimeEdit::Seconds);	QVGroupBox box2("Objects", &tab1);	QCheckBox check1("Show Galaxies", &box2);	check1.setChecked(showgalaxies);	QCheckBox check2("Show Ships", &box2);	check2.setChecked(showships);	QCheckBox check3("Show Planets", &box2);	check3.setChecked(showplanets);	QCheckBox check4("Show Asteroids", &box2);	check4.setChecked(showasteroids);	QVBox tab2(&dialog);        tab2.setMargin(5);	dialog.addTab(&tab2, "About");	QVGroupBox box3("About", &tab2);	QLabel label4("\nQStars Screen Saver Version 0.4\n\n"		      "Copyright (C) 2004, 2005 Andi Peredri <andi@ukr.net>\n\n"		      "Homepage: \thttp://qt.osdn.org.ua/qstars.html\n"		      "License:  \tGNU General Public License", &box3);	if(dialog.exec() == QDialog::Accepted)	{	    settings.writeEntry("Speed",         slider1.value());	    settings.writeEntry("Density",       slider2.value());	    settings.writeEntry("Timer",         time.secsTo(editor.time()));	    settings.writeEntry("ShowGalaxies",  check1.isChecked());	    settings.writeEntry("ShowShips",     check2.isChecked());	    settings.writeEntry("ShowPlanets",   check3.isChecked());	    settings.writeEntry("ShowAsteroids", check4.isChecked());	}    }    else if(mode == "-window-id" || mode == "-demo" || mode == "-root")    {	MainWindow window(wid);        window.show();	app.setMainWidget(&window);	return app.exec();    }    else    {	qWarning("Unknown option: " + mode +		 "\nUse -help to get a list of available command line options.\n");    }    return 0;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -