Hide preview widget in QColumnView? - qt

I want to hide the preview widget that is displayed as the last column even when it has no children. I've looked everywhere on the internet and umpteen number of users didn't want the preview widget to be added as the last column all the time.
QColumnView is rolled to empty column
Qt: is it possible to turn off previewWidget in QColumnView?
Is it possible to remove the preview widget from a qt QColumnView?
http://www.qtcentre.org/threads/59917-Columnview-removing-final-column
http://www.qtcentre.org/threads/22566-How-to-turn-off-this-annoying-feature-of-QColumnView
What's more pathetic here is, No solution has been offered till now [From 2010]. Is there any way to get rid of this annoying behaviour? If not, shouldn't the Qt developers provided this option at-least in Qt5? Let me know if I miss something here.
Note: I've tried the possible suggested solutions and none of them worked
Setting the column width to 0 - Failed
Return False for createColumn - createColumn is not at all called when the preview widget is shown

There is no way to do it. In qcolumnview.cpp in QColumnViewPrivate::createColumn(), you have (comments are mine):
if (model->hasChildren(index)) { // Create column when there are children to display
view = q->createColumn(index);
q->connect(view, SIGNAL(clicked(QModelIndex)),
q, SLOT(_q_clicked(QModelIndex)));
} else { // Create column when there are no more children => the column will show the preview widget
if (!previewColumn)
setPreviewWidget(new QWidget(q)); // Indirectly create previewColumn
view = previewColumn;
view->setMinimumWidth(qMax(view->minimumWidth(), previewWidget->minimumWidth()));
}
If you want to change the behavior of the QColumnView so that the preview widget it not always displayed you will have to contribute by fixing it yourself in Qt code and pushing to Qt git repo, or create a suggestion in Qt bug tracker and wait for someone nice to fix it.

Related

TinyMCE Wordpress wpview 'gallery' after drag & drop

sorry for the title, but it is hard to describe my problem/ question in a short sentence or title.
So here is my story:
I am writing a WP plugin, which replaces the original [gallery] shortcode. For having a correct "preview" in visual editor (TinyMCE), I also slightly modified (by replacing it) the wpview plugin. But just small changes, like removing the 'Remove' button from the inline toolbar.
All works pretty well so far. One can switch between HTML and Visual mode. The [gallery] shortcode is replaced with the HTML output in Visual mode.
The only thing/ problem is, that if one selects a gallery view and drags it around, it becomes the (original) element (with the [gallery] shortcode).
I have really no idea why and where this happens!?
So my first question is, if anyone has an idea?
Searching for a solution/ workaround for this issue, I would also like to know, if there is an event fired, when a drag & drop action ends in WP TinyMCE?
I realized, that for a drag & drop action TinyMCE appends a element with class attribute "mce-drag-container". Maybe I have to monitor the iframe document for the existence of this element (to call a function when it is removed)?
Any ideas, tips or hints for this?
The last option I could think of would be to make the wp gallery views non-draggable.
Unfortunately I could not find any information on how to do it. If it is possible in the end?
So if anyone has a clue ...?
Any help is very much appreciated.
Many thanks in advance.
Greetings
Gunther
Have you tried listening for a general content change and checking if it's a dragged image?
All TinyMCE editor events can be found in the docs: https://www.tinymce.com/docs/advanced/events/
OK, after some further investigation I found the function that caused my "problem".
It is the following (in wpview:
// Make sure views are copied as their text.
editor.on( 'drop objectselected', function( event ) {
if ( isView( event.targetClone ) ) {
event.targetClone = editor.getDoc().createTextNode(
window.decodeURIComponent( editor.dom.getAttrib( event.targetClone, 'data-wpview-text' ) )
);
}
} );
In my case this is an "unwanted behaviour", as I wanted the view to stay intact/ as is.
So the solution (in my case) is just to delete/ do not use this event/ function.

resource.id doesn't contain a definition for button and Layout

I created an Android project on Xamarin and added a button in the layout but I'm having this error of Resource.Id doesn't contain a definition for Button when i create the button using FindViewById in the Activity. Despite giving the an id to the button and layout using (android:id="#+id/btnShow"), I'm still having the error. I checked the Resource.Designer but could not find the aapt for the button.
Another issue that I faced is when I created a layout, gave it and defined it in an activity but the Resource.layout doesn't contain a definition for the layout.
However, other buttons and layouts can be defined in my activities
Actually this problem occurs when your ResourceDesigner.cs file has not yet mapped the file that you added to your resource directory(Xamarin Bug). The easiest way i would suggest to handle this situation is you comment the code you are trying to write and clean build your project and it will work like a charm. Good luck!

Print existing pdf file directly to client default printer [duplicate]

A coworker and I were having a discussion about what is and isn't possible within the browser.
Then a question came up that neither of us could answer with certainty.
Can you create a webpage such that when you navigate to it, it engages the client-side printer and attempts to print a document. For instance, whenever you visit my personal website, you'll be treated to a print out of a picture of me, smiling.
Now, this is a hideous idea. I'm aware. But the discussion intrigued me as to if it could be done, and how. My friend insisted that the best you could do was pop up the print dialog for the user, they would have to click print themselves.
Would it be possible to bypass this step? Or just some fancy script to move the mouse over the print button and click on it? Or use an activeX control to interface with a Printer API directly?
You have to prompt the user to print the current page, there's no way to bypass this step (possibly in activeX for IE). That said, there's two different ways you could prompt the user to print images of you smiling when the page is loaded.
Here's how to do it in JavaScript.
window.onload = function() {
var img = window.open("me-smiling.png");
img.print();
}
And here's how to do it in css/javascript/html (assuming your picture has the id 'me-smiling'):
CSS:
#media print {
* {
display:none;
}
img#me-smiling {
display:block;
}
}
Javascript:
window.onload = function() { window.print() }
The only solution to avoid print dialog that I found was creating a variable on Mozilla Firefox to set auto-print. Maybe is not the best solution if you need to use other browser, but in my case, I only need to print a report automatically and it works:
1- Open Firefox and type "about:config" in the address bar
2- Right click on any preference and select "New" > "Boolean"
3- Add a variable called "print.always_print_silent" with "true" value
4- Restart Firefox.
Hope help you!
AttendStar created a free add-on that suppresses the dialog box and removes all headers and footers for most versions of Firefox.
https://addons.mozilla.org/en-US/firefox/addon/attendprint/
With that feature on you can use $('img').jqprint(); and jqprint for jquery will only print that image automatically called from your web application.
As far as I know, there is no way to print a document directly, without some client intervention, like setting browser flags.
In our current project we need to print directly to the default printer, but at least with Chrome you can do it easily with additional startup arguments.
To print directly to the OS default printer you can use:
"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --user-data-dir=c:\tmp --kiosk-printing http://www.contoso.com
Another option, which may also be useful, is tos use the native print dialog instead of chromes print preview.
"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --user-data-dir=c:\tmp --disable-print-preview http://www.contoso.com
Note, that window.print() and/or Ctrl-P behave accordingly the mentioned settings.
I know, that this does not exactly answers the OPs question, but I think it somewhat related, and for web based enterprise applications this is a quite common use case. Maybe someone find it useful.
For Firefox I recommend Seamless Print Addon
You can't bypass the print dialog, as far as I know. That would be a pretty obvious security flaw if the browser allowed that. But you can bring up the print dialog with "window.print()".
I think at best you would need an ActiveX component using base windows API to obtain a device context for the default printer and try and print an embedded image using assumed values for the printer settings.
To print to the default printer automatically without seeing a print dialog prompt, I've shared some code in the following question that works in IE7, IE8 and IE9:
Bypass Printdialog in IE9
From lot of search from last few days,
I've found a best possible solution.
Till date Chrome do not support direct printing from javascript.
It has launched USB and serial API which might help.
But currently I'm using a JavaApplet solution which is open source.
https://github.com/qzind/qz-print - build
While I'm getting error in building it. I preferred a Prebuilt - QZ Print Plugin 1.9.3
desktop app, which works great.
Download it from here: https://qz.io/download/
Code Example:
/***************************************************************************
* Prototype function for printing an HTML screenshot of the existing page
* Usage: (identical to appendImage(), but uses html2canvas for png rendering)
* qz.setPaperSize("8.5in", "11.0in"); // US Letter
* qz.setAutoSize(true);
* qz.appendImage($("canvas")[0].toDataURL('image/png'));
***************************************************************************/
function printHTML5Page() {
$("#qz-status").html2canvas({
canvas: hidden_screenshot,
onrendered: function() {
if (notReady()) { return; }
// Optional, set up custom page size. These only work for PostScript printing.
// setPaperSize() must be called before setAutoSize(), setOrientation(), etc.
qz.setPaperSize("8.5in", "11.0in"); // US Letter
qz.setAutoSize(true);
qz.appendImage($("canvas")[0].toDataURL('image/png'));
//qz.setCopies(3);
qz.setCopies(parseInt(document.getElementById("copies").value));
// Automatically gets called when "qz.appendFile()" is finished.
window['qzDoneAppending'] = function() {
// Tell the applet to print.
qz.printPS();
// Remove reference to this function
window['qzDoneAppending'] = null;
};
}
});
}
Complete example can be found here:
https://gist.github.com/bkrajendra/c80de17b627e59287f7c
This is the best solution that I have found for firefox:
There is this awesome add-on Seamless Print.
It works like charm.

Aptana Studio 3 - code coloring like in Dreamweaver

I'm trying to use Aptana Studio 3 instead of phpEd. But I'd like to have the code coloring like in Dreamweaver. I made these changes in phpEd, but I can't find where to change it in Aptana.
Also, I installed the jquery bundle, but I can't to get it working...
Thanks for your help.
Preferences:Aptana:Themes. Figuring out what keyword corresponds to what display object can be a bit tricky, but it is all there.
There's actually a ticket already filed to add a theme that matches Dreamweaver: https://aptana.lighthouseapp.com/projects/35272/tickets/1508-create-dreamweaver-color-theme
I'm looking at it now, but I'm running into some internal bugs (namely https://aptana.lighthouseapp.com/projects/35272-studio/tickets/2357-scope-selectors-with-portion-prefix-match-arent-matching-properly) that I need to fix before I can finish. In any case it should be in Studio 3.0.2 and hopefully I'll fix it today and it'll be in tomorrow's nightly (here's how to get nightly builds: http://wiki.appcelerator.org/display/tis/Changing+the+Update+Type).
As for editing themes yourself, you can see the current scope at the cursor by doing Commands > Bundle Development > Show Scope. Then use scope selectors that match that sort of scope (we adopt Textmate's scoping/theming rules: http://manual.macromates.com/en/scope_selectors)
Could you finally get your theme?
If you want to create your own theme then first go to: Window->Preferences->Aptana Studio->Themes
To create a new theme just click on the "+" sign next to the themes
list.
To add elements to your new theme right click the text in your
editor and click Commands->Bundle Development->Show scope.
Copy the last section you see to the right of the hint window that
appears.
In the themes elements list click the "+" located at the bottom of
the dialog box (next to "Scope selector")
Give a friendly name to your new element.
Assign foreground/background colors to your new element.
Paste the element's scope in the "Scope selector" input box (make
sure your new element is selected, if not, click on it).
I created a theme for PHP, CSS, HTML, JS and XML editors, similar to the old aptana 2 colors. If you want to get it you can write me to jgarcias.cr at gmail dot com.
Cheers.

Show standard warning icon in Qt4

I'm trying to display a "warning" icon next to a QLineEdit if it contains invalid data. I was trying to use QStyle::standardIcon(QStyle::SP_MessageBoxWarning) to get a standard pixmap and place it inside a QLabel, and in some cases this seems to work. When running Gnome the icon is displayed correctly, but when running under KDE no icon is shown. I assume that the warning icon is simply not included in the style used under KDE.
What is the preferred way to display a "standard" warning icon in Qt? Does there exist some list which shows which icons are included in every style? How can I get an icon from a style that I know includes the warning icon?
The last time I had a similar problem, I found this Qt labs discussion useful. It informed me that QIcon now (since 4.6 I believe) has a QIcon::fromTheme function that allows you to load an icon based on the Freedesktop.org Icon Naming Specification, and in addition provide a fallback icon to be used if the current theme does not have the icon in question.
What I did was then to include some very basic icons for use as fallback, and in general specify icons only by their Freedesktop names. This gave a theme-consistent look almost always, and the program still worked in cases where people were missing icons.
As for the warning icon, I'm guessing/hoping that every theme must have the one named "dialog-warning", and that it's what you're looking for.
I hope this helps.
Edit: Oh and, in case you don't know, it can be useful to look at for example the Tango icon set to get a rough idea of what the Freedesktop names correspond to (although it is of course theme-dependent).
Qt does bundle a number of images that are resources that you can use in your own code. These images are a superset of those available via standardIcon() You may want to verify that the particular image is included in the versions of Qt you're targeting.
The end result could look like the following:
QPixmap pixmap(":/trolltech/styles/commonstyle/images/up-128.png");
// use pixmap as needed
For anyone who wants to know how to do this in a Windows environment you can:
Create a qLabel in your custom class, and then in the constructor of that class create a QIcon with the style you want, convert it into a pixmap and use the QLabel::setPixmap() function to apply it to the one you created:
QIcon icon = style()->standardIcon(QStyle::SP_MessageBoxWarning); //or
//whatever icon you choose
QPixmap pixmap = icon.pixmap(QSize(60, 60));
ui->iconLabel->setPixmap(pixmap);
ui->iconLabel->setScaledContents(true); //you can set this to fill the
//dimensions of your qLabel if you wish.

Resources