コード例 #1
0
ファイル: kwm.cpp プロジェクト: kthxbyte/KDE1-Linaro
void KWM::activate(Window w){
  if (desktop(w) != currentDesktop())
    switchToDesktop(desktop(w));
  if (isIconified(w))
    setIconify(w, FALSE);
  raise(w);
  activateInternal(w);
}
コード例 #2
0
ファイル: rootimageapp.cpp プロジェクト: KDE/lightdm
void RootImageApp::setBackground()
{
    QFile stdIn;
    stdIn.open(0, QIODevice::ReadOnly);

    QImage image;
    image.load(&stdIn, "xpm");

    QPalette palette;
    palette.setBrush(desktop()->backgroundRole(), QBrush(image));
    desktop()->setPalette(palette);
    XClearWindow(QX11Info::display(), desktop()->winId());

    quit();
}
コード例 #3
0
/**
 * Constructor of the startWindow class, completing its window.
 *
 * @param parent	The parent window
 */
startWindow::startWindow(QMap<QString, Site*> *sites, QWidget *parent) : QDialog(parent), ui(new Ui::startWindow), m_sites(sites)
{
	ui->setupUi(this);

	// Language
	QStringList languages = QDir(qApp->applicationDirPath()+"/languages").entryList(QStringList("*.qm"), QDir::Files);
	for (int i = 0; i < languages.count(); i++)
	{ languages[i].remove(".qm", Qt::CaseInsensitive); }
	ui->comboLanguage->addItems(languages);
	if (languages.contains("English"))
	{ ui->comboLanguage->setCurrentText("English"); }

	// Sources
	QStringList sources = m_sites->keys();
	ui->comboSource->addItems(sources);
	if (sources.contains("danbooru.donmai.us"))
	{ ui->comboSource->setCurrentText("danbooru.donmai.us"); }

	// Default values
	QDir desktop(QStandardPaths::writableLocation(QStandardPaths::DesktopLocation));
	ui->lineFolder->setText(desktop.absoluteFilePath("Grabber"));
	ui->lineFilename->setText("%md5%.%ext%");

	connect(this, &QDialog::accepted, this, &startWindow::save);
}
コード例 #4
0
int main(int argc, char *argv[])
{
    ::setgid(0);
    ::setuid(0);

    if (argc > 1 && strcmp(argv[1], "restore") == 0) {
        QString appsDir("/usr/share/applications/");
        QDir appl(appsDir);
        foreach (const QString &desktoppath, appl.entryList(QStringList() << "apkd_launcher_*.desktop")) {
            QString path = appsDir + desktoppath;
            QFile desktop(path);
            if (desktop.open(QFile::ReadWrite | QFile::Text)) {
                QString data;
                QTextStream stream(&desktop);
                stream.setCodec("UTF-8");
                while (!stream.atEnd()) {
                    QString line = stream.readLine();
                    if (!line.startsWith("MimeType") &&
                            !line.startsWith("X-Maemo-Method") &&
                            !line.startsWith("X-Maemo-Object") &&
                            !line.startsWith("X-Maemo-Service")) {
                        data.append(line);
                        data.append("\n");
                    }
                }
                desktop.seek(0);
                desktop.resize(0);
                stream << data;
                desktop.close();
            }
        }
        return 0;
    }
コード例 #5
0
void
MyApplication::init()
{
	time(&starttime);
	endtime = starttime + 5;
	done = false;

	qMainWindow = new QMainWindow();

	qButton = new QPushButton();
	qButton->setMinimumWidth(180);
	qButton->setMinimumHeight(35);
	QObject::connect(qButton, SIGNAL(clicked()), this, SLOT(myQuit()));
	update_button(*qButton);

	qMainWindow->setCentralWidget(qButton);
	QRect r = qMainWindow->frameGeometry();
	r.moveCenter(desktop()->availableGeometry().center());
	qMainWindow->move(r.topLeft());
	qMainWindow->show();

	timer = new QTimer(qMainWindow);
	QObject::connect(timer, SIGNAL(timeout()), this, SLOT(tick()));
	timer->start(334);
}
コード例 #6
0
ファイル: monitor.cpp プロジェクト: Moppa5/lighthouse
    void Monitor::updateAppName(const QString& fileName) {
        const QString fullName = "/usr/share/applications/" + fileName;
        if ( !QFile::exists(fullName) ) {
            qWarning() << "File not found: " << fullName << "\n";
            return;
        }

        QSettings desktop(fullName, QSettings::IniFormat);
        desktop.setIniCodec("UTF-8");
        const QString appName = desktop.value("Desktop Entry/Name", "Unknown").toString();
        if ( appName == "Unknown" ) {
            return;
        }

        QString baseName(fileName);
        if ( fileName.startsWith("apkd_launcher") ) { // android name needs cleanup
            baseName.replace("apkd_launcher_", "");
            const int n = baseName.indexOf('-');
            baseName.remove(n, baseName.length() - n);
            baseName.replace("_", ".");
        } else { // sailfish just has .desktop at the end
            baseName.replace(".desktop", "");
        }

        fAppNameMap[baseName] = appName;
    }
コード例 #7
0
ファイル: sys_app.c プロジェクト: ziyaofeng/WUZIQI
/*********************
导航栏执行
参数:pback 返回键函数指针
pmenu 菜单键函数指针
**********************/
void guiddo(void (*pback)(void),void (*pmenu)(void),x)
{
	if(x<80&&x>0) {Show_Str(20,288,"←",32,White,Blue);pback();}
	if(x>80&&x<160) {Show_Str(104,288,"█",32,0xa254,Blue);LCD_DrawLine( 108, 304, 131,304, White );
		LCD_DrawLine( 120, 293, 120,315, White );LCD_DrawLine( 80, 288, 80,320, White );desktop();}
	if(x>160&&x<240){ Show_Str(187,288,"〓",32,White,Blue);pmenu();}
}
コード例 #8
0
ファイル: kwm.cpp プロジェクト: kthxbyte/KDE1-Linaro
QString KWM::getProperties(Window w){
  QString result;
  QRect rect;
  int data[13];
  int i = 0;
  int n = 0;
  data[n++]=desktop(w);
  rect = geometry(w);
  data[n++]=rect.x();
  data[n++]=rect.y();
  data[n++]=rect.width();
  data[n++]=rect.height();
  rect = geometryRestore(w);
  data[n++]=rect.x();
  data[n++]=rect.y();
  data[n++]=rect.width();
  data[n++]=rect.height();
  data[n++]=isIconified(w)?1:0;
  data[n++]=isMaximized(w)?maximizeMode(w):0;
  data[n++]=isSticky(w)?1:0;
  data[n++]=getDecoration(w);

  QString s;
  for (i=0;i<n;i++){
    s.setNum(data[i]);
    result.append(s);
    if (i<n-1)
      result.append("+");
  }
  return result;
}
コード例 #9
0
KScriptAction::KScriptAction( const QString &scriptDesktopFile, QObject *interface, KActionCollection *ac )
    : QObject(interface), KScriptClientInterface( )
{
    m_interface = 0L;
    m_action = 0L;
    m_isValid = false;
    m_refs = 0;
    // Read the desktop file
    if(KDesktopFile::isDesktopFile(scriptDesktopFile))
    {
        KDesktopFile desktop(scriptDesktopFile, true);
        QFileInfo scriptPath(scriptDesktopFile);
        
        m_scriptFile = scriptPath.dirPath(true) + "/" + desktop.readEntry("X-KDE-ScriptName", "");
        m_scriptName = desktop.readName();
        m_scriptType = desktop.readType();
        QString scriptTypeQuery = "([X-KDE-Script-Runner] == '" + m_scriptType + "')";
	KTrader::OfferList offers = KTrader::self()->query( "KScriptRunner/KScriptRunner", scriptTypeQuery );
        if ( !offers.isEmpty() )
        {
            m_action = new KAction(m_scriptName, KShortcut(), this, SLOT(activate()), ac, "script");
            m_isValid = true;
            m_timeout = new QTimer(this);
            QString icon = desktop.readIcon();
            m_action->setStatusText(desktop.readComment());
                if( !icon.isEmpty() ) 
                    m_action->setIcon(icon);
            m_action->setShortcutConfigurable(true);
            connect( m_timeout, SIGNAL(timeout()), SLOT(cleanup()) );
        }
    }
}
コード例 #10
0
ファイル: desktopview.cpp プロジェクト: varuna/plexydesk
   void DesktopView::loadIcons()
   {
       QDir desktop(QDir::homePath()+"/Desktop");
       desktop.setFilter(QDir::Files | QDir::NoDotAndDotDot);
       desktop.setSorting(QDir::Size | QDir::Reversed);
       QFileInfoList list = desktop.entryInfoList();

     //  d->iconWatcher->setFuture(QtConcurrent::mapped(list, LoadIcon(d->iconprovider, d->row, d->column)));

       for (int i = 0; i < list.size(); i++) {
         QFileInfo fileInfo = list.at(i);
         QPixmap iconpixmap (DesktopWidget::applicationDirPath() +
            "/share/plexy/skins/widgets/widget01/Icon.png");
         //TODO
         //Shared pointer please

         Icon * icon = new Icon(d->iconprovider, QRect(0,0,iconpixmap.width(),iconpixmap.height()));
         icon->setContent(fileInfo.absoluteFilePath());
         if(icon->isValid()) {
         scene()->addItem(icon);
         icon->setPos(d->row,d->column);
         icon->show();
         d->icons.append(icon);
         } else {
             delete icon;
         }
       }

   }
コード例 #11
0
void
MyApplication::renderDone()
{
	desktop()->setBackgroundPixmap( renderer.pixmap() );
	desktop()->repaint( true );
	renderer.saveCacheFile();
	renderer.cleanup();
	for (unsigned i=0; i<renderer.numRenderers(); ++i)
	{
		KBackgroundRenderer * r = renderer.renderer(i);
		if (r->backgroundMode() == KBackgroundSettings::Program ||
		    (r->multiWallpaperMode() != KBackgroundSettings::NoMulti &&
		     r->multiWallpaperMode() != KBackgroundSettings::NoMultiRandom))
			return;
	}
	quit();
}
コード例 #12
0
ファイル: SSG_Planet.cpp プロジェクト: cwriter/SFMLGame
int SSG_Planet::internal_onclick(const sf::Vector2f& mpos, const sf::Mouse::Button& but)
{
	if(m_info_show) return 0;
	
	m_info_window = sfg::Window::Create(
		sfg::Window::Style::TOPLEVEL | sfg::Window::Style::CLOSE);
	m_info_window->GetSignal(sfg::Window::OnCloseButton).Connect([this](){
		m_info_window->Show(false);
		this->m_info_show = false;
		desktop()->Remove(m_info_window);
	});
	m_info_window->SetTitle("Properties of planet \"" + m_name + "\"");
	
	auto table = sfg::Table::Create();
	
	auto masslabel = sfg::Label::Create("Mass:");
	
	std::ostringstream strm;
	strm << std::scientific << this->getMass().getScalar().get_d();
	
	m_info_masstext = sfg::Label::Create(strm.str() + "kg");
	m_info_masstext->SetAlignment(sf::Vector2f(1.f,0.f));
	
	auto poslabel = sfg::Label::Create("Position:");
	
	strm.str(std::string());
	
	strm << std::scientific << "(" << this->x().get_d() << "|" << this->y().get_d() << ")m";
	m_info_postext = sfg::Label::Create(strm.str());
	m_info_postext->SetAlignment(sf::Vector2f(1.f,0.f));
	
	
	table->Attach(masslabel, sf::Rect<sf::Uint32>(0,0,1,1), sfg::Table::EXPAND, sfg::Table::EXPAND);
	table->Attach(m_info_masstext, sf::Rect<sf::Uint32>(1,0,1,1), sfg::Table::EXPAND | sfg::Table::FILL, sfg::Table::EXPAND);
	
	table->Attach(poslabel, sf::Rect<sf::Uint32>(0,1,1,1), sfg::Table::EXPAND, sfg::Table::EXPAND);
	table->Attach(m_info_postext, sf::Rect<sf::Uint32>(1,1,1,1), sfg::Table::EXPAND | sfg::Table::FILL, sfg::Table::EXPAND);
	
	m_info_window->Add(table);
	desktop()->Add(m_info_window);
	
	
	m_info_show = true;
	
	return 0;
}
コード例 #13
0
ファイル: krootimage.cpp プロジェクト: aarontc/kde-workspace
void
MyApplication::renderDone()
{
    QPalette palette;
    palette.setBrush(desktop()->backgroundRole(), QBrush(renderer.pixmap()));
    desktop()->setPalette(palette);
    XClearWindow(QX11Info::display(), desktop()->winId());

    renderer.saveCacheFile();
    renderer.cleanup();
    for (unsigned i = 0; i < renderer.numRenderers(); ++i) {
        KBackgroundRenderer *r = renderer.renderer(i);
        if (r->backgroundMode() == KBackgroundSettings::Program ||
            (r->multiWallpaperMode() != KBackgroundSettings::NoMulti &&
             r->multiWallpaperMode() != KBackgroundSettings::NoMultiRandom))
            return;
    }
    quit();
}
コード例 #14
0
void SystemDirNotify::init()
{
	if( mInited )
		return;
	mInited = true;
	KGlobal::dirs()->addResourceType("system_entries",
		KStandardDirs::kde_default("data") + "systemview");

	QStringList names_found;
	QStringList dirList = KGlobal::dirs()->resourceDirs("system_entries");

	QStringList::ConstIterator dirpath = dirList.begin();
	QStringList::ConstIterator end = dirList.end();
	for(; dirpath!=end; ++dirpath)
	{
		QDir dir = *dirpath;
		if (!dir.exists()) continue;

		QStringList filenames
			= dir.entryList( QDir::Files | QDir::Readable );

		QStringList::ConstIterator name = filenames.begin();
		QStringList::ConstIterator endf = filenames.end();

		for(; name!=endf; ++name)
		{
			if (!names_found.contains(*name))
			{
				KDesktopFile desktop(*dirpath+*name, true);

				QString system_name = *name;
				system_name.truncate(system_name.length()-8);

				KURL system_url("system:/"+system_name);
				
				if ( !desktop.readURL().isEmpty() )
				{
					m_urlMap[desktop.readURL()] = system_url;
					names_found.append( *name );
				}
				else if ( !desktop.readPath().isEmpty() )
				{
					KURL url;
					url.setPath( desktop.readPath() );
					m_urlMap[url] = system_url;
					names_found.append( *name );
				}
			}
		}
	}
}
コード例 #15
0
ファイル: UtilLinux.cpp プロジェクト: EasyCoding/desura-app
std::wstring getDesktopPath(std::wstring extra)
{
	// Convert std::string to std::wstring using std::copy
	std::string temp(getCmdStdout("xdg-user-dir DESKTOP", 1));
	std::wstring desktop(temp.length(),L' ');
	std::copy(temp.begin(), temp.end(), desktop.begin());
	//std::wstring desktop((wchar_t*) getCmdStdout("xdg-user-dir DESKTOP", 1).c_str());
	if(!desktop.empty())
	{
		desktop += L"/";
		desktop += extra;
	}
	// Do some error checking if desktop is empty
	return desktop;
}
コード例 #16
0
ファイル: auto_select.cpp プロジェクト: gam3/trasker
void AddAuto::setAuto()
{
    int id = project->getId();

// Being checked causes a wild card.  Empty string is wildcard
//BUG you can't match an empty string!

    QString host(checkBox_host->isChecked() ? "" : Host->text());
    QString class_name(checkBox_class->isChecked() ? "" : Class->text());
    QString name(checkBox_name->isChecked() ? "" : Name->text());
    QString role(checkBox_role->isChecked() ? "" : Role->text());
    QString title(checkBox_title->isChecked() ? "" : Title->text());
    QString desktop(checkBox_desktop->isChecked() ? "" : Desktop->currentText());

    ttcp->addauto( id, host, class_name, name, role, title, desktop );
}
コード例 #17
0
ファイル: Application.cpp プロジェクト: pvdk/QtOgreFramework
	////////////////////////////////////////////////////////////////////////////////
	/// Centers a widget inside its parent, or inside the desktop if no
	/// parent is provided. This requires the widget to be free to move.
	/// If not (e.g. its in a layout) then the behaviour is undefined
	/// \param widgetToCenter the widget to centre
	/// \param parent the parent of the widget
	////////////////////////////////////////////////////////////////////////////////	
	void Application::centerWidget(QWidget* widgetToCenter, QWidget* parent)
	{
		QRect parentGeometry;
		if(parent != 0)
		{
			parentGeometry = parent->frameGeometry();
		}
		else
		{
			parentGeometry = desktop()->availableGeometry();
		}

		int xOffset = (parentGeometry.width() - widgetToCenter->frameGeometry().width()) / 2;
		int yOffset = (parentGeometry.height() - widgetToCenter->frameGeometry().height()) / 2;
		widgetToCenter->move(parentGeometry.x() + xOffset, parentGeometry.y() + yOffset);
	}
コード例 #18
0
ファイル: main.c プロジェクト: guoyanxiao1991/five-chess
int main(void)
{
    pthread_t id;
    int  ret;
/*
    fb_line(0,0,1279,1023,0x0000ff00);
    fb_line(0,1023,1279,0,0x00ff0000);

    fb_line(0,10,1279,600,0x00ff0000);

    fb_line(0,10,100,600,0x00ff0000);

    sleep(9);
*/
    create_scr_fb(); 
/*
    memset((char *)fb_v.mem,0,1280*1024);
    chess_board();
    chess_print(130,80);
    draw_circle(500,500,0x0000ff00);
    draw_circle(100,100,0x00ff0000);
    draw_circle(200,200,0x000000ff);
   
    fb_circle(500, 500, 300, 0x00ff0000);
*/
    desktop();
    chess_board();
//   chess_print(1030,800,0x0000ff00);
/*
    draw_cursor(500,500);
    sleep(1);
    restore_shape(500,500);
    draw_cursor(50,50);
    sleep(1);
    restore_shape(50,50);
    draw_cursor(1000,1000);
    sleep(1);
    restore_shape(1000,1000);

    sleep(10);
*/
   client_init() ;
   ret= pthread_create(&id,NULL,(void*)mouse_doing,NULL);
   while(1) recv_msg();

   return 0;
}
コード例 #19
0
void RemoteMenu::initialize()
{
    int id = 0;
    if (KickerSettings::showMenuTitles())
    {
        insertTitle(i18n("Network Folders"));
    }

    id = insertItem(SmallIcon("wizard"), i18n("Add Network Folder"));
    connectItem(id, this, SLOT(startWizard()));
    id = insertItem(SmallIcon("kfm"), i18n("Manage Network Folders"));
    connectItem(id, this, SLOT(openRemoteDir()));

    insertSeparator();

    m_desktopMap.clear();
    QStringList names_found;
    QStringList dirList = KGlobal::dirs()->resourceDirs("remote_entries");

    QStringList::ConstIterator dirpath = dirList.begin();
    QStringList::ConstIterator end = dirList.end();
    for(; dirpath!=end; ++dirpath)
    {
        QDir dir = *dirpath;
        if (!dir.exists()) continue;

        QStringList filenames
            = dir.entryList( QDir::Files | QDir::Readable );

        QStringList::ConstIterator name = filenames.begin();
        QStringList::ConstIterator endf = filenames.end();

        for(; name!=endf; ++name)
        {
            if (!names_found.contains(*name))
            {
                names_found.append(*name);
                QString filename = *dirpath+*name;
                KDesktopFile desktop(filename);
                id = insertItem(SmallIcon(desktop.readIcon()), desktop.readName());
                m_desktopMap[id] = filename;
            }
        }
    }
}
コード例 #20
0
ファイル: autorun_xdg.cpp プロジェクト: qTox/qTox
bool Platform::setAutorun(bool on)
{
    QString dirPath = getAutostartDirPath();
    QFile desktop(getAutostartFilePath(dirPath));
    if (on) {
        if (!QDir().mkpath(dirPath) || !desktop.open(QFile::WriteOnly | QFile::Truncate))
            return false;
        desktop.write("[Desktop Entry]\n");
        desktop.write("Type=Application\n");
        desktop.write("Name=qTox\n");
        desktop.write("Exec=");
        desktop.write(currentCommandLine().toUtf8());
        desktop.write("\n");
        desktop.close();
        return true;
    } else
        return desktop.remove();
}
コード例 #21
0
ActivePet::~ActivePet()
{
    m_files->ignore(m_requestFolderPath, m_dispatcher);
    // Kill any stray processes.
    if (!TerminateJobObject(m_job.get(), -1)) {
        printf("TerminateJobObject() failed: %d", GetLastError());
    }

    // TODO: Change this algorithm for transient accounts.
    std::for_each(m_syncers.begin(), m_syncers.end(), delete_element<Syncer*>());

    RegKey editables = RegKey::HKCU.open(Constants::registryPets() + L"\\" + m_petname + L"\\" + Constants::editables());
    editables.removeSubKeys();

    // Unload the profile.
    UnloadUserProfile(m_session.get(), m_profile);

    // Undo the changes to the winsta0 and desktop DACLs.
    auto_buffer<PSID> logon_sid = GetLogonSID(m_session.get());
    if (NULL == logon_sid.get()) {
        return;
    }
    auto_close<HWINSTA, &::CloseWindowStation> winsta0(OpenWindowStation(L"winsta0", FALSE, READ_CONTROL | WRITE_DAC));
	if (NULL == winsta0.get()) {
        printf("OpenWindowStation() failed: %d", GetLastError());
        return;
	}
	if (!RemoveAceFromWindowStation(winsta0.get(), logon_sid.get())) {
        printf("RemoveAceFromWindowStation() failed: %d", GetLastError());
		return;
	}
    auto_close<HDESK, &::CloseDesktop> desktop(OpenDesktop(L"default", 0, FALSE,
                                                           READ_CONTROL | WRITE_DAC |
                                                           DESKTOP_WRITEOBJECTS | DESKTOP_READOBJECTS));
	if (NULL == desktop.get()) {
        printf("OpenDesktop() failed: %d", GetLastError());
		return;
	}
    if (!RemoveAceFromDesktop(desktop.get(), logon_sid.get())) {
        printf("AddAceToDesktop() failed: %d", GetLastError());
		return;
	}
}
コード例 #22
0
ファイル: app.cpp プロジェクト: Ram-Z/hexdame
void
App::initGUI()
{
    // Construct the main window
    _mainwindow.reset(new QMainWindow);

    loadActions();
    loadStatusBar();

    // TODO test this on a non-tiling WM
    QDesktopWidget *desktopwidget = desktop();
    int preferredwidth = 1024;
    int preferredheight = 768;
    int leftmargin = (desktopwidget->width() - preferredwidth) / 2;
    int topmargin  = (desktopwidget->height() - preferredheight) / 2;
    _mainwindow->move(leftmargin, topmargin);

    // Display the main window
    _mainwindow->setVisible(true);

    newGame();
}
コード例 #23
0
ファイル: main.cpp プロジェクト: ahb0327/Drawpile
void DrawpileApp::openBlankDocument()
{
	// Open a new window with a blank image
	QSettings cfg;

	QSize maxSize = desktop()->screenGeometry().size();
	QSize size = cfg.value("history/newsize").toSize();

	if(size.width()<100 || size.height()<100) {
		// No previous size, or really small size
		size = QSize(800, 600);
	} else {
		// Make sure previous size is not ridiculously huge
		size = size.boundedTo(maxSize);
	}

	QColor color = cfg.value("history/newcolor").value<QColor>();
	if(!color.isValid())
		color = Qt::white;

	MainWindow *win = new MainWindow;
	win->newDocument(size, color);
}
コード例 #24
0
bool X11AutoRun::autoRunOn()
{
    QDir dir = autoRunDir();
    if (dir == QDir()) {
        dir.mkdir("autostart");
        dir.cd("autostart");
    }

    QString content = QString("[Desktop Entry]\n"
                    "Encoding=UTF-8\n"
                    "Name=%1\n"
                    "GenericName=\n"
                    "Type=Application\n"
                    "Exec=%2\n"
                    "Terminal=false\n"
                    "X-GNOME-Autostart-Delay=10\n")
            .arg(QApplication::applicationName(), QApplication::applicationFilePath());

    QFile desktop(dir.path() + QDir::separator() + QApplication::applicationName() + ".desktop");
    desktop.open(QFile::WriteOnly);
    desktop.write(content.toUtf8());
    desktop.close();
    return true;
}
コード例 #25
0
ActivePet::ActivePet(wchar_t* user_password,
                     std::wstring petname,
                     FileEventLoop* files) : m_petname(petname),
                                             m_files(files),
                                             m_session(INVALID_HANDLE_VALUE),
                                             m_profile(INVALID_HANDLE_VALUE),
                                             m_job(CreateJobObject(NULL, NULL)),
                                             m_next_editable_name(1),
                                             m_ticks_while_invisible(0)
{
    // Create a new logon session for the pet.
    std::wstring petRegistryPath = Constants::registryPets() + L"\\" + m_petname;
	RegKey petkey = RegKey::HKCU.open(petRegistryPath);
	std::wstring accountName = petkey.getValue(L"accountName");
    std::wstring accountRegistryPath = Constants::registryAccounts() + L"\\" + accountName;
	RegKey accountKey = RegKey::HKCU.open(accountRegistryPath);	
	std::wstring password = accountKey.getValue(L"password");
	if (!LogonUser(accountName.c_str(), NULL, password.c_str(),
				   LOGON32_LOGON_INTERACTIVE,
				   LOGON32_PROVIDER_DEFAULT,
				   &m_session)) {
        printf("LogonUser() failed: %d\n", GetLastError());
        return;
	}

    // Tweak the Winsta0 and desktop ACLs to allow the pet to create windows.
    auto_buffer<PSID> logon_sid = GetLogonSID(m_session.get());
    if (NULL == logon_sid.get()) {
        return;
    }
    auto_close<HWINSTA, &::CloseWindowStation> winsta0(OpenWindowStation(L"winsta0", FALSE, READ_CONTROL | WRITE_DAC));
	if (NULL == winsta0.get()) {
        printf("OpenWindowStation() failed: %d\n", GetLastError());
        return;
	}
	if (!AddAceToWindowStation(winsta0.get(), logon_sid.get())) {
        printf("AddAceToWindowStation() failed: %d", GetLastError());
		return;
	}
    auto_close<HDESK, &::CloseDesktop> desktop(OpenDesktop(L"default", 0, FALSE,
                                                           READ_CONTROL | WRITE_DAC |
                                                           DESKTOP_WRITEOBJECTS | DESKTOP_READOBJECTS));
	if (NULL == desktop.get()) {
        printf("OpenDesktop() failed: %d\n", GetLastError());
		return;
	}
    if (!AddAceToDesktop(desktop.get(), logon_sid.get())) {
        printf("AddAceToDesktop() failed: %d\n", GetLastError());
		return;
	}

    // Load the pet account's registry hive.
    wchar_t account[128] = {};
    wcsncpy(account, accountName.c_str(), 128);
	PROFILEINFO profile = { sizeof(PROFILEINFO), 0, account };
	if (!LoadUserProfile(m_session.get(), &profile)) {
        printf("LoadUserProfile() failed: %d\n", GetLastError());
		return;
	}
    m_profile = profile.hProfile;

    // Initialize the pet job.
	if (NULL == m_job.get()) {
        printf("CreateJobObject() failed: %d\n", GetLastError());
		return;
	}
    JOBOBJECT_BASIC_UI_RESTRICTIONS buir = { JOB_OBJECT_UILIMIT_HANDLES };
	if (!SetInformationJobObject(m_job.get(), JobObjectBasicUIRestrictions, &buir, sizeof buir)) {
        printf("SetInformationJobObject() failed: %d\n", GetLastError());
	}

    // Some apps fail to launch without access to the desktop window.
	if (!UserHandleGrantAccess(GetDesktopWindow(), m_job.get(), TRUE)) {
        printf("UserHandleGrantAccess() failed: %d\n", GetLastError());
	}

    // Give apps access to all the standard cursors.
	if (!UserHandleGrantAccess(LoadCursor(NULL, IDC_ARROW), m_job.get(), TRUE)) {
        printf("UserHandleGrantAccess() failed: %d\n", GetLastError());
	}
	if (!UserHandleGrantAccess(LoadCursor(NULL, IDC_IBEAM), m_job.get(), TRUE)) {
        printf("UserHandleGrantAccess() failed: %d\n", GetLastError());
	}
	if (!UserHandleGrantAccess(LoadCursor(NULL, IDC_WAIT), m_job.get(), TRUE)) {
        printf("UserHandleGrantAccess() failed: %d\n", GetLastError());
	}
	if (!UserHandleGrantAccess(LoadCursor(NULL, IDC_CROSS), m_job.get(), TRUE)) {
        printf("UserHandleGrantAccess() failed: %d\n", GetLastError());
	}
	if (!UserHandleGrantAccess(LoadCursor(NULL, IDC_UPARROW), m_job.get(), TRUE)) {
        printf("UserHandleGrantAccess() failed: %d\n", GetLastError());
	}
	if (!UserHandleGrantAccess(LoadCursor(NULL, IDC_SIZE), m_job.get(), TRUE)) {
        printf("UserHandleGrantAccess() failed: %d\n", GetLastError());
	}
	if (!UserHandleGrantAccess(LoadCursor(NULL, IDC_ICON), m_job.get(), TRUE)) {
        printf("UserHandleGrantAccess() failed: %d\n", GetLastError());
	}
	if (!UserHandleGrantAccess(LoadCursor(NULL, IDC_SIZENWSE), m_job.get(), TRUE)) {
        printf("UserHandleGrantAccess() failed: %d\n", GetLastError());
	}
	if (!UserHandleGrantAccess(LoadCursor(NULL, IDC_SIZENESW), m_job.get(), TRUE)) {
        printf("UserHandleGrantAccess() failed: %d\n", GetLastError());
	}
	if (!UserHandleGrantAccess(LoadCursor(NULL, IDC_SIZEWE), m_job.get(), TRUE)) {
        printf("UserHandleGrantAccess() failed: %d\n", GetLastError());
	}
	if (!UserHandleGrantAccess(LoadCursor(NULL, IDC_SIZENS), m_job.get(), TRUE)) {
        printf("UserHandleGrantAccess() failed: %d\n", GetLastError());
	}
	if (!UserHandleGrantAccess(LoadCursor(NULL, IDC_SIZEALL), m_job.get(), TRUE)) {
        printf("UserHandleGrantAccess() failed: %d\n", GetLastError());
	}
	if (!UserHandleGrantAccess(LoadCursor(NULL, IDC_NO), m_job.get(), TRUE)) {
        printf("UserHandleGrantAccess() failed: %d\n", GetLastError());
	}
	if (!UserHandleGrantAccess(LoadCursor(NULL, IDC_HAND), m_job.get(), TRUE)) {
        printf("UserHandleGrantAccess() failed: %d\n", GetLastError());
	}
	if (!UserHandleGrantAccess(LoadCursor(NULL, IDC_APPSTARTING), m_job.get(), TRUE)) {
        printf("UserHandleGrantAccess() failed: %d\n", GetLastError());
	}
	if (!UserHandleGrantAccess(LoadCursor(NULL, IDC_HELP), m_job.get(), TRUE)) {
        printf("UserHandleGrantAccess() failed: %d\n", GetLastError());
	}

    // Setup the use records for the printers.
    std::set<std::wstring> servers;
    RegKey printers = RegKey::HKCU.open(L"Printers\\Connections");
    for (int i = 0; true; ++i) {
        RegKey printer = printers.getSubKey(i);
        if (!printer.isGood()) {
            break;
        }
        std::wstring server = printer.getValue(L"Server");
        if (servers.count(server) == 0) {

            std::wstring resource = server + L"\\IPC$";
            auto_array<wchar_t> remote(resource.length() + 1);
            lstrcpy(remote.get(), resource.c_str());

            USE_INFO_2 use = {};
            use.ui2_remote = remote.get();
            use.ui2_domainname = _wgetenv(L"USERDOMAIN");
            use.ui2_username = _wgetenv(L"USERNAME");;
            use.ui2_password = user_password;
            use.ui2_asg_type = USE_WILDCARD;

            auto_impersonation impersonate(m_session.get());

            DWORD arg_error;
            NET_API_STATUS error = NetUseAdd(NULL, 2, (BYTE*)&use, &arg_error);
            if (error) {
                printf("NetUseAdd() failed: %d\n", error);
            } else {
                servers.insert(server);
            }
        }
    }

    // Add the message handlers.
    //m_requestFolderPath = accountKey.getValue(Constants::petDataPathName()) + Constants::requestPath();
    m_requestFolderPath = Constants::requestsPath(Constants::polarisDataPath(Constants::userProfilePath(accountName)));
    m_dispatcher = new MessageDispatcher(m_requestFolderPath);
    m_files->watch(m_requestFolderPath, m_dispatcher);
    m_dispatcher->add("sendmail",makeSendMailHandler());
// TODO    m_dispatcher->add("GetOpenFileNameA", makeGetOpenFileNameAHandler(this));
    m_dispatcher->add("GetOpenFileNameW", makeGetOpenFileNameWHandler(this));
	m_dispatcher->add("GetClipboardData", makeGetClipboardDataHandler());
}
コード例 #26
0
ファイル: activation.cpp プロジェクト: Fat-Zer/tdebase
/*!
  Sets the client's active state to \a act.

  This function does only change the visual appearance of the client,
  it does not change the focus setting. Use
  Workspace::activateClient() or Workspace::requestFocus() instead.

  If a client receives or looses the focus, it calls setActive() on
  its own.

 */
void Client::setActive( bool act, bool updateOpacity_)
    {
    if ( active == act )
        return;
    active = act;
    workspace()->setActiveClient( act ? this : NULL, Allowed );

    if (updateOpacity_) updateOpacity();
    if (isModal() && transientFor())
    {
        if (!act) transientFor()->updateOpacity();
        else if (!transientFor()->custom_opacity) transientFor()->setOpacity(options->translucentActiveWindows, options->activeWindowOpacity);
    }
    updateShadowSize();

    if ( active )
    {
        Notify::raise( Notify::Activate );
        if (options->shadowEnabled(true))
            {
            if (options->shadowEnabled(false))
                {
                // Wait for inactive shadow to expose occluded windows and give
                // them a chance to redraw before painting the active shadow
                removeShadow();
                drawDelayedShadow();
                if (!isDesktop() &&
                       this != workspace()->topClientOnDesktop(desktop()))
                    // If the newly activated window's isn't the desktop, wait
                    // for its shadow to draw, then redraw any shadows
                    // overlapping it.
                    drawOverlappingShadows(true);
                }
            else
                drawShadow();
            }
        }
    else
        {
        removeShadow();

        if (options->shadowEnabled(false))
            {
            if (this == workspace()->topClientOnDesktop(desktop()))
                {
                /* If the newly deactivated window is the top client on the
                 * desktop, then the newly activated window is below it; ensure
                 * that the deactivated window's shadow draws after the
                 * activated window's shadow.
                 */
                if ((shadowAfterClient = workspace()->activeClient()))
                    {
                    drawShadowAfter(shadowAfterClient);
                    }
                }
            else
                {
                drawDelayedShadow();
                }
            }
        }

    if( !active )
        cancelAutoRaise();

    if( !active && shade_mode == ShadeActivated )
        setShade( ShadeNormal );
        
    StackingUpdatesBlocker blocker( workspace());
    workspace()->updateClientLayer( this ); // active windows may get different layer
    // TODO optimize? mainClients() may be a bit expensive
    ClientList mainclients = mainClients();
    for( ClientList::ConstIterator it = mainclients.begin();
         it != mainclients.end();
         ++it )
        if( (*it)->isFullScreen()) // fullscreens go high even if their transient is active
            workspace()->updateClientLayer( *it );
    if( decoration != NULL )
        decoration->activeChange();
    updateMouseGrab();
    updateUrgency(); // demand attention again if it's still urgent
    }
コード例 #27
0
	void maskImageWidget::init(const QImage& image)
	{
		setWindowTitle(tr("Mask Editor"));

		QPixmap load("coral_open32x32.png");
		QPixmap save("coral_save32x32.png");
		QPixmap undo("coral_undo32x32.png");
		QPixmap redo("coral_redo32x32.png");
		QPixmap pen("coral_pencil32x32.png");
		QPixmap eraser("coral_eraser32x32.png");			

		QAction *canvasloadmask = new QAction(this);
		canvasloadmask->setIcon(load);
		canvasloadmask->setText(tr("&Load Mask"));
		QAction *canvassavemask = new QAction(this);
		canvassavemask->setIcon(QIcon(save));
		canvassavemask->setText(tr("&Save Mask"));
		QAction *canvasundo = new QAction(this);
		canvasundo->setIcon(QIcon(undo));
		canvasundo->setText(tr("&Undo"));
		canvasundo->setShortcut(QKeySequence("Ctrl+Z"));
		QAction *canvasredo = new QAction(this);
		canvasredo->setIcon(QIcon(redo));
		canvasredo->setText(tr("&Redo"));
		canvasredo->setShortcut(QKeySequence("Ctrl+Shift+Z"));
		QAction *canvasclear = new QAction(tr("&Clear"), this);
		canvasclear->setShortcut(QKeySequence("Ctrl+C"));

		QAction *canvaspen = new QAction(this);
		canvaspen->setIcon(QIcon(pen));
		canvaspen->setText(tr("&Pen"));
		QAction *canvaseraser = new QAction(this);
		canvaseraser->setIcon(QIcon(eraser));
		canvaseraser->setText(tr("&Eraser"));

		QActionGroup *actions(new QActionGroup(this));
		actions->addAction(canvaspen);
		actions->addAction(canvaseraser);
		canvaspen->setCheckable(true);
		canvaseraser->setCheckable(true);
		canvaspen->setChecked(true);
		actions->setExclusive(true);

		QAction *canvasOK = new QAction(this);
		canvasOK->setText("OK");
		QAction *canvasCancel = new QAction(this);
		canvasCancel->setText("Cancel");

		QBoxLayout *layout(new QVBoxLayout(this));

		// We don't want a real-size image. We will downscale it!
		QImage image_to_use = image;
		pimpl_->realwidth_ = image.width();
		pimpl_->realheight_ = image.height();
		qDebug("maskImageWidget::Init real wxh %i x%i",pimpl_->realwidth_,pimpl_->realheight_);
		QDesktopWidget *desktop(QApplication::desktop());
		if (image.width() > (desktop->width() * .8) ||
				image.height() > (desktop->height() * .8))
		{
			int width(desktop->width()), height(desktop->height());
			image_to_use = image.scaled((int)std::floor(width * .75),
																	(int)std::floor(height * .75), Qt::KeepAspectRatio);
		}
		pimpl_->render_area_ = new maskRenderWidget(image_to_use, this);

		QToolBar *canvas_toolbar(new QToolBar(this));
		canvas_toolbar->addSeparator();
		canvas_toolbar->addAction(canvasloadmask);
		canvas_toolbar->addAction(canvassavemask);
		canvas_toolbar->addSeparator();
		
		canvas_toolbar->addAction(canvasundo);
		canvas_toolbar->addAction(canvasredo);
		canvas_toolbar->addSeparator();
		
		QSpinBox *pen_width(new QSpinBox(canvas_toolbar));
		pen_width->setToolTip(tr("Pen Width"));
		pen_width->setRange(0, 80);
		pen_width->setSingleStep(2);
		pen_width->setValue(16);
		connect(pen_width, SIGNAL(valueChanged(int)), SLOT(setCanvasPenWidth(int)));
		canvas_toolbar->addWidget(pen_width);
		canvas_toolbar->addAction(canvaspen);
		canvas_toolbar->addAction(canvaseraser);
		canvas_toolbar->addSeparator();

		QSpinBox *gradient(new QSpinBox(canvas_toolbar));
		gradient->setToolTip("Gradient Threshold");
		gradient->setRange(0, 255);
		gradient->setValue(pimpl_->threshold_gradient_);
		connect(gradient, SIGNAL(valueChanged(int)), SLOT(setGradientThreshold(int)));
		
		QSpinBox *fixed(new QSpinBox(canvas_toolbar));
		fixed->setToolTip("Fixed Threshold");
		fixed->setRange(0, 255);
		fixed->setValue(pimpl_->threshold_fixed_);
		connect(fixed, SIGNAL(valueChanged(int)), SLOT(setFixedThreshold(int)));
		
		canvas_toolbar->addWidget(gradient);
		canvas_toolbar->addWidget(fixed);
		canvas_toolbar->addSeparator();

		canvas_toolbar->addAction(canvasOK);
		canvas_toolbar->addAction(canvasCancel);

		layout->addWidget(canvas_toolbar);
		layout->addWidget(pimpl_->render_area_);
		layout->setSizeConstraint(QLayout::SetFixedSize);

		connect(canvasloadmask, SIGNAL(activated()), SLOT(loadMask()));
		connect(canvassavemask, SIGNAL(activated()), SLOT(saveMask()));
		connect(canvasundo, SIGNAL(activated()), pimpl_->render_area_, SLOT(undo()));
		connect(canvasredo, SIGNAL(activated()), pimpl_->render_area_, SLOT(redo()));
		connect(canvasclear, SIGNAL(activated()), pimpl_->render_area_, SLOT(clear()));
		connect(canvaspen, SIGNAL(activated()), SLOT(setCanvasPen()));
		connect(canvaseraser, SIGNAL(activated()), SLOT(setCanvasEraser()));

		connect(pimpl_->render_area_, SIGNAL(pointSelected(const QPoint &)), SLOT(automaticMask(const QPoint &)));

		connect(canvasOK, SIGNAL(activated()), SLOT(accept()));
		connect(canvasCancel, SIGNAL(activated()), SLOT(reject()));
	}
コード例 #28
0
ファイル: skpackage.cpp プロジェクト: KDE/superkaramba
bool SkPackage::installPackage(const QString &archivePath, const QString &packageRoot)
{
    kDebug()<<"archivePath="<<archivePath<<"packageRoot="<<packageRoot;

    ThemeFile theme(archivePath);

    QDir root(packageRoot);
    const QString name = QString("sk_%1").arg(theme.id());
    if( !root.cd(name) && ( !root.mkdir(name) || !root.cd(name) ) ) {
        return false;
    }

    const QString path = root.path();
    //if( ! theme.extractArchiveTo(path) ) {
    if( ! theme.copyArchiveTo(path) ) {
        kWarning()<<"Failed to copy archive="<<archivePath<<" to path="<<path;
        return false;
    }

    setPath(path);

    Plasma::PackageMetadata data;
    data.setPluginName(name);
    data.setImplementationApi("superkaramba");
    data.setCategory("SuperKaramba");
    //data.setServiceType(const QString &);
    data.setName(theme.name());
    data.setDescription(i18n("SuperKaramba Theme"));
    data.setAuthor(theme.author());
    data.setEmail(theme.authorEmail());
    data.setVersion(theme.version());
    data.setWebsite(theme.homepage());
    data.setLicense(theme.license());
    //data.setApplication("superkaramba");
    //data.setRequiredVersion(const QString &);

    QString iconfile = "superkaramba";
    if( ! theme.iconName().isEmpty() ) {
        theme.extractArchiveFileTo(theme.iconName(), path);
        QFileInfo fi(path, theme.iconName());
        if( fi.exists() )
            iconfile = fi.absoluteFilePath();
    }

    Plasma::Package::registerPackage(data, iconfile);

#if 0
    // write a desktop-file that is used by Plasma to know about our new applet.
    const QString desktopfile = KStandardDirs::locateLocal("services", QString("plasma-scriptengine-%1.desktop").arg(name));
    KDesktopFile desktop(desktopfile);
    KConfigGroup group = desktop.desktopGroup();

    group.writeEntry("Name", theme.name());
    group.writeEntry("Comment", i18n("SuperKaramba Theme"));
    group.writeEntry("Type", "Service");
    group.writeEntry("ServiceTypes", "Plasma/Applet");

    QString iconfile = "superkaramba";
    if( ! theme.iconName().isEmpty() ) {
        QFileInfo fi(path, theme.iconName());
        if( fi.exists() )
            iconfile = fi.absoluteFilePath();
    }
    group.writeEntry("Icon", iconfile);

    group.writeEntry("X-KDE-PluginInfo-Name", name);
    group.writeEntry("X-KDE-PluginInfo-Version", theme.version());
    group.writeEntry("X-KDE-PluginInfo-Author", theme.author());
    group.writeEntry("X-KDE-PluginInfo-Email", theme.authorEmail());
    group.writeEntry("X-KDE-PluginInfo-Website", theme.homepage());
    group.writeEntry("X-KDE-PluginInfo-License", theme.license());
    group.writeEntry("X-KDE-PluginInfo-Category", "SuperKaramba");
    group.writeEntry("X-KDE-PluginInfo-EnabledByDefault", "true");

    // the SkAppletScript ScriptEngine implementation is responsible for our new applet.
    group.writeEntry("X-Plasma-API", "superkaramba");
    // it is an applet.
    group.writeEntry("X-Plasma-ComponentTypes", "Applet");
    // the SkPackage PackageStructure implementation is responsible for the applets package format.
    group.writeEntry("X-Plasma-PackageFormat", "superkaramba");

    group.sync();

    // rebuild the cache to let e.g. Plasma know about our new desktop-file.
    //FIXME would be better if we just let plasma know about the new desktop-file and let it add on the fly without using the sycoca
    QDBusMessage msg = QDBusMessage::createSignal("/", "org.kde.KSycoca", "notifyDatabaseChanged" );
    msg << QStringList();
    if( QDBusConnection::sessionBus().isConnected() )
        QDBusConnection::sessionBus().send(msg);
#endif
    return true;
}
コード例 #29
0
void GBMJDesktopController::DisplayHu(unsigned char chSite,const unsigned char *data,unsigned char chLen)
{
    djDebug()<<"GBMJDesktopController::DisplayHu"<<"seat"<<chSite<<"len"<<chLen;
    DebugBuffer( (const char*)data, chLen );
    unsigned char ch;
    QString strName;
    DJGraphicsPixmapItem *item;
    DJGraphicsTextItem	*itemText;
    QPixmap			pix;
    QFont			font;
    int x,y,i;

    for ( int i = 0; i <= panelController()->numberOfSeats(); ++i ) {
        clearSeatTypeItems(i,0);
    }

    DJGameUser *user	= panelController()->player( chSite );
    if ( user )
        strName	= user->userName();
    else
        strName	= tr("no name");
    if(data[0] == chSite || data[0] == 0 || data[0]>4)
    {
        strName+= tr("zi mo");
        strName += tr("hu");
    } else
    {
        strName += tr("hu");
        strName += QString(" , ");
        DJGameUser *dianpao	= panelController()->player( data[0] );
        if ( dianpao )
            strName	+= dianpao->userName();
        else
            strName	+= tr("no name");
        strName += tr("dian pao");
    }
    //itemText = new DJGameTextItem(strName,canvas(),m,0x01,0x01,DJGAME_DESKTOP_TYPE_HU_TEXT,false);
    itemText	= new DJGraphicsTextItem(strName, 0, desktop()->scene());
    appendSeatTypeItem(chSite,DJGAME_DESKTOP_TYPE_HU_TEXT,itemText);
    font = itemText->font();
    font.setPointSize(28);
    font.setBold(true);
    itemText->setFont(font);
    int h;
    pix = GetView1Card(1,false,false,&h);
    GetDesktopCenterPoint(&x,&y,NULL);
    x -= (7*pix.width());
    y = DJGAME_MAHJONG_DESKTOP_AVATAR_MAXHEIGHT+20;
    itemText->setZValue(3000);
    itemText->setVirtualPos( QPointF(x,y) );
    itemText->setMatrix( desktop()->scaleMatrix() );
    itemText->adjustPos( desktop()->totalMatrix() );
    itemText->show();
    y += 50;

    DJGraphicsPixmapItem *huit = NULL;
    if(data[2]>0)
    {
        djDebug()<<"data[2]="<<hex<<data[2];
        for(i=0; i<data[2]; i++)
        {
            djDebug()<<"card="<<hex<<(data[3+i]&0x3F);
            pix = GetView1Card((data[3+i]&0x3F),false,false,&h);
            item = new DJGraphicsPixmapItem(pix, 0, desktop()->scene());
            appendSeatTypeItem(chSite,DJGAME_DESKTOP_TYPE_HU_CARD,item);
            if((data[3+i]&0x3F) == (data[1] & 0x3F))
                huit = item;
            item->setZValue(3000);
            item->setVirtualPos( QPointF(x,y) );
            item->setMatrix( desktop()->scaleMatrix() );
            item->adjustPos( desktop()->totalMatrix() );
            item->show();
            x += pix.width();
        }
        if(huit != NULL)
            huit->setDJSelected(true);
        ch = data[2]+3;
        GetDesktopCenterPoint(&x,NULL,NULL);
        y += pix.height()+20;
        i=0;
        QString str;
        font.setPointSize(24);
        while(data[ch] != 0 && ch<chLen)
        {
            str = tr(fanNames[data[ch]]);
            //itemText = new DJGameTextItem(str,canvas(),m,0x01,0x01,DJGAME_DESKTOP_TYPE_HU_TEXT,false);
            itemText	= new DJGraphicsTextItem(str, 0, desktop()->scene());
            appendSeatTypeItem(chSite,DJGAME_DESKTOP_TYPE_HU_TEXT,itemText);
            itemText->setFont(font);
            itemText->setAlignment(Qt::AlignRight);
            itemText->setZValue(3000);
            itemText->setVirtualPos( QPointF(x,y) );
            itemText->setMatrix( desktop()->scaleMatrix() );
            itemText->adjustPos( desktop()->totalMatrix() );
            itemText->show();

            str = QString(" : %1 ").arg(data[ch+1])+ tr("fan");
            //itemText = new DJGameTextItem(str,canvas(),m,0x01,0x01,DJGAME_DESKTOP_TYPE_HU_TEXT,false);
            itemText	= new DJGraphicsTextItem(str, 0, desktop()->scene());
            appendSeatTypeItem(chSite,DJGAME_DESKTOP_TYPE_HU_TEXT,itemText);
            itemText->setFont(font);
            i+=data[ch+1];
            itemText->setZValue(3000);
            itemText->setVirtualPos( QPointF(x,y) );
            itemText->setMatrix( desktop()->scaleMatrix() );
            itemText->adjustPos( desktop()->totalMatrix() );
            itemText->show();
            y+=30;

            ch+=2;
        }
        str = tr("total");
        //itemText = new DJGameTextItem(str,canvas(),m,0x01,0x01,DJGAME_DESKTOP_TYPE_HU_TEXT,false);
        itemText	= new DJGraphicsTextItem(str, 0, desktop()->scene());
        appendSeatTypeItem(chSite,DJGAME_DESKTOP_TYPE_HU_TEXT,itemText);
        itemText->setFont(font);
        itemText->setAlignment(Qt::AlignRight);
        itemText->setZValue(3000);
        itemText->setVirtualPos( QPointF(x,y) );
        itemText->setMatrix( desktop()->scaleMatrix() );
        itemText->adjustPos( desktop()->totalMatrix() );
        itemText->show();

        str = QString(" : %1 ").arg(i)+tr("fan");
        //itemText = new DJGameTextItem(str,canvas(),m,0x01,0x01,DJGAME_DESKTOP_TYPE_HU_TEXT,false);
        itemText	= new DJGraphicsTextItem(str, 0, desktop()->scene());
        appendSeatTypeItem(chSite,DJGAME_DESKTOP_TYPE_HU_TEXT,itemText);
        itemText->setFont(font);
        itemText->setZValue(3000);
        itemText->setVirtualPos( QPointF(x,y) );
        itemText->setMatrix( desktop()->scaleMatrix() );
        itemText->adjustPos( desktop()->totalMatrix() );
        itemText->show();
    }
}
コード例 #30
0
GBMJDesktopController::GBMJDesktopController( DJPanelController* panelController, const QSize& size, QWidget *parent )
    : DJDesktopMJController(panelController,size,parent)
{
    djDebug()<<"GBMJDesktopController constructor"<<size;

    PMahjongRoom pmjroom = (PMahjongRoom)((panelController->gameRoom())->privateRoom());
    SetRule(&(pmjroom->rule));

    m_toolbar	= new QWidget(desktop());
    QHBoxLayout *layout	= new QHBoxLayout( m_toolbar );
    layout->setMargin( 0 );
    layout->setSpacing( 0 );

    m_style = new QToolButton;
    m_style->setEnabled(true);
    m_style->setToolTip(tr("change style of pool cards"));
    m_style->setIcon( QIcon(":/BaseRes/image/desktop/toolbutton/arrange.png") );
    m_style->setIconSize( djToolButtonSize );
    connect(m_style,SIGNAL(clicked()),this,SLOT(ClickStyle()));
    layout->addWidget( m_style );

    m_qi = new QToolButton;
    m_qi->setEnabled(false);
    m_qi->setToolTip(tr("pass"));
    m_qi->setIcon( QIcon(":/BaseRes/image/desktop/toolbutton/qi.png") );
    m_qi->setIconSize( djToolButtonSize );
    connect(m_qi,SIGNAL(clicked()),this,SLOT(ClickQi()));
    layout->addWidget( m_qi );

    m_chu = new QToolButton;
    m_chu->setEnabled(false);
    m_chu->setToolTip(tr("throw a card"));
    m_chu->setIcon( QIcon(":/BaseRes/image/desktop/toolbutton/chu.png") );
    m_chu->setIconSize( djToolButtonSize );
    connect(m_chu,SIGNAL(clicked()),this,SLOT(ClickChu()));
    layout->addWidget( m_chu );

    m_chi = new QToolButton;
    m_chi->setEnabled(false);
    m_chi->setToolTip(tr("chi a card"));
    m_chi->setIcon( QIcon(":/BaseRes/image/desktop/toolbutton/chi.png") );
    m_chi->setIconSize( djToolButtonSize );
    connect(m_chi,SIGNAL(clicked()),this,SLOT(ClickChi()));
    layout->addWidget( m_chi );

    m_peng = new QToolButton;
    m_peng->setEnabled(false);
    m_peng->setToolTip(tr("peng a card"));
    m_peng->setIcon( QIcon(":/BaseRes/image/desktop/toolbutton/peng.png") );
    m_peng->setIconSize( djToolButtonSize );
    connect(m_peng,SIGNAL(clicked()),this,SLOT(ClickPeng()));
    layout->addWidget( m_peng );

    m_gang = new QToolButton;
    m_gang->setEnabled(false);
    m_gang->setToolTip(tr("gang a card"));
    m_gang->setIcon( QIcon(":/BaseRes/image/desktop/toolbutton/gang.png") );
    m_gang->setIconSize( djToolButtonSize );
    connect(m_gang,SIGNAL(clicked()),this,SLOT(ClickGang()));
    layout->addWidget( m_gang );

    m_ting = new QToolButton;
    m_ting->setEnabled(false);
    m_ting->setToolTip(tr("ready to hu"));
    m_ting->setIcon( QIcon(":/BaseRes/image/desktop/toolbutton/ting.png") );
    m_ting->setIconSize( djToolButtonSize );
    connect(m_ting,SIGNAL(clicked()),this,SLOT(ClickTing()));
    layout->addWidget( m_ting );

    m_hu = new QToolButton;
    m_hu->setEnabled(false);
    m_hu->setToolTip(tr("hu"));
    m_hu->setIcon( QIcon(":/BaseRes/image/desktop/toolbutton/hu.png") );
    m_hu->setIconSize( djToolButtonSize );
    connect(m_hu,SIGNAL(clicked()),this,SLOT(ClickHu()));
    layout->addWidget( m_hu );

    c_bReqTing = false;

    StaticInitDesktop();
}