aboutsummaryrefslogtreecommitdiff
path: root/src-qt5/core
diff options
context:
space:
mode:
authorKen Moore <ken@ixsystems.com>2017-10-02 05:14:40 -0400
committerKen Moore <ken@ixsystems.com>2017-10-02 05:14:40 -0400
commitf98507eb3fef50e900c9ceb3606e4cdea78fbd64 (patch)
tree5fc0e4cf008d826fa7bd5f236845c0b0308fb196 /src-qt5/core
parentCommit some minor updates/tests to the GL widgets. need to avoid QPainter if ... (diff)
downloadlumina-f98507eb3fef50e900c9ceb3606e4cdea78fbd64.tar.gz
lumina-f98507eb3fef50e900c9ceb3606e4cdea78fbd64.tar.bz2
lumina-f98507eb3fef50e900c9ceb3606e4cdea78fbd64.zip
Add a "copy" button to the QSS page for copying files to make changes.
Diffstat (limited to 'src-qt5/core')
-rw-r--r--src-qt5/core/lumina-theme-engine/src/lthemeengine/qsspage.cpp33
-rw-r--r--src-qt5/core/lumina-theme-engine/src/lthemeengine/qsspage.h1
-rw-r--r--src-qt5/core/lumina-theme-engine/src/lthemeengine/qsspage.ui41
3 files changed, 73 insertions, 2 deletions
diff --git a/src-qt5/core/lumina-theme-engine/src/lthemeengine/qsspage.cpp b/src-qt5/core/lumina-theme-engine/src/lthemeengine/qsspage.cpp
index cd88fb56..6377016c 100644
--- a/src-qt5/core/lumina-theme-engine/src/lthemeengine/qsspage.cpp
+++ b/src-qt5/core/lumina-theme-engine/src/lthemeengine/qsspage.cpp
@@ -31,6 +31,7 @@ QSSPage::QSSPage(QWidget *parent, bool desktop) : TabPage(parent), m_ui(new Ui::
m_ui->removeButton->setIcon(QIcon::fromTheme("edit-delete"));
m_ui->tool_enable->setEnabled(false);
m_ui->tool_disable->setEnabled(false);
+ m_ui->copyButton->setEnabled(false);
}
QSSPage::~QSSPage(){
@@ -56,6 +57,7 @@ void QSSPage::on_qssListWidget_currentItemChanged(QListWidgetItem *current, QLis
}
//qDebug() << "Got Current Item Changed";
m_ui->tool_disable->setEnabled(current!=0);
+ m_ui->copyButton->setEnabled(current!=0);
if(current){
m_ui->editButton->setEnabled(current->data(QSS_WRITABLE_ROLE).toBool());
m_ui->removeButton->setEnabled(current->data(QSS_WRITABLE_ROLE).toBool());
@@ -76,6 +78,7 @@ void QSSPage::on_list_disabled_currentItemChanged(QListWidgetItem *current, QLis
}
//qDebug() << "Got Current Item Changed";
m_ui->tool_enable->setEnabled(current!=0);
+ m_ui->copyButton->setEnabled(current!=0);
if(current){
m_ui->editButton->setEnabled(current->data(QSS_WRITABLE_ROLE).toBool());
m_ui->removeButton->setEnabled(current->data(QSS_WRITABLE_ROLE).toBool());
@@ -127,6 +130,36 @@ void QSSPage::on_editButton_clicked(){
}
}
+void QSSPage::on_copyButton_clicked(){
+ QListWidgetItem *sel = currentSelection();
+ if(sel==0){ return; }
+ QString name = QInputDialog::getText(this, tr("Enter Style Sheet Name"), tr("File name:"), QLineEdit::Normal, sel->text().section(".qss",0,0)+"_copy");
+ if(name.isEmpty()){ return; }
+ if(!name.endsWith(".qss", Qt::CaseInsensitive)){ name.append(".qss"); }
+ QString filePath;
+ if(desktop_qss){ filePath = lthemeengine::userDesktopStyleSheetPath() + name; }
+ else{ filePath = lthemeengine::userStyleSheetPath() + name; }
+ if(QFile::exists(filePath)){
+ QMessageBox::warning(this, tr("Error"), tr("The file \"%1\" already exists").arg(filePath));
+ return;
+ }
+ // Make sure the directory exists
+ QString dir = filePath.section("/",0,-2);
+ if(!QFile::exists(dir)){
+ QDir D(dir);
+ D.mkpath(dir);
+ }
+ //Copy the file over
+ QFile::copy(sel->data(QSS_FULL_PATH_ROLE).toString(), filePath);
+ //creating item
+ QFileInfo info(filePath);
+ QListWidgetItem *item = new QListWidgetItem(info.fileName(), m_ui->list_disabled);
+ item->setToolTip(info.filePath());
+ item->setData(QSS_FULL_PATH_ROLE, info.filePath());
+ item->setData(QSS_WRITABLE_ROLE, info.isWritable());
+ m_ui->list_disabled->setCurrentRow(m_ui->list_disabled->count()-1);
+}
+
void QSSPage::on_removeButton_clicked(){
QListWidgetItem *item = currentSelection();
if(!item){ return; }
diff --git a/src-qt5/core/lumina-theme-engine/src/lthemeengine/qsspage.h b/src-qt5/core/lumina-theme-engine/src/lthemeengine/qsspage.h
index 5b0025c5..07df4ac2 100644
--- a/src-qt5/core/lumina-theme-engine/src/lthemeengine/qsspage.h
+++ b/src-qt5/core/lumina-theme-engine/src/lthemeengine/qsspage.h
@@ -24,6 +24,7 @@ private slots:
void on_qssListWidget_currentItemChanged(QListWidgetItem *current, QListWidgetItem *);
void on_list_disabled_currentItemChanged(QListWidgetItem *current, QListWidgetItem *);
void on_createButton_clicked();
+ void on_copyButton_clicked();
void on_editButton_clicked();
void on_removeButton_clicked();
void on_renameButton_clicked();
diff --git a/src-qt5/core/lumina-theme-engine/src/lthemeengine/qsspage.ui b/src-qt5/core/lumina-theme-engine/src/lthemeengine/qsspage.ui
index f9a980f3..def99dd0 100644
--- a/src-qt5/core/lumina-theme-engine/src/lthemeengine/qsspage.ui
+++ b/src-qt5/core/lumina-theme-engine/src/lthemeengine/qsspage.ui
@@ -63,7 +63,7 @@
<item>
<spacer name="horizontalSpacer_2">
<property name="sizePolicy">
- <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
+ <sizepolicy hsizetype="Fixed" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@@ -168,7 +168,7 @@
<item>
<spacer name="horizontalSpacer_3">
<property name="sizePolicy">
- <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
+ <sizepolicy hsizetype="Fixed" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@@ -222,16 +222,41 @@
<property name="enabled">
<bool>true</bool>
</property>
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
<property name="text">
<string>Create</string>
</property>
</widget>
</item>
<item>
+ <widget class="QToolButton" name="copyButton">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Copy</string>
+ </property>
+ </widget>
+ </item>
+ <item>
<widget class="QPushButton" name="editButton">
<property name="enabled">
<bool>false</bool>
</property>
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
<property name="text">
<string>Edit</string>
</property>
@@ -242,6 +267,12 @@
<property name="enabled">
<bool>false</bool>
</property>
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
<property name="text">
<string>Rename</string>
</property>
@@ -252,6 +283,12 @@
<property name="enabled">
<bool>false</bool>
</property>
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
<property name="text">
<string>Remove</string>
</property>
bgstack15