#include #include "rqmainwindow.h" #include #include #include #include #include #include #include #include #include #include RQMainWindow::RQMainWindow(RPackageLister *lister) :KMainWindow(0,"Kynaptic"), m_view(new RQMainWindow_View(this,this,lister)) { // tell the KMainWindow that this is indeed the main widget setCentralWidget(m_view); // then, setup our actions setupActions(); // and a status bar statusBar()->show(); // apply the saved mainwindow settings, if any, and ask the mainwindow // to automatically save settings if changed: window size, toolbar // position, icon size, etc. setAutoSaveSettings(); // allow the view to change the statusbar and caption connect(m_view, SIGNAL(signalChangeStatusbar(const QString&)), this, SLOT(changeStatusbar(const QString&))); connect(m_view, SIGNAL(signalChangeCaption(const QString&)), this, SLOT(changeCaption(const QString&))); m_view->restoreState(); //m_view->show(); show(); } void RQMainWindow::setupActions() { //definition of the STANDARD KDE actions KStdAction::quit(kapp, SLOT(quit()), actionCollection()); m_toolbarAction = KStdAction::showToolbar(this, SLOT(optionsShowToolbar()), actionCollection()); m_statusbarAction = KStdAction::showStatusbar(this, SLOT(optionsShowStatusbar()), actionCollection()); KStdAction::keyBindings(this, SLOT(optionsConfigureKeys()), actionCollection()); KStdAction::configureToolbars(this, SLOT(optionsConfigureToolbars()), actionCollection()); KStdAction::preferences(this, SLOT(optionsPreferences()), actionCollection()); KStdAction::undo(m_view, SLOT(undo()), actionCollection()); KStdAction::redo(m_view, SLOT(redo()), actionCollection()); KStdAction::find(m_view, SLOT(findPackage()), actionCollection()); // Specific Kynaptic action KIconLoader *loader = KGlobal::iconLoader(); KAction *ImportMarksAction = new KAction(i18n("&Import Marked Changes..."), 0, m_view, SLOT(importMarks()),actionCollection(), "ImportMarks_action"); KAction *ExportMarksAction = new KAction(i18n("&Export Marked Changes..."), 0, m_view, SLOT(exportMarks()),actionCollection(), "ExportMarks_action"); KAction *CommitAction = new KAction(i18n("&Commit Changes"),QIconSet(loader->loadIcon("proceed.png",KIcon::User)) , 0, m_view, SLOT(commitChanges()),actionCollection(), "Commit_action"); KAction *UpgradeAction = new KAction(i18n("&Upgrade All Packages..."), QIconSet(loader->loadIcon("distupgrade.png",KIcon::User)),0, m_view, SLOT(distUpgrade()),actionCollection(), "Upgrade_action"); KAction *RefreshAction = new KAction(i18n("&Refresh Package Information") , QIconSet(loader->loadIcon("update.png",KIcon::User)) , 0 , m_view, SLOT(refreshCache()),actionCollection(), "Refresh_action"); KAction *FixBrokenAction = new KAction(i18n("&Fix Broken Packages..."), 0, m_view, SLOT(fixBroken()),actionCollection(), "FixBroken_action"); KAction *FiltersAction = new KAction(i18n("F&ilters..."), 0, m_view, SLOT(editFilters()),actionCollection(), "Filters_action"); createGUI(); } void RQMainWindow::optionsShowToolbar() { // this is all very cut and paste code for showing/hiding the // toolbar if (m_toolbarAction->isChecked()) toolBar()->show(); else toolBar()->hide(); } void RQMainWindow::optionsShowStatusbar() { // this is all very cut and paste code for showing/hiding the // statusbar if (m_statusbarAction->isChecked()) statusBar()->show(); else statusBar()->hide(); } void RQMainWindow::optionsConfigureKeys() { KKeyDialog::configure(actionCollection()); } void RQMainWindow::optionsConfigureToolbars() { // use the standard toolbar editor #if defined(KDE_MAKE_VERSION) # if KDE_VERSION >= KDE_MAKE_VERSION(3,1,0) saveMainWindowSettings(KGlobal::config(), autoSaveGroup()); # else saveMainWindowSettings(KGlobal::config()); # endif #else saveMainWindowSettings(KGlobal::config()); #endif } void RQMainWindow::newToolbarConfig() { // this slot is called when user clicks "Ok" or "Apply" in the toolbar editor. // recreate our GUI, and re-apply the settings (e.g. "text under icons", etc.) createGUI(); #if defined(KDE_MAKE_VERSION) # if KDE_VERSION >= KDE_MAKE_VERSION(3,1,0) applyMainWindowSettings(KGlobal::config(), autoSaveGroup()); # else applyMainWindowSettings(KGlobal::config()); # endif #else applyMainWindowSettings(KGlobal::config()); #endif } void RQMainWindow::changeStatusbar(const QString& text) { // display the text on the statusbar statusBar()->message(text); } void RQMainWindow::changeCaption(const QString& text) { // display the text on the caption setCaption(text); } // Fix buttons in the toolbar. Right now qt-designer is // saving buttons in XPM format. // _refreshButton->setPixmap(RQPixmaps::find("update.png")); // _upgradeButton->setPixmap(RQPixmaps::find("distupgrade.png")); // _commitButton->setPixmap(RQPixmaps::find("proceed.png")); // vim:ts=3:sw=3:et