void KMSystemTray::buildPopupMenu() { // Delete any previously created popup menu delete mPopupMenu; mPopupMenu = 0; mPopupMenu = new KPopupMenu(); KMMainWidget * mainWidget = kmkernel->getKMMainWidget(); if ( !mainWidget ) return; mPopupMenu->insertTitle(*(this->pixmap()), "KMail"); KAction * action; if ( ( action = mainWidget->action("check_mail") ) ) action->plug( mPopupMenu ); if ( ( action = mainWidget->action("check_mail_in") ) ) action->plug( mPopupMenu ); if ( ( action = mainWidget->action("send_queued") ) ) action->plug( mPopupMenu ); if ( ( action = mainWidget->action("send_queued_via") ) ) action->plug( mPopupMenu ); mPopupMenu->insertSeparator(); if ( ( action = mainWidget->action("new_message") ) ) action->plug( mPopupMenu ); if ( ( action = mainWidget->action("kmail_configure_kmail") ) ) action->plug( mPopupMenu ); mPopupMenu->insertSeparator(); KMainWindow *mainWin = ::qt_cast<KMainWindow*>(kmkernel->getKMMainWidget()->topLevelWidget()); if(mainWin) if ( ( action=mainWin->actionCollection()->action("file_quit") ) ) action->plug( mPopupMenu ); }
int main(int argc, char *argv[]) { KAboutData aboutData("orario", 0, ki18n("Orario"), "0.1", ki18n("Description"), KAboutData::License_GPL, ki18n("(c) 2008 Riccardo Iaconelli"), KLocalizedString(), "", "*****@*****.**"); aboutData.addAuthor(ki18n("Riccardo Iaconelli"), KLocalizedString(), "*****@*****.**"); KCmdLineArgs::init(argc, argv, &aboutData); KCmdLineOptions options; KCmdLineArgs::addCmdLineOptions(options); KCmdLineArgs::parsedArgs(); KApplication app; KMainWindow *wi = new KMainWindow; QWidget *w = new QWidget; Ui::Form ui; ui.setupUi(w); wi->setCentralWidget(w); wi->show(); return app.exec(); }
int main(int argc, char *argv[]) { KAboutData aboutData("PTT", 0, ki18n("Plasma Theme Tester"), "0.1", ki18n("Description"), KAboutData::License_GPL, ki18n("(c) 2008 Riccardo Iaconelli"), KLocalizedString(), "", "*****@*****.**"); aboutData.addAuthor(ki18n("Riccardo Iaconelli"), KLocalizedString(), "*****@*****.**"); KCmdLineArgs::init(argc, argv, &aboutData); KCmdLineOptions options; KCmdLineArgs::addCmdLineOptions(options); KCmdLineArgs::parsedArgs(); KApplication app; Ui::MainWindow ui; KMainWindow *mw = new KMainWindow; ui.setupUi(mw); // set all the properties... ui.background->setType("background"); mw->show(); return app.exec(); }
void PartManualTest::testShortcutOverride() { // FIXME: This test asks the user to press shortcut key sequences manually because // the result is different than when sending the key press via QTest::keyClick() // // When the key presses are sent manually, Konsole::TerminalDisplay::event() is called // and the overrideShortcut() signal is emitted by the part. // When the key presses are sent automatically, the shortcut is triggered but // Konsole::TerminalDisplay::event() is not called and the overrideShortcut() signal is // not emitted by the part. // Create a main window with a menu and a test // action with a shortcut set to Ctrl+S, which is also used by the terminal KMainWindow* mainWindow = new KMainWindow(); QMenu* fileMenu = mainWindow->menuBar()->addMenu("File"); QAction* testAction = fileMenu->addAction("Test"); testAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_S)); connect(testAction, SIGNAL(triggered()), this, SLOT(shortcutTriggered())); // Create terminal part and embed in into the main window KParts::Part* terminalPart = createPart(); QVERIFY(terminalPart); mainWindow->setCentralWidget(terminalPart->widget()); TerminalInterface* terminal = qobject_cast<TerminalInterface*>(terminalPart); QVERIFY(terminal); terminal->sendInput("Press Ctrl+S twice.\n"); mainWindow->show(); // Test shortcut with override disabled, so the shortcut will be triggered _shortcutTriggered = false; _override = false; _overrideCalled = false; QVERIFY(connect(terminalPart, SIGNAL(overrideShortcut(QKeyEvent*,bool&)), this, SLOT(overrideShortcut(QKeyEvent*,bool&)))); //QTest::keyClick(terminalPart->widget(),Qt::Key_S,Qt::ControlModifier); _shortcutEventLoop = new QEventLoop(); _shortcutEventLoop->exec(); QVERIFY(_overrideCalled); QVERIFY(_shortcutTriggered); QVERIFY(!_override); // Test shortcut with override enabled, so the shortcut will not be triggered _override = true; _overrideCalled = false; _shortcutTriggered = false; //QTest::keyClick(terminalPart->widget(),Qt::Key_S,Qt::ControlModifier); _shortcutEventLoop->exec(); QVERIFY(_overrideCalled); QVERIFY(!_shortcutTriggered); QVERIFY(_override); delete _shortcutEventLoop; delete terminalPart; delete mainWindow; }
KStatusBar * StatusBarExtension::statusBar() const { if ( !d->m_statusBar ) { KParts::ReadOnlyPart* part = qobject_cast<KParts::ReadOnlyPart*>(parent()); QWidget* w = part ? part->widget() : 0; KMainWindow* mw = w ? qobject_cast<KMainWindow *>( w->topLevelWidget() ) : 0; if ( mw ) d->m_statusBar = mw->statusBar(); } return d->m_statusBar; }
bool EventFilter::eventFilter(QObject *obj, QEvent *event) { Q_UNUSED(obj); if (event->type() == QEvent::Close) { m_mainWindow->close(); return true; } else if (event->type() == QEvent::Show) { m_mainWindow->show(); return true; } else if (event->type() == QEvent::Hide) { m_mainWindow->hide(); return true; } return false; }
int main( int argc, char **argv ) { KApplication app( argc, argv, "kxmlguitest" ); // KXMLGUIClient looks in the "data" resource for the .rc files // Let's add $PWD (ideally $srcdir instead...) to it KGlobal::dirs()->addResourceDir( "data", QDir::currentDirPath() ); KMainWindow *mainwindow = new KMainWindow; QLineEdit* line = new QLineEdit( mainwindow ); mainwindow->setCentralWidget( line ); mainwindow->show(); KXMLGUIBuilder *builder = new KXMLGUIBuilder( mainwindow ); KXMLGUIFactory *factory = new KXMLGUIFactory( builder ); Client *shell = new Client; shell->setInstance( new KInstance( "konqueror" ) ); shell->instance()->dirs()->addResourceDir( "data", QDir::currentDirPath() ); (void)new KAction( "Split", "view_left_right", 0, 0, 0, shell->actionCollection(), "splitviewh" ); shell->setXMLFile( "./kxmlguitest_shell.rc" ); factory->addClient( shell ); Client *part = new Client; (void)new KAction( "decfont", "viewmag-", 0, 0, 0, part->actionCollection(), "decFontSizes" ); (void)new KAction( "sec", "unlock", Qt::ALT + Qt::Key_1, part, SLOT( slotSec() ), part->actionCollection(), "security" ); part->setXMLFile( "./kxmlguitest_part.rc" ); factory->addClient( part ); for ( int i = 0; i < 10; ++i ) { factory->removeClient( part ); factory->addClient( part ); } return app.exec(); }
void Glossary::rebuildGlossaryCache() { KMainWindow *mainWindow = dynamic_cast<KMainWindow *>( kapp->mainWidget() ); Q_ASSERT( mainWindow ); mainWindow->statusBar()->message( i18n( "Rebuilding cache..." ) ); KProcess *meinproc = new KProcess; connect( meinproc, SIGNAL( processExited( KProcess * ) ), this, SLOT( meinprocExited( KProcess * ) ) ); *meinproc << locate( "exe", QString::fromLatin1( "meinproc" ) ); *meinproc << QString::fromLatin1( "--output" ) << m_cacheFile; *meinproc << QString::fromLatin1( "--stylesheet" ) << locate( "data", QString::fromLatin1( "khelpcenter/glossary.xslt" ) ); *meinproc << m_sourceFile; meinproc->start( KProcess::NotifyOnExit ); }
void Glossary::meinprocExited( KProcess *meinproc ) { delete meinproc; if ( !QFile::exists( m_cacheFile ) ) return; m_config->writePathEntry( "CachedGlossary", m_sourceFile ); m_config->writeEntry( "CachedGlossaryTimestamp", glossaryCTime() ); m_config->sync(); m_status = CacheOk; KMainWindow *mainWindow = dynamic_cast<KMainWindow *>( kapp->mainWidget() ); Q_ASSERT( mainWindow ); mainWindow->statusBar()->message( i18n( "Rebuilding cache... done." ), 2000 ); buildGlossaryTree(); }
void KVerbosApp::slotFileQuit() { slotStatusMsg(i18n("Exiting...")); saveOptions(); // close the first window, the list makes the next one the first again. // This ensures that queryClose() is called on each window to ask for closing KMainWindow* w; // In der Dokumentation konnte ich leider nicht finden, wozu diese memberliste gut ist. if(memberList) { for(w=memberList->first(); w!=0; w=memberList->next()) { // only close the window if the closeEvent is accepted. If the user presses Cancel on the saveModified() dialog, // the window and the application stay open. if(!w->close()) break; } } slotStatusMsg(i18n("Ready.")); }
void KMouthApp::slotFileQuit() { slotStatusMsg(i18nc("Shutting down the application", "Exiting...")); saveOptions(); // close the first window, the list makes the next one the first again. // This ensures that queryClose() is called on each window to ask for closing KMainWindow* w; if (!memberList().isEmpty()) { for (int i = 0; i < memberList().size(); ++i) { // only close the window if the closeEvent is accepted. If the user presses Cancel on the saveModified() dialog, // the window and the application stay open. w = memberList().at(i); if (!w->close()) break; #ifdef __GNUC__ #warning "kde4: how remove it ?.???" #endif //memberList()->removeRef(w); } } }
/** * if centralWidget() is a QTabWidget an instance of KTabbedMainWindow will be created * @param other * @return */ KMainWindow *KMainWindowFactory::create(QMainWindow *other) { KMainWindow *mainWindow = 0; if (other->isVisible()) other->hide(); if (other->inherits("KMainWindow")) { qWarning() << QObject::tr("Can't create a KMainWindow from KMainWindow"); return static_cast<KMainWindow *>(other); } if (QWidget *central = other->centralWidget()) { if (QTabWidget *tabWidget = dynamic_cast<QTabWidget *>(central)) { mainWindow = new KTabbedMainWindow; static_cast<KTabbedMainWindow *>(mainWindow)->setTabWidget(tabWidget); } else { mainWindow = new KMainWindow; central->setParent(mainWindow); mainWindow->setCentralWidget(central); } } QList<QDockWidget *> docks = other->findChildren<QDockWidget *>(); foreach (QDockWidget *dock, docks) { dock->widget()->setWindowTitle(dock->windowTitle()); dock->widget()->setWindowIcon(dock->windowIcon()); Qt::DockWidgetArea area = other->dockWidgetArea(dock); if (area == 0) area = Qt::LeftDockWidgetArea; mainWindow->addToolView(dock->widget(), area); }
int main(int argc, char **argv) { QString aboutText("KDE- und Qt-Programmierung\n(c) 2000 Addison-Wesley Germany"); KCmdLineArgs::init(argc, argv, "kexample", aboutText, "1.0"); KApplication app; KMainWindow *top = new KMainWindow(0); QPopupMenu *filePopup = new QPopupMenu(top); KAction *quitAction; quitAction = KStdAction::quit(&app, SLOT(quit())); quitAction->plug(filePopup); top->menuBar()->insertItem(i18n("&File"), filePopup); top->menuBar()->insertSeparator(); top->menuBar()->insertItem(i18n("&Help"), top->helpMenu()); QLabel *text = new QLabel(i18n("<h1>Hello, world!</h1>"), top); top->setCentralWidget(text); top->show(); return app.exec(); }
int main(int argc, char **argv) { KAboutData about(QByteArray("ktechlab"), QByteArray("KTechLab Icon Tester"), ki18n("KTechLab Icon Tester"), VERSION, ki18n(description), KAboutData::License_GPL, ki18n("(C) 2003-2009, The KTechLab developers"), ki18n(""), "http://ktechlab.org", "*****@*****.**" ); KCmdLineArgs::init(argc, argv, &about); KApplication testLoadedIconsApp; KMainWindow *mainWnd = new KMainWindow; QScrollArea *mainWidget = new QScrollArea; QWidget *tableWidget = new QWidget; mainWidget->setWidget(tableWidget); mainWidget->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn); mainWidget->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); mainWidget->setWidgetResizable(true); QGridLayout *mainLayout = new QGridLayout; tableWidget->setLayout(mainLayout); mainWnd->setCentralWidget(mainWidget); const int iconCount = sizeof(iconNames)/sizeof(iconNames[0]); for (int iconNr = 0; iconNr < iconCount; ++iconNr) { addIcon(mainLayout, iconNames[iconNr]); } // TODO add assertion if all icons have been properly loaded /* addIcon(mainLayout, "asd"); addIcon(mainLayout, "rotate_cw"); addIcon(mainLayout, "rotate_ccw"); addIcon(mainLayout, "text"); addIcon(mainLayout, "rotate"); addIcon(mainLayout, "player_play"); addIcon(mainLayout, "player_pause"); addIcon(mainLayout, "stop"); addIcon(mainLayout, "reload"); addIcon(mainLayout, "ktechlab_circuit"); addIcon(mainLayout, "fork"); addIcon(mainLayout, "convert_to_microbe"); addIcon(mainLayout, "convert_to_assembly"); addIcon(mainLayout, "convert_to_hex"); addIcon(mainLayout, "convert_to_pic"); addIcon(mainLayout, "down"); addIcon(mainLayout, "button_cancel"); addIcon(mainLayout, "folder"); addIcon(mainLayout, "template-source"); addIcon(mainLayout, "source_c"); addIcon(mainLayout, "ktechlab_circuit"); addIcon(mainLayout, "ktechlab_flowcode"); addIcon(mainLayout, "exec"); addIcon(mainLayout, "oscilloscope"); */ /* { KIcon testIcon("foo"); QPixmap testPixmap = testIcon.pixmap(64, 64); QLabel *ql = new QLabel; ql->setPixmap(testPixmap); ql->setIconText("label text"); mainLayout->addWidget(ql, 1, 1); QLabel *qt = new QLabel; qt->setText("asd"); mainLayout->addWidget(qt, 1, 2); } */ mainWnd->show(); return testLoadedIconsApp.exec(); }
int main(int argc, char *argv[]) { KCmdLineArgs::init(argc, argv, "Testkhtml", "a basic web browser using the KHTML library", "1.0"); KCmdLineArgs::addCmdLineOptions(options); KApplication a; KCmdLineArgs *args = KCmdLineArgs::parsedArgs( ); if ( args->count() == 0 ) { KCmdLineArgs::usage(); ::exit( 1 ); } KHTMLFactory *fac = new KHTMLFactory(); KMainWindow *toplevel = new KMainWindow(); KHTMLPart *doc = new KHTMLPart( toplevel, 0, toplevel, 0, KHTMLPart::BrowserViewGUI ); Dummy *dummy = new Dummy( doc ); QObject::connect( doc->browserExtension(), SIGNAL( openURLRequest( const KURL &, const KParts::URLArgs & ) ), dummy, SLOT( slotOpenURL( const KURL&, const KParts::URLArgs & ) ) ); if (args->url(0).url().right(4).find(".xml", 0, false) == 0) { KParts::URLArgs ags(doc->browserExtension()->urlArgs()); ags.serviceType = "text/xml"; doc->browserExtension()->setURLArgs(ags); } doc->openURL( args->url(0) ); // DOMTreeView * dtv = new DOMTreeView(0, doc, "DomTreeView"); // dtv->show(); toplevel->setCentralWidget( doc->widget() ); toplevel->resize( 640, 800); // dtv->resize(toplevel->width()/2, toplevel->height()); QDomDocument d = doc->domDocument(); QDomElement viewMenu = d.documentElement().firstChild().childNodes().item( 2 ).toElement(); QDomElement e = d.createElement( "action" ); e.setAttribute( "name", "debugRenderTree" ); viewMenu.appendChild( e ); e = d.createElement( "action" ); e.setAttribute( "name", "debugDOMTree" ); viewMenu.appendChild( e ); QDomElement toolBar = d.documentElement().firstChild().nextSibling().toElement(); e = d.createElement( "action" ); e.setAttribute( "name", "reload" ); toolBar.insertBefore( e, toolBar.firstChild() ); e = d.createElement( "action" ); e.setAttribute( "name", "print" ); toolBar.insertBefore( e, toolBar.firstChild() ); (void)new KAction( "Reload", "reload", Qt::Key_F5, dummy, SLOT( reload() ), doc->actionCollection(), "reload" ); KAction* kprint = new KAction( "Print", "print", 0, doc->browserExtension(), SLOT( print() ), doc->actionCollection(), "print" ); kprint->setEnabled(true); toplevel->guiFactory()->addClient( doc ); doc->setJScriptEnabled(true); doc->setJavaEnabled(true); doc->setURLCursor(QCursor(Qt::PointingHandCursor)); a.setTopWidget(doc->widget()); QWidget::connect(doc, SIGNAL(setWindowCaption(const QString &)), doc->widget(), SLOT(setCaption(const QString &))); doc->widget()->show(); toplevel->show(); ((QScrollView *)doc->widget())->viewport()->show(); int ret = a.exec(); //delete doc; //delete dtv; khtml::Cache::clear(); khtml::CSSStyleSelector::clear(); khtml::RenderStyle::cleanup(); delete fac; return ret; }