CustomFileDialog::CustomFileDialog( QWidget* parent ) : QFileDialog( parent, 0, false ) { QToolButton *p = new QToolButton( this ); p->setPixmap( QPixmap( globalbookmark_xpm ) ); QToolTip::add( p, tr( "Bookmarks" ) ); bookmarkMenu = new QPopupMenu( this ); connect( bookmarkMenu, SIGNAL( activated( int ) ), this, SLOT( bookmarkChosen( int ) ) ); addId = bookmarkMenu->insertItem( "Add bookmark" ); clearId = bookmarkMenu->insertItem( QPixmap(folder_trash), "Clear bookmarks" ); bookmarkMenu->insertSeparator(); p->setPopup( bookmarkMenu ); p->setPopupDelay(0); addToolButton( p, true ); QToolButton *b = new QToolButton( this ); QToolTip::add( b, tr( "Go Home!" ) ); b->setPixmap( QPixmap( homepage_xpm ) ); connect( b, SIGNAL( clicked() ), this, SLOT( goHome() ) ); addToolButton( b ); }
CAdministrationWindow::CAdministrationWindow(QWidget* parent, CMySQLServer *m) : CMyWindow(parent, "CAdministrationWindow") { (void)statusBar(); blocked = false; myApp()->incCritical(); setCaption("[" + m->connectionName() + "] " + trUtf8("Administration Panel")); setIcon(getPixmapIcon("applicationIcon")); enableMessageWindow(true); if (!m->oneConnection()) { m_mysql = new CMySQLServer(m->connectionName(), messagePanel()); m_mysql->connect(); delete_mysql = true; } else { m_mysql = m; //POSIBLE BUG ... need to make m_mysql redirect messages & errors to this->messagePanel() also. Currently they are in consoleWindow() //probably need to disable the timer ! delete_mysql = false; } setCentralWidget( new QWidget( this, "qt_central_widget")); CAdministrationWindowLayout = new QGridLayout( centralWidget(), 1, 1, 4, 2, "CAdministrationWindowLayout"); tabWidget = new QTabWidget( centralWidget(), "tabWidget"); processList = new CProcessListTable(tabWidget, m_mysql); tabWidget->insertTab(processList, getPixmapIcon("showProcessListIcon"), tr("Process List"), SHOW_PROCESSLIST); status = new CServerStatusTable(tabWidget, m_mysql); tabWidget->insertTab(status, getPixmapIcon("showStatusIcon"), tr("Status"), SHOW_STATUS); variables = new CShowServerVariables(tabWidget, m_mysql); tabWidget->insertTab(variables, getPixmapIcon("showVariablesIcon"), tr("Variables"), SHOW_VARIABLES); save_menu = new QPopupMenu(this); connect(save_menu, SIGNAL(activated(int)), this, SLOT(save(int))); save_menu->insertItem(getPixmapIcon("showProcessListIcon"), tr("&Process List"), MENU_SAVE_PROCESSLIST); save_menu->insertItem(getPixmapIcon("showStatusIcon"), tr("&Status"), MENU_SAVE_STATUS); save_menu->insertItem(getPixmapIcon("showVariablesIcon"), tr("&Variables"), MENU_SAVE_VARIABLES); save_menu->insertItem(tr("&InnoDB Status"), MENU_SAVE_INNODB_STATUS); has_innodb = CInnoDBStatus::hasInnoDB(m_mysql); if (has_innodb) { innoDBStatus = new CInnoDBStatus(tabWidget, m_mysql); tabWidget->insertTab(innoDBStatus, tr("InnoDB Status"), SHOW_INNODB_STATUS); } else save_menu->setItemEnabled(MENU_SAVE_INNODB_STATUS, false); CAdministrationWindowLayout->addWidget( tabWidget, 0, 0 ); viewShowMessagesAction = new CAction (tr("Show Messages"), tr("Show &Messages"), Qt::CTRL + Qt::Key_M, this, "fileShowMessagesAction", true); viewShowMessagesAction->setParentMenuText(tr("View")); connect(viewShowMessagesAction, SIGNAL(toggled(bool)), this, SLOT(showMessages(bool))); CAction * fileCloseAction = new CAction (tr("Close"), getPixmapIcon("closeIcon"), tr("&Close"), 0, this, "fileCloseAction"); fileCloseAction->setParentMenuText(tr("File")); connect(fileCloseAction, SIGNAL(activated()), this, SLOT(close())); fileRefreshAction = new CAction (tr("Refresh"), getPixmapIcon("refreshIcon"), tr("&Refresh"), Qt::Key_F5, this, "fileRefreshAction"); fileRefreshAction->setParentMenuText(tr("File")); connect(fileRefreshAction, SIGNAL(activated()), this, SLOT(refresh())); actionKillProcessAction = new CAction (tr("Kill Process"), getPixmapIcon("killProcessIcon"), tr("&Kill Process"), Qt::CTRL + Qt::Key_K, this, "actionKillProcessAction"); actionKillProcessAction->setParentMenuText(tr("Action")); connect(actionKillProcessAction, SIGNAL(activated()), this, SLOT(killProcesses())); CAction * actionPingAction = new CAction (tr("Ping"), getPixmapIcon("pingIcon"), tr("&Ping"), Qt::CTRL + Qt::Key_P, this, "actionPingAction"); actionPingAction->setParentMenuText(tr("Action")); connect(actionPingAction, SIGNAL(activated()), this, SLOT(ping())); CAction * actionShutdownAction = new CAction (tr("Shutdown"), getPixmapIcon("serverShutdownIcon"), tr("&Shutdown"), 0, this, "actionShutdownAction"); actionShutdownAction->setParentMenuText(tr("Action")); connect(actionShutdownAction, SIGNAL(activated()), this, SLOT(shutdown())); fileTimerAction = new CAction (tr("Start Refresh Timer"), getPixmapIcon("timerIcon"), tr("Start Refresh &Timer"), Qt::CTRL + Qt::Key_T, this, "fileTimerAction", true); fileTimerAction->setParentMenuText(tr("File")); connect(fileTimerAction, SIGNAL(toggled(bool)), this, SLOT(fileTimerActionToggled(bool))); QPopupMenu *fileMenu = new QPopupMenu(this); QPopupMenu *actionMenu = new QPopupMenu(this); QPopupMenu *viewMenu = new QPopupMenu(this); connect(viewMenu, SIGNAL(aboutToShow()), this, SLOT(viewMenuAboutToShow())); fileMenu->insertItem(getPixmapIcon("saveIcon"), tr("Save"), save_menu); fileMenu->insertSeparator(); fileRefreshAction->addTo(fileMenu); fileMenu->insertSeparator(); fileTimerAction->addTo(fileMenu); fileMenu->insertSeparator(); fileCloseAction->addTo(fileMenu); menuBar()->insertItem(tr("&File"), fileMenu); viewShowMessagesAction->addTo(viewMenu); menuBar()->insertItem(tr("&View"), viewMenu); actionKillProcessAction->addTo(actionMenu); flush_menu = flushMenu(m_mysql->mysql()); connect(flush_menu, SIGNAL(activated(int)), this, SLOT(flush(int))); actionMenu->insertItem(getPixmapIcon("flushIcon"),tr("Flush"), flush_menu); actionPingAction->addTo(actionMenu); actionMenu->insertSeparator(); actionShutdownAction->addTo(actionMenu); menuBar()->insertItem(tr("&Action"), actionMenu); new CHotKeyEditorMenu(this, menuBar(), "HotKeyEditor"); QToolBar * actionToolBar = new QToolBar(tr("Action Bar"), this, Top); QToolButton * saveTypeButton = new QToolButton(actionToolBar); saveTypeButton->setPopup(save_menu); saveTypeButton->setPixmap(getPixmapIcon("saveIcon")); saveTypeButton->setTextLabel(tr("Save"), true); saveTypeButton->setPopupDelay(0); actionToolBar->addSeparator(); actionKillProcessAction->addTo(actionToolBar); QToolButton * flushTypeButton = new QToolButton(actionToolBar); flushTypeButton->setPopup(flush_menu); flushTypeButton->setPixmap(getPixmapIcon("flushIcon")); flushTypeButton->setTextLabel(tr("Flush"), true); flushTypeButton->setPopupDelay(0); actionPingAction->addTo(actionToolBar); actionToolBar->addSeparator(); actionShutdownAction->addTo(actionToolBar); QToolBar * refreshToolBar = new QToolBar(tr("Refresh Bar"), this, Top ); fileRefreshAction->addTo(refreshToolBar); refreshToolBar->addSeparator(); QLabel * delayLabel = new QLabel(refreshToolBar, "delayLabel" ); delayLabel->setMinimumSize(QSize(65, 0)); delayLabel->setText(tr("Refresh Rate (sec)")); delay = new QSpinBox(refreshToolBar, "delayBox"); delay->setMinimumSize(QSize( 50, 0)); delay->setMaxValue(7200); delay->setMinValue(1); CConfig *cfg = new CConfig(); delay->setValue(cfg->readNumberEntry("Refresh Rate", 30)); status->setTraditionalMode(strtobool(cfg->readStringEntry("Status Traditional Mode", "true"))); delete cfg; status->refresh(); fileTimerAction->addTo(refreshToolBar); refreshTimer = new QTimer(this); connect(refreshTimer, SIGNAL(timeout()), this, SLOT(refresh())); connect(tabWidget, SIGNAL(currentChanged (QWidget *)), this, SLOT(tabChanged(QWidget *))); myResize(600, 400); }
//The main constructor. GofunWidget::GofunWidget(WFlags f) : QWidget(0,0,f) { //Set up some accelerators accel = new QAccel(this); //Do some layout magic QHBoxLayout* hbox = new QHBoxLayout(this); QVBoxLayout* vbox = new QVBoxLayout(); QHBoxLayout* hboxr = new QHBoxLayout(); QHBoxLayout* hboxlabel = new QHBoxLayout(); //This button group contains the buttons for the different directories cats_bg = new GofunVButtonGroup(this); cats_bg->setExclusive(true); cats_bg->setSizePolicy(QSizePolicy::Minimum,QSizePolicy::Expanding,false); connect(cats_bg, SIGNAL(clicked(int)),this, SLOT(changeDirectory(int))); //We 'load' this WidgetStack with GofunIconViews later on view_ws = new QWidgetStack(this); view_ws->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding,false); //It should be obvious what that is being QPushButton* quit = new QPushButton(tr("Quit"), this, "quit"); quit->setFont(QFont("Times", 18)); quit->setSizePolicy(QSizePolicy::Minimum,QSizePolicy::Minimum,false); connect(quit, SIGNAL(clicked()), qApp, SLOT(quit())); //The button marking your way to the settings-dialog QToolButton* config = new QToolButton(this); config->setPixmap(QPixmap("config.png")); QToolTip::add(config,tr("Settings")); connect(config, SIGNAL(clicked()),this, SLOT(openSettingsDlg())); //A helpful help-button QToolButton* help = new QToolButton(this); help->setPixmap(QPixmap("help.png")); QToolTip::add(help,tr("Help")); connect(help, SIGNAL(clicked()),this, SLOT(showHelp())); //Layout magic, basically we add the WidgetStack and a vertical box to the //top horizontal box hbox->addWidget(view_ws); hbox->addLayout(vbox); //Isn't it nice? QLabel* gflabel = new QLabel("GoFun",this); gflabel->setFont(QFont("Times",18, QFont::Bold)); gflabel->setSizePolicy(QSizePolicy::Minimum,QSizePolicy::Minimum,0); vbox->addLayout(hboxlabel); hboxlabel->addWidget(gflabel); //Common it is ... QToolButton* gficon = new QToolButton(this); gficon->setFixedWidth(32); gficon->setPixmap(QPixmap("gofun.png")); QToolTip::add(gficon,tr("About")); hboxlabel->addWidget(gficon); connect(gficon,SIGNAL(clicked()),this,SLOT(showAbout())); //The last steps in our layout magic vbox->addWidget(cats_bg); tools_cat = new GofunDirectoryButton("GoTools",this); vbox->addWidget(tools_cat); QWidget* wid = new QWidget(this); wid->setMinimumHeight(5); vbox->addWidget(wid); vbox->addLayout(hboxr); hboxr->addWidget(quit); hboxr->addWidget(config); hboxr->addWidget(help); //This toolbutton shall be used to add directories QToolButton* cat_add = new QToolButton(Qt::DownArrow,cats_bg); connect(cat_add, SIGNAL(clicked()),this, SLOT(popupDirectoryAdd())); QToolTip::add(cat_add,tr("Click this button to operate on directories")); cats_bg->insert(cat_add); //Now load the whole GoFun-Data and care for its displaying loadData(); }