diff --git a/smb4k/smb4kconfigpageauthentication.cpp b/smb4k/smb4kconfigpageauthentication.cpp index 4310759..46d091e 100644 --- a/smb4k/smb4kconfigpageauthentication.cpp +++ b/smb4k/smb4kconfigpageauthentication.cpp @@ -1,735 +1,729 @@ /*************************************************************************** The configuration page for the authentication settings of Smb4K ------------------- begin : Sa Nov 15 2003 copyright : (C) 2003-2019 by Alexander Reinholdt email : alexander.reinholdt@kdemail.net ***************************************************************************/ /*************************************************************************** * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, but * * WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * * General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., 51 Franklin Street, Suite 500, Boston,* * MA 02110-1335, USA * ***************************************************************************/ // application specific includes #include "smb4kconfigpageauthentication.h" #include "core/smb4ksettings.h" // Qt includes #include #include #include #include #include #include #include #include #include // KDE includes #include #include #include Smb4KConfigPageAuthentication::Smb4KConfigPageAuthentication(QWidget *parent) : QWidget(parent) { m_entries_displayed = false; m_maybe_changed = false; // // Layout // QVBoxLayout *layout = new QVBoxLayout(this); - layout->setSpacing(5); - layout->setContentsMargins(0, 0, 0, 0); // // Settings group box // QGroupBox *settingsBox = new QGroupBox(i18n("Settings"), this); QVBoxLayout *settingsBoxLayout = new QVBoxLayout(settingsBox); - settingsBoxLayout->setSpacing(5); // Wallet usage QCheckBox *useWallet = new QCheckBox(Smb4KSettings::self()->useWalletItem()->label(), settingsBox); useWallet->setObjectName("kcfg_UseWallet"); connect(useWallet, SIGNAL(toggled(bool)), this, SLOT(slotKWalletButtonToggled(bool))); settingsBoxLayout->addWidget(useWallet, 0); // Default login QCheckBox *defaultAuth = new QCheckBox(Smb4KSettings::self()->useDefaultLoginItem()->label(), settingsBox); defaultAuth->setObjectName("kcfg_UseDefaultLogin"); connect(defaultAuth, SIGNAL(toggled(bool)), this, SLOT(slotDefaultLoginToggled(bool))); settingsBoxLayout->addWidget(defaultAuth, 0); layout->addWidget(settingsBox, 0); // // Wallet Entries group box // QGroupBox *walletEntriesBox = new QGroupBox(i18n("Wallet Entries"), this); QVBoxLayout *walletEntriesBoxLayout = new QVBoxLayout(walletEntriesBox); - walletEntriesBoxLayout->setSpacing(5); // // Wallet Entries editor // QWidget *walletEntriesEditor = new QWidget(walletEntriesBox); walletEntriesEditor->setObjectName("WalletEntriesEditor"); QGridLayout *walletEntriesEditorLayout= new QGridLayout(walletEntriesEditor); - walletEntriesEditorLayout->setSpacing(5); // // The list view // QListWidget *walletEntriesWidget = new QListWidget(walletEntriesEditor); walletEntriesWidget->setObjectName("WalletEntriesWidget"); walletEntriesWidget->setDragDropMode(QListWidget::NoDragDrop); walletEntriesWidget->setSelectionMode(QListWidget::SingleSelection); walletEntriesWidget->setContextMenuPolicy(Qt::ActionsContextMenu); walletEntriesWidget->viewport()->installEventFilter(this); // Edit action QAction *editAction = new QAction(KDE::icon("edit-rename"), i18n("Edit"), walletEntriesWidget); editAction->setObjectName("EditAction"); editAction->setEnabled(false); connect(editAction, SIGNAL(triggered(bool)), this, SLOT(slotEditClicked())); walletEntriesWidget->addAction(editAction); // Remove action QAction *removeAction = new QAction(KDE::icon("edit-delete"), i18n("Remove"), walletEntriesWidget); removeAction->setObjectName("RemoveAction"); removeAction->setEnabled(false); connect(removeAction, SIGNAL(triggered(bool)), this, SLOT(slotRemoveClicked())); walletEntriesWidget->addAction(removeAction); // Clear action QAction *clearAction = new QAction(KDE::icon("edit-clear-list"), i18n("Clear"), walletEntriesWidget); clearAction->setObjectName("ClearAction"); clearAction->setEnabled(false); connect(clearAction, SIGNAL(triggered(bool)), this, SLOT(slotClearClicked())); walletEntriesWidget->addAction(clearAction); connect(walletEntriesWidget, SIGNAL(itemSelectionChanged()), this, SLOT(slotItemSelectionChanged())); walletEntriesEditorLayout->addWidget(walletEntriesWidget, 0, 0, 7, 1, 0); // // Load button // QPushButton *loadButton = new QPushButton(walletEntriesEditor); loadButton->setObjectName("LoadButton"); loadButton->setText(i18n("Load")); loadButton->setIcon(KDE::icon("document-open")); loadButton->setWhatsThis(i18n("The login information that was stored by Smb4K will be loaded from the wallet.")); connect(loadButton, SIGNAL(clicked(bool)), this, SIGNAL(loadWalletEntries())); walletEntriesEditorLayout->addWidget(loadButton, 0, 1, 0); // // Save button // QPushButton *saveButton = new QPushButton(walletEntriesEditor); saveButton->setObjectName("SaveButton"); saveButton->setText(i18n("Save")); saveButton->setIcon(KDE::icon("document-save-all")); saveButton->setWhatsThis(i18n("All modifications you applied are saved to the wallet.")); saveButton->setEnabled(false); connect(saveButton, SIGNAL(clicked(bool)), this, SIGNAL(saveWalletEntries())); connect(saveButton, SIGNAL(clicked(bool)), this, SLOT(slotSaveClicked(bool))); walletEntriesEditorLayout->addWidget(saveButton, 1, 1, 0); walletEntriesEditorLayout->addItem(new QSpacerItem(0, 10, QSizePolicy::Fixed, QSizePolicy::Fixed), 2, 1); // // The details widget // KCollapsibleGroupBox *detailsBox = new KCollapsibleGroupBox(walletEntriesEditor); detailsBox->setObjectName("DetailsBox"); detailsBox->setTitle(i18n("Details")); detailsBox->setEnabled(false); QVBoxLayout *detailsBoxLayout = new QVBoxLayout(detailsBox); - detailsBoxLayout->setSpacing(5); QTableWidget *detailsWidget = new QTableWidget(detailsBox); detailsWidget->setObjectName("DetailsWidget"); detailsWidget->horizontalHeader()->setVisible(false); detailsWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents); detailsWidget->verticalHeader()->setVisible(false); detailsWidget->verticalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents); detailsWidget->viewport()->installEventFilter(this); detailsBoxLayout->addWidget(detailsWidget, 0); walletEntriesEditorLayout->addWidget(detailsBox, 5, 1, 0); walletEntriesEditorLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::Fixed, QSizePolicy::MinimumExpanding), 6, 1); walletEntriesBoxLayout->addWidget(walletEntriesEditor, 0); layout->addWidget(walletEntriesBox, 0); // // Adjustments // slotKWalletButtonToggled(useWallet->isChecked()); slotDefaultLoginToggled(defaultAuth->isChecked()); // // Set focus // loadButton->setFocus(); } Smb4KConfigPageAuthentication::~Smb4KConfigPageAuthentication() { } void Smb4KConfigPageAuthentication::insertWalletEntries(const QList &list) { // // Insert the list of authentication information // m_entriesList = list; // // Reset the changed flag, since we are (re)loading the information // m_maybe_changed = false; emit walletEntriesModified(); // // Get the list wirdget // QListWidget *walletEntriesWidget = findChild("WalletEntriesWidget"); // // Clear the list widget // walletEntriesWidget->clear(); // // Insert the authentication information entries into the // list widget // for (Smb4KAuthInfo *authInfo : m_entriesList) { switch (authInfo->type()) { case UnknownNetworkItem: { (void) new QListWidgetItem(KDE::icon("dialog-password"), i18n("Default Login"), walletEntriesWidget); break; } default: { (void) new QListWidgetItem(KDE::icon("dialog-password"), authInfo->displayString(), walletEntriesWidget); break; } } } // // Sort the entries // walletEntriesWidget->sortItems(); // // Set the display flag to true // m_entries_displayed = true; // // Enable buttons and actions // findChild("SaveButton")->setEnabled(walletEntriesWidget->count() != 0); findChild("ClearAction")->setEnabled(walletEntriesWidget->count() != 0); } bool Smb4KConfigPageAuthentication::eventFilter(QObject *object, QEvent *e) { // // Get the list widget // QListWidget *walletEntriesWidget = findChild("WalletEntriesWidget"); // // Process the events in the list widget // if (object == walletEntriesWidget->viewport()) { // If the user clicked on the viewport of the entries view, clear // the details widget and the "Details" button, if no item // is under the mouse. if (e->type() == QEvent::MouseButtonPress) { QMouseEvent *event = static_cast(e); QPoint pos = walletEntriesWidget->mapFromGlobal(event->globalPos()); if (!walletEntriesWidget->itemAt(pos)) { clearDetails(); walletEntriesWidget->clearSelection(); findChild("EditAction")->setEnabled(false); findChild("RemoveAction")->setEnabled(false); } } return walletEntriesWidget->viewport()->eventFilter(object, e); } return QWidget::eventFilter(object, e); } void Smb4KConfigPageAuthentication::loadDetails(Smb4KAuthInfo *authInfo) { // // Get the widgets // QTableWidget *detailsWidget = findChild("DetailsWidget"); KCollapsibleGroupBox *detailsGroupBox = findChild("DetailsBox"); QListWidget *walletEntriesWidget = findChild("WalletEntriesWidget"); // // Fill the details table widget with the information // switch (authInfo->type()) { case Host: case Share: { detailsWidget->setColumnCount(2); detailsWidget->setRowCount(4); QTableWidgetItem *entry_label = new QTableWidgetItem(i18n("Entry")); entry_label->setFlags(entry_label->flags() & Qt::ItemIsEditable); entry_label->setForeground(palette().text()); QTableWidgetItem *entry = new QTableWidgetItem(authInfo->displayString()); entry->setFlags(entry->flags() & Qt::ItemIsEditable); entry->setForeground(palette().text()); QTableWidgetItem *workgroup_label = new QTableWidgetItem(i18n("Workgroup")); workgroup_label->setFlags(workgroup_label->flags() & Qt::ItemIsEditable); workgroup_label->setForeground(palette().text()); QTableWidgetItem *login_label = new QTableWidgetItem(i18n("Login")); login_label->setFlags(login_label->flags() & Qt::ItemIsEditable); login_label->setForeground(palette().text()); QTableWidgetItem *password_label = new QTableWidgetItem(i18n("Password")); password_label->setFlags(password_label->flags() & Qt::ItemIsEditable); password_label->setForeground(palette().text()); detailsWidget->setItem(0, 0, entry_label); detailsWidget->setItem(0, 1, entry); detailsWidget->setItem(1, 0, workgroup_label); detailsWidget->setItem(1, 1, new QTableWidgetItem(authInfo->workgroupName())); detailsWidget->setItem(2, 0, login_label); detailsWidget->setItem(2, 1, new QTableWidgetItem(authInfo->userName())); detailsWidget->setItem(3, 0, password_label); detailsWidget->setItem(3, 1, new QTableWidgetItem(authInfo->password())); break; } default: { detailsWidget->setColumnCount(2); detailsWidget->setRowCount(3); QTableWidgetItem *entry_label = new QTableWidgetItem(i18n("Entry")); entry_label->setFlags(entry_label->flags() & Qt::ItemIsEditable); entry_label->setForeground(palette().text()); QTableWidgetItem *entry = new QTableWidgetItem(i18n("Default Login")); entry->setFlags(entry->flags() & Qt::ItemIsEditable); entry->setForeground(palette().text()); QTableWidgetItem *login_label = new QTableWidgetItem(i18n("Login")); login_label->setFlags(login_label->flags() & Qt::ItemIsEditable); login_label->setForeground(palette().text()); QTableWidgetItem *password_label = new QTableWidgetItem(i18n("Password")); password_label->setFlags(password_label->flags() & Qt::ItemIsEditable); password_label->setForeground(palette().text()); detailsWidget->setItem(0, 0, entry_label); detailsWidget->setItem(0, 1, entry); detailsWidget->setItem(1, 0, login_label); detailsWidget->setItem(1, 1, new QTableWidgetItem(authInfo->userName())); detailsWidget->setItem(2, 0, password_label); detailsWidget->setItem(2, 1, new QTableWidgetItem(authInfo->password())); break; } } // // Connect signals // connect(detailsWidget, SIGNAL(cellChanged(int,int)), this, SLOT(slotDetailsChanged(int,int))); // // Enable the details box // detailsGroupBox->setEnabled(!walletEntriesWidget->selectedItems().isEmpty()); } void Smb4KConfigPageAuthentication::clearDetails() { // // Get the widgets // QTableWidget *detailsWidget = findChild("DetailsWidget"); KCollapsibleGroupBox *detailsGroupBox = findChild("DetailsBox"); QListWidget *walletEntriesWidget = findChild("WalletEntriesWidget"); // // Disconnect signals // disconnect(detailsWidget, SIGNAL(cellChanged(int,int)), this, SLOT(slotDetailsChanged(int,int))); // // Collapse the details box and disable it. // detailsGroupBox->setExpanded(false); detailsGroupBox->setEnabled(!walletEntriesWidget->selectedItems().isEmpty()); // // Clear the table widget // if (detailsWidget->rowCount() != 0 && detailsWidget->columnCount() != 0) { detailsWidget->clear(); detailsWidget->setRowCount(0); detailsWidget->setColumnCount(0); } } ///////////////////////////////////////////////////////////////////////////// // SLOT IMPLEMENTATIONS ///////////////////////////////////////////////////////////////////////////// void Smb4KConfigPageAuthentication::slotKWalletButtonToggled(bool checked) { findChild("kcfg_UseDefaultLogin")->setEnabled(checked); findChild("WalletEntriesEditor")->setEnabled(checked); } void Smb4KConfigPageAuthentication::slotDefaultLoginToggled(bool checked) { if (checked && !Smb4KSettings::useDefaultLogin()) { emit setDefaultLogin(); } } void Smb4KConfigPageAuthentication::slotItemSelectionChanged() { // // Get the list widget // QListWidget *walletEntriesWidget = findChild("WalletEntriesWidget"); // // Clear details widget // clearDetails(); // // Get the authentication information and load its // details into the details widget // if (walletEntriesWidget->currentItem()) { for (Smb4KAuthInfo *authInfo : m_entriesList) { if (walletEntriesWidget->currentItem()->text() == authInfo->displayString() || (walletEntriesWidget->currentItem()->text() == i18n("Default Login") && authInfo->type() == UnknownNetworkItem)) { loadDetails(authInfo); break; } } // Enable actions findChild("EditAction")->setEnabled(true); findChild("RemoveAction")->setEnabled(true); } } void Smb4KConfigPageAuthentication::slotDetailsChanged(int row, int column) { // // Get the widget // QTableWidget *detailsWidget = findChild("DetailsWidget"); // // Find the right authentication information and pass the modifications // for (Smb4KAuthInfo *authInfo : m_entriesList) { if (QString::compare(detailsWidget->item(0, 1)->text(), authInfo->displayString()) == 0 || (QString::compare(detailsWidget->item(0, 1)->text(), i18n("Default Login")) == 0 && authInfo->type() == UnknownNetworkItem)) { switch (authInfo->type()) { case Host: case Share: { if (column == 1) { switch (row) { case 1: // Workgroup { authInfo->setWorkgroupName(detailsWidget->item(row, column)->text()); break; } case 2: // Login { authInfo->setUserName(detailsWidget->item(row, column)->text()); break; } case 3: // Password { authInfo->setPassword(detailsWidget->item(row, column)->text()); break; } default: { break; } } } break; } default: { if (column == 1) { switch (row) { case 1: // Login { authInfo->setUserName(detailsWidget->item(row, column)->text()); break; } case 2: // Password { authInfo->setPassword(detailsWidget->item(row, column)->text()); break; } default: { break; } } } break; } } break; } } // // Tell the program that the authentication information may be changed // and emit the appropriate signal // m_maybe_changed = true; emit walletEntriesModified(); } void Smb4KConfigPageAuthentication::slotEditClicked() { // // Get the widgets // KCollapsibleGroupBox *detailsGroupBox = findChild("DetailsBox"); QListWidget *walletEntriesWidget = findChild("WalletEntriesWidget"); if (walletEntriesWidget->currentItem()) { // // Since the details have been loaded to the details widget already // by slotItemSelectionChanged(), only open the details widget here. // if (!detailsGroupBox->isExpanded()) { detailsGroupBox->setExpanded(true); } } } void Smb4KConfigPageAuthentication::slotRemoveClicked() { // // Get the list widget // QListWidget *walletEntriesWidget = findChild("WalletEntriesWidget"); // // Clear the details widget // clearDetails(); // // Remove the appropriate entry from the list of authentication information // for (int i = 0; i < m_entriesList.size(); ++i) { if (QString::compare(walletEntriesWidget->currentItem()->text(), m_entriesList.at(i)->displayString()) == 0 || (QString::compare(walletEntriesWidget->currentItem()->text(), i18n("Default Login")) == 0 && m_entriesList.at(i)->type() == UnknownNetworkItem)) { switch (m_entriesList.at(i)->type()) { case UnknownNetworkItem: { QCheckBox *default_login = findChild("kcfg_UseDefaultLogin"); default_login->setChecked(false); break; } default: { break; } } delete m_entriesList.takeAt(i); break; } else { continue; } } // // Remove the current item // delete walletEntriesWidget->currentItem(); // // Enable actions // findChild("ClearAction")->setEnabled((walletEntriesWidget->count() != 0)); // // Tell the program that the authentication information may be changed // and emit the appropriate signal // m_maybe_changed = true; emit walletEntriesModified(); } void Smb4KConfigPageAuthentication::slotClearClicked() { // // Get the list widget // QListWidget *walletEntriesWidget = findChild("WalletEntriesWidget"); // // Clear the details widget // clearDetails(); // // Remove all entries from the view // while (walletEntriesWidget->count() != 0) { delete walletEntriesWidget->item(0); } // // Remove all entries from the list off authentication information // while(!m_entriesList.isEmpty()) { delete m_entriesList.takeFirst(); } // // Enabled widgets // findChild("ClearAction")->setEnabled(false); // // Uncheck the Default Login checkbox // findChild("kcfg_UseDefaultLogin")->setChecked(false); // // Tell the program that the authentication information may be changed // and emit the appropriate signal // m_maybe_changed = true; emit walletEntriesModified(); } void Smb4KConfigPageAuthentication::slotSaveClicked(bool /*checked*/) { // // Get the list widget // QListWidget *walletEntriesWidget = findChild("WalletEntriesWidget"); // // Disable buttons // findChild("EditAction")->setEnabled(false); findChild("RemoveAction")->setEnabled(false); findChild("ClearAction")->setEnabled((walletEntriesWidget->count() != 0)); // // Clear the selection in the list view // walletEntriesWidget->clearSelection(); // // Tell the program that the authentication information may be changed // and emit the appropriate signal // m_maybe_changed = false; emit walletEntriesModified(); } diff --git a/smb4k/smb4kconfigpagecustomoptions.cpp b/smb4k/smb4kconfigpagecustomoptions.cpp index a34065c..ba4c744 100644 --- a/smb4k/smb4kconfigpagecustomoptions.cpp +++ b/smb4k/smb4kconfigpagecustomoptions.cpp @@ -1,1919 +1,1904 @@ /*************************************************************************** The configuration page for the custom options ------------------- begin : Sa Jan 19 2013 copyright : (C) 2013-2019 by Alexander Reinholdt email : alexander.reinholdt@kdemail.net ***************************************************************************/ /*************************************************************************** * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, but * * WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * * General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., 51 Franklin Street, Suite 500, Boston,* * MA 02110-1335, USA * ***************************************************************************/ // application specific includes #include "smb4kconfigpagecustomoptions.h" #include "core/smb4ksettings.h" #include "core/smb4kcustomoptions.h" #include "core/smb4kglobal.h" #if defined(Q_OS_LINUX) #include "core/smb4kmountsettings_linux.h" #elif defined(Q_OS_FREEBSD) || defined(Q_OS_NETBSD) #include "core/smb4kmountsettings_bsd.h" #endif // Qt includes #include #include #include #include #include #include // KDE includes #include #include using namespace Smb4KGlobal; Smb4KConfigPageCustomOptions::Smb4KConfigPageCustomOptions(QWidget *parent) : QWidget(parent) { m_maybe_changed = false; // // Layout // QHBoxLayout *layout = new QHBoxLayout(this); - layout->setSpacing(5); setLayout(layout); // // Set up the list widget // QListWidget *optionsListWidget = new QListWidget(this); optionsListWidget->setObjectName("OptionsListWidget"); optionsListWidget->setSelectionMode(QListWidget::SingleSelection); optionsListWidget->setContextMenuPolicy(Qt::CustomContextMenu); connect(optionsListWidget, SIGNAL(itemDoubleClicked(QListWidgetItem*)), SLOT(slotEditCustomItem(QListWidgetItem*))); connect(optionsListWidget, SIGNAL(itemSelectionChanged()), SLOT(slotItemSelectionChanged())); connect(optionsListWidget, SIGNAL(customContextMenuRequested(QPoint)), SLOT(slotCustomContextMenuRequested(QPoint))); layout->addWidget(optionsListWidget, 0); QAction *editAction = new QAction(KDE::icon("edit-rename"), i18n("Edit"), optionsListWidget); editAction->setObjectName("edit_action"); editAction->setEnabled(false); QAction *removeAction = new QAction(KDE::icon("edit-delete"), i18n("Remove"), optionsListWidget); removeAction->setObjectName("remove_action"); removeAction->setEnabled(false); QAction *clearAction = new QAction(KDE::icon("edit-clear-list"), i18n("Clear List"), optionsListWidget); clearAction->setObjectName("clear_action"); clearAction->setEnabled(false); optionsListWidget->addAction(editAction); optionsListWidget->addAction(removeAction); optionsListWidget->addAction(clearAction); KActionMenu *actionMenu = new KActionMenu(optionsListWidget); actionMenu->setObjectName("ActionMenu"); actionMenu->addAction(editAction); actionMenu->addAction(removeAction); actionMenu->addAction(clearAction); connect(editAction, SIGNAL(triggered(bool)), SLOT(slotEditActionTriggered(bool))); connect(removeAction, SIGNAL(triggered(bool)), SLOT(slotRemoveActionTriggered(bool))); connect(clearAction, SIGNAL(triggered(bool)), SLOT(slotClearActionTriggered(bool))); // // Set up the tab widget // QTabWidget *tabWidget = new QTabWidget(this); tabWidget->setObjectName("TabWidget"); layout->addWidget(tabWidget, 0); // // Network item tab // QWidget *itemTab = new QWidget(tabWidget); QVBoxLayout *itemTabLayout = new QVBoxLayout(itemTab); - itemTabLayout->setSpacing(5); // Identification QGroupBox *identificationBox = new QGroupBox(i18n("Identification"), itemTab); QGridLayout *identificationBoxLayout = new QGridLayout(identificationBox); - identificationBoxLayout->setSpacing(5); QLabel *workgroupLabel = new QLabel(i18n("Workgroup:"), identificationBox); KLineEdit *workgroup = new KLineEdit(identificationBox); workgroup->setObjectName("Workgroup"); // workgroup->setClearButtonEnabled(true); workgroup->setReadOnly(true); workgroupLabel->setBuddy(workgroup); identificationBoxLayout->addWidget(workgroupLabel, 0, 0, 0); identificationBoxLayout->addWidget(workgroup, 0, 1, 0); QLabel *locationLabel = new QLabel(i18n("Location:"), identificationBox); KLineEdit *location = new KLineEdit(identificationBox); location->setObjectName("Location"); // location->setClearButtonEnabled(true); location->setReadOnly(true); locationLabel->setBuddy(location); identificationBoxLayout->addWidget(locationLabel, 1, 0, 0); identificationBoxLayout->addWidget(location, 1, 1, 0); QLabel *ipAddressLabel = new QLabel(i18n("IP Address:"), identificationBox); KLineEdit *ipAddress = new KLineEdit(identificationBox); ipAddress->setObjectName("IPAddress"); ipAddress->setClearButtonEnabled(true); ipAddressLabel->setBuddy(ipAddress); identificationBoxLayout->addWidget(ipAddressLabel, 2, 0, 0); identificationBoxLayout->addWidget(ipAddress, 2, 1, 0); itemTabLayout->addWidget(identificationBox, 0); itemTabLayout->addStretch(100); tabWidget->addTab(itemTab, i18n("Network Item")); // // Mounting tab // setupMountingTab(); // // Samba tab // QWidget *sambaTab = new QWidget(tabWidget); QVBoxLayout *sambaTabLayout = new QVBoxLayout(sambaTab); - sambaTabLayout->setSpacing(5); // Common Options QGroupBox *commonSambaOptionsBox = new QGroupBox(i18n("Common Options"), sambaTab); QGridLayout *commonSambaOptionsBoxLayout = new QGridLayout(commonSambaOptionsBox); - commonSambaOptionsBoxLayout->setSpacing(5); // SMB port QCheckBox *useSmbPort = new QCheckBox(Smb4KSettings::self()->useRemoteSmbPortItem()->label(), commonSambaOptionsBox); useSmbPort->setObjectName("UseSmbPort"); QSpinBox *smbPort = new QSpinBox(commonSambaOptionsBox); smbPort->setObjectName("SmbPort"); smbPort->setMinimum(Smb4KSettings::self()->remoteSmbPortItem()->minValue().toInt()); smbPort->setMaximum(Smb4KSettings::self()->remoteSmbPortItem()->maxValue().toInt()); // smbPort->setSliderEnabled(true); commonSambaOptionsBoxLayout->addWidget(useSmbPort, 0, 0, 0); commonSambaOptionsBoxLayout->addWidget(smbPort, 0, 1, 0); sambaTabLayout->addWidget(commonSambaOptionsBox, 0); // Authentication QGroupBox *authenticationBox = new QGroupBox(i18n("Authentication"), sambaTab); QVBoxLayout *authenticationBoxLayout = new QVBoxLayout(authenticationBox); - authenticationBoxLayout->setSpacing(5); // Kerberos QCheckBox *useKerberos = new QCheckBox(Smb4KSettings::self()->useKerberosItem()->label(), authenticationBox); useKerberos->setObjectName("UseKerberos"); authenticationBoxLayout->addWidget(useKerberos, 0); sambaTabLayout->addWidget(authenticationBox, 0); sambaTabLayout->addStretch(100); tabWidget->addTab(sambaTab, i18n("Samba")); // // Wake-On-LAN tab // // NOTE: If you change the texts here, also alter them in the custom // options dialog // QWidget *wakeOnLanTab = new QWidget(tabWidget); QVBoxLayout *wakeOnLanTabLayout = new QVBoxLayout(wakeOnLanTab); - wakeOnLanTabLayout->setSpacing(5); // MAC address QGroupBox *macAddressBox = new QGroupBox(i18n("MAC Address"), wakeOnLanTab); QGridLayout *macAddressBoxLayout = new QGridLayout(macAddressBox); - macAddressBoxLayout->setSpacing(5); // MAC address QLabel *macAddressLabel = new QLabel(i18n("MAC Address:"), macAddressBox); KLineEdit *macAddress = new KLineEdit(macAddressBox); macAddress->setObjectName("MACAddress"); macAddress->setClearButtonEnabled(true); macAddress->setInputMask("HH:HH:HH:HH:HH:HH;_"); // MAC address, see QLineEdit doc macAddressLabel->setBuddy(macAddress); macAddressBoxLayout->addWidget(macAddressLabel, 0, 0, 0); macAddressBoxLayout->addWidget(macAddress, 0, 1, 0); wakeOnLanTabLayout->addWidget(macAddressBox, 0); // Wake-On-LAN Actions QGroupBox *wakeOnLANActionsBox = new QGroupBox(i18n("Actions"), wakeOnLanTab); QVBoxLayout *wakeOnLANActionsBoxLayout = new QVBoxLayout(wakeOnLANActionsBox); - wakeOnLANActionsBoxLayout->setSpacing(5); // Send magic package before network scan QCheckBox *sendPackageBeforeScan = new QCheckBox(i18n("Send magic package before scanning the network neighborhood"), wakeOnLANActionsBox); sendPackageBeforeScan->setObjectName("SendPackageBeforeScan"); wakeOnLANActionsBoxLayout->addWidget(sendPackageBeforeScan, 0); // Send magic package before mount QCheckBox *sendPackageBeforeMount = new QCheckBox(i18n("Send magic package before mounting a share"), wakeOnLanTab); sendPackageBeforeMount->setObjectName("SendPackageBeforeMount"); wakeOnLANActionsBoxLayout->addWidget(sendPackageBeforeMount, 0); wakeOnLanTabLayout->addWidget(wakeOnLANActionsBox, 0); wakeOnLanTabLayout->addStretch(100); tabWidget->addTab(wakeOnLanTab, i18n("Wake-On-LAN")); // // Clear the editor widgets, i.e. set them to the default empty values. // clearEditors(); } Smb4KConfigPageCustomOptions::~Smb4KConfigPageCustomOptions() { } #if defined(Q_OS_LINUX) // // Linux // void Smb4KConfigPageCustomOptions::setupMountingTab() { // // Get the tab widget // QTabWidget *tabWidget = findChild("TabWidget"); // // Custom options for mounting // QWidget *mountingTab = new QWidget(tabWidget); QVBoxLayout *mountingTabLayout = new QVBoxLayout(mountingTab); - mountingTabLayout->setSpacing(5); // // Common options // QGroupBox *commonBox = new QGroupBox(i18n("Common Options"), mountingTab); QGridLayout *commonBoxLayout = new QGridLayout(commonBox); - commonBoxLayout->setSpacing(5); QCheckBox *remountAlways = new QCheckBox(i18n("Always remount this share"), commonBox); remountAlways->setObjectName("RemountAlways"); remountAlways->setEnabled(false); commonBoxLayout->addWidget(remountAlways, 0, 0, 1, 2, 0); // Write access QCheckBox *useWriteAccess = new QCheckBox(Smb4KMountSettings::self()->useWriteAccessItem()->label(), commonBox); useWriteAccess->setObjectName("UseWriteAccess"); KComboBox *writeAccess = new KComboBox(commonBox); writeAccess->setObjectName("WriteAccess"); QString readWriteText = Smb4KMountSettings::self()->writeAccessItem()->choices().value(Smb4KMountSettings::EnumWriteAccess::ReadWrite).label; QString readOnlyText = Smb4KMountSettings::self()->writeAccessItem()->choices().value(Smb4KMountSettings::EnumWriteAccess::ReadOnly).label; writeAccess->addItem(readWriteText); writeAccess->addItem(readOnlyText); commonBoxLayout->addWidget(useWriteAccess, 1, 0, 0); commonBoxLayout->addWidget(writeAccess, 1, 1, 0); // Remote file system port QCheckBox *useFilesystemPort = new QCheckBox(Smb4KMountSettings::self()->useRemoteFileSystemPortItem()->label(), commonBox); useFilesystemPort->setObjectName("UseFilesystemPort"); QSpinBox *filesystemPort = new QSpinBox(commonBox); filesystemPort->setObjectName("FileSystemPort"); filesystemPort->setMinimum(Smb4KMountSettings::self()->remoteFileSystemPortItem()->minValue().toInt()); filesystemPort->setMaximum(Smb4KMountSettings::self()->remoteFileSystemPortItem()->maxValue().toInt()); // filesystemPort->setSliderEnabled(true); commonBoxLayout->addWidget(useFilesystemPort, 2, 0, 0); commonBoxLayout->addWidget(filesystemPort, 2, 1, 0); mountingTabLayout->addWidget(commonBox, 0); // // CIFS Unix Extensions Support // QGroupBox *extensionsSupportBox = new QGroupBox(i18n("CIFS Unix Extensions Support"), mountingTab); QGridLayout *extensionsSupportBoxLayout = new QGridLayout(extensionsSupportBox); - extensionsSupportBoxLayout->setSpacing(5); QCheckBox *cifsExtensionsSupport = new QCheckBox(i18n("This server supports the CIFS Unix extensions"), extensionsSupportBox); cifsExtensionsSupport->setObjectName("CifsExtensionsSupport"); extensionsSupportBoxLayout->addWidget(cifsExtensionsSupport, 0, 0, 1, 2, 0); // User Id QCheckBox *useUserId = new QCheckBox(Smb4KMountSettings::self()->useUserIdItem()->label(), extensionsSupportBox); useUserId->setObjectName("UseUserId"); KComboBox *userId = new KComboBox(extensionsSupportBox); userId->setObjectName("UserId"); QList allUsers = KUser::allUsers(); for (const KUser &u : allUsers) { userId->addItem(QString("%1 (%2)").arg(u.loginName()).arg(u.userId().nativeId()), QVariant::fromValue(u.groupId().nativeId())); } extensionsSupportBoxLayout->addWidget(useUserId, 1, 0, 0); extensionsSupportBoxLayout->addWidget(userId, 1, 1, 0); // Group Id QCheckBox *useGroupId = new QCheckBox(Smb4KMountSettings::self()->useGroupIdItem()->label(), extensionsSupportBox); useGroupId->setObjectName("UseGroupId"); KComboBox *groupId = new KComboBox(extensionsSupportBox); groupId->setObjectName("GroupId"); QList allGroups = KUserGroup::allGroups(); for (const KUserGroup &g : allGroups) { groupId->addItem(QString("%1 (%2)").arg(g.name()).arg(g.groupId().nativeId()), QVariant::fromValue(g.groupId().nativeId())); } extensionsSupportBoxLayout->addWidget(useGroupId, 2, 0, 0); extensionsSupportBoxLayout->addWidget(groupId, 2, 1, 0); // File mode QCheckBox *useFileMode = new QCheckBox(Smb4KMountSettings::self()->useFileModeItem()->label(), extensionsSupportBox); useFileMode->setObjectName("UseFileMode"); KLineEdit *fileMode = new KLineEdit(extensionsSupportBox); fileMode->setObjectName("FileMode"); fileMode->setClearButtonEnabled(true); fileMode->setAlignment(Qt::AlignRight); extensionsSupportBoxLayout->addWidget(useFileMode, 3, 0, 0); extensionsSupportBoxLayout->addWidget(fileMode, 3, 1, 0); // Directory mode QCheckBox *useDirectoryMode = new QCheckBox(Smb4KMountSettings::self()->useDirectoryModeItem()->label(), extensionsSupportBox); useDirectoryMode->setObjectName("UseDirectoryMode"); KLineEdit *directoryMode = new KLineEdit(extensionsSupportBox); directoryMode->setObjectName("DirectoryMode"); directoryMode->setClearButtonEnabled(true); directoryMode->setAlignment(Qt::AlignRight); extensionsSupportBoxLayout->addWidget(useDirectoryMode, 4, 0, 0); extensionsSupportBoxLayout->addWidget(directoryMode, 4, 1, 0); mountingTabLayout->addWidget(extensionsSupportBox, 0); // // Advanced options // QGroupBox *advancedOptionsBox = new QGroupBox(i18n("Advanced Options"), mountingTab); QGridLayout *advancedOptionsBoxLayout = new QGridLayout(advancedOptionsBox); - advancedOptionsBoxLayout->setSpacing(5); // Security mode QCheckBox *useSecurityMode = new QCheckBox(Smb4KMountSettings::self()->useSecurityModeItem()->label(), advancedOptionsBox); useSecurityMode->setObjectName("UseSecurityMode"); KComboBox *securityMode = new KComboBox(advancedOptionsBox); securityMode->setObjectName("SecurityMode"); QString noneText = Smb4KMountSettings::self()->securityModeItem()->choices().value(Smb4KMountSettings::EnumSecurityMode::None).label; QString krb5Text = Smb4KMountSettings::self()->securityModeItem()->choices().value(Smb4KMountSettings::EnumSecurityMode::Krb5).label; QString krb5iText = Smb4KMountSettings::self()->securityModeItem()->choices().value(Smb4KMountSettings::EnumSecurityMode::Krb5i).label; QString ntlmText = Smb4KMountSettings::self()->securityModeItem()->choices().value(Smb4KMountSettings::EnumSecurityMode::Ntlm).label; QString ntlmiText = Smb4KMountSettings::self()->securityModeItem()->choices().value(Smb4KMountSettings::EnumSecurityMode::Ntlmi).label; QString ntlmv2Text = Smb4KMountSettings::self()->securityModeItem()->choices().value(Smb4KMountSettings::EnumSecurityMode::Ntlmv2).label; QString ntlmv2iText = Smb4KMountSettings::self()->securityModeItem()->choices().value(Smb4KMountSettings::EnumSecurityMode::Ntlmv2i).label; QString ntlmsspText = Smb4KMountSettings::self()->securityModeItem()->choices().value(Smb4KMountSettings::EnumSecurityMode::Ntlmssp).label; QString ntlmsspiText = Smb4KMountSettings::self()->securityModeItem()->choices().value(Smb4KMountSettings::EnumSecurityMode::Ntlmsspi).label; securityMode->addItem(noneText); securityMode->addItem(krb5Text); securityMode->addItem(krb5iText); securityMode->addItem(ntlmText); securityMode->addItem(ntlmiText); securityMode->addItem(ntlmv2Text); securityMode->addItem(ntlmv2iText); securityMode->addItem(ntlmsspText); advancedOptionsBoxLayout->addWidget(useSecurityMode, 0, 0, 0); advancedOptionsBoxLayout->addWidget(securityMode, 0, 1, 0); mountingTabLayout->addWidget(advancedOptionsBox, 0); mountingTabLayout->addStretch(100); tabWidget->addTab(mountingTab, i18n("Mounting")); } #elif defined(Q_OS_FREEBSD) || defined(Q_OS_NETBSD) // // FreeBSD and NetBSD // void Smb4KConfigPageCustomOptions::setupMountingTab() { // // Get the tab widget // QTabWidget *tabWidget = findChild("TabWidget"); // // Custom options for mounting // QWidget *mountingTab = new QWidget(tabWidget); QVBoxLayout *mountingTabLayout = new QVBoxLayout(mountingTab); - mountingTabLayout->setSpacing(5); // // Common options // QGroupBox *commonBox = new QGroupBox(i18n("Common Options"), mountingTab); QGridLayout *commonBoxLayout = new QGridLayout(commonBox); - commonBoxLayout->setSpacing(5); QCheckBox *remountAlways = new QCheckBox(i18n("Always remount this share"), commonBox); remountAlways->setObjectName("RemountAlways"); remountAlways->setEnabled(false); commonBoxLayout->addWidget(remountAlways, 0, 0, 1, 2, 0); // User Id QCheckBox *useUserId = new QCheckBox(Smb4KMountSettings::self()->useUserIdItem()->label(), commonBox); useUserId->setObjectName("UseUserId"); KComboBox *userId = new KComboBox(commonBox); userId->setObjectName("UserId"); QList allUsers = KUser::allUsers(); for (const KUser &u : allUsers) { userId->addItem(QString("%1 (%2)").arg(u.loginName()).arg(u.userId().nativeId()), QVariant::fromValue(u.groupId().nativeId())); } commonBoxLayout->addWidget(useUserId, 1, 0, 0); commonBoxLayout->addWidget(userId, 1, 1, 0); // Group Id QCheckBox *useGroupId = new QCheckBox(Smb4KMountSettings::self()->useGroupIdItem()->label(), commonBox); useGroupId->setObjectName("UseGroupId"); KComboBox *groupId = new KComboBox(commonBox); groupId->setObjectName("GroupId"); QList allGroups = KUserGroup::allGroups(); for (const KUserGroup &g : allGroups) { groupId->addItem(QString("%1 (%2)").arg(g.name()).arg(g.groupId().nativeId()), QVariant::fromValue(g.groupId().nativeId())); } commonBoxLayout->addWidget(useGroupId, 2, 0, 0); commonBoxLayout->addWidget(groupId, 2, 1, 0); // File mode QCheckBox *useFileMode = new QCheckBox(Smb4KMountSettings::self()->useFileModeItem()->label(), commonBox); useFileMode->setObjectName("UseFileMode"); KLineEdit *fileMode = new KLineEdit(commonBox); fileMode->setObjectName("FileMode"); fileMode->setClearButtonEnabled(true); fileMode->setAlignment(Qt::AlignRight); commonBoxLayout->addWidget(useFileMode, 3, 0, 0); commonBoxLayout->addWidget(fileMode, 3, 1, 0); // Directory mode QCheckBox *useDirectoryMode = new QCheckBox(Smb4KMountSettings::self()->useDirectoryModeItem()->label(), commonBox); useDirectoryMode->setObjectName("UseDirectoryMode"); KLineEdit *directoryMode = new KLineEdit(commonBox); directoryMode->setObjectName("DirectoryMode"); directoryMode->setClearButtonEnabled(true); directoryMode->setAlignment(Qt::AlignRight); commonBoxLayout->addWidget(useDirectoryMode, 4, 0, 0); commonBoxLayout->addWidget(directoryMode, 4, 1, 0); mountingTabLayout->addWidget(commonBox, 0); mountingTabLayout->addStretch(100); tabWidget->addTab(mountingTab, i18n("Mounting")); } #else // // Generic (without mount options) // void Smb4KConfigPageCustomOptions::setupMountingTab() { // The operating system is not support } #endif void Smb4KConfigPageCustomOptions::insertCustomOptions(const QList &list) { // // If the global list of options has not been loaded, set it here // if (m_optionsList.isEmpty()) { m_optionsList = list; } // // Get the list widget and display the new options // QListWidget *optionsListWidget = findChild("OptionsListWidget"); if (optionsListWidget) { // Clear the list widget while (optionsListWidget->count() != 0) { delete optionsListWidget->item(0); } // Display the new options for (const OptionsPtr &o : m_optionsList) { switch (o->type()) { case Host: { QListWidgetItem *item = new QListWidgetItem(KDE::icon("network-server"), o->displayString(), optionsListWidget, Host); item->setData(Qt::UserRole, o->url().toDisplayString()); break; } case Share: { QListWidgetItem *item = new QListWidgetItem(KDE::icon("folder-network"), o->displayString(), optionsListWidget, Share); item->setData(Qt::UserRole, o->url().toDisplayString()); break; } default: { break; } } } optionsListWidget->sortItems(Qt::AscendingOrder); } } const QList Smb4KConfigPageCustomOptions::getCustomOptions() { return m_optionsList; } void Smb4KConfigPageCustomOptions::clearEditors() { // // Clear current options // m_currentOptions.clear(); // // Workgroup // KLineEdit *workgroup = findChild("Workgroup"); if (workgroup) { workgroup->clear(); } // // Location // KLineEdit *location = findChild("Location"); if (location) { location->clear(); } // // IP address // KLineEdit *ipAddress = findChild("IPAddress"); if (ipAddress) { disconnect(ipAddress, SIGNAL(textEdited(QString)), this, SLOT(slotEntryChanged())); ipAddress->clear(); } // // Remounting // QCheckBox *remountAlways = findChild("RemountAlways"); if (remountAlways) { disconnect(remountAlways, SIGNAL(toggled(bool)), this, SLOT(slotEntryChanged())); remountAlways->setChecked(false); } // // User Id // QCheckBox *useUserId = findChild("UseUserId"); if (useUserId) { disconnect(useUserId, SIGNAL(toggled(bool)), this, SLOT(slotEntryChanged())); useUserId->setChecked(false); } KComboBox *userId = findChild("UserId"); if (userId) { disconnect(userId, SIGNAL(currentIndexChanged(int)), this, SLOT(slotEntryChanged())); KUser user((K_UID)Smb4KMountSettings::userId().toInt()); userId->setCurrentText(QString("%1 (%2)").arg(user.loginName()).arg(user.userId().nativeId())); } // // Group Id // QCheckBox *useGroupId = findChild("UseGroupId"); if (useGroupId) { disconnect(useGroupId, SIGNAL(toggled(bool)), this, SLOT(slotEntryChanged())); useGroupId->setChecked(false); } KComboBox *groupId = findChild("GroupId"); if (groupId) { disconnect(groupId, SIGNAL(currentIndexChanged(int)), this, SLOT(slotEntryChanged())); KUserGroup group((K_GID)Smb4KMountSettings::groupId().toInt()); groupId->setCurrentText(QString("%1 (%2)").arg(group.name()).arg(group.groupId().nativeId())); } // // File mode // QCheckBox *useFileMode = findChild("UseFileMode"); if (useFileMode) { disconnect(useFileMode, SIGNAL(toggled(bool)), this, SLOT(slotEntryChanged())); useFileMode->setChecked(false); } KLineEdit *fileMode = findChild("FileMode"); if (fileMode) { disconnect(fileMode, SIGNAL(textEdited(QString)), this, SLOT(slotEntryChanged())); fileMode->setText(Smb4KMountSettings::fileMode()); } // // Directory mode // QCheckBox *useDirectoryMode = findChild("UseDirectoryMode"); if (useDirectoryMode) { disconnect(useDirectoryMode, SIGNAL(toggled(bool)), this, SLOT(slotEntryChanged())); useDirectoryMode->setChecked(false); } KLineEdit *directoryMode = findChild("DirectoryMode"); if (directoryMode) { disconnect(directoryMode, SIGNAL(textEdited(QString)), this, SLOT(slotEntryChanged())); directoryMode->setText(Smb4KMountSettings::fileMode()); } #if defined(Q_OS_LINUX) // // Write access // QCheckBox *useWriteAccess = findChild("UseWriteAccess"); if (useWriteAccess) { disconnect(useWriteAccess, SIGNAL(toggled(bool)), this, SLOT(slotEntryChanged())); useWriteAccess->setChecked(false); } KComboBox *writeAccess = findChild("WriteAccess"); if (writeAccess) { disconnect(writeAccess, SIGNAL(currentIndexChanged(int)), this, SLOT(slotEntryChanged())); QString readWriteText = Smb4KMountSettings::self()->writeAccessItem()->choices().value(Smb4KMountSettings::EnumWriteAccess::ReadWrite).label; QString readOnlyText = Smb4KMountSettings::self()->writeAccessItem()->choices().value(Smb4KMountSettings::EnumWriteAccess::ReadOnly).label; switch (Smb4KMountSettings::writeAccess()) { case Smb4KMountSettings::EnumWriteAccess::ReadWrite: { writeAccess->setCurrentText(readWriteText); break; } case Smb4KMountSettings::EnumWriteAccess::ReadOnly: { writeAccess->setCurrentText(readOnlyText); break; } default: { break; } } } // // File system port // QCheckBox *useFilesystemPort = findChild("UseFilesystemPort"); if (useFilesystemPort) { disconnect(useFilesystemPort, SIGNAL(toggled(bool)), this, SLOT(slotEntryChanged())); useFilesystemPort->setChecked(false); } QSpinBox *filesystemPort = findChild("FileSystemPort"); if (filesystemPort) { disconnect(filesystemPort, SIGNAL(valueChanged(int)), this, SLOT(slotEntryChanged())); filesystemPort->setValue(Smb4KMountSettings::remoteFileSystemPort()); } // // CIFS Unix Extensions Support // QCheckBox *cifsExtensionsSupport = findChild("CifsExtensionsSupport"); if (cifsExtensionsSupport) { disconnect(cifsExtensionsSupport, SIGNAL(toggled(bool)), this, SLOT(slotEntryChanged())); disconnect(cifsExtensionsSupport, SIGNAL(toggled(bool)), this, SLOT(slotCifsUnixExtensionsSupport(bool))); cifsExtensionsSupport->setChecked(false); } // // Security mode // QCheckBox *useSecurityMode = findChild("UseSecurityMode"); if (useSecurityMode) { disconnect(useSecurityMode, SIGNAL(toggled(bool)), this, SLOT(slotEntryChanged())); useSecurityMode->setChecked(false); } KComboBox *securityMode = findChild("SecurityMode"); if (securityMode) { disconnect(securityMode, SIGNAL(currentIndexChanged(int)), this, SLOT(slotEntryChanged())); QString noneText = Smb4KMountSettings::self()->securityModeItem()->choices().value(Smb4KMountSettings::EnumSecurityMode::None).label; QString krb5Text = Smb4KMountSettings::self()->securityModeItem()->choices().value(Smb4KMountSettings::EnumSecurityMode::Krb5).label; QString krb5iText = Smb4KMountSettings::self()->securityModeItem()->choices().value(Smb4KMountSettings::EnumSecurityMode::Krb5i).label; QString ntlmText = Smb4KMountSettings::self()->securityModeItem()->choices().value(Smb4KMountSettings::EnumSecurityMode::Ntlm).label; QString ntlmiText = Smb4KMountSettings::self()->securityModeItem()->choices().value(Smb4KMountSettings::EnumSecurityMode::Ntlmi).label; QString ntlmv2Text = Smb4KMountSettings::self()->securityModeItem()->choices().value(Smb4KMountSettings::EnumSecurityMode::Ntlmv2).label; QString ntlmv2iText = Smb4KMountSettings::self()->securityModeItem()->choices().value(Smb4KMountSettings::EnumSecurityMode::Ntlmv2i).label; QString ntlmsspText = Smb4KMountSettings::self()->securityModeItem()->choices().value(Smb4KMountSettings::EnumSecurityMode::Ntlmssp).label; QString ntlmsspiText = Smb4KMountSettings::self()->securityModeItem()->choices().value(Smb4KMountSettings::EnumSecurityMode::Ntlmsspi).label; switch (Smb4KMountSettings::securityMode()) { case Smb4KMountSettings::EnumSecurityMode::None: { securityMode->setCurrentText(noneText); break; } case Smb4KMountSettings::EnumSecurityMode::Krb5: { securityMode->setCurrentText(krb5Text); break; } case Smb4KMountSettings::EnumSecurityMode::Krb5i: { securityMode->setCurrentText(krb5iText); break; } case Smb4KMountSettings::EnumSecurityMode::Ntlm: { securityMode->setCurrentText(ntlmText); break; } case Smb4KMountSettings::EnumSecurityMode::Ntlmi: { securityMode->setCurrentText(ntlmiText); break; } case Smb4KMountSettings::EnumSecurityMode::Ntlmv2: { securityMode->setCurrentText(ntlmv2Text); break; } case Smb4KMountSettings::EnumSecurityMode::Ntlmv2i: { securityMode->setCurrentText(ntlmv2iText); break; } case Smb4KMountSettings::EnumSecurityMode::Ntlmssp: { securityMode->setCurrentText(ntlmsspText); break; } case Smb4KMountSettings::EnumSecurityMode::Ntlmsspi: { securityMode->setCurrentText(ntlmsspiText); break; } default: { break; } } } #endif // // SMB port // QCheckBox *useSmbPort = findChild("UseSmbPort"); if (useSmbPort) { disconnect(useSmbPort, SIGNAL(toggled(bool)), this, SLOT(slotEntryChanged())); useSmbPort->setChecked(false); } QSpinBox *smbPort = findChild("SmbPort"); if (smbPort) { disconnect(smbPort, SIGNAL(valueChanged(int)), this, SLOT(slotEntryChanged())); smbPort->setValue(Smb4KSettings::remoteSmbPort()); } // // Kerberos // QCheckBox *useKerberos = findChild("UseKerberos"); if (useKerberos) { disconnect(useKerberos, SIGNAL(toggled(bool)), this, SLOT(slotEntryChanged())); useKerberos->setChecked(false); } // // MAC address // KLineEdit *macAddress = findChild("MACAddress"); if (macAddress) { disconnect(macAddress, SIGNAL(textEdited(QString)), this, SLOT(slotEntryChanged())); disconnect(macAddress, SIGNAL(textEdited(QString)), this, SLOT(slotEnableWOLFeatures(QString))); macAddress->clear(); macAddress->setInputMask("HH:HH:HH:HH:HH:HH;_"); } // // Wake-On-Lan: send package before scan // QCheckBox *sendPackageBeforeScan = findChild("SendPackageBeforeScan"); if (sendPackageBeforeScan) { disconnect(sendPackageBeforeScan, SIGNAL(toggled(bool)), this, SLOT(slotEntryChanged())); sendPackageBeforeScan->setChecked(false); } // // Wake-On-Lan: Send package before mount // QCheckBox *sendPackageBeforeMount = findChild("SendPackageBeforeMount"); if (sendPackageBeforeMount) { disconnect(sendPackageBeforeMount, SIGNAL(toggled(bool)), this, SLOT(slotEntryChanged())); sendPackageBeforeMount->setChecked(false); } // // Disable widgets // QTabWidget *tabWidget = findChild("TabWidget"); if (tabWidget) { tabWidget->setEnabled(false); } } void Smb4KConfigPageCustomOptions::setCurrentOptions(const QString& url) { for (const OptionsPtr &o : m_optionsList) { if (url == o->url().toString()) { m_currentOptions = o; break; } } } void Smb4KConfigPageCustomOptions::populateEditors() { // // Workgroup // KLineEdit *workgroup = findChild("Workgroup"); if (workgroup) { workgroup->setText(m_currentOptions->workgroupName()); } // // Location // KLineEdit *location = findChild("Location"); if (location) { location->setText(m_currentOptions->displayString()); } // // IP address // KLineEdit *ipAddress = findChild("IPAddress"); if (ipAddress) { ipAddress->setText(m_currentOptions->ipAddress()); connect(ipAddress, SIGNAL(textEdited(QString)), this, SLOT(slotEntryChanged())); } // // Remounting // QCheckBox *remountAlways = findChild("RemountAlways"); if (remountAlways) { remountAlways->setEnabled(m_currentOptions->type() == Share); if (m_currentOptions->remount() == Smb4KCustomOptions::RemountAlways) { remountAlways->setChecked(true); } else { remountAlways->setChecked(false); } connect(remountAlways, SIGNAL(toggled(bool)), this, SLOT(slotEntryChanged())); } // // User Id // QCheckBox *useUserId = findChild("UseUserId"); if (useUserId) { useUserId->setChecked(m_currentOptions->useUser()); connect(useUserId, SIGNAL(toggled(bool)), this, SLOT(slotEntryChanged())); } KComboBox *userId = findChild("UserId"); if (userId) { userId->setCurrentText(QString("%1 (%2)").arg(m_currentOptions->user().loginName()).arg(m_currentOptions->user().userId().nativeId())); connect(userId, SIGNAL(currentIndexChanged(int)), this, SLOT(slotEntryChanged())); } // // Group Id // QCheckBox *useGroupId = findChild("UseGroupId"); if (useGroupId) { useGroupId->setChecked(m_currentOptions->useGroup()); connect(useGroupId, SIGNAL(toggled(bool)), this, SLOT(slotEntryChanged())); } KComboBox *groupId = findChild("GroupId"); if (groupId) { groupId->setCurrentText(QString("%1 (%2)").arg(m_currentOptions->group().name()).arg(m_currentOptions->group().groupId().nativeId())); connect(groupId, SIGNAL(currentIndexChanged(int)), this, SLOT(slotEntryChanged())); } // // File mode // QCheckBox *useFileMode = findChild("UseFileMode"); if (useFileMode) { useFileMode->setChecked(m_currentOptions->useFileMode()); connect(useFileMode, SIGNAL(toggled(bool)), this, SLOT(slotEntryChanged())); } KLineEdit *fileMode = findChild("FileMode"); if (fileMode) { fileMode->setText(m_currentOptions->fileMode()); connect(fileMode, SIGNAL(textEdited(QString)), this, SLOT(slotEntryChanged())); } // // Directory mode // QCheckBox *useDirectoryMode = findChild("UseDirectoryMode"); if (useDirectoryMode) { useDirectoryMode->setChecked(m_currentOptions->useFileMode()); connect(useDirectoryMode, SIGNAL(toggled(bool)), this, SLOT(slotEntryChanged())); } KLineEdit *directoryMode = findChild("DirectoryMode"); if (directoryMode) { directoryMode->setText(m_currentOptions->directoryMode()); connect(directoryMode, SIGNAL(textEdited(QString)), this, SLOT(slotEntryChanged())); } #if defined(Q_OS_LINUX) // // Write access // QCheckBox *useWriteAccess = findChild("UseWriteAccess"); if (useWriteAccess) { useWriteAccess->setChecked(m_currentOptions->useWriteAccess()); connect(useWriteAccess, SIGNAL(toggled(bool)), this, SLOT(slotEntryChanged())); } KComboBox *writeAccess = findChild("WriteAccess"); if (writeAccess) { QString readWriteText = Smb4KMountSettings::self()->writeAccessItem()->choices().value(Smb4KMountSettings::EnumWriteAccess::ReadWrite).label; QString readOnlyText = Smb4KMountSettings::self()->writeAccessItem()->choices().value(Smb4KMountSettings::EnumWriteAccess::ReadOnly).label; switch (m_currentOptions->writeAccess()) { case Smb4KMountSettings::EnumWriteAccess::ReadWrite: { writeAccess->setCurrentText(readWriteText); break; } case Smb4KMountSettings::EnumWriteAccess::ReadOnly: { writeAccess->setCurrentText(readOnlyText); break; } default: { break; } } connect(writeAccess, SIGNAL(currentIndexChanged(int)), this, SLOT(slotEntryChanged())); } // // File system port // QCheckBox *useFilesystemPort = findChild("UseFilesystemPort"); if (useFilesystemPort) { useFilesystemPort->setChecked(m_currentOptions->useFileSystemPort()); connect(useFilesystemPort, SIGNAL(toggled(bool)), this, SLOT(slotEntryChanged())); } QSpinBox *filesystemPort = findChild("FileSystemPort"); if (filesystemPort) { filesystemPort->setValue(m_currentOptions->fileSystemPort()); connect(filesystemPort, SIGNAL(valueChanged(int)), this, SLOT(slotEntryChanged())); } // // CIFS Unix Extensions Support // QCheckBox *cifsExtensionsSupport = findChild("CifsExtensionsSupport"); if (cifsExtensionsSupport) { connect(cifsExtensionsSupport, SIGNAL(toggled(bool)), this, SLOT(slotCifsUnixExtensionsSupport(bool))); cifsExtensionsSupport->setChecked(m_currentOptions->cifsUnixExtensionsSupport()); connect(cifsExtensionsSupport, SIGNAL(toggled(bool)), this, SLOT(slotEntryChanged())); } // // Security mode // QCheckBox *useSecurityMode = findChild("UseSecurityMode"); if (useSecurityMode) { useSecurityMode->setChecked(m_currentOptions->useSecurityMode()); connect(useSecurityMode, SIGNAL(toggled(bool)), this, SLOT(slotEntryChanged())); } KComboBox *securityMode = findChild("SecurityMode"); if (securityMode) { QString noneText = Smb4KMountSettings::self()->securityModeItem()->choices().value(Smb4KMountSettings::EnumSecurityMode::None).label; QString krb5Text = Smb4KMountSettings::self()->securityModeItem()->choices().value(Smb4KMountSettings::EnumSecurityMode::Krb5).label; QString krb5iText = Smb4KMountSettings::self()->securityModeItem()->choices().value(Smb4KMountSettings::EnumSecurityMode::Krb5i).label; QString ntlmText = Smb4KMountSettings::self()->securityModeItem()->choices().value(Smb4KMountSettings::EnumSecurityMode::Ntlm).label; QString ntlmiText = Smb4KMountSettings::self()->securityModeItem()->choices().value(Smb4KMountSettings::EnumSecurityMode::Ntlmi).label; QString ntlmv2Text = Smb4KMountSettings::self()->securityModeItem()->choices().value(Smb4KMountSettings::EnumSecurityMode::Ntlmv2).label; QString ntlmv2iText = Smb4KMountSettings::self()->securityModeItem()->choices().value(Smb4KMountSettings::EnumSecurityMode::Ntlmv2i).label; QString ntlmsspText = Smb4KMountSettings::self()->securityModeItem()->choices().value(Smb4KMountSettings::EnumSecurityMode::Ntlmssp).label; QString ntlmsspiText = Smb4KMountSettings::self()->securityModeItem()->choices().value(Smb4KMountSettings::EnumSecurityMode::Ntlmsspi).label; switch (m_currentOptions->securityMode()) { case Smb4KMountSettings::EnumSecurityMode::None: { securityMode->setCurrentText(noneText); break; } case Smb4KMountSettings::EnumSecurityMode::Krb5: { securityMode->setCurrentText(krb5Text); break; } case Smb4KMountSettings::EnumSecurityMode::Krb5i: { securityMode->setCurrentText(krb5iText); break; } case Smb4KMountSettings::EnumSecurityMode::Ntlm: { securityMode->setCurrentText(ntlmText); break; } case Smb4KMountSettings::EnumSecurityMode::Ntlmi: { securityMode->setCurrentText(ntlmiText); break; } case Smb4KMountSettings::EnumSecurityMode::Ntlmv2: { securityMode->setCurrentText(ntlmv2Text); break; } case Smb4KMountSettings::EnumSecurityMode::Ntlmv2i: { securityMode->setCurrentText(ntlmv2iText); break; } case Smb4KMountSettings::EnumSecurityMode::Ntlmssp: { securityMode->setCurrentText(ntlmsspText); break; } case Smb4KMountSettings::EnumSecurityMode::Ntlmsspi: { securityMode->setCurrentText(ntlmsspiText); break; } default: { break; } } connect(securityMode, SIGNAL(currentIndexChanged(int)), this, SLOT(slotEntryChanged())); } slotCifsUnixExtensionsSupport(cifsExtensionsSupport->isChecked()); #endif // // SMB port // QCheckBox *useSmbPort = findChild("UseSmbPort"); if (useSmbPort) { useSmbPort->setChecked(m_currentOptions->useSmbPort()); connect(useSmbPort, SIGNAL(toggled(bool)), this, SLOT(slotEntryChanged())); } QSpinBox *smbPort = findChild("SmbPort"); if (smbPort) { smbPort->setValue(m_currentOptions->smbPort()); connect(smbPort, SIGNAL(valueChanged(int)), this, SLOT(slotEntryChanged())); } // // Kerberos // QCheckBox *useKerberos = findChild("UseKerberos"); if (useKerberos) { useKerberos->setChecked(m_currentOptions->useKerberos()); connect(useKerberos, SIGNAL(toggled(bool)), this, SLOT(slotEntryChanged())); } // // MAC address // KLineEdit *macAddress = findChild("MACAddress"); if (macAddress) { macAddress->setText(m_currentOptions->macAddress()); connect(macAddress, SIGNAL(textEdited(QString)), this, SLOT(slotEntryChanged())); connect(macAddress, SIGNAL(textEdited(QString)), this, SLOT(slotEnableWOLFeatures(QString))); slotEnableWOLFeatures(m_currentOptions->macAddress()); } // // Wake-On-Lan: Send package before scan // QCheckBox *sendPackageBeforeScan = findChild("SendPackageBeforeScan"); if (sendPackageBeforeScan) { sendPackageBeforeScan->setChecked(m_currentOptions->wolSendBeforeNetworkScan()); connect(sendPackageBeforeScan, SIGNAL(toggled(bool)), this, SLOT(slotEntryChanged())); } // // Wake-On-Lan: Send package before mount // QCheckBox *sendPackageBeforeMount = findChild("SendPackageBeforeMount"); if (sendPackageBeforeMount) { sendPackageBeforeMount->setChecked(m_currentOptions->wolSendBeforeMount()); connect(sendPackageBeforeMount, SIGNAL(toggled(bool)), this, SLOT(slotEntryChanged())); } // // Enable widgets // QTabWidget *tabWidget = findChild("TabWidget"); if (tabWidget) { // Enable the tab widget tabWidget->setEnabled(true); // Enable the Wake-On-Lan page int wolTabIndex = tabWidget->count() - 1; tabWidget->widget(wolTabIndex)->setEnabled(Smb4KSettings::enableWakeOnLAN()); } } void Smb4KConfigPageCustomOptions::commitChanges() { // // IP address // KLineEdit *ipAddress = findChild("IPAddress"); if (ipAddress) { m_currentOptions->setIpAddress(ipAddress->text()); } // // Remounting // QCheckBox *remountAlways = findChild("RemountAlways"); if (remountAlways) { if (remountAlways->isChecked()) { m_currentOptions->setRemount(Smb4KCustomOptions::RemountAlways); } else { m_currentOptions->setRemount(Smb4KCustomOptions::UndefinedRemount); } } // // User Id // QCheckBox *useUserId = findChild("UseUserId"); if (useUserId) { m_currentOptions->setUseUser(useUserId->isChecked()); } KComboBox *userId = findChild("UserId"); if (userId) { m_currentOptions->setUser(KUser(userId->itemData(userId->currentIndex()).toInt())); } // // Group Id // QCheckBox *useGroupId = findChild("UseGroupId"); if (useGroupId) { m_currentOptions->setUseGroup(useGroupId->isChecked()); } KComboBox *groupId = findChild("GroupId"); if (groupId) { m_currentOptions->setGroup(KUserGroup(groupId->itemData(groupId->currentIndex()).toInt())); } // // File mode // QCheckBox *useFileMode = findChild("UseFileMode"); if (useFileMode) { m_currentOptions->setUseFileMode(useFileMode->isChecked()); } KLineEdit *fileMode = findChild("FileMode"); if (fileMode) { m_currentOptions->setFileMode(fileMode->text()); } // // Directory mode // QCheckBox *useDirectoryMode = findChild("UseDirectoryMode"); if (useDirectoryMode) { m_currentOptions->setUseDirectoryMode(useDirectoryMode->isChecked()); } KLineEdit *directoryMode = findChild("DirectoryMode"); if (directoryMode) { m_currentOptions->setDirectoryMode(directoryMode->text()); } #if defined(Q_OS_LINUX) // // Write access // QCheckBox *useWriteAccess = findChild("UseWriteAccess"); if (useWriteAccess) { m_currentOptions->setUseWriteAccess(useWriteAccess->isChecked()); } KComboBox *writeAccess = findChild("WriteAccess"); if (writeAccess) { QString readWriteText = Smb4KMountSettings::self()->writeAccessItem()->choices().value(Smb4KMountSettings::EnumWriteAccess::ReadWrite).label; QString readOnlyText = Smb4KMountSettings::self()->writeAccessItem()->choices().value(Smb4KMountSettings::EnumWriteAccess::ReadOnly).label; if (writeAccess->currentText() == readWriteText) { m_currentOptions->setWriteAccess(Smb4KMountSettings::EnumWriteAccess::ReadWrite); } else if (writeAccess->currentText() == readOnlyText) { m_currentOptions->setWriteAccess(Smb4KMountSettings::EnumWriteAccess::ReadOnly); } } // // File system port // QCheckBox *useFilesystemPort = findChild("UseFilesystemPort"); if (useFilesystemPort) { m_currentOptions->setUseFileSystemPort(useFilesystemPort->isChecked()); } QSpinBox *filesystemPort = findChild("FileSystemPort"); if (filesystemPort) { m_currentOptions->setFileSystemPort(filesystemPort->value()); } // // CIFS Unix Extensions Support // QCheckBox *cifsExtensionsSupport = findChild("CifsExtensionsSupport"); if (cifsExtensionsSupport) { m_currentOptions->setCifsUnixExtensionsSupport(cifsExtensionsSupport->isChecked()); } // // Security mode // QCheckBox *useSecurityMode = findChild("UseSecurityMode"); if (useSecurityMode) { m_currentOptions->setUseSecurityMode(useSecurityMode->isChecked()); } KComboBox *securityMode = findChild("SecurityMode"); if (securityMode) { QString noneText = Smb4KMountSettings::self()->securityModeItem()->choices().value(Smb4KMountSettings::EnumSecurityMode::None).label; QString krb5Text = Smb4KMountSettings::self()->securityModeItem()->choices().value(Smb4KMountSettings::EnumSecurityMode::Krb5).label; QString krb5iText = Smb4KMountSettings::self()->securityModeItem()->choices().value(Smb4KMountSettings::EnumSecurityMode::Krb5i).label; QString ntlmText = Smb4KMountSettings::self()->securityModeItem()->choices().value(Smb4KMountSettings::EnumSecurityMode::Ntlm).label; QString ntlmiText = Smb4KMountSettings::self()->securityModeItem()->choices().value(Smb4KMountSettings::EnumSecurityMode::Ntlmi).label; QString ntlmv2Text = Smb4KMountSettings::self()->securityModeItem()->choices().value(Smb4KMountSettings::EnumSecurityMode::Ntlmv2).label; QString ntlmv2iText = Smb4KMountSettings::self()->securityModeItem()->choices().value(Smb4KMountSettings::EnumSecurityMode::Ntlmv2i).label; QString ntlmsspText = Smb4KMountSettings::self()->securityModeItem()->choices().value(Smb4KMountSettings::EnumSecurityMode::Ntlmssp).label; QString ntlmsspiText = Smb4KMountSettings::self()->securityModeItem()->choices().value(Smb4KMountSettings::EnumSecurityMode::Ntlmsspi).label; if (securityMode->currentText() == noneText) { m_currentOptions->setSecurityMode(Smb4KMountSettings::EnumSecurityMode::None); } else if (securityMode->currentText() == krb5Text) { m_currentOptions->setSecurityMode(Smb4KMountSettings::EnumSecurityMode::Krb5); } else if (securityMode->currentText() == krb5iText) { m_currentOptions->setSecurityMode(Smb4KMountSettings::EnumSecurityMode::Krb5i); } else if (securityMode->currentText() == ntlmText) { m_currentOptions->setSecurityMode(Smb4KMountSettings::EnumSecurityMode::Ntlm); } else if (securityMode->currentText() == ntlmiText) { m_currentOptions->setSecurityMode(Smb4KMountSettings::EnumSecurityMode::Ntlmi); } else if (securityMode->currentText() == ntlmv2Text) { m_currentOptions->setSecurityMode(Smb4KMountSettings::EnumSecurityMode::Ntlmv2); } else if (securityMode->currentText() == ntlmv2iText) { m_currentOptions->setSecurityMode(Smb4KMountSettings::EnumSecurityMode::Ntlmv2i); } else if (securityMode->currentText() == ntlmsspText) { m_currentOptions->setSecurityMode(Smb4KMountSettings::EnumSecurityMode::Ntlmssp); } else if (securityMode->currentText() == ntlmsspiText) { m_currentOptions->setSecurityMode(Smb4KMountSettings::EnumSecurityMode::Ntlmsspi); } } #endif // // SMB port // QCheckBox *useSmbPort = findChild("UseSmbPort"); if (useSmbPort) { m_currentOptions->setUseSmbPort(useSmbPort->isChecked()); } QSpinBox *smbPort = findChild("SmbPort"); if (smbPort) { m_currentOptions->setSmbPort(smbPort->value()); } // // Kerberos // QCheckBox *useKerberos = findChild("UseKerberos"); if (useKerberos) { m_currentOptions->setUseKerberos(useKerberos->isChecked()); } // // MAC address // KLineEdit *macAddress = findChild("MACAddress"); if (macAddress) { m_currentOptions->setMACAddress(macAddress->text()); } // // Wake-On-Lan: Send package before scan // QCheckBox *sendPackageBeforeScan = findChild("SendPackageBeforeScan"); if (sendPackageBeforeScan) { m_currentOptions->setWOLSendBeforeNetworkScan(sendPackageBeforeScan->isChecked()); } // // Wake-On-Lan: Send package before mount // QCheckBox *sendPackageBeforeMount = findChild("SendPackageBeforeMount"); if (sendPackageBeforeMount) { m_currentOptions->setWOLSendBeforeMount(sendPackageBeforeMount->isChecked()); } // // In case the options are defined for a host, propagate them // to the options of shares belonging to that host. Overwrite // the settings // if (m_currentOptions->type() == Host) { for (const OptionsPtr &o : m_optionsList) { if (o->type() == Share && o->hostName() == m_currentOptions->hostName() && o->workgroupName() == m_currentOptions->workgroupName()) { o->setIpAddress(m_currentOptions->ipAddress()); o->setUseUser(m_currentOptions->useUser()); o->setUser(m_currentOptions->user()); o->setUseGroup(m_currentOptions->useGroup()); o->setGroup(m_currentOptions->group()); o->setUseFileMode(m_currentOptions->useFileMode()); o->setFileMode(m_currentOptions->fileMode()); o->setUseDirectoryMode(m_currentOptions->useDirectoryMode()); o->setDirectoryMode(m_currentOptions->directoryMode()); #if defined(Q_OS_LINUX) o->setCifsUnixExtensionsSupport(m_currentOptions->cifsUnixExtensionsSupport()); o->setUseFileSystemPort(m_currentOptions->useFileSystemPort()); o->setFileSystemPort(m_currentOptions->fileSystemPort()); o->setUseSecurityMode(m_currentOptions->useSecurityMode()); o->setSecurityMode(m_currentOptions->securityMode()); o->setUseWriteAccess(m_currentOptions->useWriteAccess()); o->setWriteAccess(m_currentOptions->writeAccess()); #endif o->setUseSmbPort(m_currentOptions->useSmbPort()); o->setSmbPort(m_currentOptions->smbPort()); o->setUseKerberos(m_currentOptions->useKerberos()); o->setMACAddress(m_currentOptions->macAddress()); o->setWOLSendBeforeNetworkScan(m_currentOptions->wolSendBeforeNetworkScan()); o->setWOLSendBeforeMount(m_currentOptions->wolSendBeforeMount()); } } } m_maybe_changed = true; emit customSettingsModified(); } bool Smb4KConfigPageCustomOptions::eventFilter(QObject* obj, QEvent* e) { QListWidget *optionsListWidget = findChild("OptionsListWidget"); if (optionsListWidget) { if (obj == optionsListWidget->viewport()) { if (e->type() == QEvent::MouseButtonPress) { QMouseEvent *mev = static_cast(e); QPoint pos = optionsListWidget->viewport()->mapFromGlobal(mev->globalPos()); QListWidgetItem *item = optionsListWidget->itemAt(pos); if (!item) { clearEditors(); optionsListWidget->clearSelection(); } } } } return QObject::eventFilter(obj, e); } void Smb4KConfigPageCustomOptions::slotEditCustomItem(QListWidgetItem *item) { setCurrentOptions(item->data(Qt::UserRole).toString()); if (m_currentOptions) { populateEditors(); } else { clearEditors(); } } void Smb4KConfigPageCustomOptions::slotItemSelectionChanged() { clearEditors(); } void Smb4KConfigPageCustomOptions::slotCustomContextMenuRequested(const QPoint& pos) { QListWidget *optionsListWidget = findChild("OptionsListWidget"); if (optionsListWidget) { QListWidgetItem *item = optionsListWidget->itemAt(pos); for (QAction *a : optionsListWidget->actions()) { if (a->objectName() == "edit_action") { a->setEnabled(item != 0); } else if (a->objectName() == "remove_action") { a->setEnabled(item != 0); } else if (a->objectName() == "clear_action") { a->setEnabled(optionsListWidget->count() != 0); } } KActionMenu *actionMenu = optionsListWidget->findChild("ActionMenu"); if (actionMenu) { actionMenu->menu()->popup(optionsListWidget->viewport()->mapToGlobal(pos)); } } } void Smb4KConfigPageCustomOptions::slotEditActionTriggered(bool /*checked*/) { QListWidget *optionsListWidget = findChild("OptionsListWidget"); if (optionsListWidget) { slotEditCustomItem(optionsListWidget->currentItem()); } } void Smb4KConfigPageCustomOptions::slotRemoveActionTriggered(bool /*checked*/) { QListWidget *optionsListWidget = findChild("OptionsListWidget"); if (optionsListWidget) { QListWidgetItem *item = optionsListWidget->currentItem(); if (item) { setCurrentOptions(item->data(Qt::UserRole).toString()); int index = m_optionsList.indexOf(m_currentOptions); if (index != -1) { m_optionsList.takeAt(index).clear(); } KLineEdit *location = findChild("Location"); if (location) { if (item->text() == location->text()) { clearEditors(); } } delete item; m_currentOptions.clear(); m_maybe_changed = true; emit customSettingsModified(); } } } void Smb4KConfigPageCustomOptions::slotClearActionTriggered(bool /*checked*/) { clearEditors(); QListWidget *optionsListWidget = findChild("OptionsListWidget"); if (optionsListWidget) { while (optionsListWidget->count() != 0) { delete optionsListWidget->item(0); } } while (!m_optionsList.isEmpty()) { m_optionsList.takeFirst().clear(); } m_currentOptions.clear(); m_maybe_changed = true; emit customSettingsModified(); } void Smb4KConfigPageCustomOptions::slotEntryChanged() { commitChanges(); } void Smb4KConfigPageCustomOptions::slotEnableWOLFeatures(const QString &mac_address) { QRegExp exp("..\\:..\\:..\\:..\\:..\\:.."); // // Wake-On_lan: send package before scan // QCheckBox *sendPackageBeforeScan = findChild("SendPackageBeforeScan"); if (sendPackageBeforeScan) { sendPackageBeforeScan->setEnabled(exp.exactMatch(mac_address)); } // // Wake-On-Lan: send package before mount // QCheckBox *sendPackageBeforeMount = findChild("SendPackageBeforeMount"); if (sendPackageBeforeMount) { sendPackageBeforeMount->setEnabled(exp.exactMatch(mac_address)); } } void Smb4KConfigPageCustomOptions::slotCifsUnixExtensionsSupport(bool on) { // // User Id // QCheckBox *useUserId = findChild("UseUserId"); if (useUserId) { useUserId->setEnabled(!on); } KComboBox *userId = findChild("UserId"); if (userId) { userId->setEnabled(!on); } // // Group Id // QCheckBox *useGroupId = findChild("UseGroupId"); if (useGroupId) { useGroupId->setEnabled(!on); } KComboBox *groupId = findChild("GroupId"); if (groupId) { groupId->setEnabled(!on); } // // File mode // QCheckBox *useFileMode = findChild("UseFileMode"); if (useFileMode) { useFileMode->setEnabled(!on); } KLineEdit *fileMode = findChild("FileMode"); if (fileMode) { fileMode->setEnabled(!on); } // // Directory mode // QCheckBox *useDirectoryMode = findChild("UseDirectoryMode"); if (useDirectoryMode) { useDirectoryMode->setEnabled(!on); } KLineEdit *directoryMode = findChild("DirectoryMode"); if (directoryMode) { directoryMode->setEnabled(!on); } } diff --git a/smb4k/smb4kconfigpagemounting.cpp b/smb4k/smb4kconfigpagemounting.cpp index ae97f97..67d8031 100644 --- a/smb4k/smb4kconfigpagemounting.cpp +++ b/smb4k/smb4kconfigpagemounting.cpp @@ -1,950 +1,912 @@ /*************************************************************************** The configuration page for the mount options ------------------- begin : So Mär 22 2015 copyright : (C) 2015-2019 by Alexander Reinholdt email : alexander.reinholdt@kdemail.net ***************************************************************************/ /*************************************************************************** * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, but * * WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * * General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., 51 Franklin Street, Suite 500, Boston,* * MA 02110-1335, USA * ***************************************************************************/ // application specific includes #include "smb4kconfigpagemounting.h" #include "core/smb4kglobal.h" #if defined(Q_OS_LINUX) #include "core/smb4kmountsettings_linux.h" #elif defined(Q_OS_FREEBSD) || defined(Q_OS_NETBSD) #include "core/smb4kmountsettings_bsd.h" #endif // Qt includes #include #include #include #include #include #include #include #include // KDE includes #include #include #include #include #include #include using namespace Smb4KGlobal; Smb4KConfigPageMounting::Smb4KConfigPageMounting(QWidget* parent): QTabWidget(parent) { setupWidget(); } Smb4KConfigPageMounting::~Smb4KConfigPageMounting() { } #if defined(Q_OS_LINUX) // // Linux // void Smb4KConfigPageMounting::setupWidget() { // // Basic Settings tab // QWidget *basicTab = new QWidget(this); QVBoxLayout *basicTabLayout = new QVBoxLayout(basicTab); - basicTabLayout->setSpacing(5); - basicTabLayout->setContentsMargins(0, 0, 0, 0); // // Directories // QGroupBox *directoryBox = new QGroupBox(i18n("Directories"), basicTab); - QGridLayout *directoryBoxLayout = new QGridLayout(directoryBox); - directoryBoxLayout->setSpacing(5); QLabel *prefixLabel = new QLabel(Smb4KMountSettings::self()->mountPrefixItem()->label(), directoryBox); KUrlRequester *prefix = new KUrlRequester(directoryBox); prefix->setMode(KFile::Directory | KFile::LocalOnly); prefix->setObjectName("kcfg_MountPrefix"); prefixLabel->setBuddy(prefix); QCheckBox *lowercaseSubdirs = new QCheckBox(Smb4KMountSettings::self()->forceLowerCaseSubdirsItem()->label(), directoryBox); lowercaseSubdirs->setObjectName("kcfg_ForceLowerCaseSubdirs"); directoryBoxLayout->addWidget(prefixLabel, 0, 0, 0); directoryBoxLayout->addWidget(prefix, 0, 1, 0); directoryBoxLayout->addWidget(lowercaseSubdirs, 1, 0, 1, 2, 0); basicTabLayout->addWidget(directoryBox, 0); // // Behavior // QGroupBox *behaviorBox = new QGroupBox(i18n("Behavior"), this); QGridLayout *behaviorBoxLayout = new QGridLayout(behaviorBox); - behaviorBoxLayout->setSpacing(5); QCheckBox *remountShares = new QCheckBox(Smb4KMountSettings::self()->remountSharesItem()->label(), behaviorBox); remountShares->setObjectName("kcfg_RemountShares"); QLabel *remountAttemptsLabel = new QLabel(Smb4KMountSettings::self()->remountAttemptsItem()->label(), behaviorBox); remountAttemptsLabel->setIndent(25); QSpinBox *remountAttempts = new QSpinBox(behaviorBox); remountAttempts->setObjectName("kcfg_RemountAttempts"); remountAttemptsLabel->setBuddy(remountAttempts); QLabel *remountIntervalLabel = new QLabel(Smb4KMountSettings::self()->remountIntervalItem()->label(), behaviorBox); remountIntervalLabel->setIndent(25); QSpinBox *remountInterval = new QSpinBox(behaviorBox); remountInterval->setObjectName("kcfg_RemountInterval"); remountInterval->setSuffix(i18n(" min")); remountIntervalLabel->setBuddy(remountInterval); QCheckBox *unmountAllShares = new QCheckBox(Smb4KMountSettings::self()->unmountSharesOnExitItem()->label(), behaviorBox); unmountAllShares->setObjectName("kcfg_UnmountSharesOnExit"); QCheckBox *unmountForeignShares = new QCheckBox(Smb4KMountSettings::self()->unmountForeignSharesItem()->label(), behaviorBox); unmountForeignShares->setObjectName("kcfg_UnmountForeignShares"); QCheckBox *unmountInaccessibleShares = new QCheckBox(Smb4KMountSettings::self()->forceUnmountInaccessibleItem()->label(), behaviorBox); unmountInaccessibleShares->setObjectName("kcfg_ForceUnmountInaccessible"); QCheckBox *detectAllShares = new QCheckBox(Smb4KMountSettings::self()->detectAllSharesItem()->label(), behaviorBox); detectAllShares->setObjectName("kcfg_DetectAllShares"); behaviorBoxLayout->addWidget(remountShares, 0, 0, 1, 2, 0); behaviorBoxLayout->addWidget(remountAttemptsLabel, 1, 0, 0); behaviorBoxLayout->addWidget(remountAttempts, 1, 1, 0); behaviorBoxLayout->addWidget(remountIntervalLabel, 2, 0, 0); behaviorBoxLayout->addWidget(remountInterval, 2, 1, 0); behaviorBoxLayout->addWidget(unmountAllShares, 3, 0, 1, 2, 0); behaviorBoxLayout->addWidget(unmountInaccessibleShares, 4, 0, 1, 2, 0); behaviorBoxLayout->addWidget(unmountForeignShares, 5, 0, 1, 2, 0); behaviorBoxLayout->addWidget(detectAllShares, 6, 0, 1, 2, 0); basicTabLayout->addWidget(behaviorBox, 0); basicTabLayout->addStretch(100); addTab(basicTab, i18n("Basic Settings")); // // Common Mount Settings tab // QWidget *commonTab = new QWidget(this); QVBoxLayout *commonTabLayout = new QVBoxLayout(commonTab); - commonTabLayout->setSpacing(5); - commonTabLayout->setContentsMargins(0, 0, 0, 0); // // Common options group box // QGroupBox *commonOptions = new QGroupBox(i18n("Common Options"), commonTab); - QGridLayout *commonOptionsLayout = new QGridLayout(commonOptions); - commonOptionsLayout->setSpacing(5); // Write access QCheckBox *useWriteAccess = new QCheckBox(Smb4KMountSettings::self()->useWriteAccessItem()->label(), commonOptions); useWriteAccess->setObjectName("kcfg_UseWriteAccess"); KComboBox *writeAccess = new KComboBox(commonOptions); writeAccess->setObjectName("kcfg_WriteAccess"); QList writeAccessChoices = Smb4KMountSettings::self()->writeAccessItem()->choices(); for (const KCoreConfigSkeleton::ItemEnum::Choice &wa : writeAccessChoices) { writeAccess->addItem(wa.label); } commonOptionsLayout->addWidget(useWriteAccess, 0, 0, 0); commonOptionsLayout->addWidget(writeAccess, 0, 1, 0); // Character set QCheckBox *useCharacterSet = new QCheckBox(Smb4KMountSettings::self()->useClientCharsetItem()->label(), commonOptions); useCharacterSet->setObjectName("kcfg_UseClientCharset"); KComboBox *characterSet = new KComboBox(commonOptions); characterSet->setObjectName("kcfg_ClientCharset"); QList charsetChoices = Smb4KMountSettings::self()->clientCharsetItem()->choices(); for (const KCoreConfigSkeleton::ItemEnum::Choice &c : charsetChoices) { characterSet->addItem(c.label); } commonOptionsLayout->addWidget(useCharacterSet, 1, 0, 0); commonOptionsLayout->addWidget(characterSet, 1, 1, 0); // Remote filesystem port QCheckBox *useFilesystemPort = new QCheckBox(Smb4KMountSettings::self()->useRemoteFileSystemPortItem()->label(), commonOptions); useFilesystemPort->setObjectName("kcfg_UseRemoteFileSystemPort"); QSpinBox *filesystemPort = new QSpinBox(commonOptions); filesystemPort->setObjectName("kcfg_RemoteFileSystemPort"); commonOptionsLayout->addWidget(useFilesystemPort, 2, 0, 0); commonOptionsLayout->addWidget(filesystemPort, 2, 1, 0); commonTabLayout->addWidget(commonOptions, 0); // // CIFS Unix Extensions Support group box // QGroupBox *cifsExtensionSupportBox= new QGroupBox(i18n("CIFS Unix Extensions Support"), commonTab); - QGridLayout *cifsExtensionSupportLayout = new QGridLayout(cifsExtensionSupportBox); - cifsExtensionSupportLayout->setSpacing(5); // CIFS Unix extensions support QCheckBox *cifsExtensionsSupport = new QCheckBox(Smb4KMountSettings::self()->cifsUnixExtensionsSupportItem()->label(), cifsExtensionSupportBox); cifsExtensionsSupport->setObjectName("kcfg_CifsUnixExtensionsSupport"); cifsExtensionSupportLayout->addWidget(cifsExtensionsSupport, 0, 0, 1, 2, 0); // User information QCheckBox *useUserId = new QCheckBox(Smb4KMountSettings::self()->useUserIdItem()->label(), cifsExtensionSupportBox); useUserId->setObjectName("kcfg_UseUserId"); QWidget *userIdInputWidget = new QWidget(cifsExtensionSupportBox); userIdInputWidget->setObjectName("UserIdInputWidget"); QGridLayout *userLayout = new QGridLayout(userIdInputWidget); - userLayout->setSpacing(5); - userLayout->setContentsMargins(0, 0, 0, 0); KLineEdit *userId = new KLineEdit(userIdInputWidget); userId->setObjectName("kcfg_UserId"); userId->setAlignment(Qt::AlignRight); userId->setReadOnly(true); QToolButton *userChooser = new QToolButton(userIdInputWidget); userChooser->setIcon(KDE::icon("edit-find-user")); userChooser->setToolTip(i18n("Choose a different user")); userChooser->setPopupMode(QToolButton::InstantPopup); QMenu *userMenu = new QMenu(userChooser); userChooser->setMenu(userMenu); QList allUsers = KUser::allUsers(); for (const KUser &u : allUsers) { QAction *userAction = userMenu->addAction(QString("%1 (%2)").arg(u.loginName()).arg(u.userId().nativeId())); userAction->setData(u.userId().nativeId()); } userLayout->addWidget(userId, 0, 0, 0); userLayout->addWidget(userChooser, 0, 1, Qt::AlignCenter); cifsExtensionSupportLayout->addWidget(useUserId, 1, 0, 0); cifsExtensionSupportLayout->addWidget(userIdInputWidget, 1, 1, 0); // Group information QCheckBox *useGroupId = new QCheckBox(Smb4KMountSettings::self()->useGroupIdItem()->label(), cifsExtensionSupportBox); useGroupId->setObjectName("kcfg_UseGroupId"); QWidget *groupIdInputWidget = new QWidget(cifsExtensionSupportBox); groupIdInputWidget->setObjectName("GroupIdInputWidget"); QGridLayout *groupLayout = new QGridLayout(groupIdInputWidget); - groupLayout->setSpacing(5); - groupLayout->setContentsMargins(0, 0, 0, 0); KLineEdit *groupId = new KLineEdit(groupIdInputWidget); groupId->setObjectName("kcfg_GroupId"); groupId->setAlignment(Qt::AlignRight); groupId->setReadOnly(true); QToolButton *groupChooser = new QToolButton(groupIdInputWidget); groupChooser->setIcon(KDE::icon("edit-find-user")); groupChooser->setToolTip(i18n("Choose a different group")); groupChooser->setPopupMode(QToolButton::InstantPopup); QMenu *groupMenu = new QMenu(groupChooser); groupChooser->setMenu(groupMenu); QList groupList = KUserGroup::allGroups(); for (const KUserGroup &g : groupList) { QAction *groupAction = groupMenu->addAction(QString("%1 (%2)").arg(g.name()).arg(g.groupId().nativeId())); groupAction->setData(g.groupId().nativeId()); } groupLayout->addWidget(groupId, 0, 0, 0); groupLayout->addWidget(groupChooser, 0, 1, Qt::AlignCenter); cifsExtensionSupportLayout->addWidget(useGroupId, 2, 0, 0); cifsExtensionSupportLayout->addWidget(groupIdInputWidget, 2, 1, 0); // File mask QCheckBox *useFileMode = new QCheckBox(Smb4KMountSettings::self()->useFileModeItem()->label(), cifsExtensionSupportBox); useFileMode->setObjectName("kcfg_UseFileMode"); KLineEdit *fileMode = new KLineEdit(cifsExtensionSupportBox); fileMode->setObjectName("kcfg_FileMode"); fileMode->setClearButtonEnabled(true); fileMode->setAlignment(Qt::AlignRight); cifsExtensionSupportLayout->addWidget(useFileMode, 3, 0, 0); cifsExtensionSupportLayout->addWidget(fileMode, 3, 1, 0); // Directory mask QCheckBox *useDirectoryMode = new QCheckBox(Smb4KMountSettings::self()->useDirectoryModeItem()->label(), cifsExtensionSupportBox); useDirectoryMode->setObjectName("kcfg_UseDirectoryMode"); KLineEdit *directoryMode = new KLineEdit(cifsExtensionSupportBox); directoryMode->setObjectName("kcfg_DirectoryMode"); directoryMode->setClearButtonEnabled(true); directoryMode->setAlignment(Qt::AlignRight); cifsExtensionSupportLayout->addWidget(useDirectoryMode, 4, 0, 0); cifsExtensionSupportLayout->addWidget(directoryMode, 4, 1, 0); commonTabLayout->addWidget(cifsExtensionSupportBox, 1, 0); commonTabLayout->addStretch(100); addTab(commonTab, i18n("Common Mount Settings")); // // Advanced Mount Settings tab // QWidget *advancedTab = new QWidget(this); QVBoxLayout *advancedTabLayout = new QVBoxLayout(advancedTab); - advancedTabLayout->setSpacing(5); - advancedTabLayout->setContentsMargins(0, 0, 0, 0); QGroupBox *advancedOptions = new QGroupBox(i18n("Advanced Options"), advancedTab); - QGridLayout *advancedOptionsLayout = new QGridLayout(advancedOptions); - advancedOptionsLayout->setSpacing(5); // Force Uid QCheckBox *forceUid = new QCheckBox(Smb4KMountSettings::self()->forceUIDItem()->label(), advancedOptions); forceUid->setObjectName("kcfg_ForceUID"); advancedOptionsLayout->addWidget(forceUid, 0, 0, 0); // Force Gid QCheckBox *forceGid = new QCheckBox(Smb4KMountSettings::self()->forceGIDItem()->label(), advancedOptions); forceGid->setObjectName("kcfg_ForceGID"); advancedOptionsLayout->addWidget(forceGid, 0, 1, 0); // Permission checks QCheckBox *permissionChecks = new QCheckBox(Smb4KMountSettings::self()->permissionChecksItem()->label(), advancedOptions); permissionChecks->setObjectName("kcfg_PermissionChecks"); advancedOptionsLayout->addWidget(permissionChecks, 1, 0, 0); // Client controls Ids QCheckBox *clientControlsIds = new QCheckBox(Smb4KMountSettings::self()->clientControlsIDsItem()->label(), advancedOptions); clientControlsIds->setObjectName("kcfg_ClientControlsIDs"); advancedOptionsLayout->addWidget(clientControlsIds, 1, 1, 0); // Use server inode numbers QCheckBox *useServerInodes = new QCheckBox(Smb4KMountSettings::self()->serverInodeNumbersItem()->label(), advancedOptions); useServerInodes->setObjectName("kcfg_ServerInodeNumbers"); advancedOptionsLayout->addWidget(useServerInodes, 2, 0, 0); // Translate reserved characters QCheckBox *translateReservedCharacters = new QCheckBox(Smb4KMountSettings::self()->translateReservedCharsItem()->label(), advancedOptions); translateReservedCharacters->setObjectName("kcfg_TranslateReservedChars"); advancedOptionsLayout->addWidget(translateReservedCharacters, 2, 1, 0); // No locking QCheckBox *no_locking = new QCheckBox(Smb4KMountSettings::self()->noLockingItem()->label(), advancedOptions); no_locking->setObjectName("kcfg_NoLocking"); advancedOptionsLayout->addWidget(no_locking, 3, 0, 0); // Extra widget for the rest of the options QWidget *advancedOptionsExtraWidget = new QWidget(advancedOptions); - QGridLayout *advancedOptionsExtraWidgetLayout = new QGridLayout(advancedOptionsExtraWidget); - advancedOptionsExtraWidgetLayout->setSpacing(5); - advancedOptionsExtraWidgetLayout->setContentsMargins(0, 0, 0, 0); // SMB protocol version QCheckBox *useSmbProtocol = new QCheckBox(Smb4KMountSettings::self()->useSmbProtocolVersionItem()->label(), advancedOptionsExtraWidget); useSmbProtocol->setObjectName("kcfg_UseSmbProtocolVersion"); KComboBox *smbProtocol = new KComboBox(advancedOptionsExtraWidget); smbProtocol->setObjectName("kcfg_SmbProtocolVersion"); QList smbProtocolChoices = Smb4KMountSettings::self()->smbProtocolVersionItem()->choices(); for (const KCoreConfigSkeleton::ItemEnum::Choice &c : smbProtocolChoices) { smbProtocol->addItem(c.label); } advancedOptionsExtraWidgetLayout->addWidget(useSmbProtocol, 0, 0, 0); advancedOptionsExtraWidgetLayout->addWidget(smbProtocol, 0, 1, 0); // Cache mode QCheckBox *useCacheMode = new QCheckBox(Smb4KMountSettings::self()->useCacheModeItem()->label(), advancedOptionsExtraWidget); useCacheMode->setObjectName("kcfg_UseCacheMode"); KComboBox *cacheMode = new KComboBox(advancedOptionsExtraWidget); cacheMode->setObjectName("kcfg_CacheMode"); QList cacheModeChoices = Smb4KMountSettings::self()->cacheModeItem()->choices(); for (const KCoreConfigSkeleton::ItemEnum::Choice &c : cacheModeChoices) { cacheMode->addItem(c.label); } advancedOptionsExtraWidgetLayout->addWidget(useCacheMode, 1, 0, 0); advancedOptionsExtraWidgetLayout->addWidget(cacheMode, 1, 1, 0); // Security mode QCheckBox *useSecurityMode = new QCheckBox(Smb4KMountSettings::self()->useSecurityModeItem()->label(), advancedOptionsExtraWidget); useSecurityMode->setObjectName("kcfg_UseSecurityMode"); KComboBox *securityMode = new KComboBox(advancedOptionsExtraWidget); securityMode->setObjectName("kcfg_SecurityMode"); QList securityModeChoices = Smb4KMountSettings::self()->securityModeItem()->choices(); for (const KConfigSkeleton::ItemEnum::Choice &c : securityModeChoices) { securityMode->addItem(c.label); } advancedOptionsExtraWidgetLayout->addWidget(useSecurityMode, 2, 0, 0); advancedOptionsExtraWidgetLayout->addWidget(securityMode, 2, 1, 0); // Additional options QLabel *additionalOptionsLabel = new QLabel(Smb4KMountSettings::self()->customCIFSOptionsItem()->label(), advancedOptionsExtraWidget); QWidget *additionalOptionsWidget = new QWidget(advancedOptionsExtraWidget); - QHBoxLayout *additionalOptionsWidgetLayout = new QHBoxLayout(additionalOptionsWidget); - additionalOptionsWidgetLayout->setSpacing(5); - additionalOptionsWidgetLayout->setContentsMargins(0, 0, 0, 0); KLineEdit *additionalOptions = new KLineEdit(additionalOptionsWidget); additionalOptions->setObjectName("kcfg_CustomCIFSOptions"); additionalOptions->setReadOnly(true); additionalOptions->setClearButtonEnabled(true); additionalOptionsLabel->setBuddy(additionalOptions); QToolButton *additionalOptionsEdit = new QToolButton(advancedOptionsExtraWidget); additionalOptionsEdit->setIcon(KDE::icon("document-edit")); additionalOptionsEdit->setToolTip(i18n("Edit the additional CIFS options.")); additionalOptionsWidgetLayout->addWidget(additionalOptions, 0); additionalOptionsWidgetLayout->addWidget(additionalOptionsEdit, 0); advancedOptionsExtraWidgetLayout->addWidget(additionalOptionsLabel, 3, 0, 0); advancedOptionsExtraWidgetLayout->addWidget(additionalOptionsWidget, 3, 1, 0); advancedOptionsLayout->addWidget(advancedOptionsExtraWidget, 4, 0, 1, 2, 0); advancedTabLayout->addWidget(advancedOptions, 0); advancedTabLayout->addStretch(100); addTab(advancedTab, i18n("Advanced Mount Settings")); // // Adjust widgets // slotCIFSUnixExtensionsSupport(Smb4KMountSettings::cifsUnixExtensionsSupport()); // // Connections // connect(userMenu, SIGNAL(triggered(QAction*)), this, SLOT(slotNewUserTriggered(QAction*))); connect(groupMenu, SIGNAL(triggered(QAction*)), this, SLOT(slotNewGroupTriggered(QAction*))); connect(cifsExtensionsSupport, SIGNAL(clicked(bool)), this, SLOT(slotCIFSUnixExtensionsSupport(bool))); connect(additionalOptionsEdit, SIGNAL(clicked(bool)), this, SLOT(slotAdditionalCIFSOptions())); } #elif defined(Q_OS_FREEBSD) || defined(Q_OS_NETBSD) // // FreeBSD and NetBSD // void Smb4KConfigPageMounting::setupWidget() { // // Basic Settings tab // QWidget *basicTab = new QWidget(this); QVBoxLayout *basicTabLayout = new QVBoxLayout(basicTab); - basicTabLayout->setSpacing(5); - basicTabLayout->setContentsMargins(0, 0, 0, 0); - +// // // Directories // QGroupBox *directoryBox = new QGroupBox(i18n("Directories"), basicTab); - QGridLayout *directoryBoxLayout = new QGridLayout(directoryBox); - directoryBoxLayout->setSpacing(5); QLabel *prefixLabel = new QLabel(Smb4KMountSettings::self()->mountPrefixItem()->label(), directoryBox); KUrlRequester *prefix = new KUrlRequester(directoryBox); prefix->setMode(KFile::Directory | KFile::LocalOnly); prefix->setObjectName("kcfg_MountPrefix"); prefixLabel->setBuddy(prefix); QCheckBox *lowercaseSubdirs = new QCheckBox(Smb4KMountSettings::self()->forceLowerCaseSubdirsItem()->label(), directoryBox); lowercaseSubdirs->setObjectName("kcfg_ForceLowerCaseSubdirs"); directoryBoxLayout->addWidget(prefixLabel, 0, 0, 0); directoryBoxLayout->addWidget(prefix, 0, 1, 0); directoryBoxLayout->addWidget(lowercaseSubdirs, 1, 0, 1, 2, 0); basicTabLayout->addWidget(directoryBox, 0); // // Behavior // QGroupBox *behaviorBox = new QGroupBox(i18n("Behavior"), basicTab); QGridLayout *behaviorBoxLayout = new QGridLayout(behaviorBox); - behaviorBoxLayout->setSpacing(5); QCheckBox *remountShares = new QCheckBox(Smb4KMountSettings::self()->remountSharesItem()->label(), behaviorBox); remountShares->setObjectName("kcfg_RemountShares"); QLabel *remountAttemptsLabel = new QLabel(Smb4KMountSettings::self()->remountAttemptsItem()->label(), behaviorBox); remountAttemptsLabel->setIndent(25); QSpinBox *remountAttempts = new QSpinBox(behaviorBox); remountAttempts->setObjectName("kcfg_RemountAttempts"); remountAttemptsLabel->setBuddy(remountAttempts); QLabel *remountIntervalLabel = new QLabel(Smb4KMountSettings::self()->remountIntervalItem()->label(), behaviorBox); remountIntervalLabel->setIndent(25); QSpinBox *remountInterval = new QSpinBox(behaviorBox); remountInterval->setObjectName("kcfg_RemountInterval"); remountInterval->setSuffix(i18n(" min")); remountIntervalLabel->setBuddy(remountInterval); QCheckBox *unmountAllShares = new QCheckBox(Smb4KMountSettings::self()->unmountSharesOnExitItem()->label(), behaviorBox); unmountAllShares->setObjectName("kcfg_UnmountSharesOnExit"); QCheckBox *unmountForeignShares = new QCheckBox(Smb4KMountSettings::self()->unmountForeignSharesItem()->label(), behaviorBox); unmountForeignShares->setObjectName("kcfg_UnmountForeignShares"); QCheckBox *detectAllShares = new QCheckBox(Smb4KMountSettings::self()->detectAllSharesItem()->label(), behaviorBox); detectAllShares->setObjectName("kcfg_DetectAllShares"); behaviorBoxLayout->addWidget(remountShares, 0, 0, 1, 2, 0); behaviorBoxLayout->addWidget(remountAttemptsLabel, 1, 0, 0); behaviorBoxLayout->addWidget(remountAttempts, 1, 1, 0); behaviorBoxLayout->addWidget(remountIntervalLabel, 2, 0, 0); behaviorBoxLayout->addWidget(remountInterval, 2, 1, 0); behaviorBoxLayout->addWidget(unmountAllShares, 3, 0, 1, 2, 0); behaviorBoxLayout->addWidget(unmountForeignShares, 4, 0, 1, 2, 0); behaviorBoxLayout->addWidget(detectAllShares, 5, 0, 1, 2, 0); basicTabLayout->addWidget(behaviorBox, 0); basicTabLayout->addStretch(100); addTab(basicTab, i18n("Basic Settings")); // // Mount Settings tab // QWidget *mountTab = new QWidget(this); QVBoxLayout *mountTabLayout = new QVBoxLayout(mountTab); - mountTabLayout->setSpacing(5); - mountTabLayout->setContentsMargins(0, 0, 0, 0); // // Common Options // QGroupBox *commonOptionsBox = new QGroupBox(i18n("Common Options"), mountTab); QGridLayout *commonOptionsBoxLayout = new QGridLayout(commonOptionsBox); - commonOptionsBoxLayout->setSpacing(5); // User information QCheckBox *useUserId = new QCheckBox(Smb4KMountSettings::self()->useUserIdItem()->label(), commonOptionsBox); useUserId->setObjectName("kcfg_UseUserId"); QWidget *userIdInputWidget = new QWidget(commonOptionsBox); userIdInputWidget->setObjectName("UserIdInputWidget"); QGridLayout *userLayout = new QGridLayout(userIdInputWidget); - userLayout->setSpacing(5); - userLayout->setContentsMargins(0, 0, 0, 0); KLineEdit *userId = new KLineEdit(userIdInputWidget); userId->setObjectName("kcfg_UserId"); userId->setAlignment(Qt::AlignRight); userId->setReadOnly(true); QToolButton *userChooser = new QToolButton(userIdInputWidget); userChooser->setIcon(KDE::icon("edit-find-user")); userChooser->setToolTip(i18n("Choose a different user")); userChooser->setPopupMode(QToolButton::InstantPopup); QMenu *userMenu = new QMenu(userChooser); userChooser->setMenu(userMenu); QList allUsers = KUser::allUsers(); for (const KUser &u : allUsers) { QAction *userAction = userMenu->addAction(QString("%1 (%2)").arg(u.loginName()).arg(u.userId().nativeId())); userAction->setData(u.userId().nativeId()); } userLayout->addWidget(userId, 0, 0, 0); userLayout->addWidget(userChooser, 0, 1, Qt::AlignCenter); commonOptionsBoxLayout->addWidget(useUserId, 0, 0, 0); commonOptionsBoxLayout->addWidget(userIdInputWidget, 0, 1, 0); // Group information QCheckBox *useGroupId = new QCheckBox(Smb4KMountSettings::self()->useGroupIdItem()->label(), commonOptionsBox); useGroupId->setObjectName("kcfg_UseGroupId"); QWidget *groupIdInputWidget = new QWidget(commonOptionsBox); groupIdInputWidget->setObjectName("GroupIdInputWidget"); QGridLayout *groupLayout = new QGridLayout(groupIdInputWidget); - groupLayout->setSpacing(5); - groupLayout->setContentsMargins(0, 0, 0, 0); KLineEdit *groupId = new KLineEdit(groupIdInputWidget); groupId->setObjectName("kcfg_GroupId"); groupId->setAlignment(Qt::AlignRight); groupId->setReadOnly(true); QToolButton *groupChooser = new QToolButton(groupIdInputWidget); groupChooser->setIcon(KDE::icon("edit-find-user")); groupChooser->setToolTip(i18n("Choose a different group")); groupChooser->setPopupMode(QToolButton::InstantPopup); QMenu *groupMenu = new QMenu(groupChooser); groupChooser->setMenu(groupMenu); QList groupList = KUserGroup::allGroups(); for (const KUserGroup &g : groupList) { QAction *groupAction = groupMenu->addAction(QString("%1 (%2)").arg(g.name()).arg(g.groupId().nativeId())); groupAction->setData(g.groupId().nativeId()); } groupLayout->addWidget(groupId, 0, 0, 0); groupLayout->addWidget(groupChooser, 0, 1, Qt::AlignCenter); commonOptionsBoxLayout->addWidget(useGroupId, 1, 0, 0); commonOptionsBoxLayout->addWidget(groupIdInputWidget, 1, 1, 0); // File mask QCheckBox *useFileMode = new QCheckBox(Smb4KMountSettings::self()->useFileModeItem()->label(), commonOptionsBox); useFileMode->setObjectName("kcfg_UseFileMode"); KLineEdit *fileMode = new KLineEdit(commonOptionsBox); fileMode->setObjectName("kcfg_FileMode"); fileMode->setClearButtonEnabled(true); fileMode->setAlignment(Qt::AlignRight); commonOptionsBoxLayout->addWidget(useFileMode, 2, 0, 0); commonOptionsBoxLayout->addWidget(fileMode, 2, 1, 0); // Directory mask QCheckBox *useDirectoryMode = new QCheckBox(Smb4KMountSettings::self()->useDirectoryModeItem()->label(), commonOptionsBox); useDirectoryMode->setObjectName("kcfg_UseDirectoryMode"); KLineEdit *directoryMode = new KLineEdit(commonOptionsBox); directoryMode->setObjectName("kcfg_DirectoryMode"); directoryMode->setClearButtonEnabled(true); directoryMode->setAlignment(Qt::AlignRight); commonOptionsBoxLayout->addWidget(useDirectoryMode, 3, 0, 0); commonOptionsBoxLayout->addWidget(directoryMode, 3, 1, 0); // // Character sets // QGroupBox *characterSetsBox = new QGroupBox(i18n("Character Sets"), mountTab); QGridLayout *characterSetsBoxLayout = new QGridLayout(characterSetsBox); - characterSetsBoxLayout->setSpacing(5); // Client character set QCheckBox *useCharacterSets = new QCheckBox(Smb4KMountSettings::self()->useCharacterSetsItem()->label(), characterSetsBox); useCharacterSets->setObjectName("kcfg_UseCharacterSets"); QLabel *clientCharacterSetLabel = new QLabel(Smb4KMountSettings::self()->clientCharsetItem()->label(), characterSetsBox); clientCharacterSetLabel->setIndent(25); clientCharacterSetLabel->setObjectName("ClientCharacterSetLabel"); KComboBox *clientCharacterSet = new KComboBox(characterSetsBox); clientCharacterSet->setObjectName("kcfg_ClientCharset"); QList charsetChoices = Smb4KMountSettings::self()->clientCharsetItem()->choices(); for (const KCoreConfigSkeleton::ItemEnum::Choice &c : charsetChoices) { clientCharacterSet->addItem(c.label); } clientCharacterSetLabel->setBuddy(clientCharacterSet); // Server character set QLabel *serverCharacterSetLabel = new QLabel(Smb4KMountSettings::self()->serverCodepageItem()->label(), characterSetsBox); serverCharacterSetLabel->setIndent(25); serverCharacterSetLabel->setObjectName("ServerCodepageLabel"); KComboBox *serverCharacterSet = new KComboBox(characterSetsBox); serverCharacterSet->setObjectName("kcfg_ServerCodepage"); QList codepageChoices = Smb4KMountSettings::self()->serverCodepageItem()->choices(); for (const KCoreConfigSkeleton::ItemEnum::Choice &c : codepageChoices) { serverCharacterSet->addItem(c.label); } serverCharacterSetLabel->setBuddy(serverCharacterSet); characterSetsBoxLayout->addWidget(useCharacterSets, 0, 0, 1, 2, 0); characterSetsBoxLayout->addWidget(clientCharacterSetLabel, 1, 0, 0); characterSetsBoxLayout->addWidget(clientCharacterSet, 1, 1, 0); characterSetsBoxLayout->addWidget(serverCharacterSetLabel, 2, 0, 0); characterSetsBoxLayout->addWidget(serverCharacterSet, 2, 1, 0); mountTabLayout->addWidget(commonOptionsBox, 0); mountTabLayout->addWidget(characterSetsBox, 0); mountTabLayout->addStretch(100); addTab(mountTab, i18n("Mount Settings")); // // Connections // connect(userMenu, SIGNAL(triggered(QAction*)), this, SLOT(slotNewUserTriggered(QAction*))); connect(groupMenu, SIGNAL(triggered(QAction*)), this, SLOT(slotNewGroupTriggered(QAction*))); connect(useCharacterSets, SIGNAL(toggled(bool)), this, SLOT(slotCharacterSets(bool))); // // Enable / disable widgets // slotCharacterSets(Smb4KMountSettings::useCharacterSets()); } #else // // Dummy // void Smb4KConfigPageMounting::setupWidget() { } #endif void Smb4KConfigPageMounting::slotNewUserTriggered(QAction *action) { KLineEdit *userId = findChild("kcfg_UserId"); if (userId) { userId->setText(action->data().toString()); } } void Smb4KConfigPageMounting::slotNewGroupTriggered(QAction *action) { KLineEdit *groupId = findChild("kcfg_GroupId"); if (groupId) { groupId->setText(action->data().toString()); } } void Smb4KConfigPageMounting::slotCIFSUnixExtensionsSupport(bool checked) { QCheckBox *useUserId = findChild("kcfg_UseUserId"); if (useUserId) { useUserId->setEnabled(!checked); } QWidget *userIdInputWidget = findChild("UserIdInputWidget"); if (userIdInputWidget) { userIdInputWidget->setEnabled(!checked); } QCheckBox *useGroupId = findChild("kcfg_UseGroupId"); if (useGroupId) { useGroupId->setEnabled(!checked); } QWidget *groupIdInputWidget = findChild("GroupIdInputWidget"); if (groupIdInputWidget) { groupIdInputWidget->setEnabled(!checked); } QCheckBox *useFileMode = findChild("kcfg_UseFileMode"); if (useFileMode) { useFileMode->setEnabled(!checked); } KLineEdit *fileMode = findChild("kcfg_FileMode"); if (fileMode) { fileMode->setEnabled(!checked); } QCheckBox *useDirectoryMode = findChild("kcfg_UseDirectoryMode"); if (useDirectoryMode) { useDirectoryMode->setEnabled(!checked); } KLineEdit *directoryMode = findChild("kcfg_DirectoryMode"); if (directoryMode) { directoryMode->setEnabled(!checked); } } void Smb4KConfigPageMounting::slotAdditionalCIFSOptions() { #if defined(Q_OS_LINUX) KLineEdit *cifsOptions = findChild("kcfg_CustomCIFSOptions"); if (cifsOptions) { QString options = cifsOptions->originalText(); bool ok = false; options = QInputDialog::getText(this, i18n("Additional CIFS Options"), i18n("Enter the desired options as a comma separated list:"), QLineEdit::Normal, options, &ok); if (ok) { if(!options.trimmed().isEmpty()) { // SECURITY: Only pass those arguments to mount.cifs that do not pose // a potential security risk and that have not already been defined. // // This is, among others, the proper fix to the security issue reported // by Heiner Markert (aka CVE-2014-2581). QStringList whitelist = whitelistedMountArguments(); QStringList deniedArgs; QStringList list = options.split(',', QString::SkipEmptyParts); QMutableStringListIterator it(list); while (it.hasNext()) { QString arg = it.next().section("=", 0, 0); if (!whitelist.contains(arg)) { deniedArgs << arg; it.remove(); } } if (!deniedArgs.isEmpty()) { QString msg = i18np("The following entry is going to be removed from the additional options: %2. Please read the handbook for details.", "The following %1 entries are going to be removed from the additional options: %2. Please read the handbook for details.", deniedArgs.size(), deniedArgs.join(", ")); KMessageBox::sorry(this, msg); } cifsOptions->setText(list.join(",").trimmed()); } else { cifsOptions->clear(); } } } #endif } void Smb4KConfigPageMounting::slotCharacterSets(bool on) { // // Client character set // QLabel *clientCharacterSetLabel = findChild("ClientCharacterSetLabel"); if (clientCharacterSetLabel) { clientCharacterSetLabel->setEnabled(on); } KComboBox *clientCharacterSet = findChild("kcfg_ClientCharset"); if (clientCharacterSet) { clientCharacterSet->setEnabled(on); } // // Server character set // QLabel *serverCharacterSetLabel = findChild("ServerCodepageLabel"); if (serverCharacterSetLabel) { serverCharacterSetLabel->setEnabled(on); } KComboBox *serverCharacterSet = findChild("kcfg_ServerCodepage"); if (serverCharacterSet) { serverCharacterSet->setEnabled(on); } } diff --git a/smb4k/smb4kconfigpageprofiles.cpp b/smb4k/smb4kconfigpageprofiles.cpp index 5f98858..1f38735 100644 --- a/smb4k/smb4kconfigpageprofiles.cpp +++ b/smb4k/smb4kconfigpageprofiles.cpp @@ -1,205 +1,200 @@ /*************************************************************************** The configuration page for the profiles ------------------- begin : Do Aug 07 2014 copyright : (C) 2014-2019 by Alexander Reinholdt email : alexander.reinholdt@kdemail.net ***************************************************************************/ /*************************************************************************** * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, but * * WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * * General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., 51 Franklin Street, Suite 500, Boston,* * MA 02110-1335, USA * ***************************************************************************/ // application specific includes #include "smb4kconfigpageprofiles.h" #include "core/smb4ksettings.h" #include "core/smb4kprofilemanager.h" // Qt includes #include #include #include // KDE includes #include #include Smb4KConfigPageProfiles::Smb4KConfigPageProfiles(QWidget* parent) : QWidget(parent) { // Layout QVBoxLayout *layout = new QVBoxLayout(this); - layout->setSpacing(5); - layout->setContentsMargins(0, 0, 0, 0); QGroupBox *settings = new QGroupBox(i18n("Settings"), this); - - QVBoxLayout *settings_layout = new QVBoxLayout(settings); - settings_layout->setSpacing(5); -// settings_layout->setMargin(0); + QVBoxLayout *settingsLayout = new QVBoxLayout(settings); // Use profiles - QCheckBox *use_profiles = new QCheckBox(Smb4KSettings::self()->useProfilesItem()->label(), settings); - use_profiles->setObjectName("kcfg_UseProfiles"); + QCheckBox *useProfiles = new QCheckBox(Smb4KSettings::self()->useProfilesItem()->label(), settings); + useProfiles->setObjectName("kcfg_UseProfiles"); // Use profile migration assistant - QCheckBox *use_assistant = new QCheckBox(Smb4KSettings::self()->useMigrationAssistantItem()->label(), settings); - use_assistant->setObjectName("kcfg_UseMigrationAssistant"); + QCheckBox *useAssistant = new QCheckBox(Smb4KSettings::self()->useMigrationAssistantItem()->label(), settings); + useAssistant->setObjectName("kcfg_UseMigrationAssistant"); - settings_layout->addWidget(use_profiles, 0, 0); - settings_layout->addWidget(use_assistant, 1, 0); + settingsLayout->addWidget(useProfiles, 0, 0); + settingsLayout->addWidget(useAssistant, 1, 0); QGroupBox *profiles = new QGroupBox(i18n("Profiles"), this); - QVBoxLayout *profiles_layout = new QVBoxLayout(profiles); - profiles_layout->setSpacing(5); + QVBoxLayout *profilesLayout = new QVBoxLayout(profiles); + profilesLayout->setSpacing(5); // List of profiles m_profiles = new KEditListWidget(profiles); m_profiles->setObjectName("kcfg_ProfilesList"); m_profiles->setEnabled(Smb4KSettings::self()->useProfiles()); - profiles_layout->addWidget(m_profiles, 0, 0); + profilesLayout->addWidget(m_profiles, 0, 0); layout->addWidget(settings, 0, 0); layout->addWidget(profiles, 1, 0); - connect(use_profiles, SIGNAL(stateChanged(int)), this, SLOT(slotEnableWidget(int))); + connect(useProfiles, SIGNAL(stateChanged(int)), this, SLOT(slotEnableWidget(int))); connect(m_profiles, SIGNAL(removed(QString)), this, SLOT(slotProfileRemoved(QString))); connect(m_profiles->lineEdit(), SIGNAL(editingFinished()), this, SLOT(slotProfileChanged())); } Smb4KConfigPageProfiles::~Smb4KConfigPageProfiles() { } QList< QPair > Smb4KConfigPageProfiles::renamedProfiles() const { return m_renamed; } void Smb4KConfigPageProfiles::clearRenamedProfiles() { m_renamed.clear(); } QStringList Smb4KConfigPageProfiles::removedProfiles() const { return m_removed; } void Smb4KConfigPageProfiles::clearRemovedProfiles() { m_removed.clear(); } void Smb4KConfigPageProfiles::slotEnableWidget(int state) { switch (state) { case Qt::Unchecked: { m_profiles->setEnabled(false); break; } case Qt::Checked: { m_profiles->setEnabled(true); break; } default: { break; } } } void Smb4KConfigPageProfiles::slotProfileRemoved(const QString& name) { // If the removed profile was renamed before, remove it from // the list. QMutableListIterator< QPair > it(m_renamed); while (it.hasNext()) { QPair entry = it.next(); if (QString::compare(entry.first, name) == 0 || QString::compare(entry.second, name) == 0) { it.remove(); } } m_removed << name; } void Smb4KConfigPageProfiles::slotProfileChanged() { QStringList savedProfiles = Smb4KProfileManager::self()->profilesList(); QStringList currentProfiles = m_profiles->items(); if (savedProfiles.size() == currentProfiles.size()) { QMutableStringListIterator it(savedProfiles); while (it.hasNext()) { QString entry = it.next(); int index = currentProfiles.indexOf(entry); if (index != -1) { currentProfiles.removeAt(index); it.remove(); } } if (!savedProfiles.isEmpty() && !currentProfiles.isEmpty()) { // Take care that multiple renamings will have the correct // result. bool write = true; for (int i = 0; i < m_renamed.size(); ++i) { if (QString::compare(savedProfiles.first(), m_renamed.at(i).first, Qt::CaseSensitive) == 0) { QPair pair = static_cast< QPair >(m_renamed.at(i)); pair.second = currentProfiles.first(); write = false; break; } } // Write the renamed profile to the list, if necessary. if (write) { QPair renamed(savedProfiles.first(), currentProfiles.first()); m_renamed << renamed; } } } } diff --git a/smb4k/smb4kconfigpagesynchronization.cpp b/smb4k/smb4kconfigpagesynchronization.cpp index 386f0c8..6c37609 100644 --- a/smb4k/smb4kconfigpagesynchronization.cpp +++ b/smb4k/smb4kconfigpagesynchronization.cpp @@ -1,586 +1,559 @@ /*************************************************************************** The configuration page for the synchronization options ------------------- begin : So Nov 20 2005 copyright : (C) 2005-2019 by Alexander Reinholdt email : alexander.reinholdt@kdemail.net ***************************************************************************/ /*************************************************************************** * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, but * * WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * * General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., 51 Franklin Street, Suite 500, Boston,* * MA 02110-1335, USA * ***************************************************************************/ // application specific includes #include "smb4kconfigpagesynchronization.h" #include "core/smb4ksettings.h" // Qt includes #include #include #include #include #include #include #include // KDE includes #include #include #include Smb4KConfigPageSynchronization::Smb4KConfigPageSynchronization(QWidget *parent) : QTabWidget(parent) { // // 'Basic Settings' tab // QWidget *basicTab = new QWidget(this); QVBoxLayout *basicTabLayout = new QVBoxLayout(basicTab); - basicTabLayout->setSpacing(5); - basicTabLayout->setContentsMargins(0, 0, 0, 0); // Default destination (rsync) QGroupBox *pathsBox = new QGroupBox(i18n("Default Destination"), basicTab); QGridLayout *pathsBoxLayout = new QGridLayout(pathsBox); - pathsBoxLayout->setSpacing(5); QLabel *rsyncPrefixLabel = new QLabel(Smb4KSettings::self()->rsyncPrefixItem()->label(), pathsBox); KUrlRequester *rsyncPrefix = new KUrlRequester(pathsBox); rsyncPrefix->setMode(KFile::Directory|KFile::LocalOnly); rsyncPrefix->setObjectName("kcfg_RsyncPrefix"); rsyncPrefixLabel->setBuddy(rsyncPrefix); pathsBoxLayout->addWidget(rsyncPrefixLabel, 0, 0, 0); pathsBoxLayout->addWidget(rsyncPrefix, 0, 1, 0); // Behavior QGroupBox *behaviorBox = new QGroupBox(i18n("Behavior"), basicTab); QGridLayout *behaviorBoxLayout = new QGridLayout(behaviorBox); - behaviorBoxLayout->setSpacing(5); QCheckBox *archiveMode = new QCheckBox(Smb4KSettings::self()->archiveModeItem()->label(), behaviorBox); archiveMode->setObjectName("kcfg_ArchiveMode"); QCheckBox *recurseDirs = new QCheckBox(Smb4KSettings::self()->recurseIntoDirectoriesItem()->label(), behaviorBox); recurseDirs->setObjectName("kcfg_RecurseIntoDirectories"); QCheckBox *relativePaths = new QCheckBox(Smb4KSettings::self()->relativePathNamesItem()->label(), behaviorBox); relativePaths->setObjectName("kcfg_RelativePathNames"); QCheckBox *noImpliedDirs = new QCheckBox(Smb4KSettings::self()->noImpliedDirectoriesItem()->label(), behaviorBox); noImpliedDirs->setObjectName("kcfg_NoImpliedDirectories"); QCheckBox *transferDirs = new QCheckBox(Smb4KSettings::self()->transferDirectoriesItem()->label(), behaviorBox); transferDirs->setObjectName("kcfg_TransferDirectories"); behaviorBoxLayout->addWidget(archiveMode, 0, 0, 0); behaviorBoxLayout->addWidget(recurseDirs, 0, 1, 0); behaviorBoxLayout->addWidget(relativePaths, 1, 0, 0); behaviorBoxLayout->addWidget(noImpliedDirs, 1, 1, 0); behaviorBoxLayout->addWidget(transferDirs, 2, 0, 0); // Backup QGroupBox *backupBox = new QGroupBox(i18n("Backup"), basicTab); QGridLayout *backupBoxLayout = new QGridLayout(backupBox); - backupBoxLayout->setSpacing(5); QCheckBox *makeBackups = new QCheckBox(Smb4KSettings::self()->makeBackupsItem()->label(), backupBox); makeBackups->setObjectName("kcfg_MakeBackups"); QCheckBox *backupSuffixButton = new QCheckBox(Smb4KSettings::self()->useBackupSuffixItem()->label(), backupBox); backupSuffixButton->setObjectName("kcfg_UseBackupSuffix"); KLineEdit *backupSuffix = new KLineEdit(backupBox); backupSuffix->setObjectName("kcfg_BackupSuffix"); backupSuffix->setClearButtonEnabled(true); QCheckBox *backupDirButton = new QCheckBox(Smb4KSettings::self()->useBackupDirectoryItem()->label(), backupBox); backupDirButton->setObjectName("kcfg_UseBackupDirectory"); KUrlRequester *backupDir= new KUrlRequester(backupBox); backupDir->setObjectName("kcfg_BackupDirectory"); backupDir->setMode(KFile::Directory | KFile::LocalOnly); backupBoxLayout->addWidget(makeBackups, 0, 0, 0); backupBoxLayout->addWidget(backupSuffixButton, 1, 0, 0); backupBoxLayout->addWidget(backupSuffix, 1, 1, 0); backupBoxLayout->addWidget(backupDirButton, 2, 0, 0); backupBoxLayout->addWidget(backupDir, 2, 1, 0); basicTabLayout->addWidget(pathsBox, 0); basicTabLayout->addWidget(behaviorBox, 0); basicTabLayout->addWidget(backupBox, 0); basicTabLayout->addStretch(100); addTab(basicTab, i18n("Basic Settings")); // // 'File Handling' tab // QWidget *fileHandlingTab = new QWidget(this); QVBoxLayout *fileHandlingTabLayout = new QVBoxLayout(fileHandlingTab); - fileHandlingTabLayout->setSpacing(5); - fileHandlingTabLayout->setContentsMargins(0, 0, 0, 0); // General QGroupBox *generalHandlingBox = new QGroupBox(i18n("General"), fileHandlingTab); QGridLayout *generalHandlingBoxLayout = new QGridLayout(generalHandlingBox); - generalHandlingBoxLayout->setSpacing(5); QCheckBox *updateTarget = new QCheckBox(Smb4KSettings::self()->updateTargetItem()->label(), generalHandlingBox); updateTarget->setObjectName("kcfg_UpdateTarget"); QCheckBox *updateInPlace = new QCheckBox(Smb4KSettings::self()->updateInPlaceItem()->label(), generalHandlingBox); updateInPlace->setObjectName("kcfg_UpdateInPlace"); QCheckBox *sparseFiles = new QCheckBox(Smb4KSettings::self()->efficientSparseFileHandlingItem()->label(), generalHandlingBox); sparseFiles->setObjectName("kcfg_EfficientSparseFileHandling"); QCheckBox *copyFilesWhole = new QCheckBox(Smb4KSettings::self()->copyFilesWholeItem()->label(), generalHandlingBox); copyFilesWhole->setObjectName("kcfg_CopyFilesWhole"); QCheckBox *updateExisting = new QCheckBox(Smb4KSettings::self()->updateExistingItem()->label(), generalHandlingBox); updateExisting->setObjectName("kcfg_UpdateExisting"); QCheckBox *ignoreExisting = new QCheckBox(Smb4KSettings::self()->ignoreExistingItem()->label(), generalHandlingBox); ignoreExisting->setObjectName("kcfg_IgnoreExisting"); generalHandlingBoxLayout->addWidget(updateTarget, 0, 0, 0); generalHandlingBoxLayout->addWidget(updateInPlace, 0, 1, 0); generalHandlingBoxLayout->addWidget(sparseFiles, 1, 0, 0); generalHandlingBoxLayout->addWidget(copyFilesWhole, 1, 1, 0); generalHandlingBoxLayout->addWidget(updateExisting, 2, 0, 0); generalHandlingBoxLayout->addWidget(ignoreExisting, 2, 1, 0); // Links QGroupBox *linksBox = new QGroupBox(i18n("Links"), fileHandlingTab); QGridLayout *linksBoxLayout = new QGridLayout(linksBox); - linksBoxLayout->setSpacing(5); QCheckBox *preserveLinks = new QCheckBox(Smb4KSettings::self()->preserveSymlinksItem()->label(), linksBox); preserveLinks->setObjectName("kcfg_PreserveSymlinks"); QCheckBox *transformLinks = new QCheckBox(Smb4KSettings::self()->transformSymlinksItem()->label(), linksBox); transformLinks->setObjectName("kcfg_TransformSymlinks"); QCheckBox *transformUnsafe = new QCheckBox(Smb4KSettings::self()->transformUnsafeSymlinksItem()->label(), linksBox); transformUnsafe->setObjectName("kcfg_TransformUnsafeSymlinks"); QCheckBox *ignoreUnsafe = new QCheckBox(Smb4KSettings::self()->ignoreUnsafeSymlinksItem()->label(), linksBox); ignoreUnsafe->setObjectName("kcfg_IgnoreUnsafeSymlinks"); QCheckBox *mungeLinks = new QCheckBox(Smb4KSettings::self()->mungeSymlinksItem()->label(), linksBox); mungeLinks->setObjectName("kcfg_MungeSymlinks"); QCheckBox *preserveHlinks = new QCheckBox(Smb4KSettings::self()->preserveHardLinksItem()->label(), linksBox); preserveHlinks->setObjectName("kcfg_PreserveHardLinks"); QCheckBox *copyDirLinks = new QCheckBox(Smb4KSettings::self()->copyDirectorySymlinksItem()->label(), linksBox); copyDirLinks->setObjectName("kcfg_CopyDirectorySymlinks"); QCheckBox *keepDirLinks = new QCheckBox(Smb4KSettings::self()->keepDirectorySymlinksItem()->label(), linksBox); keepDirLinks->setObjectName("kcfg_KeepDirectorySymlinks"); linksBoxLayout->addWidget(preserveLinks, 0, 0, 0); linksBoxLayout->addWidget(transformLinks, 0, 1, 0); linksBoxLayout->addWidget(transformUnsafe, 1, 0, 0); linksBoxLayout->addWidget(ignoreUnsafe, 1, 1, 0); linksBoxLayout->addWidget(mungeLinks, 2, 0, 0); linksBoxLayout->addWidget(preserveHlinks, 2, 1, 0); linksBoxLayout->addWidget(copyDirLinks, 3, 0, 0); linksBoxLayout->addWidget(keepDirLinks, 3, 1, 0); // Permissions & Attributes QGroupBox *permissionsBox = new QGroupBox(i18n("Permissions, etc."), fileHandlingTab); QGridLayout *permissionsBoxLayout = new QGridLayout(permissionsBox); - permissionsBoxLayout->setSpacing(5); QCheckBox *preservePerms = new QCheckBox(Smb4KSettings::self()->preservePermissionsItem()->label(), permissionsBox); preservePerms->setObjectName("kcfg_PreservePermissions"); QCheckBox *preserveOwner = new QCheckBox(Smb4KSettings::self()->preserveOwnerItem()->label(), permissionsBox); preserveOwner->setObjectName("kcfg_PreserveOwner"); QCheckBox *preserveGroup = new QCheckBox(Smb4KSettings::self()->preserveGroupItem()->label(), permissionsBox); preserveGroup->setObjectName("kcfg_PreserveGroup"); QCheckBox *preserveDevices = new QCheckBox(Smb4KSettings::self()->preserveDevicesAndSpecialsItem()->label(), permissionsBox); preserveDevices->setObjectName("kcfg_PreserveDevicesAndSpecials"); QCheckBox *preserveTimes = new QCheckBox(Smb4KSettings::self()->preserveTimesItem()->label(), permissionsBox); preserveTimes->setObjectName("kcfg_PreserveTimes"); QCheckBox *omitDirTimes = new QCheckBox(Smb4KSettings::self()->omitDirectoryTimesItem()->label(), permissionsBox); omitDirTimes->setObjectName("kcfg_OmitDirectoryTimes"); permissionsBoxLayout->addWidget(preservePerms, 0, 0, 0); permissionsBoxLayout->addWidget(preserveOwner, 0, 1, 0); permissionsBoxLayout->addWidget(preserveGroup, 1, 0, 0); permissionsBoxLayout->addWidget(preserveDevices, 1, 1, 0); permissionsBoxLayout->addWidget(preserveTimes, 2, 0, 0); permissionsBoxLayout->addWidget(omitDirTimes, 2, 1, 0); fileHandlingTabLayout->addWidget(generalHandlingBox, 0); fileHandlingTabLayout->addWidget(linksBox, 0); fileHandlingTabLayout->addWidget(permissionsBox, 0); fileHandlingTabLayout->addStretch(100); addTab(fileHandlingTab, i18n("File Handling")); // // 'File Transfer' tab // QWidget *transferTab = new QWidget(this); QVBoxLayout *transferTabLayout = new QVBoxLayout(transferTab); - transferTabLayout->setSpacing(5); - transferTabLayout->setContentsMargins(0, 0, 0, 0); // Compression QGroupBox *compressionBox = new QGroupBox(i18n("Compression"), transferTab); QGridLayout *compressionBoxLayout = new QGridLayout(compressionBox); - compressionBoxLayout->setSpacing(5); QCheckBox *compressData = new QCheckBox(Smb4KSettings::self()->compressDataItem()->label(), compressionBox); compressData->setObjectName("kcfg_CompressData"); QCheckBox *compressionLevelButton = new QCheckBox(Smb4KSettings::self()->useCompressionLevelItem()->label(), compressionBox); compressionLevelButton->setObjectName("kcfg_UseCompressionLevel"); QSpinBox *compressionLevel = new QSpinBox(compressionBox); compressionLevel->setObjectName("kcfg_CompressionLevel"); QCheckBox *skipCompressionButton = new QCheckBox(Smb4KSettings::self()->useSkipCompressionItem()->label(), compressionBox); skipCompressionButton->setObjectName("kcfg_UseSkipCompression"); KLineEdit *skipCompression = new KLineEdit(compressionBox); skipCompression->setObjectName("kcfg_SkipCompression"); skipCompression->setClearButtonEnabled(true); compressionBoxLayout->addWidget(compressData, 0, 0, 1, -1, 0); compressionBoxLayout->addWidget(compressionLevelButton, 1, 0, 1, 1, 0); compressionBoxLayout->addWidget(compressionLevel, 1, 1, 1, 1, 0); compressionBoxLayout->addWidget(skipCompressionButton, 2, 0, 1, 1, 0); compressionBoxLayout->addWidget(skipCompression, 2, 1, 1, 1, 0); // Files QGroupBox *filesBox = new QGroupBox(i18n("Files"), transferTab); QGridLayout *filesBoxLayout = new QGridLayout(filesBox); - filesBoxLayout->setSpacing(5); QCheckBox *minTransferSizeButton = new QCheckBox(Smb4KSettings::self()->useMinimalTransferSizeItem()->label(), filesBox); minTransferSizeButton->setObjectName("kcfg_UseMinimalTransferSize"); QSpinBox *minTransferSize = new QSpinBox(filesBox); minTransferSize->setObjectName("kcfg_MinimalTransferSize"); minTransferSize->setSuffix(i18n(" KiB")); QCheckBox *maxTransferSizeButton = new QCheckBox(Smb4KSettings::self()->useMaximalTransferSizeItem()->label(), filesBox); maxTransferSizeButton->setObjectName("kcfg_UseMaximalTransferSize"); QSpinBox *maxTransferSize = new QSpinBox(filesBox); maxTransferSize->setObjectName("kcfg_MaximalTransferSize"); maxTransferSize->setSuffix(i18n(" KiB")); QCheckBox *keepPartial = new QCheckBox(Smb4KSettings::self()->keepPartialItem()->label(), filesBox); keepPartial->setObjectName("kcfg_KeepPartial"); QCheckBox *partialDirButton = new QCheckBox(Smb4KSettings::self()->usePartialDirectoryItem()->label(), filesBox); partialDirButton->setObjectName("kcfg_UsePartialDirectory"); KUrlRequester *partialDir = new KUrlRequester(filesBox); partialDir->setObjectName("kcfg_PartialDirectory"); partialDir->setMode(KFile::Directory | KFile::LocalOnly); filesBoxLayout->addWidget(minTransferSizeButton, 0, 0, 0); filesBoxLayout->addWidget(minTransferSize, 0, 1, 0); filesBoxLayout->addWidget(maxTransferSizeButton, 1, 0, 0); filesBoxLayout->addWidget(maxTransferSize, 1, 1, 0); filesBoxLayout->addWidget(keepPartial, 2, 0, 1, -1, 0); filesBoxLayout->addWidget(partialDirButton, 3, 0, 0); filesBoxLayout->addWidget(partialDir, 3, 1, 0); // Miscellaneous QGroupBox *miscTransferBox = new QGroupBox(i18n("Miscellaneous"), transferTab); QGridLayout *miscTransferBoxLayout = new QGridLayout(miscTransferBox); - miscTransferBoxLayout->setSpacing(5); QCheckBox *bwLimitButton = new QCheckBox(Smb4KSettings::self()->useBandwidthLimitItem()->label(), miscTransferBox); bwLimitButton->setObjectName("kcfg_UseBandwidthLimit"); QSpinBox *bwLimit = new QSpinBox(miscTransferBox); bwLimit->setObjectName("kcfg_BandwidthLimit"); bwLimit->setSuffix(i18n(" KiB/s")); miscTransferBoxLayout->addWidget(bwLimitButton, 0, 0, 0); miscTransferBoxLayout->addWidget(bwLimit, 0, 1, 0); transferTabLayout->addWidget(compressionBox, 0); transferTabLayout->addWidget(filesBox, 0); transferTabLayout->addWidget(miscTransferBox, 0); transferTabLayout->addStretch(100); addTab(transferTab, i18n("File Transfer")); // // 'File Deletion' tab // QWidget *deleteTab = new QWidget(this); QVBoxLayout *deleteTabLayout = new QVBoxLayout(deleteTab); - deleteTabLayout->setSpacing(5); - deleteTabLayout->setContentsMargins(0, 0, 0, 0); // Files and Directories QGroupBox *filesAndDirsBox = new QGroupBox(i18n("Files && Directories"), deleteTab); QGridLayout *filesAndDirsBoxLayout = new QGridLayout(filesAndDirsBox); - filesAndDirsBoxLayout->setSpacing(5); QCheckBox *removeSource = new QCheckBox(Smb4KSettings::self()->removeSourceFilesItem()->label(), filesAndDirsBox); removeSource->setObjectName("kcfg_RemoveSourceFiles"); QCheckBox *deleteExtraneous = new QCheckBox(Smb4KSettings::self()->deleteExtraneousItem()->label(), filesAndDirsBox); deleteExtraneous->setObjectName("kcfg_DeleteExtraneous"); QCheckBox *deleteBefore = new QCheckBox(Smb4KSettings::self()->deleteBeforeItem()->label(), filesAndDirsBox); deleteBefore->setObjectName("kcfg_DeleteBefore"); QCheckBox *deleteAfter = new QCheckBox(Smb4KSettings::self()->deleteAfterItem()->label(), filesAndDirsBox); deleteAfter->setObjectName("kcfg_DeleteAfter"); QCheckBox *deleteDuring = new QCheckBox(Smb4KSettings::self()->deleteDuringItem()->label(), filesAndDirsBox); deleteDuring->setObjectName("kcfg_DeleteDuring"); QCheckBox *deleteExcluded = new QCheckBox(Smb4KSettings::self()->deleteExcludedItem()->label(), filesAndDirsBox); deleteExcluded->setObjectName("kcfg_DeleteExcluded"); QCheckBox *ignoreIOErrors = new QCheckBox(Smb4KSettings::self()->ignoreErrorsItem()->label(), filesAndDirsBox); ignoreIOErrors->setObjectName("kcfg_IgnoreErrors"); QCheckBox *forceDirDeletion = new QCheckBox(Smb4KSettings::self()->forceDirectoryDeletionItem()->label(), filesAndDirsBox); forceDirDeletion->setObjectName("kcfg_ForceDirectoryDeletion"); filesAndDirsBoxLayout->addWidget(removeSource, 0, 0, 0); filesAndDirsBoxLayout->addWidget(deleteExtraneous, 0, 1, 0); filesAndDirsBoxLayout->addWidget(deleteBefore, 1, 0, 0); filesAndDirsBoxLayout->addWidget(deleteAfter, 1, 1, 0); filesAndDirsBoxLayout->addWidget(deleteDuring, 2, 0, 0); filesAndDirsBoxLayout->addWidget(deleteExcluded, 2, 1, 0); filesAndDirsBoxLayout->addWidget(ignoreIOErrors, 3, 0, 0); filesAndDirsBoxLayout->addWidget(forceDirDeletion, 3, 1, 0); // Restrictions QGroupBox *restrictionsBox = new QGroupBox(i18n("Restrictions"), deleteTab); QGridLayout *restrictionsBoxLayout = new QGridLayout(restrictionsBox); - restrictionsBoxLayout->setSpacing(5); QCheckBox *maxDeleteButton = new QCheckBox(Smb4KSettings::self()->useMaximumDeleteItem()->label(), restrictionsBox); maxDeleteButton->setObjectName("kcfg_UseMaximumDelete"); QSpinBox *maxDelete = new QSpinBox(restrictionsBox); maxDelete->setObjectName("kcfg_MaximumDeleteValue"); restrictionsBoxLayout->addWidget(maxDeleteButton, 0, 0, 0); restrictionsBoxLayout->addWidget(maxDelete, 0, 1, 0); deleteTabLayout->addWidget(filesAndDirsBox, 0); deleteTabLayout->addWidget(restrictionsBox, 0); deleteTabLayout->addStretch(100); addTab(deleteTab, i18n("File Deletion")); // // 'Filter' tab // QWidget *filterTab = new QWidget(this); QVBoxLayout *filterTabLayout = new QVBoxLayout(filterTab); - filterTabLayout->setSpacing(5); - filterTabLayout->setContentsMargins(0, 0, 0, 0); // General QGroupBox *generalFilterBox = new QGroupBox(i18n("General"), filterTab); QGridLayout *generalFilterBoxLayout = new QGridLayout(generalFilterBox); - generalFilterBoxLayout->setSpacing(5); QCheckBox *cvsExclude = new QCheckBox(Smb4KSettings::self()->useCVSExcludeItem()->label(), generalFilterBox); cvsExclude->setObjectName("kcfg_UseCVSExclude"); QCheckBox *excludePatternButton = new QCheckBox(Smb4KSettings::self()->useExcludePatternItem()->label(), generalFilterBox); excludePatternButton->setObjectName("kcfg_UseExcludePattern"); KLineEdit *excludePattern = new KLineEdit(generalFilterBox); excludePattern->setObjectName("kcfg_ExcludePattern"); excludePattern->setClearButtonEnabled(true); QCheckBox *excludeFromButton = new QCheckBox(Smb4KSettings::self()->useExcludeFromItem()->label(), generalFilterBox); excludeFromButton->setObjectName("kcfg_UseExcludeFrom"); KUrlRequester *excludeFrom = new KUrlRequester(generalFilterBox); excludeFrom->setObjectName("kcfg_ExcludeFrom"); excludeFrom->setMode(KFile::File | KFile::LocalOnly); QCheckBox *includePatternButton = new QCheckBox(Smb4KSettings::self()->useIncludePatternItem()->label(), generalFilterBox); includePatternButton->setObjectName("kcfg_UseIncludePattern"); KLineEdit *includePattern = new KLineEdit(generalFilterBox); includePattern->setObjectName("kcfg_IncludePattern"); includePattern->setClearButtonEnabled(true); QCheckBox *includeFromButton = new QCheckBox(Smb4KSettings::self()->useIncludeFromItem()->label(), generalFilterBox); includeFromButton->setObjectName("kcfg_UseIncludeFrom"); KUrlRequester *includeFrom = new KUrlRequester(generalFilterBox); includeFrom->setObjectName("kcfg_IncludeFrom"); includeFrom->setMode(KFile::File | KFile::LocalOnly); generalFilterBoxLayout->addWidget(cvsExclude, 0, 0, 1, -1, 0); generalFilterBoxLayout->addWidget(excludePatternButton, 1, 0, 0); generalFilterBoxLayout->addWidget(excludePattern, 1, 1, 0); generalFilterBoxLayout->addWidget(excludeFromButton, 2, 0, 0); generalFilterBoxLayout->addWidget(excludeFrom, 2, 1, 0); generalFilterBoxLayout->addWidget(includePatternButton, 3, 0, 0); generalFilterBoxLayout->addWidget(includePattern, 3, 1, 0); generalFilterBoxLayout->addWidget(includeFromButton, 4, 0, 0); generalFilterBoxLayout->addWidget(includeFrom, 4, 1, 0); // Filter rules QGroupBox *filterRulesBox = new QGroupBox(i18n("Filter Rules"), filterTab); QGridLayout *filterRulesBoxLayout = new QGridLayout(filterRulesBox); - filterRulesBoxLayout->setSpacing(5); QLabel *customRulesLabel = new QLabel(Smb4KSettings::self()->customFilteringRulesItem()->label(), filterRulesBox); KLineEdit *customRules = new KLineEdit(filterRulesBox); customRules->setObjectName("kcfg_CustomFilteringRules"); customRules->setClearButtonEnabled(true); customRulesLabel->setBuddy(customRules); QLabel *specialRulesLabel = new QLabel(i18n("Special filter rules:"), filterRulesBox); QCheckBox *useFFilterRule = new QCheckBox(Smb4KSettings::self()->useFFilterRuleItem()->label(), filterRulesBox); useFFilterRule->setObjectName("kcfg_UseFFilterRule"); QCheckBox *useFFFilterRule = new QCheckBox(Smb4KSettings::self()->useFFFilterRuleItem()->label(), filterRulesBox); useFFFilterRule->setObjectName("kcfg_UseFFFilterRule"); filterRulesBoxLayout->addWidget(customRulesLabel, 0, 0, 0); filterRulesBoxLayout->addWidget(customRules, 0, 1, 0); filterRulesBoxLayout->addWidget(specialRulesLabel, 1, 0, 1, -1, 0); filterRulesBoxLayout->addWidget(useFFilterRule, 2, 0, 1, -1, 0); filterRulesBoxLayout->addWidget(useFFFilterRule, 3, 0, 1, -1, 0); filterTabLayout->addWidget(generalFilterBox, 0); filterTabLayout->addWidget(filterRulesBox, 0); filterTabLayout->addStretch(100); addTab(filterTab, i18n("Filtering")); // // 'Miscellaneous' tab // QWidget *miscTab = new QWidget(this); QVBoxLayout *miscTabLayout = new QVBoxLayout(miscTab); - miscTabLayout->setSpacing(5); - miscTabLayout->setContentsMargins(0, 0, 0, 0); // Checksums QGroupBox *checksumsBox= new QGroupBox(i18n("Checksums"), miscTab); QGridLayout *checksumsBoxLayout = new QGridLayout(checksumsBox); - checksumsBoxLayout->setSpacing(5); QCheckBox *blockSizeButton = new QCheckBox(Smb4KSettings::self()->useBlockSizeItem()->label(), checksumsBox); blockSizeButton->setObjectName("kcfg_UseBlockSize"); QSpinBox *blockSize = new QSpinBox(checksumsBox); blockSize->setObjectName("kcfg_BlockSize"); QCheckBox *checksumSeedButton = new QCheckBox(Smb4KSettings::self()->useChecksumSeedItem()->label(), checksumsBox); checksumSeedButton->setObjectName("kcfg_UseChecksumSeed"); QSpinBox *checksumSeed = new QSpinBox(checksumsBox); checksumSeed->setObjectName("kcfg_ChecksumSeed"); QCheckBox *useChecksum = new QCheckBox(Smb4KSettings::self()->useChecksumItem()->label(), checksumsBox); useChecksum->setObjectName("kcfg_UseChecksum"); checksumsBoxLayout->addWidget(blockSizeButton, 0, 0, 0); checksumsBoxLayout->addWidget(blockSize, 0, 1, 0); checksumsBoxLayout->addWidget(checksumSeedButton, 1, 0, 0); checksumsBoxLayout->addWidget(checksumSeed, 1, 1, 0); checksumsBoxLayout->addWidget(useChecksum, 2, 0, 0); // Miscellaneous QGroupBox *miscBox = new QGroupBox(i18n("Miscellaneous"), miscTab); QGridLayout *miscBoxLayout = new QGridLayout(miscBox); - miscBoxLayout->setSpacing(5); QCheckBox *oneFilesystem = new QCheckBox(Smb4KSettings::self()->oneFileSystemItem()->label(), miscBox); oneFilesystem->setObjectName("kcfg_OneFileSystem"); QCheckBox *delayUpdates = new QCheckBox(Smb4KSettings::self()->delayUpdatesItem()->label(), miscBox); delayUpdates->setObjectName("kcfg_DelayUpdates"); miscBoxLayout->addWidget(oneFilesystem, 0, 0, 0); miscBoxLayout->addWidget(delayUpdates, 0, 1, 0); miscTabLayout->addWidget(checksumsBox, 0); miscTabLayout->addWidget(miscBox, 0); miscTabLayout->addStretch(100); addTab(miscTab, i18n("Miscellaneous")); // // Connections // connect(archiveMode, SIGNAL(toggled(bool)), this, SLOT(slotArchiveToggled(bool))); connect(recurseDirs, SIGNAL(toggled(bool)), this, SLOT(slotUncheckArchive(bool))); connect(preserveLinks, SIGNAL(toggled(bool)), this, SLOT(slotUncheckArchive(bool))); connect(preservePerms, SIGNAL(toggled(bool)), this, SLOT(slotUncheckArchive(bool))); connect(preserveTimes, SIGNAL(toggled(bool)), this, SLOT(slotUncheckArchive(bool))); connect(preserveGroup, SIGNAL(toggled(bool)), this, SLOT(slotUncheckArchive(bool))); connect(preserveOwner, SIGNAL(toggled(bool)), this, SLOT(slotUncheckArchive(bool))); connect(preserveDevices, SIGNAL(toggled(bool)), this, SLOT(slotUncheckArchive(bool))); connect(useFFilterRule, SIGNAL(toggled(bool)), this, SLOT(slotFFilterRuleToggled(bool))); connect(useFFFilterRule, SIGNAL(toggled(bool)), this, SLOT(slotFFFilterRuleToggled(bool))); connect(makeBackups, SIGNAL(toggled(bool)), this, SLOT(slotBackupToggled(bool))); connect(compressData, SIGNAL(toggled(bool)), this, SLOT(slotCompressToggled(bool))); connect(keepPartial, SIGNAL(toggled(bool)), this, SLOT(slotKeepPartialToggled(bool))); slotArchiveToggled(Smb4KSettings::archiveMode()); slotBackupToggled(Smb4KSettings::makeBackups()); slotCompressToggled(Smb4KSettings::compressData()); slotKeepPartialToggled(Smb4KSettings::keepPartial()); } Smb4KConfigPageSynchronization::~Smb4KConfigPageSynchronization() { } ///////////////////////////////////////////////////////////////////////////// // SLOT IMPLEMENTATIONS ///////////////////////////////////////////////////////////////////////////// void Smb4KConfigPageSynchronization::slotArchiveToggled(bool checked) { if (checked) { findChild("kcfg_RecurseIntoDirectories")->setChecked(checked); findChild("kcfg_PreserveSymlinks")->setChecked(checked); findChild("kcfg_PreservePermissions")->setChecked(checked); findChild("kcfg_PreserveTimes")->setChecked(checked); findChild("kcfg_PreserveGroup")->setChecked(checked); findChild("kcfg_PreserveOwner")->setChecked(checked); findChild("kcfg_PreserveDevicesAndSpecials")->setChecked(checked); } } void Smb4KConfigPageSynchronization::slotUncheckArchive(bool checked) { if (!checked) { findChild("kcfg_ArchiveMode")->setChecked(checked); } } void Smb4KConfigPageSynchronization::slotBackupToggled(bool checked) { findChild("kcfg_UseBackupDirectory")->setEnabled(checked); findChild("kcfg_BackupDirectory")->setEnabled(checked); findChild("kcfg_UseBackupSuffix")->setEnabled(checked); findChild("kcfg_BackupSuffix")->setEnabled(checked); } void Smb4KConfigPageSynchronization::slotCompressToggled(bool checked) { findChild("kcfg_UseCompressionLevel")->setEnabled(checked); findChild("kcfg_CompressionLevel")->setEnabled(checked); findChild("kcfg_UseSkipCompression")->setEnabled(checked); findChild("kcfg_SkipCompression")->setEnabled(checked); } void Smb4KConfigPageSynchronization::slotKeepPartialToggled(bool checked) { findChild("kcfg_UsePartialDirectory")->setEnabled(checked); findChild("kcfg_PartialDirectory")->setEnabled(checked); } void Smb4KConfigPageSynchronization::slotFFilterRuleToggled(bool on) { QCheckBox *ff_filter = findChild("kcfg_UseFFFilterRule"); if (on && ff_filter->isChecked()) { ff_filter->setChecked(false); } } void Smb4KConfigPageSynchronization::slotFFFilterRuleToggled(bool on) { QCheckBox *f_filter = findChild("kcfg_UseFFilterRule"); if (on && f_filter->isChecked()) { f_filter->setChecked(false); } } diff --git a/smb4k/smb4kconfigpageuserinterface.cpp b/smb4k/smb4kconfigpageuserinterface.cpp index b92074b..84b1a4b 100644 --- a/smb4k/smb4kconfigpageuserinterface.cpp +++ b/smb4k/smb4kconfigpageuserinterface.cpp @@ -1,227 +1,159 @@ /*************************************************************************** This configuration page takes care of all settings concerning the user interface ------------------- begin : Mi Aug 30 2006 copyright : (C) 2006-2019 by Alexander Reinholdt email : alexander.reinholdt@kdemail.net ***************************************************************************/ /*************************************************************************** * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, but * * WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * * General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., 51 Franklin Street, Suite 500, Boston,* * MA 02110-1335, USA * ***************************************************************************/ // application specific includes #include "smb4kconfigpageuserinterface.h" #include "core/smb4ksettings.h" // Qt includes #include #include #include #include #include #include #include // KDE includes #include #include Smb4KConfigPageUserInterface::Smb4KConfigPageUserInterface(QWidget *parent) : QWidget(parent) { // // Layout // QVBoxLayout *layout = new QVBoxLayout(this); - layout->setSpacing(5); - layout->setContentsMargins(0, 0, 0, 0); // // Main Window settings // QGroupBox *mainWindowBox = new QGroupBox(i18n("Main Window"), this); QGridLayout *mainWindowBoxLayout = new QGridLayout(mainWindowBox); - mainWindowBoxLayout->setSpacing(5); QLabel *tabOrientationLabel = new QLabel(Smb4KSettings::self()->mainWindowTabOrientationItem()->label(), mainWindowBox); KComboBox *tabOrientation = new KComboBox(mainWindowBox); tabOrientation->setObjectName("kcfg_MainWindowTabOrientation"); QList tabOrientationChoices = Smb4KSettings::self()->mainWindowTabOrientationItem()->choices(); for (const KCoreConfigSkeleton::ItemEnum::Choice &to : tabOrientationChoices) { tabOrientation->addItem(to.label); } tabOrientationLabel->setBuddy(tabOrientation); mainWindowBoxLayout->addWidget(tabOrientationLabel, 0, 0, 0); mainWindowBoxLayout->addWidget(tabOrientation, 0, 1, 0); QCheckBox *showBookmarkLabel = new QCheckBox(Smb4KSettings::self()->showCustomBookmarkLabelItem()->label(), mainWindowBox); showBookmarkLabel->setObjectName("kcfg_ShowCustomBookmarkLabel"); mainWindowBoxLayout->addWidget(showBookmarkLabel, 1, 0, 1, 2, 0); layout->addWidget(mainWindowBox, 0); // // Network Neighborhood settings // QGroupBox *networkNeighhoodBox = new QGroupBox(i18n("Network Neighborhood"), this); QGridLayout *networkNeighhoodBoxLayout = new QGridLayout(networkNeighhoodBox); networkNeighhoodBoxLayout->setSpacing(5); QCheckBox *autoExpand = new QCheckBox(Smb4KSettings::self()->autoExpandNetworkItemsItem()->label(), networkNeighhoodBox); autoExpand->setObjectName("kcfg_AutoExpandNetworkItems"); networkNeighhoodBoxLayout->addWidget(autoExpand, 0, 0, 0); QCheckBox *showType = new QCheckBox(Smb4KSettings::self()->showTypeItem()->label(), networkNeighhoodBox); showType->setObjectName("kcfg_ShowType"); networkNeighhoodBoxLayout->addWidget(showType, 0, 1, 0); QCheckBox *showIpAddress = new QCheckBox(Smb4KSettings::self()->showIPAddressItem()->label(), networkNeighhoodBox); showIpAddress->setObjectName("kcfg_ShowIPAddress"); networkNeighhoodBoxLayout->addWidget(showIpAddress, 1, 0, 0); QCheckBox *showComment = new QCheckBox(Smb4KSettings::self()->showCommentItem()->label(), networkNeighhoodBox); showComment->setObjectName("kcfg_ShowComment"); networkNeighhoodBoxLayout->addWidget(showComment, 1, 1, 0); QCheckBox *showNetworkTooltip = new QCheckBox(Smb4KSettings::self()->showNetworkItemToolTipItem()->label(), networkNeighhoodBox); showNetworkTooltip->setObjectName("kcfg_ShowNetworkItemToolTip"); networkNeighhoodBoxLayout->addWidget(showNetworkTooltip, 2, 0, 1, 2, 0); layout->addWidget(networkNeighhoodBox, 0); // // Shares View settings // QGroupBox *sharesViewBox = new QGroupBox(i18n("Shares View"), this); QGridLayout *sharesViewBoxLayout = new QGridLayout(sharesViewBox); - sharesViewBoxLayout->setSpacing(5); QLabel *viewModeLabel = new QLabel(Smb4KSettings::self()->sharesViewModeItem()->label(), sharesViewBox); KComboBox *viewMode = new KComboBox(sharesViewBox); viewMode->setObjectName("kcfg_SharesViewMode"); QList sharesViewModeChoices = Smb4KSettings::self()->sharesViewModeItem()->choices(); for (const KCoreConfigSkeleton::ItemEnum::Choice &vm : sharesViewModeChoices) { viewMode->addItem(vm.label); } viewModeLabel->setBuddy(viewMode); sharesViewBoxLayout->addWidget(viewModeLabel, 0, 0, 0); sharesViewBoxLayout->addWidget(viewMode, 0, 1, 0); QCheckBox *showShareTooltip = new QCheckBox(Smb4KSettings::self()->showShareToolTipItem()->label(), sharesViewBox); showShareTooltip->setObjectName("kcfg_ShowShareToolTip"); sharesViewBoxLayout->addWidget(showShareTooltip, 1, 0, 1, 2, 0); layout->addWidget(sharesViewBox, 0); layout->addStretch(100); - - - -// // Network item tooltips -// QGroupBox *network_tooltips_box = new QGroupBox(i18n("Tooltips"), networkNeighborhoodTab); -// -// QGridLayout *n_tooltips_layout = new QGridLayout(network_tooltips_box); -// n_tooltips_layout->setSpacing(5); -// - -// -// n_tooltips_layout->addWidget(network_tooltip, 0, 0, 0); -// -// networkNeighborhoodTabLayout->addWidget(behavior_box); -// networkNeighborhoodTabLayout->addWidget(columns_box); -// networkNeighborhoodTabLayout->addWidget(network_tooltips_box); -// networkNeighborhoodTabLayout->addStretch(100); -// -// addTab(networkNeighborhoodTab, i18n("Network Neighborhood")); -// -// // -// // Shares view -// // -// QWidget *shares_view_tab = new QWidget(this); -// -// QVBoxLayout *shares_view_layout = new QVBoxLayout(shares_view_tab); -// shares_view_layout->setSpacing(5); -// shares_view_layout->setMargin(0); -// -// // View -// QGroupBox *viewBox = new QGroupBox(i18n("View Mode"), shares_view_tab); -// QHBoxLayout *viewBoxLayout = new QHBoxLayout(viewBox); -// viewBoxLayout->setSpacing(5); -// -// QLabel *viewModeLabel = new QLabel(Smb4KSettings::self()->sharesViewModeItem()->label(), viewBox); -// KComboBox *viewMode = new KComboBox(viewBox); -// viewMode->setObjectName("kcfg_SharesViewMode"); -// viewMode->insertItem(Smb4KSettings::EnumSharesViewMode::IconView, -// Smb4KSettings::self()->sharesViewModeItem()->choices().value(Smb4KSettings::EnumSharesViewMode::IconView).label); -// viewMode->insertItem(Smb4KSettings::EnumSharesViewMode::ListView, -// Smb4KSettings::self()->sharesViewModeItem()->choices().value(Smb4KSettings::EnumSharesViewMode::ListView).label); -// viewModeLabel->setBuddy(viewMode); -// -// viewBoxLayout->addWidget(viewModeLabel); -// viewBoxLayout->addWidget(viewMode); -// -// // Share tooltips -// QGroupBox *share_tooltips_box = new QGroupBox(i18n("Tooltips"), shares_view_tab); -// -// QGridLayout *s_tooltips_layout = new QGridLayout(share_tooltips_box); -// s_tooltips_layout->setSpacing(5); -// -// QCheckBox *show_share_tooltip = new QCheckBox(Smb4KSettings::self()->showShareToolTipItem()->label(), share_tooltips_box); -// show_share_tooltip->setObjectName("kcfg_ShowShareToolTip"); -// -// s_tooltips_layout->addWidget(show_share_tooltip, 0, 0, 0); -// -// QSpacerItem *spacer4 = new QSpacerItem(10, 10, QSizePolicy::Preferred, QSizePolicy::Expanding); -// -// shares_view_layout->addWidget(viewBox); -// shares_view_layout->addWidget(share_tooltips_box); -// shares_view_layout->addItem(spacer4); -// -// addTab(shares_view_tab, i18n("Mounted Shares")); } Smb4KConfigPageUserInterface::~Smb4KConfigPageUserInterface() { } ///////////////////////////////////////////////////////////////////////////// // SLOT IMPLEMENTATIONS /////////////////////////////////////////////////////////////////////////////