RegisteredUsersDialog::~RegisteredUsersDialog()
{
#ifndef COMPILE_ON_MAC
	if(!parent())KVI_OPTION_RECT(KviOption_rectRegisteredUsersDialogGeometry) = QRect(pos().x(),pos().y(),size().width(),size().height());
#else
	if(!parent())KVI_OPTION_RECT(KviOption_rectRegisteredUsersDialogGeometry) = geometry();
#endif

	g_pRegisteredUsersDialog = 0;

	delete g_pLocalRegisteredUserDataBase;
	g_pLocalRegisteredUserDataBase = 0;
}
Exemple #2
0
OptionsDialog::~OptionsDialog()
{
    if(!parent())
        KVI_OPTION_RECT(KviOption_rectGeneralOptionsDialogGeometry) = QRect(pos().x(),pos().y(),size().width(),size().height());
    if(g_pOptionsDialogDict)
        g_pOptionsDialogDict->remove(m_szGroup);
}
Exemple #3
0
KviMainWindow::~KviMainWindow()
{
	KVI_OPTION_BOOL(KviOption_boolFrameIsMaximized) = isMaximized();
	KVI_OPTION_RECT(KviOption_rectFrameGeometry) = QRect(pos().x(), pos().y(),
	    size().width(), size().height());

	KVI_OPTION_BOOL(KviOption_boolStatusBarVisible) = m_pStatusBar ? true : false;

	KviCustomToolBarManager::instance()->storeVisibilityState();

	saveToolBarPositions();
	saveModuleExtensionToolBars();

	// Call the frame destructor callback AFTER saving the toolbar positions
	// This is because the destructor callback kills alls the KVS objects
	// and thus the eventual user toolbar objects too and their position
	// wouldn't be saved if they are shown at startup.

	g_pApp->frameDestructorCallback();

	// Now start killing stuff

	// Explicitly kill all the module extension toolbars: qt has NOT to delete them: we must call their "die" method
	while(KviMexToolBar * t = m_pModuleExtensionToolBarList->first())
		t->die();
	delete m_pModuleExtensionToolBarList;

	KVI_OPTION_BOOL(KviOption_boolShowDockExtension) = m_pTrayIcon != nullptr;

	if(m_pTrayIcon)
	{
		m_pTrayIcon->die();
		m_pTrayIcon = nullptr;
	}

	if(m_pStatusBar)
	{
		delete m_pStatusBar;
		m_pStatusBar = nullptr;
	}

	//close all not console windows
	for(int i = m_pWinList->count() - 1; i >= 0; --i)
	{
		KviWindow * wnd = m_pWinList->at(i);
		if(wnd->type() != KviWindow::Console)
			closeWindow(wnd);
	}

	// close all the remaining windows (consoles)
	while(m_pWinList->first())
		closeWindow(m_pWinList->first());

	delete m_pWinList;
	delete m_pAccellerators;

	g_pMainWindow = nullptr;
}
Exemple #4
0
void KviMainWindow::moveEvent(QMoveEvent * e)
{
	KVI_OPTION_RECT(KviOption_rectFrameGeometry) = QRect(pos().x(), pos().y(),
	    size().width(), size().height());
#ifdef COMPILE_PSEUDO_TRANSPARENCY
	updatePseudoTransparency();
#endif
	KviTalMainWindow::moveEvent(e);
}
Exemple #5
0
OptionsDialog::OptionsDialog(QWidget * par,const QString &szGroup,bool bModal)
    : QDialog(par)
{
    setObjectName("general_options_dialog");

    setWindowIcon(*(g_pIconManager->getSmallIcon(KviIconManager::KVIrc)));

    m_szGroup = szGroup;

    QString szDialogTitle;

    if(szGroup.isEmpty() || KviQString::equalCI(szGroup,"general"))
    {
        szDialogTitle = __tr2qs_ctx("General Preferences","options");
    } else if(KviQString::equalCI(szGroup,"theme"))
    {
        szDialogTitle = __tr2qs_ctx("Theme Preferences","options");
    } else {
        szDialogTitle = __tr2qs_ctx("KVIrc Preferences","options");
    }

    QString szDialog = __tr2qs_ctx("This dialog contains a set of KVIrc settings.<br> Use the icons " \
                                   "on the left to navigate through the option pages. The text box in the " \
                                   "bottom left corner is a small search engine. It will highlight the " \
                                   "pages that contain options related to the search term you have entered.","options");


    QString szInfoTips;
    szInfoTips = __tr2qs_ctx("Many settings have tooltips that can be shown by holding " \
                             "the cursor over their label for a few seconds.","options");

    QString szOkCancelButtons = __tr2qs_ctx("When you have finished, click \"<b>OK</b>\" to accept your changes " \
                                            "or \"<b>Cancel</b>\" to discard them. Clicking \"<b>Apply</b>\" will commit your " \
                                            "changes without closing the window.","options");

    QString szFrontText = QString(
                              "<table width=\"100%\" height=\"100%\" valign=\"top\" align=\"center\" cellpadding=\"4\">" \
                              "<tr>" \
                              "<td bgcolor=\"#303030\" valign=\"top\">" \
                              "<center><h1><font color=\"#FFFFFF\">%1</font></h1></center>" \
                              "</td>" \
                              "</tr>" \
                              "<tr>" \
                              "<td valign=\"bottom\">" \
                              "<p>" \
                              "%2" \
                              "</p>" \
                              "<br style=\"line-height:5px;\"/>" \
                              "<p>" \
                              "%3" \
                              "</p>" \
                              "<br style=\"line-height:5px;\"/>" \
                              "<p>" \
                              "%4" \
                              "</p>" \
                              "</td>" \
                              "</tr>" \
                              "</table>"
                          ).arg(szDialogTitle, szDialog, szInfoTips, szOkCancelButtons);

    QString szCaption = szDialogTitle + " - KVIrc";
    setWindowTitle(szCaption);

    QGridLayout * g1 = new QGridLayout(this);
    QSplitter * spl = new QSplitter(Qt::Horizontal,this);
    spl->setChildrenCollapsible(false);

    g1->addWidget(spl,0,0,1,5);

    KviTalVBox * vbox = new KviTalVBox(spl);
    vbox->setSpacing(2);
    vbox->setMargin(3);

    // Controlling list view
    m_pTreeWidget = new QTreeWidget(vbox);

    m_pTreeWidget->header()->hide();
    m_pTreeWidget->setRootIsDecorated(true);
    m_pTreeWidget->setSortingEnabled(false);
    m_pTreeWidget->setSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::MinimumExpanding);
    m_pTreeWidget->setCurrentItem(NULL);

    connect(m_pTreeWidget,SIGNAL(currentItemChanged(QTreeWidgetItem*, QTreeWidgetItem *)),this,SLOT(treeWidgetItemSelectionChanged(QTreeWidgetItem *, QTreeWidgetItem *)));

    KviTalHBox * hbox = new KviTalHBox(vbox);
    hbox->setSpacing(2);
    hbox->setMargin(3);

    m_pSearchLineEdit = new QLineEdit(hbox);
    connect(m_pSearchLineEdit,SIGNAL(returnPressed()),this,SLOT(searchClicked()));
    m_pSearchButton = new QToolButton(hbox);
    m_pSearchButton->setIconSize(QSize(16,16));
    m_pSearchButton->setIcon(*(g_pIconManager->getSmallIcon(KviIconManager::Search)));
    connect(m_pSearchButton,SIGNAL(clicked()),this,SLOT(searchClicked()));
    connect(m_pSearchLineEdit,SIGNAL(textChanged(const QString &)),this,SLOT(searchLineEditTextChanged(const QString &)));

    QString szTip = __tr2qs_ctx("<p>This is the search tool for this options dialog.</p>" \
                                "<p>You can enter a search term either in your native " \
                                "language or in English and press the button on the right. " \
                                "The pages that contain some options related to the " \
                                "search term will be highlighted and you will be able " \
                                "to quickly find them.</p><p>Try \"nickname\" for example.</p>","options");
    KviTalToolTip::add(m_pSearchLineEdit,szTip);
    KviTalToolTip::add(m_pSearchButton,szTip);

    vbox = new KviTalVBox(spl);
    vbox->setSpacing(2);
    vbox->setMargin(3);

    m_pCategoryLabel = new QLabel("<b>&nbsp;</b>",vbox);
    m_pCategoryLabel->setObjectName("labgeneraloptions");

    QFrame * f = new QFrame(vbox);
    f->setFrameStyle(QFrame::HLine | QFrame::Sunken);

    // Widget stack
    m_pWidgetStack = new QStackedWidget(vbox);
    vbox->setStretchFactor(m_pWidgetStack,1);

    // First widget visible
    m_pFrontWidget = new OptionsDialogFrontWidget(m_pWidgetStack,szFrontText);
    m_pWidgetStack->addWidget(m_pFrontWidget);

    int idx = m_pWidgetStack->indexOf(m_pFrontWidget);
    m_pWidgetStack->widget(idx)->raise();

    //  Ok,Cancel,Help
    QPushButton * b = new QPushButton(__tr2qs_ctx("&OK","options"),this);
    b->setObjectName("btnok");
    KviTalToolTip::add(b,__tr2qs_ctx("Close this dialog, accepting all changes.","options"));
    connect(b,SIGNAL(clicked()),this,SLOT(okClicked()));
    //b->setMinimumWidth(whatIsThisWidth);
    b->setIcon(*(g_pIconManager->getSmallIcon(KviIconManager::Accept)));
    g1->addWidget(b,1,2);

    b = new QPushButton(__tr2qs_ctx("&Apply","options"),this);
    b->setObjectName("btnapply");
    KviTalToolTip::add(b,__tr2qs_ctx("Commit all changes immediately.","options"));
    connect(b,SIGNAL(clicked()),this,SLOT(applyClicked()));
    b->setIcon(*(g_pIconManager->getSmallIcon(KviIconManager::Accept)));
    g1->addWidget(b,1,3);

    b = new QPushButton(__tr2qs_ctx("Cancel","options"),this);
    b->setObjectName("btncancel");
    KviTalToolTip::add(b,__tr2qs_ctx("Close this dialog, discarding all changes.","options"));
    b->setDefault(true);
    //b->setMinimumWidth(whatIsThisWidth);
    connect(b,SIGNAL(clicked()),this,SLOT(cancelClicked()));
    b->setIcon(*(g_pIconManager->getSmallIcon(KviIconManager::Discard)));
    g1->addWidget(b,1,4);

    g1->setRowStretch(0,1);
    g1->setColumnStretch(1,1);


    fillTreeWidget(0,g_pOptionsInstanceManager->instanceEntryTree(),szGroup);

    if(!parent())
    {
        if(KVI_OPTION_RECT(KviOption_rectGeneralOptionsDialogGeometry).y() < 5)
            KVI_OPTION_RECT(KviOption_rectGeneralOptionsDialogGeometry).setY(5);

        //setGeometry(KVI_OPTION_RECT(KviOption_rectGeneralOptionsDialogGeometry));
        resize(KVI_OPTION_RECT(KviOption_rectGeneralOptionsDialogGeometry).width(),
               KVI_OPTION_RECT(KviOption_rectGeneralOptionsDialogGeometry).height());
        move(KVI_OPTION_RECT(KviOption_rectGeneralOptionsDialogGeometry).x(),
             KVI_OPTION_RECT(KviOption_rectGeneralOptionsDialogGeometry).y());
    }

    new QShortcut(Qt::Key_Escape,this,SLOT(close()));

    if(bModal)
        setWindowModality(par ? Qt::WindowModal : Qt::ApplicationModal);
}
Exemple #6
0
void KviMainWindow::resizeEvent(QResizeEvent * e)
{
	KVI_OPTION_RECT(KviOption_rectFrameGeometry) = QRect(pos().x(), pos().y(),
	    size().width(), size().height());
	KviTalMainWindow::resizeEvent(e);
}
Exemple #7
0
KviMainWindow::KviMainWindow(QWidget * pParent)
    : KviTalMainWindow(pParent, "kvirc_frame")
{
	g_pMainWindow = this;
	setAttribute(Qt::WA_DeleteOnClose);
	setAutoFillBackground(false);
	setAttribute(Qt::WA_TranslucentBackground);
	//disable this flag that gets enabled by qt when using Qt::WA_TranslucentBackground
	setAttribute(Qt::WA_NoSystemBackground, false);
#if !(defined(COMPILE_ON_WINDOWS) || defined(COMPILE_ON_MINGW) || defined(COMPILE_KDE_SUPPORT))
	// Under windows, the icon is builtin; under kde, KApplication sets it for us
	// We try to avois this as much as possible, since it forces the use of the low-res 16x16 icon
	setWindowIcon(*(g_pIconManager->getSmallIcon(KviIconManager::KVIrc)));
#endif

	m_pWinList = new KviPointerList<KviWindow>;
	setWindowTitle(KVI_DEFAULT_FRAME_CAPTION);
	m_pWinList->setAutoDelete(false);

	m_pModuleExtensionToolBarList = new KviPointerList<KviMexToolBar>;
	m_pModuleExtensionToolBarList->setAutoDelete(false);

	m_pActiveContext = nullptr;

	m_pTrayIcon = nullptr;

	m_pSplitter = new QSplitter(Qt::Horizontal, this);
	m_pSplitter->setObjectName("main_frame_splitter");
	m_pSplitter->setChildrenCollapsible(false);

	setCentralWidget(m_pSplitter);

	setIconSize(KVI_OPTION_UINT(KviOption_uintToolBarIconSize));
	setButtonStyle(KVI_OPTION_UINT(KviOption_uintToolBarButtonStyle));

	m_pWindowStack = new KviWindowStack(m_pSplitter, "mdi_manager");

	// This theoretically had to exists before KviWindowStack (that uses enterSdiMode)
	m_pAccellerators = new KviPointerList<QShortcut>;
	m_pMenuBar = new KviMenuBar(this, "main_menu_bar");
	setMenuWidget(m_pMenuBar);
#ifndef COMPILE_ON_MAC
	m_pMenuBar->setVisible(KVI_OPTION_BOOL(KviOption_boolMenuBarVisible));
#endif

	if(KVI_OPTION_BOOL(KviOption_boolStatusBarVisible))
	{
		m_pStatusBar = new KviStatusBar(this);
		setStatusBar(m_pStatusBar);
		// torque: moved out of status bar constructor
		// because module init functions executed in load()
		// couldn't access the status bar via g_pMainWindow->mainStatusBar()
		// (assignment of m_pStatusBar happened after load() and
		// the init function)
		m_pStatusBar->load();
	}
	else
	{
		m_pStatusBar = nullptr;
	}

	m_pWindowList = nullptr;

	createWindowList();

	if((KVI_OPTION_RECT(KviOption_rectFrameGeometry).width() < 100) || (KVI_OPTION_RECT(KviOption_rectFrameGeometry).height() < 100) || (KVI_OPTION_RECT(KviOption_rectFrameGeometry).x() > g_pApp->desktop()->width()) || (KVI_OPTION_RECT(KviOption_rectFrameGeometry).y() > g_pApp->desktop()->height()))
	{
		// Try to find some reasonable defaults
		// prefer primary screen for first startup
		int primary_screen = g_pApp->desktop()->primaryScreen();
		QRect r = g_pApp->desktop()->screenGeometry(primary_screen);
		r.setLeft(r.left() + 10);
		r.setRight(r.right() - 100);
		r.setTop(r.top() + 10);
		r.setBottom(r.bottom() - 200);
		KVI_OPTION_RECT(KviOption_rectFrameGeometry) = r;
	}

	resize(KVI_OPTION_RECT(KviOption_rectFrameGeometry).width(),
	    KVI_OPTION_RECT(KviOption_rectFrameGeometry).height());
	move(KVI_OPTION_RECT(KviOption_rectFrameGeometry).x(),
	    KVI_OPTION_RECT(KviOption_rectFrameGeometry).y());

	if(KVI_OPTION_BOOL(KviOption_boolFrameIsMaximized))
		showMaximized();

	applyOptions();

	installAccelerators();
}
RegisteredUsersDialog::RegisteredUsersDialog(QWidget * par)
: QWidget(par)
{
	g_pRegisteredUsersDialog = this;

	g_pLocalRegisteredUserDataBase = new KviRegisteredUserDataBase();
	g_pLocalRegisteredUserDataBase->copyFrom(g_pRegisteredUserDataBase);

	setWindowIcon(*(g_pIconManager->getSmallIcon(KviIconManager::RegUsers)));
	setWindowTitle(__tr2qs_ctx("Registered Users - KVIrc","register"));

	QGridLayout * g = new QGridLayout(this);


	m_pListView = new KviRegisteredUsersListView(this);
	m_pListView->setItemDelegate(new RegisteredUsersDialogItemDelegate());

	connect(m_pListView,SIGNAL(itemPressed(QTreeWidgetItem *,int)),this,SLOT(itemPressed(QTreeWidgetItem *,int)));
	connect(m_pListView,SIGNAL(itemDoubleClicked(QTreeWidgetItem *, int)),this,SLOT(itemDoubleClicked(QTreeWidgetItem *, int)));

	g->addWidget(m_pListView,0,0,2,2);

	KviTalVBox * vbox = new KviTalVBox(this);
	vbox->setSpacing(4);
	g->addWidget(vbox,0,2);

	m_pWizardAddButton = new QPushButton(__tr2qs_ctx("Add (Wizard)...","register"),vbox);
	connect(m_pWizardAddButton,SIGNAL(clicked()),this,SLOT(addWizardClicked()));
	m_pWizardAddButton->setToolTip(__tr2qs_ctx("Add a registered user by means of a user-friendly wizard.","register"));
	m_pWizardAddButton->setIcon(*(g_pIconManager->getSmallIcon(KviIconManager::NewItemByWizard)));


	m_pAddButton = new QPushButton(__tr2qs_ctx("&Add...","register"),vbox);
	connect(m_pAddButton,SIGNAL(clicked()),this,SLOT(addClicked()));
	m_pAddButton->setToolTip(__tr2qs_ctx("Open the edit dialog to create a new user entry.","register"));
	m_pAddButton->setIcon(*(g_pIconManager->getSmallIcon(KviIconManager::NewItem)));

	m_pAddGroupButton = new QPushButton(__tr2qs_ctx("&Add Group...","register"),vbox);
	connect(m_pAddGroupButton,SIGNAL(clicked()),this,SLOT(addGroupClicked()));
	m_pAddGroupButton->setToolTip(__tr2qs_ctx("Adds a new group","register"));
	m_pAddGroupButton->setIcon(*(g_pIconManager->getSmallIcon(KviIconManager::NewItem)));

	m_pRemoveButton = new QPushButton(__tr2qs_ctx("Re&move","register"),vbox);
	connect(m_pRemoveButton,SIGNAL(clicked()),this,SLOT(removeClicked()));
	m_pRemoveButton->setEnabled(false);
	m_pRemoveButton->setToolTip(__tr2qs_ctx("Remove the currently selected entries.","register"));
	m_pRemoveButton->setIcon(*(g_pIconManager->getSmallIcon(KviIconManager::DeleteItem)));


	m_pEditButton = new QPushButton(__tr2qs_ctx("&Edit...","register"),vbox);
	connect(m_pEditButton,SIGNAL(clicked()),this,SLOT(editClicked()));
	m_pEditButton->setEnabled(false);
	m_pEditButton->setToolTip(__tr2qs_ctx("Edit the first selected entry.","register"));
	m_pEditButton->setIcon(*(g_pIconManager->getSmallIcon(KviIconManager::EditItem)));

	QFrame * f = new QFrame(vbox);
	f->setFrameStyle(QFrame::HLine | QFrame::Sunken);

	m_pSelectAllButton = new QPushButton(__tr2qs_ctx("Select all","register"),vbox);
	connect(m_pSelectAllButton,SIGNAL(clicked()),this,SLOT(selectAllClicked()));
	m_pSelectAllButton->setToolTip(__tr2qs_ctx("Select all the entries","register"));
	m_pSelectAllButton->setIcon(*(g_pIconManager->getSmallIcon(KviIconManager::Plus)));

	m_pExportButton = new QPushButton(__tr2qs_ctx("Export To...","register"),vbox);
	m_pExportButton->setEnabled(false);
	connect(m_pExportButton,SIGNAL(clicked()),this,SLOT(exportClicked()));
	m_pExportButton->setToolTip(__tr2qs_ctx("Export the selected entries to a file.<br>All the data associated with the selected registered users will be exported.<br>You (or anyone else) can later import the entries by using the \"Import\" button.","register"));
	m_pExportButton->setIcon(*(g_pIconManager->getSmallIcon(KviIconManager::Floppy)));


	m_pImportButton = new QPushButton(__tr2qs_ctx("Import From...","register"),vbox);
	connect(m_pImportButton,SIGNAL(clicked()),this,SLOT(importClicked()));
	m_pImportButton->setToolTip(__tr2qs_ctx("Import entries from a file exported earlier by the \"export\" function of this dialog.","register"));
	m_pImportButton->setIcon(*(g_pIconManager->getSmallIcon(KviIconManager::Folder)));


	KviTalHBox * hbox = new KviTalHBox(this);
	hbox->setSpacing(4);
	g->addWidget(hbox,3,1,1,2);

	QPushButton * b;


	b = new QPushButton(__tr2qs_ctx("&OK","register"),hbox);
	connect(b,SIGNAL(clicked()),this,SLOT(okClicked()));
	b->setIcon(*(g_pIconManager->getSmallIcon(KviIconManager::Accept)));
	//b->setMinimumWidth(120);

	b = new QPushButton(__tr2qs_ctx("Cancel","register"),hbox);
	connect(b,SIGNAL(clicked()),this,SLOT(cancelClicked()));
	b->setIcon(*(g_pIconManager->getSmallIcon(KviIconManager::Discard)));
	//b->setMinimumWidth(120);

	g->addItem(new QSpacerItem(0, 15), 2, 0);
	g->setColumnStretch(0,1);
	g->setRowStretch(1,1);

	connect(m_pListView,SIGNAL(itemSelectionChanged()),this,SLOT(selectionChanged()));
	connect(m_pListView,SIGNAL(rightButtonPressed(QTreeWidgetItem *, QPoint)),this,SLOT(rightButtonPressed(QTreeWidgetItem *, QPoint)));

	new QShortcut(Qt::Key_Escape, this, SLOT(cancelClicked()));

	fillList();

	if(!parent())
	{
		if(KVI_OPTION_RECT(KviOption_rectRegisteredUsersDialogGeometry).y() < 5)
			KVI_OPTION_RECT(KviOption_rectRegisteredUsersDialogGeometry).setY(5);

		//setGeometry(KVI_OPTION_RECT(KviOption_rectRegisteredUsersDialogGeometry));
		resize(KVI_OPTION_RECT(KviOption_rectRegisteredUsersDialogGeometry).width(),
			KVI_OPTION_RECT(KviOption_rectRegisteredUsersDialogGeometry).height());

		QRect rect = g_pApp->desktop()->screenGeometry(g_pMainWindow);
		move(rect.x() + ((rect.width() - KVI_OPTION_RECT(KviOption_rectRegisteredUsersDialogGeometry).width())/2),rect.y() + ((rect.height() - KVI_OPTION_RECT(KviOption_rectRegisteredUsersDialogGeometry).height())/2));

	}
}